mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2026-01-20 15:20:19 +01:00
Little speedup and less size fft
Better support other size LCD and font Fix CH1 unstable at begin sweep
This commit is contained in:
parent
59b9534a5c
commit
20649012df
41
fft.h
41
fft.h
|
|
@ -95,7 +95,6 @@ static void fft256(float array[][2], const uint8_t dir) {
|
|||
const uint8_t real = dir & 1;
|
||||
const uint8_t imag = ~real & 1;
|
||||
uint16_t i;
|
||||
uint16_t size;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
uint16_t j = reverse_bits(i, levels);
|
||||
|
|
@ -108,39 +107,22 @@ static void fft256(float array[][2], const uint8_t dir) {
|
|||
array[j][imag] = temp;
|
||||
}
|
||||
}
|
||||
#ifdef FFT_USE_SIN_COS_TABLE
|
||||
const uint16_t size = 2;
|
||||
uint16_t halfsize = size / 2;
|
||||
uint16_t tablestep = n / size;
|
||||
uint16_t j, k;
|
||||
// Cooley-Tukey decimation-in-time radix-2 FFT
|
||||
for (size = 2; size <= n; size *= 2) {
|
||||
uint16_t halfsize = size / 2;
|
||||
uint16_t tablestep = n / size;
|
||||
for (i = 0; i < n; i += size) {
|
||||
uint16_t j, k;
|
||||
for (;tablestep; tablestep>>=1, halfsize<<=1) {
|
||||
for (i = 0; i < n; i+=2*halfsize) {
|
||||
for (j = i, k = 0; j < i + halfsize; j++, k += tablestep) {
|
||||
uint16_t l = j + halfsize;
|
||||
#ifdef FFT_USE_SIN_COS_TABLE
|
||||
float s = SIN(k);
|
||||
float c = COS(k);
|
||||
float tpre = array[l][real] * c + array[l][imag] * s;
|
||||
float tpim = -array[l][real] * s + array[l][imag] * c;
|
||||
array[l][real] = array[j][real] - tpre;
|
||||
array[l][imag] = array[j][imag] - tpim;
|
||||
array[j][real] += tpre;
|
||||
array[j][imag] += tpim;
|
||||
}
|
||||
}
|
||||
// if (size == n) // Prevent overflow in 'size *= 2'
|
||||
// break;
|
||||
}
|
||||
#else
|
||||
// Cooley-Tukey decimation-in-time radix-2 FFT
|
||||
for (size = 2; size <= n; size *= 2) {
|
||||
uint16_t halfsize = size / 2;
|
||||
uint16_t tablestep = n / size;
|
||||
for (i = 0; i < n; i += size) {
|
||||
uint16_t j, k;
|
||||
for (j = i, k = 0; j < i + halfsize; j++, k += tablestep) {
|
||||
uint16_t l = j + halfsize;
|
||||
float c = cos((2 * VNA_PI / 256) * k);
|
||||
float s = sin((2 * VNA_PI / 256) * k);
|
||||
float c = cos(2 * VNA_PI * k / 256);
|
||||
float s = sin(2 * VNA_PI * k / 256);
|
||||
#endif
|
||||
float tpre = array[l][real] * c + array[l][imag] * s;
|
||||
float tpim = -array[l][real] * s + array[l][imag] * c;
|
||||
array[l][real] = array[j][real] - tpre;
|
||||
|
|
@ -149,10 +131,7 @@ static void fft256(float array[][2], const uint8_t dir) {
|
|||
array[j][imag] += tpim;
|
||||
}
|
||||
}
|
||||
// if (size == n) // Prevent overflow in 'size *= 2'
|
||||
// break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void fft256_forward(float array[][2]) {
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ void ili9341_init(void)
|
|||
}
|
||||
|
||||
#ifndef __USE_DISPLAY_DMA__
|
||||
void ili9341_fill(int x, int y, int w, int h, int color)
|
||||
void ili9341_fill(int x, int y, int w, int h, uint16_t color)
|
||||
{
|
||||
//uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) };
|
||||
//uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) };
|
||||
|
|
@ -423,7 +423,7 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
|
|||
//
|
||||
|
||||
// Fill region by some color
|
||||
void ili9341_fill(int x, int y, int w, int h, int color)
|
||||
void ili9341_fill(int x, int y, int w, int h, uint16_t color)
|
||||
{
|
||||
uint32_t xx = __REV16(x | ((x + w - 1) << 16));
|
||||
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
|
||||
|
|
|
|||
31
main.c
31
main.c
|
|
@ -640,15 +640,15 @@ VNA_SHELL_FUNCTION(cmd_capture)
|
|||
(void)argc;
|
||||
(void)argv;
|
||||
int i, y;
|
||||
#if SPI_BUFFER_SIZE < (3*320 + 1)
|
||||
#if SPI_BUFFER_SIZE < (3*LCD_WIDTH + 1)
|
||||
#error "Low size of spi_buffer for cmd_capture"
|
||||
#endif
|
||||
// read 2 row pixel time (read buffer limit by 2/3 + 1 from spi_buffer size)
|
||||
for (y = 0; y < 240; y += 2) {
|
||||
for (y = 0; y < LCD_HEIGHT; y += 2) {
|
||||
// use uint16_t spi_buffer[2048] (defined in ili9341) for read buffer
|
||||
uint8_t *buf = (uint8_t *)spi_buffer;
|
||||
ili9341_read_memory(0, y, 320, 2, 2 * 320, spi_buffer);
|
||||
for (i = 0; i < 4 * 320; i++) {
|
||||
ili9341_read_memory(0, y, LCD_WIDTH, 2, 2 * LCD_WIDTH, spi_buffer);
|
||||
for (i = 0; i < 4 * LCD_WIDTH; i++) {
|
||||
streamPut(shell_stream, *buf++);
|
||||
}
|
||||
}
|
||||
|
|
@ -704,6 +704,7 @@ config_t config = {
|
|||
.trace_color = { DEFAULT_TRACE_1_COLOR, DEFAULT_TRACE_2_COLOR, DEFAULT_TRACE_3_COLOR, DEFAULT_TRACE_4_COLOR },
|
||||
// .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel
|
||||
.touch_cal = { 338, 522, 153, 192 }, // 2.8 inch LCD panel
|
||||
// .touch_cal = { 252, 450, 111, 150 }, //4.0" LCD
|
||||
.freq_mode = FREQ_MODE_START_STOP,
|
||||
.harmonic_freq_threshold = 300000000,
|
||||
.vbat_offset = 500
|
||||
|
|
@ -783,10 +784,6 @@ duplicate_buffer_to_dump(int16_t *p)
|
|||
// need for process data, while DMA fill next buffer
|
||||
void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
|
||||
{
|
||||
#if PORT_SUPPORTS_RT
|
||||
int32_t cnt_s = port_rt_get_counter_value();
|
||||
int32_t cnt_e;
|
||||
#endif
|
||||
int16_t *p = &rx_buffer[offset];
|
||||
(void)i2sp;
|
||||
if (wait_count > 0){
|
||||
|
|
@ -800,12 +797,6 @@ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
|
|||
#endif
|
||||
--wait_count;
|
||||
}
|
||||
#if PORT_SUPPORTS_RT
|
||||
cnt_e = port_rt_get_counter_value();
|
||||
stat.interval_cycles = cnt_s - stat.last_counter_value;
|
||||
stat.busy_cycles = cnt_e - cnt_s;
|
||||
stat.last_counter_value = cnt_s;
|
||||
#endif
|
||||
stat.callback_count++;
|
||||
}
|
||||
|
||||
|
|
@ -828,7 +819,8 @@ static const I2SConfig i2sconfig = {
|
|||
// main loop for measurement
|
||||
bool sweep(bool break_on_operation)
|
||||
{
|
||||
int delay=1;
|
||||
int delay;
|
||||
int st_delay = 3;
|
||||
if (p_sweep>=sweep_points || break_on_operation == false) RESET_SWEEP;
|
||||
|
||||
// blink LED while scanning
|
||||
|
|
@ -836,10 +828,9 @@ bool sweep(bool break_on_operation)
|
|||
// Power stabilization after LED off, also align timings on delay == 0
|
||||
for (; p_sweep < sweep_points; p_sweep++) { // 5300
|
||||
if (frequencies[p_sweep] == 0) break;
|
||||
delay+= set_frequency(frequencies[p_sweep]);
|
||||
delay = set_frequency(frequencies[p_sweep]);
|
||||
tlv320aic3204_select(0); // CH0:REFLECTION, reset and begin measure
|
||||
DSP_START(delay);
|
||||
delay = 0;
|
||||
DSP_START(delay+st_delay);
|
||||
//================================================
|
||||
// Place some code thats need execute while delay
|
||||
//================================================
|
||||
|
|
@ -847,13 +838,13 @@ bool sweep(bool break_on_operation)
|
|||
(*sample_func)(measured[0][p_sweep]); // calculate reflection coefficient
|
||||
|
||||
tlv320aic3204_select(1); // CH1:TRANSMISSION, reset and begin measure
|
||||
DSP_START(DELAY_CHANNEL_CHANGE);
|
||||
DSP_START(DELAY_CHANNEL_CHANGE+st_delay);
|
||||
//================================================
|
||||
// Place some code thats need execute while delay
|
||||
//================================================
|
||||
DSP_WAIT_READY;
|
||||
(*sample_func)(measured[1][p_sweep]); // calculate transmission coefficient
|
||||
|
||||
st_delay = 0;
|
||||
if (cal_status & CALSTAT_APPLY)
|
||||
apply_error_term_at(p_sweep);
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,9 @@ extern const uint8_t x5x7_bits [];
|
|||
#define FONT_GET_DATA(ch) (&x5x7_bits[ch*7])
|
||||
#define FONT_GET_WIDTH(ch) (8-(x5x7_bits[ch*7]&7))
|
||||
#define FONT_MAX_WIDTH 7
|
||||
#define FONT_WIDTH 5
|
||||
#define FONT_GET_HEIGHT 7
|
||||
#define FONT_STR_HEIGHT 8
|
||||
|
||||
extern const uint16_t numfont16x22[];
|
||||
#define NUM_FONT_GET_DATA(ch) (&numfont16x22[ch*22])
|
||||
|
|
@ -317,6 +319,9 @@ extern volatile uint8_t redraw_request;
|
|||
// Define size of screen buffer in pixels (one pixel 16bit size)
|
||||
#define SPI_BUFFER_SIZE 2048
|
||||
|
||||
#define LCD_WIDTH 320
|
||||
#define LCD_HEIGHT 240
|
||||
|
||||
#define DEFAULT_FG_COLOR RGB565(255,255,255)
|
||||
#define DEFAULT_BG_COLOR RGB565( 0, 0, 0)
|
||||
#define DEFAULT_GRID_COLOR RGB565(128,128,128)
|
||||
|
|
@ -339,7 +344,7 @@ extern uint16_t spi_buffer[SPI_BUFFER_SIZE];
|
|||
void ili9341_init(void);
|
||||
void ili9341_test(int mode);
|
||||
void ili9341_bulk(int x, int y, int w, int h);
|
||||
void ili9341_fill(int x, int y, int w, int h, int color);
|
||||
void ili9341_fill(int x, int y, int w, int h, uint16_t color);
|
||||
void ili9341_set_foreground(uint16_t fg);
|
||||
void ili9341_set_background(uint16_t fg);
|
||||
void ili9341_clear_screen(void);
|
||||
|
|
|
|||
34
plot.c
34
plot.c
|
|
@ -47,8 +47,8 @@ pixel_t *cell_buffer = (pixel_t *)spi_buffer;
|
|||
#endif
|
||||
|
||||
// indicate dirty cells (not redraw if cell data not changed)
|
||||
#define MAX_MARKMAP_X ((320+CELLWIDTH-1)/CELLWIDTH)
|
||||
#define MAX_MARKMAP_Y ((240+CELLHEIGHT-1)/CELLHEIGHT)
|
||||
#define MAX_MARKMAP_X ((LCD_WIDTH+CELLWIDTH-1)/CELLWIDTH)
|
||||
#define MAX_MARKMAP_Y ((LCD_HEIGHT+CELLHEIGHT-1)/CELLHEIGHT)
|
||||
// Define markmap mask size
|
||||
#if MAX_MARKMAP_X <= 8
|
||||
typedef uint8_t map_t;
|
||||
|
|
@ -845,7 +845,7 @@ static inline void
|
|||
markmap_upperarea(void)
|
||||
{
|
||||
// Hardcoded, Text info from upper area
|
||||
invalidate_rect(0, 0, AREA_WIDTH_NORMAL, 31);
|
||||
invalidate_rect(0, 0, AREA_WIDTH_NORMAL, 3*FONT_STR_HEIGHT);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -1332,7 +1332,7 @@ draw_cell(int m, int n)
|
|||
#endif
|
||||
// Draw trace and marker info on the top (50 system ticks for all screen calls)
|
||||
#if 1
|
||||
if (n == 0)
|
||||
if (n <= (3*FONT_STR_HEIGHT)/CELLHEIGHT)
|
||||
cell_draw_marker_info(x0, y0);
|
||||
#endif
|
||||
// PULSE;
|
||||
|
|
@ -1373,10 +1373,10 @@ draw_all_cells(bool flush_markmap)
|
|||
for (n = 0; n < (area_height+CELLHEIGHT-1) / CELLHEIGHT; n++) {
|
||||
if ((markmap[0][n] | markmap[1][n]) & (1 << m)) {
|
||||
draw_cell(m, n);
|
||||
// ili9341_fill(m*CELLWIDTH+10, n*CELLHEIGHT, 2, 2, RGB565(255,0,0));
|
||||
//ili9341_fill(m*CELLWIDTH+OFFSETX, n*CELLHEIGHT, 2, 2, RGB565(255,0,0));
|
||||
}
|
||||
// else
|
||||
// ili9341_fill(m*CELLWIDTH+10, n*CELLHEIGHT, 2, 2, RGB565(0,255,0));
|
||||
//ili9341_fill(m*CELLWIDTH+OFFSETX, n*CELLHEIGHT, 2, 2, RGB565(0,255,0));
|
||||
}
|
||||
// STOP_PROFILE
|
||||
if (flush_markmap) {
|
||||
|
|
@ -1428,7 +1428,7 @@ void
|
|||
request_to_draw_cells_behind_menu(void)
|
||||
{
|
||||
// Values Hardcoded from ui.c
|
||||
invalidate_rect(320-70, 0, 319, 239);
|
||||
invalidate_rect(LCD_WIDTH-70, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
|
||||
redraw_request |= REDRAW_CELLS;
|
||||
}
|
||||
|
||||
|
|
@ -1436,7 +1436,7 @@ void
|
|||
request_to_draw_cells_behind_numeric_input(void)
|
||||
{
|
||||
// Values Hardcoded from ui.c
|
||||
invalidate_rect(0, 240-32, 319, 239);
|
||||
invalidate_rect(0, LCD_HEIGHT-32, LCD_WIDTH-1, LCD_HEIGHT-1);
|
||||
redraw_request |= REDRAW_CELLS;
|
||||
}
|
||||
|
||||
|
|
@ -1492,7 +1492,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
if (!markers[mk].enabled)
|
||||
continue;
|
||||
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
int ypos = 1 + (j/2)*(FONT_STR_HEIGHT) - y0;
|
||||
|
||||
ili9341_set_foreground(config.trace_color[t]);
|
||||
if (mk == active_marker)
|
||||
|
|
@ -1525,7 +1525,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
if (!uistat.marker_delta && previous_marker >= 0 && active_marker != previous_marker && markers[previous_marker].enabled) {
|
||||
int idx0 = markers[previous_marker].index;
|
||||
int xpos = (WIDTH/2+30) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
int ypos = 1 + (j/2)*(FONT_STR_HEIGHT) - y0;
|
||||
|
||||
plot_printf(buf, sizeof buf, S_DELTA"%d-%d:", active_marker+1, previous_marker+1);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
|
|
@ -1546,7 +1546,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
if (!trace[t].enabled)
|
||||
continue;
|
||||
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
int ypos = 1 + (j/2)*(FONT_STR_HEIGHT) - y0;
|
||||
|
||||
ili9341_set_foreground(config.trace_color[t]);
|
||||
if (t == uistat.current_trace)
|
||||
|
|
@ -1568,7 +1568,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
|
||||
// draw marker frequency
|
||||
int xpos = (WIDTH/2+40) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
int ypos = 1 + (j/2)*(FONT_STR_HEIGHT) - y0;
|
||||
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
if (uistat.lever_mode == LM_MARKER)
|
||||
|
|
@ -1589,7 +1589,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
if (electrical_delay != 0) {
|
||||
// draw electrical delay
|
||||
int xpos = 21 + CELLOFFSETX - x0;
|
||||
int ypos = 1 + ((j+1)/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
int ypos = 1 + ((j+1)/2)*(FONT_STR_HEIGHT) - y0;
|
||||
|
||||
if (uistat.lever_mode == LM_EDELAY)
|
||||
cell_drawstring(S_SARROW, xpos, ypos);
|
||||
|
|
@ -1623,7 +1623,7 @@ draw_frequencies(void)
|
|||
}
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
ili9341_fill(0, FREQUENCIES_YPOS, 320, FONT_GET_HEIGHT, DEFAULT_BG_COLOR);
|
||||
ili9341_fill(0, FREQUENCIES_YPOS, LCD_WIDTH, FONT_GET_HEIGHT, DEFAULT_BG_COLOR);
|
||||
if (uistat.lever_mode == LM_CENTER)
|
||||
buf1[0] = S_SARROW[0];
|
||||
if (uistat.lever_mode == LM_SPAN)
|
||||
|
|
@ -1640,13 +1640,13 @@ draw_cal_status(void)
|
|||
char c[3];
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
ili9341_fill(0, y, OFFSETX, 6*(FONT_GET_HEIGHT+1), DEFAULT_BG_COLOR);
|
||||
ili9341_fill(0, y, OFFSETX, 6*(FONT_STR_HEIGHT), DEFAULT_BG_COLOR);
|
||||
if (cal_status & CALSTAT_APPLY) {
|
||||
c[0] = cal_status & CALSTAT_INTERPOLATED ? 'c' : 'C';
|
||||
c[1] = active_props == ¤t_props ? '*' : '0' + lastsaveid;
|
||||
c[2] = 0;
|
||||
ili9341_drawstring(c, x, y);
|
||||
y +=FONT_GET_HEIGHT+1;
|
||||
y +=FONT_STR_HEIGHT;
|
||||
}
|
||||
int i;
|
||||
static const struct {char text, zero, mask;} calibration_text[]={
|
||||
|
|
@ -1656,7 +1656,7 @@ draw_cal_status(void)
|
|||
{'T', 0, CALSTAT_ET},
|
||||
{'X', 0, CALSTAT_EX}
|
||||
};
|
||||
for (i = 0; i < 5; i++, y+=FONT_GET_HEIGHT+1)
|
||||
for (i = 0; i < 5; i++, y+=FONT_STR_HEIGHT)
|
||||
if (cal_status & calibration_text[i].mask)
|
||||
ili9341_drawstring(&calibration_text[i].text, x, y);
|
||||
}
|
||||
|
|
|
|||
46
ui.c
46
ui.c
|
|
@ -307,9 +307,9 @@ touch_cal_exec(void)
|
|||
y1 = last_touch_y;
|
||||
|
||||
ili9341_clear_screen();
|
||||
ili9341_line(320-1, 240-1, 320-1, 240-32);
|
||||
ili9341_line(320-1, 240-1, 320-32, 240-1);
|
||||
ili9341_drawstring("TOUCH LOWER RIGHT", 230, 220);
|
||||
ili9341_line(LCD_WIDTH-1, LCD_HEIGHT-1, LCD_WIDTH-1, LCD_HEIGHT-32);
|
||||
ili9341_line(LCD_WIDTH-1, LCD_HEIGHT-1, LCD_WIDTH-32, LCD_HEIGHT-1);
|
||||
ili9341_drawstring("TOUCH LOWER RIGHT", LCD_HEIGHT-FONT_GET_HEIGHT-10, LCD_WIDTH-17*(FONT_WIDTH)-10);
|
||||
|
||||
touch_wait_release();
|
||||
x2 = last_touch_x;
|
||||
|
|
@ -317,8 +317,8 @@ touch_cal_exec(void)
|
|||
|
||||
config.touch_cal[0] = x1;
|
||||
config.touch_cal[1] = y1;
|
||||
config.touch_cal[2] = (x2 - x1) * 16 / 320;
|
||||
config.touch_cal[3] = (y2 - y1) * 16 / 240;
|
||||
config.touch_cal[2] = (x2 - x1) * 16 / LCD_WIDTH;
|
||||
config.touch_cal[3] = (y2 - y1) * 16 / LCD_HEIGHT;
|
||||
|
||||
//redraw_all();
|
||||
touch_start_watchdog();
|
||||
|
|
@ -1136,7 +1136,7 @@ menu_invoke(int item)
|
|||
#define KP_WIDTH 48
|
||||
#define KP_HEIGHT 48
|
||||
// Key x, y position (0 - 15) on screen
|
||||
#define KP_GET_X(posx) ((posx)*KP_WIDTH + (320-64-KP_WIDTH*4))
|
||||
#define KP_GET_X(posx) ((posx)*KP_WIDTH + (LCD_WIDTH-64-KP_WIDTH*4))
|
||||
#define KP_GET_Y(posy) ((posy)*KP_HEIGHT + 12 )
|
||||
|
||||
// Key names
|
||||
|
|
@ -1268,10 +1268,10 @@ draw_keypad(void)
|
|||
static void
|
||||
draw_numeric_area_frame(void)
|
||||
{
|
||||
ili9341_fill(0, 240-NUM_INPUT_HEIGHT, 320, NUM_INPUT_HEIGHT, config.menu_normal_color);
|
||||
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT, config.menu_normal_color);
|
||||
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
||||
ili9341_set_background(config.menu_normal_color);
|
||||
ili9341_drawstring(keypad_mode_label[keypad_mode], 10, 240-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
|
||||
ili9341_drawstring(keypad_mode_label[keypad_mode], 10, LCD_HEIGHT-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
|
||||
//ili9341_drawfont(KP_KEYPAD, 300, 216);
|
||||
}
|
||||
|
||||
|
|
@ -1303,16 +1303,16 @@ draw_numeric_input(const char *buf)
|
|||
ili9341_set_foreground(fg);
|
||||
ili9341_set_background(bg);
|
||||
if (c >= 0) // c is number
|
||||
ili9341_drawfont(c, x, 240-NUM_INPUT_HEIGHT+4);
|
||||
ili9341_drawfont(c, x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4);
|
||||
else if (focused) // c not number, but focused
|
||||
ili9341_drawfont(0, x, 240-NUM_INPUT_HEIGHT+4);
|
||||
ili9341_drawfont(0, x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4);
|
||||
else // erase
|
||||
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_HEIGHT, NUM_FONT_GET_WIDTH+2+8, bg);
|
||||
ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_HEIGHT, NUM_FONT_GET_WIDTH+2+8, bg);
|
||||
|
||||
x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
|
||||
}
|
||||
// erase last
|
||||
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, NUM_FONT_GET_WIDTH+2+8, config.menu_normal_color);
|
||||
ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, NUM_FONT_GET_WIDTH+2+8, config.menu_normal_color);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1417,18 +1417,18 @@ draw_menu_buttons(const menuitem_t *menu)
|
|||
// focus only in MENU mode but not in KEYPAD mode
|
||||
if (ui_mode == UI_MENU && i == selection)
|
||||
bg = config.menu_active_color;
|
||||
ili9341_fill(320-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT-2, bg);
|
||||
ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT-2, bg);
|
||||
|
||||
menu_item_modify_attribute(menu, i, &fg, &bg);
|
||||
ili9341_set_foreground(fg);
|
||||
ili9341_set_background(bg);
|
||||
if (menu_is_multiline(menu[i].label, &l1, &l2)) {
|
||||
ili9341_fill(320-MENU_BUTTON_WIDTH+3, y+5, MENU_BUTTON_WIDTH-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg);
|
||||
ili9341_drawstring(l1, 320-MENU_BUTTON_WIDTH+5, y+7);
|
||||
ili9341_drawstring(l2, 320-MENU_BUTTON_WIDTH+5, y+7+FONT_GET_HEIGHT+1);
|
||||
ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH+3, y+5, MENU_BUTTON_WIDTH-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg);
|
||||
ili9341_drawstring(l1, LCD_WIDTH-MENU_BUTTON_WIDTH+5, y+7);
|
||||
ili9341_drawstring(l2, LCD_WIDTH-MENU_BUTTON_WIDTH+5, y+7+FONT_GET_HEIGHT+1);
|
||||
} else {
|
||||
ili9341_fill(320-MENU_BUTTON_WIDTH+3, y+8, MENU_BUTTON_WIDTH-6, 2+FONT_GET_HEIGHT+2, bg);
|
||||
ili9341_drawstring(menu[i].label, 320-MENU_BUTTON_WIDTH+5, y+10);
|
||||
ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH+3, y+8, MENU_BUTTON_WIDTH-6, 2+FONT_GET_HEIGHT+2, bg);
|
||||
ili9341_drawstring(menu[i].label, LCD_WIDTH-MENU_BUTTON_WIDTH+5, y+10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1457,7 +1457,7 @@ menu_apply_touch(void)
|
|||
if (menu[i].type == MT_BLANK)
|
||||
continue;
|
||||
int y = MENU_BUTTON_HEIGHT*i;
|
||||
if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && 320-MENU_BUTTON_WIDTH < touch_x) {
|
||||
if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && LCD_WIDTH-MENU_BUTTON_WIDTH < touch_x) {
|
||||
menu_select_touch(i);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1476,13 +1476,13 @@ draw_menu(void)
|
|||
static void
|
||||
erase_menu_buttons(void)
|
||||
{
|
||||
ili9341_fill(320-MENU_BUTTON_WIDTH, 0, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX, DEFAULT_BG_COLOR);
|
||||
ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, 0, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX, DEFAULT_BG_COLOR);
|
||||
}
|
||||
|
||||
static void
|
||||
erase_numeric_input(void)
|
||||
{
|
||||
ili9341_fill(0, 240-NUM_INPUT_HEIGHT, 320, NUM_INPUT_HEIGHT, DEFAULT_BG_COLOR);
|
||||
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT, DEFAULT_BG_COLOR);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1612,7 +1612,7 @@ ui_mode_numeric(int _keypad_mode)
|
|||
keypad_mode = _keypad_mode;
|
||||
ui_mode = UI_NUMERIC;
|
||||
area_width = AREA_WIDTH_NORMAL;
|
||||
area_height = 240-NUM_INPUT_HEIGHT;//AREA_HEIGHT_NORMAL - 32;
|
||||
area_height = LCD_HEIGHT-NUM_INPUT_HEIGHT;//AREA_HEIGHT_NORMAL - 32;
|
||||
|
||||
draw_numeric_area_frame();
|
||||
fetch_numeric_target();
|
||||
|
|
@ -1925,7 +1925,7 @@ numeric_apply_touch(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (touch_y > 240-40) {
|
||||
if (touch_y > LCD_HEIGHT-40) {
|
||||
int n = 9 - (touch_x - 64) / 20;
|
||||
uistat.digit = n;
|
||||
uistat.digit_mode = TRUE;
|
||||
|
|
|
|||
Loading…
Reference in a new issue