Use "palette" index for draw all on display

Colors stored in config
Now possible change any color by 'color' command and store for use
master
DiSlord 5 years ago
parent 94cfd46996
commit 52b4f2bd58

@ -309,7 +309,7 @@ static void spi_init(void)
static void send_command(uint8_t cmd, uint8_t len, const uint8_t *data) static void send_command(uint8_t cmd, uint8_t len, const uint8_t *data)
{ {
// Uncomment on low speed SPI (possible get here before previous tx complete) // Uncomment on low speed SPI (possible get here before previous tx complete)
// while (SPI_IN_TX_RX); while (SPI_IN_TX_RX(LCD_SPI));
LCD_CS_LOW; LCD_CS_LOW;
LCD_DC_CMD; LCD_DC_CMD;
SPI_WRITE_8BIT(LCD_SPI, cmd); SPI_WRITE_8BIT(LCD_SPI, cmd);
@ -399,14 +399,18 @@ void ili9341_init(void)
} }
} }
void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette) static void ili9341_setWindow(int x, int y, int w, int h){
{
//uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; //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) }; //uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) };
uint32_t xx = __REV16(x | ((x + w - 1) << 16)); uint32_t xx = __REV16(x | ((x + w - 1) << 16));
uint32_t yy = __REV16(y | ((y + h - 1) << 16)); uint32_t yy = __REV16(y | ((y + h - 1) << 16));
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx); send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx);
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy); send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy);
}
void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette)
{
ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
uint8_t *buf = (uint8_t *)spi_buffer; uint8_t *buf = (uint8_t *)spi_buffer;
@ -418,12 +422,7 @@ void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette)
#ifndef __USE_DISPLAY_DMA__ #ifndef __USE_DISPLAY_DMA__
void ili9341_fill(int x, int y, int w, int h, uint16_t 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) }; ili9341_setWindow(x, y ,w, h);
//uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) };
uint32_t xx = __REV16(x | ((x + w - 1) << 16));
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t*)&xx);
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
int32_t len = w * h; int32_t len = w * h;
while (len-- > 0) while (len-- > 0)
@ -432,13 +431,7 @@ void ili9341_fill(int x, int y, int w, int h, uint16_t color)
void ili9341_bulk(int x, int y, int w, int h) void ili9341_bulk(int x, int y, int w, int h)
{ {
//uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; ili9341_setWindow(x, y ,w, h);
//uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) };
uint16_t *buf = spi_buffer;
uint32_t xx = __REV16(x | ((x + w - 1) << 16));
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx);
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
int32_t len = w * h; int32_t len = w * h;
while (len-- > 0) while (len-- > 0)
@ -449,17 +442,12 @@ void ili9341_bulk(int x, int y, int w, int h)
// Use DMA for send data // Use DMA for send data
// //
// Fill region by some color // Fill region by some color
void ili9341_fill(int x, int y, int w, int h, uint16_t color) void ili9341_fill(int x, int y, int w, int h)
{ {
//uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; ili9341_setWindow(x, y ,w, h);
//uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) };
uint32_t xx = __REV16(x | ((x + w - 1) << 16));
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx);
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
dmaStreamSetMemory0(dmatx, &color); dmaStreamSetMemory0(dmatx, &background_color);
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD); dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD);
dmaStreamFlush(w * h); dmaStreamFlush(w * h);
} }
@ -467,10 +455,7 @@ void ili9341_fill(int x, int y, int w, int h, uint16_t color)
// Copy spi_buffer to region // Copy spi_buffer to region
void ili9341_bulk(int x, int y, int w, int h) void ili9341_bulk(int x, int y, int w, int h)
{ {
uint32_t xx = __REV16(x | ((x + w - 1) << 16)); ili9341_setWindow(x, y ,w, h);
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx);
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
// Init Tx DMA mem->spi, set size, mode (spi and mem data size is 16 bit) // Init Tx DMA mem->spi, set size, mode (spi and mem data size is 16 bit)
@ -485,12 +470,7 @@ void ili9341_bulk(int x, int y, int w, int h)
void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
{ {
//uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; ili9341_setWindow(x, y ,w, h);
//uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) };
uint32_t xx = __REV16(x | ((x + w - 1) << 16));
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx);
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy);
send_command(ILI9341_MEMORY_READ, 0, NULL); send_command(ILI9341_MEMORY_READ, 0, NULL);
// Skip data from rx buffer // Skip data from rx buffer
spi_DropRx(); spi_DropRx();
@ -523,12 +503,8 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
uint16_t dummy_tx = 0; uint16_t dummy_tx = 0;
uint8_t *rgbbuf = (uint8_t *)out; uint8_t *rgbbuf = (uint8_t *)out;
uint16_t data_size = len * 3; uint16_t data_size = len * 3;
//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) }; ili9341_setWindow(x, y ,w, h);
uint32_t xx = __REV16(x | ((x + w - 1) << 16));
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx);
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy);
send_command(ILI9341_MEMORY_READ, 0, NULL); send_command(ILI9341_MEMORY_READ, 0, NULL);
// Init Rx DMA buffer, size, mode (spi and mem data size is 8 bit) // Init Rx DMA buffer, size, mode (spi and mem data size is 8 bit)
@ -573,20 +549,22 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
void ili9341_clear_screen(void) void ili9341_clear_screen(void)
{ {
ili9341_fill(0, 0, ILI9341_WIDTH, ILI9341_HEIGHT, background_color); ili9341_fill(0, 0, ILI9341_WIDTH, ILI9341_HEIGHT);
} }
#ifndef ili9341_set_foreground #ifndef ili9341_set_foreground
void ili9341_set_foreground(uint16_t fg) void ili9341_set_foreground(uint16_t fg_idx)
{ {
foreground_color = fg; // if (fg_idx >= 32) fg_idx = 0;
foreground_color = GET_PALTETTE_COLOR(fg_idx);
} }
#endif #endif
#ifndef ili9341_set_background #ifndef ili9341_set_background
void ili9341_set_background(uint16_t bg) void ili9341_set_background(uint16_t bg_idx)
{ {
background_color = bg; // if (bg_idx >= 32) bg_idx = 0;
background_color = GET_PALTETTE_COLOR(bg_idx);
} }
#endif #endif
@ -740,7 +718,7 @@ void ili9341_line(int x0, int y0, int x1, int y1)
if (e2 < dy) { err += dx; y0 += sy; } if (e2 < dy) { err += dx; y0 += sy; }
} }
#endif #endif
SWAP(foreground_color, background_color);
if (x0 > x1) { if (x0 > x1) {
SWAP(x0, x1); SWAP(x0, x1);
SWAP(y0, y1); SWAP(y0, y1);
@ -765,12 +743,13 @@ void ili9341_line(int x0, int y0, int x1, int y1)
} }
} }
if (dy > 0) if (dy > 0)
ili9341_fill(x0, y0, dx, dy, foreground_color); ili9341_fill(x0, y0, dx, dy);
else else
ili9341_fill(x0, y0+dy, dx, -dy, foreground_color); ili9341_fill(x0, y0+dy, dx, -dy);
x0 += dx; x0 += dx;
y0 += dy; y0 += dy;
} }
SWAP(foreground_color, background_color);
} }
#if 0 #if 0

@ -863,11 +863,6 @@ usage:
config_t config = { config_t config = {
.magic = CONFIG_MAGIC, .magic = CONFIG_MAGIC,
.dac_value = 1922, .dac_value = 1922,
.grid_color = DEFAULT_GRID_COLOR,
.ham_color = DEFAULT_HAM_COLOR,
.menu_normal_color = DEFAULT_MENU_COLOR,
.menu_active_color = DEFAULT_MENU_ACTIVE_COLOR,
.trace_color = { DEFAULT_TRACE_1_COLOR, DEFAULT_TRACE_2_COLOR, DEFAULT_TRACE_3_COLOR},
// .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel // .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel
.touch_cal = { 347, 495, 160, 205 }, // 2.8 inch LCD panel .touch_cal = { 347, 495, 160, 205 }, // 2.8 inch LCD panel
._mode = _MODE_USB, ._mode = _MODE_USB,
@ -875,6 +870,7 @@ config_t config = {
#ifdef __VNA__ #ifdef __VNA__
.harmonic_freq_threshold = 300000000, .harmonic_freq_threshold = 300000000,
#endif #endif
.lcd_palette = LCD_DEFAULT_PALETTE,
.vbat_offset = 500, .vbat_offset = 500,
.low_level_offset = 100, // Uncalibrated .low_level_offset = 100, // Uncalibrated
.high_level_offset = 100, // Uncalibrated .high_level_offset = 100, // Uncalibrated
@ -904,7 +900,7 @@ static const marker_t def_markers[MARKERS_MAX] = {
}; };
// Load propeties default settings // Load propeties default settings
void load_default_properties(void) void load_LCD_properties(void)
{ {
//Magic add on caldata_save //Magic add on caldata_save
//current_props.magic = CONFIG_MAGIC; //current_props.magic = CONFIG_MAGIC;
@ -2234,43 +2230,19 @@ VNA_SHELL_FUNCTION(cmd_color)
int i; int i;
if (argc != 2) { if (argc != 2) {
shell_printf("usage: color {id} {rgb24}\r\n"); shell_printf("usage: color {id} {rgb24}\r\n");
for (i=-3; i < TRACES_MAX; i++) { for (i=0; i < MAX_PALETTE; i++) {
#if 0 color = GET_PALTETTE_COLOR(i);
switch(i) { color = HEXRGB(color);
case -3: color = config.grid_color; break; shell_printf(" %2d: 0x%06x\r\n", i, color);
case -2: color = config.menu_normal_color; break;
case -1: color = config.menu_active_color; break;
default: color = config.trace_color[i];break;
}
#else
// WARNING!!! Dirty hack for size, depend from config struct
color = config.trace_color[i];
#endif
color = ((color >> 3) & 0x001c00) |
((color >> 5) & 0x0000f8) |
((color << 16) & 0xf80000) |
((color << 13) & 0x00e000);
// color = (color>>8)|(color<<8);
// color = ((color<<8)&0xF80000)|((color<<5)&0x00FC00)|((color<<3)&0x0000F8);
shell_printf(" %d: 0x%06x\r\n", i, color);
} }
return; return;
} }
i = my_atoi(argv[0]); i = my_atoi(argv[0]);
if (i < -3 && i >= TRACES_MAX) if (i >= MAX_PALETTE)
return; return;
color = RGBHEX(my_atoui(argv[1])); color = RGBHEX(my_atoui(argv[1]));
#if 0 config.lcd_palette[i] = color;
switch(i) {
case -3: config.grid_color = color; break;
case -2: config.menu_normal_color = color; break;
case -1: config.menu_active_color = color; break;
default: config.trace_color[i] = color;break;
}
#else
// WARNING!!! Dirty hack for size, depend from config struct
config.trace_color[i] = color;
#endif
// Redraw all // Redraw all
redraw_request|= REDRAW_AREA; redraw_request|= REDRAW_AREA;
} }
@ -2742,7 +2714,7 @@ static UARTConfig uart_cfg_1 = {
#endif #endif
#if 0 #if 0
static const SerialConfig default_config = static const SerialConfig LCD_config =
{ {
9600, 9600,
0, 0,
@ -2851,7 +2823,7 @@ int main(void)
/* restore config */ /* restore config */
config_recall(); config_recall();
if (caldata_recall(0) == -1) { if (caldata_recall(0) == -1) {
load_default_properties(); load_LCD_properties();
} }
/* /*
@ -2902,7 +2874,7 @@ int main(void)
#endif #endif
if (caldata_recall(0) == -1) { if (caldata_recall(0) == -1) {
load_default_properties(); load_LCD_properties();
} }
set_refer_output(-1); set_refer_output(-1);
@ -2973,8 +2945,8 @@ void hard_fault_handler_c(uint32_t *sp)
int y = 0; int y = 0;
int x = OFFSETX + 1; int x = OFFSETX + 1;
static char buf[96]; static char buf[96];
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
plot_printf(buf, sizeof(buf), "SP 0x%08x", (uint32_t)sp);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); plot_printf(buf, sizeof(buf), "SP 0x%08x", (uint32_t)sp);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT);
plot_printf(buf, sizeof(buf), "R0 0x%08x", r0);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); plot_printf(buf, sizeof(buf), "R0 0x%08x", r0);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT);

@ -399,6 +399,9 @@ extern const uint8_t numfont16x22[];
#define S_OHM "\036" // 0x1E #define S_OHM "\036" // 0x1E
#define S_DEGREE "\037" // 0x1F #define S_DEGREE "\037" // 0x1F
// Max palette indexes in config
#define MAX_PALETTE 32
// trace // trace
#define MAX_TRACE_TYPE 12 #define MAX_TRACE_TYPE 12
enum trace_type { enum trace_type {
@ -446,30 +449,27 @@ typedef struct trace {
typedef struct config { typedef struct config {
int32_t magic; int32_t magic;
uint16_t dac_value; uint16_t lcd_palette[MAX_PALETTE];
uint16_t grid_color;
uint16_t menu_normal_color;
uint16_t menu_active_color;
uint16_t trace_color[TRACES_MAX];
int16_t touch_cal[4]; int16_t touch_cal[4];
int8_t _mode;
uint32_t _serial_speed; uint32_t _serial_speed;
#ifdef __VNA__ #ifdef __VNA__
uint32_t harmonic_freq_threshold; uint32_t harmonic_freq_threshold;
#endif #endif
uint16_t dac_value;
uint16_t vbat_offset; uint16_t vbat_offset;
float low_level_offset; float low_level_offset;
float high_level_offset; float high_level_offset;
uint32_t correction_frequency[CORRECTION_POINTS]; uint32_t correction_frequency[CORRECTION_POINTS];
float correction_value[CORRECTION_POINTS]; float correction_value[CORRECTION_POINTS];
uint32_t deviceid; uint32_t deviceid;
uint16_t ham_color; uint32_t setting_frequency_10mhz;
uint16_t gridlines; uint16_t gridlines;
uint16_t hambands; uint16_t hambands;
int8_t cor_am;
int8_t _mode; int8_t cor_am;
int8_t cor_wfm; int8_t cor_wfm;
int8_t cor_nfm; int8_t cor_nfm;
uint32_t setting_frequency_10mhz;
int8_t dummy; int8_t dummy;
// uint8_t _reserved[22]; // uint8_t _reserved[22];
uint32_t checksum; uint32_t checksum;
@ -572,12 +572,10 @@ extern volatile uint8_t redraw_request;
* ili9341.c * ili9341.c
*/ */
// SPI bus revert byte order // SPI bus revert byte order
//gggBBBbb RRRrrGGG // 16-bit gggBBBbb RRRrrGGG
#define byteReverse16(x) (uint16_t)(((x) << 8) & 0xff00) | (((x) >> 8) & 0xff) #define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) )
#define RGB565(r,g,b) byteReverse16( ((((uint16_t)(r))<<8)&0b1111100000000000) | ((((uint16_t)(g))<<3)&0b0000011111100000) | ((((uint16_t)(b))>>3)&0b0000000000011111) )
//#define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) )
#define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) ) #define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) )
#define HEXRGB(hex) ( (((hex)>>3)&0x001c00) | (((hex)>>5)&0x0000f8) | (((hex)<<16)&0xf80000) | (((hex)<<13)&0x00e000) )
// Define size of screen buffer in pixels (one pixel 16bit size) // Define size of screen buffer in pixels (one pixel 16bit size)
#define SPI_BUFFER_SIZE (CELLWIDTH*CELLHEIGHT) #define SPI_BUFFER_SIZE (CELLWIDTH*CELLHEIGHT)
@ -585,27 +583,71 @@ extern volatile uint8_t redraw_request;
#define LCD_WIDTH 320 #define LCD_WIDTH 320
#define LCD_HEIGHT 240 #define LCD_HEIGHT 240
#define DEFAULT_FG_COLOR RGB565(255,255,255) #define LCD_BG_COLOR 0
#define DEFAULT_BG_COLOR RGB565( 0, 0, 0) #define LCD_FG_COLOR 1
#define DARK_GREY RGB565(140,140,140) #define LCD_GRID_COLOR 2
#define LIGHT_GREY RGB565(220,220,220) #define LCD_MENU_COLOR 3
#define DEFAULT_GRID_COLOR RGB565(128,128,128) #define LCD_MENU_TEXT_COLOR 4
#define DEFAULT_HAM_COLOR RGB565(80,80,80) #define LCD_MENU_ACTIVE_COLOR 5
#define DEFAULT_GRID_VALUE_COLOR RGB565(196,196,196) #define LCD_TRACE_1_COLOR 6
#define DEFAULT_MENU_COLOR RGB565(255,255,255) #define LCD_TRACE_2_COLOR 7
#define DEFAULT_MENU_TEXT_COLOR RGB565( 0, 0, 0) #define LCD_TRACE_3_COLOR 8
#define DEFAULT_MENU_ACTIVE_COLOR RGB565(180,255,180) #define LCD_TRACE_4_COLOR 9
#define DEFAULT_TRACE_1_COLOR RGB565(255, 0, 0) /* RGB565(255,255, 0) */ #define LCD_NORMAL_BAT_COLOR 10
#define DEFAULT_TRACE_2_COLOR RGB565( 0,255, 0)/* RGB565( 0,255,255) */ #define LCD_LOW_BAT_COLOR 11
#define DEFAULT_TRACE_3_COLOR RGB565(255,255, 0)/* RGB565( 0,255, 0) */ #define LCD_TRIGGER_COLOR 12
#define DEFAULT_TRIGGER_COLOR RGB565( 0, 0,255)/* RGB565( 0 0,255) */ #define LCD_RISE_EDGE_COLOR 13
//#define DEFAULT_TRACE_4_COLOR RGB565(255, 0,255) #define LCD_FALLEN_EDGE_COLOR 14
#define DEFAULT_NORMAL_BAT_COLOR RGB565( 31,227, 0) #define LCD_SWEEP_LINE_COLOR 15
#define DEFAULT_LOW_BAT_COLOR RGB565(255, 0, 0) #define LCD_BW_TEXT_COLOR 16
#define DEFAULT_SPEC_INPUT_COLOR RGB565(128,255,128); #define LCD_INPUT_TEXT_COLOR 17
#define BRIGHT_COLOR_BLUE RGB565(0,0,255) #define LCD_INPUT_BG_COLOR 18
#define BRIGHT_COLOR_RED RGB565(255,128,128) #define LCD_BRIGHT_COLOR_BLUE 19
#define BRIGHT_COLOR_GREEN RGB565(0,255,0) #define LCD_BRIGHT_COLOR_RED 20
#define LCD_BRIGHT_COLOR_GREEN 21
#define LCD_DARK_GREY 22
#define LCD_LIGHT_GREY 23
#define LCD_HAM_COLOR 24
#define LCD_GRID_VALUE_COLOR 25
#define LCD_M_REFERENCE 26
#define LCD_M_DELTA 27
#define LCD_M_NOISE 28
#define LCD_M_DEFAULT 29
#define LCD_DEFAULT_PALETTE {\
[LCD_BG_COLOR ] = RGB565( 0, 0, 0), \
[LCD_FG_COLOR ] = RGB565(255,255,255), \
[LCD_GRID_COLOR ] = RGB565(128,128,128), \
[LCD_MENU_COLOR ] = RGB565(230,230,230), \
[LCD_MENU_TEXT_COLOR ] = RGB565( 0, 0, 0), \
[LCD_MENU_ACTIVE_COLOR] = RGB565(210,210,210), \
[LCD_TRACE_1_COLOR ] = RGB565(255,255, 0), \
[LCD_TRACE_2_COLOR ] = RGB565( 0,255,255), \
[LCD_TRACE_3_COLOR ] = RGB565( 0,255, 0), \
[LCD_TRACE_4_COLOR ] = RGB565(255, 0,255), \
[LCD_NORMAL_BAT_COLOR ] = RGB565( 31,227, 0), \
[LCD_LOW_BAT_COLOR ] = RGB565(255, 0, 0), \
[LCD_TRIGGER_COLOR ] = RGB565( 0, 0,255), \
[LCD_RISE_EDGE_COLOR ] = RGB565(255,255,255), \
[LCD_FALLEN_EDGE_COLOR] = RGB565(128,128,128), \
[LCD_SWEEP_LINE_COLOR ] = RGB565( 0,255, 0), \
[LCD_BW_TEXT_COLOR ] = RGB565(128,128,128), \
[LCD_INPUT_TEXT_COLOR ] = RGB565( 0, 0, 0), \
[LCD_INPUT_BG_COLOR ] = RGB565(255,255,255), \
[LCD_BRIGHT_COLOR_BLUE] = RGB565( 0, 0,255), \
[LCD_BRIGHT_COLOR_RED ] = RGB565(255,128,128), \
[LCD_BRIGHT_COLOR_GREEN]= RGB565( 0,255, 0), \
[LCD_DARK_GREY ] = RGB565(140,140,140), \
[LCD_LIGHT_GREY ] = RGB565(220,220,220), \
[LCD_HAM_COLOR ] = RGB565( 80, 80, 80), \
[LCD_GRID_VALUE_COLOR ] = RGB565(196,196,196), \
[LCD_M_REFERENCE ] = RGB565(255,255,255), \
[LCD_M_DELTA ] = RGB565( 0,255, 0), \
[LCD_M_NOISE ] = RGB565( 0,255,255), \
[LCD_M_DEFAULT ] = RGB565(255,255, 0), \
}
#define GET_PALTETTE_COLOR(idx) config.lcd_palette[idx]
extern uint16_t foreground_color; extern uint16_t foreground_color;
extern uint16_t background_color; extern uint16_t background_color;
@ -621,15 +663,10 @@ extern uint16_t spi_buffer[SPI_BUFFER_SIZE];
void ili9341_init(void); void ili9341_init(void);
void ili9341_test(int mode); void ili9341_test(int mode);
void ili9341_bulk(int x, int y, int w, int h); void ili9341_bulk(int x, int y, int w, int h);
void ili9341_fill(int x, int y, int w, int h, uint16_t color); void ili9341_fill(int x, int y, int w, int h);
#if 1 void ili9341_set_foreground(uint16_t fg_idx);
void ili9341_set_foreground(uint16_t fg); void ili9341_set_background(uint16_t bg_idx);
void ili9341_set_background(uint16_t fg);
#else
#define ili9341_set_foreground(fg) { foreground_color = fg; }
#define ili9341_set_background(bg) { background_color = bg;}
#endif
void ili9341_clear_screen(void); void ili9341_clear_screen(void);
void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *bitmap); void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *bitmap);
@ -814,7 +851,7 @@ typedef struct properties {
//sizeof(properties_t) == 0x1200 //sizeof(properties_t) == 0x1200
#define CONFIG_MAGIC 0x434f4e46 /* 'CONF' */ #define CONFIG_MAGIC 0x434f4e47 /* 'CONF' */
extern int16_t lastsaveid; extern int16_t lastsaveid;
//extern properties_t *active_props; //extern properties_t *active_props;

@ -74,12 +74,12 @@ typedef uint32_t map_t;
uint16_t marker_color(int mtype) uint16_t marker_color(int mtype)
{ {
if (mtype & M_REFERENCE) if (mtype & M_REFERENCE)
return(RGBHEX(0xFFFFFF)); return LCD_M_REFERENCE;
if (mtype & M_DELTA) if (mtype & M_DELTA)
return(RGBHEX(0x00FF00)); return LCD_M_DELTA;
if (mtype & M_NOISE) if (mtype & M_NOISE)
return(RGBHEX(0x00FFFF)); return LCD_M_NOISE;
return(RGBHEX(0xFFFF00)); return LCD_M_DEFAULT;
} }
//#if 4 != M_TRACKING //#if 4 != M_TRACKING
@ -149,8 +149,10 @@ void update_grid(void)
grid_width = (WIDTH) * (grid / 100) / (fspan / 1000); grid_width = (WIDTH) * (grid / 100) / (fspan / 1000);
force_set_markmap(); force_set_markmap();
if (get_waterfall()) if (get_waterfall()){
ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom, 0); ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom);
}
redraw_request |= REDRAW_FREQUENCY; redraw_request |= REDRAW_FREQUENCY;
} }
@ -1539,27 +1541,28 @@ draw_cell(int m, int n)
#if 0 #if 0
// use memset 350 system ticks for all screen calls // use memset 350 system ticks for all screen calls
// as understand it use 8 bit set, slow down on 32 bit systems // as understand it use 8 bit set, slow down on 32 bit systems
memset(spi_buffer, DEFAULT_BG_COLOR, (h*CELLWIDTH)*sizeof(uint16_t)); memset(spi_buffer, LCD_BG_COLOR, (h*CELLWIDTH)*sizeof(uint16_t));
#else #else
// use direct set 35 system ticks for all screen calls // use direct set 35 system ticks for all screen calls
#if CELLWIDTH%8 != 0 #if CELLWIDTH%8 != 0
#error "CELLWIDTH % 8 should be == 0 for speed, or need rewrite cell cleanup" #error "CELLWIDTH % 8 should be == 0 for speed, or need rewrite cell cleanup"
#endif #endif
// Set DEFAULT_BG_COLOR for 8 pixels in one cycle // Set LCD_BG_COLOR for 8 pixels in one cycle
int count = h*CELLWIDTH / (16/sizeof(pixel_t)); int count = h*CELLWIDTH / 8;
uint32_t *p = (uint32_t *)cell_buffer; uint32_t *p = (uint32_t *)cell_buffer;
uint32_t clr = GET_PALTETTE_COLOR(LCD_BG_COLOR) | (GET_PALTETTE_COLOR(LCD_BG_COLOR) << 16);
while (count--) { while (count--) {
p[0] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); p[0] = clr;
p[1] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); p[1] = clr;
p[2] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); p[2] = clr;
p[3] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); p[3] = clr;
p += 4; p += 4;
} }
#endif #endif
// Draw grid // Draw grid
#if 1 #if 1
c = config.grid_color; c = GET_PALTETTE_COLOR(LCD_GRID_COLOR);
// Generate grid type list // Generate grid type list
uint32_t trace_type = 0; uint32_t trace_type = 0;
for (t = 0; t < TRACES_MAX; t++) { for (t = 0; t < TRACES_MAX; t++) {
@ -1572,7 +1575,7 @@ draw_cell(int m, int n)
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
#ifdef __HAM_BAND__ #ifdef __HAM_BAND__
if (ham_band(x+x0)) { if (ham_band(x+x0)) {
for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = config.ham_color; for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = GET_PALTETTE_COLOR(LCD_HAM_COLOR);
} }
#endif #endif
if (rectangular_grid_x(x + x0)) { if (rectangular_grid_x(x + x0)) {
@ -1618,7 +1621,7 @@ draw_cell(int m, int n)
if (tp>=0 && tp < h) if (tp>=0 && tp < h)
for (x = 0; x < w; x++) for (x = 0; x < w; x++)
if (x + x0 >= CELLOFFSETX && x + x0 <= WIDTH + CELLOFFSETX) if (x + x0 >= CELLOFFSETX && x + x0 <= WIDTH + CELLOFFSETX)
cell_buffer[tp * CELLWIDTH + x] = DEFAULT_TRIGGER_COLOR; cell_buffer[tp * CELLWIDTH + x] = LCD_TRIGGER_COLOR;
} }
#if 1 #if 1
@ -1633,7 +1636,7 @@ draw_cell(int m, int n)
for (t = 0; t < TRACES_MAX; t++) { for (t = 0; t < TRACES_MAX; t++) {
if (!trace[t].enabled) if (!trace[t].enabled)
continue; continue;
c = config.trace_color[t]; c = GET_PALTETTE_COLOR(LCD_TRACE_1_COLOR + t);
// draw polar plot (check all points) // draw polar plot (check all points)
i0 = 0; i0 = 0;
i1 = 0; i1 = 0;
@ -1674,10 +1677,10 @@ draw_cell(int m, int n)
if (x + MARKER_WIDTH >= 0 && x - MARKER_WIDTH < CELLWIDTH && if (x + MARKER_WIDTH >= 0 && x - MARKER_WIDTH < CELLWIDTH &&
y + MARKER_HEIGHT >= 0 && y - MARKER_HEIGHT < CELLHEIGHT){ y + MARKER_HEIGHT >= 0 && y - MARKER_HEIGHT < CELLHEIGHT){
// Draw marker plate // Draw marker plate
ili9341_set_foreground(config.trace_color[t]); ili9341_set_foreground(LCD_TRACE_1_COLOR + t);
cell_blit_bitmap(x, y, MARKER_WIDTH, MARKER_HEIGHT, MARKER_BITMAP(0)); cell_blit_bitmap(x, y, MARKER_WIDTH, MARKER_HEIGHT, MARKER_BITMAP(0));
// Draw marker number // Draw marker number
ili9341_set_foreground(DEFAULT_BG_COLOR); ili9341_set_foreground(LCD_BG_COLOR);
cell_blit_bitmap(x, y, MARKER_WIDTH, MARKER_HEIGHT, MARKER_BITMAP(i+1)); cell_blit_bitmap(x, y, MARKER_WIDTH, MARKER_HEIGHT, MARKER_BITMAP(i+1));
} }
// } // }
@ -1704,7 +1707,7 @@ draw_cell(int m, int n)
if (x + REFERENCE_WIDTH >= 0 && x - REFERENCE_WIDTH < CELLWIDTH) { if (x + REFERENCE_WIDTH >= 0 && x - REFERENCE_WIDTH < CELLWIDTH) {
int y = HEIGHT - float2int((get_trace_refpos(t) * GRIDY)) - y0 - REFERENCE_Y_OFFSET; int y = HEIGHT - float2int((get_trace_refpos(t) * GRIDY)) - y0 - REFERENCE_Y_OFFSET;
if (y + REFERENCE_HEIGHT >= 0 && y - REFERENCE_HEIGHT < CELLHEIGHT){ if (y + REFERENCE_HEIGHT >= 0 && y - REFERENCE_HEIGHT < CELLHEIGHT){
ili9341_set_foreground(config.trace_color[t]); ili9341_set_foreground(GET_PALTETTE_COLOR(LCD_TRACE_1_COLOR + t));
cell_blit_bitmap(x , y, REFERENCE_WIDTH, REFERENCE_HEIGHT, reference_bitmap); cell_blit_bitmap(x , y, REFERENCE_WIDTH, REFERENCE_HEIGHT, reference_bitmap);
} }
} }
@ -1942,7 +1945,7 @@ cell_draw_marker_info(int x0, int y0)
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; 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_GET_HEIGHT+1) - y0;
ili9341_set_foreground(config.trace_color[t]); ili9341_set_foreground(GET_PALTETTE_COLOR(LCD_TRACE_1_COLOR + t));
if (mk == active_marker) if (mk == active_marker)
cell_drawstring(S_SARROW, xpos, ypos); cell_drawstring(S_SARROW, xpos, ypos);
xpos += 5; xpos += 5;
@ -1964,7 +1967,7 @@ cell_draw_marker_info(int x0, int y0)
trace_get_value_string_delta(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index, markers[active_marker].index); trace_get_value_string_delta(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index, markers[active_marker].index);
else else
trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index); trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index);
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
cell_drawstring(buf, xpos, ypos); cell_drawstring(buf, xpos, ypos);
j++; j++;
} }
@ -1976,7 +1979,7 @@ cell_draw_marker_info(int x0, int y0)
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0; int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
plot_printf(buf, sizeof buf, S_DELTA"%d-%d:", active_marker+1, previous_marker+1); plot_printf(buf, sizeof buf, S_DELTA"%d-%d:", active_marker+1, previous_marker+1);
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
cell_drawstring(buf, xpos, ypos); cell_drawstring(buf, xpos, ypos);
xpos += 27; xpos += 27;
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
@ -1996,7 +1999,7 @@ cell_draw_marker_info(int x0, int y0)
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; 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_GET_HEIGHT+1) - y0;
ili9341_set_foreground(config.trace_color[t]); ili9341_set_foreground(GET_PALTETTE_COLOR(LCD_TRACE_1_COLOR + t));
if (t == uistat.current_trace) if (t == uistat.current_trace)
cell_drawstring(S_SARROW, xpos, ypos); cell_drawstring(S_SARROW, xpos, ypos);
xpos += 5; xpos += 5;
@ -2009,7 +2012,7 @@ cell_draw_marker_info(int x0, int y0)
xpos += n * 5 + 2; xpos += n * 5 + 2;
//xpos += 60; //xpos += 60;
trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], idx); trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], idx);
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
cell_drawstring(buf, xpos, ypos); cell_drawstring(buf, xpos, ypos);
j++; j++;
} }
@ -2018,7 +2021,7 @@ cell_draw_marker_info(int x0, int y0)
int xpos = (WIDTH/2+40) + CELLOFFSETX - x0; int xpos = (WIDTH/2+40) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0; int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
if (uistat.lever_mode == LM_MARKER) if (uistat.lever_mode == LM_MARKER)
cell_drawstring(S_SARROW, xpos, ypos); cell_drawstring(S_SARROW, xpos, ypos);
xpos += 5; xpos += 5;
@ -2033,7 +2036,7 @@ cell_draw_marker_info(int x0, int y0)
} }
cell_drawstring(buf, xpos, ypos); cell_drawstring(buf, xpos, ypos);
} }
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
if (electrical_delay != 0) { if (electrical_delay != 0) {
// draw electrical delay // draw electrical delay
int xpos = 21 + CELLOFFSETX - x0; int xpos = 21 + CELLOFFSETX - x0;
@ -2058,7 +2061,7 @@ static void cell_grid_line_info(int x0, int y0)
char buf[32]; char buf[32];
int xpos = GRID_X_TEXT - x0; int xpos = GRID_X_TEXT - x0;
int ypos = 0 - y0 + 2; int ypos = 0 - y0 + 2;
ili9341_set_foreground(DEFAULT_GRID_VALUE_COLOR); ili9341_set_foreground(LCD_GRID_VALUE_COLOR);
float ref = get_trace_refpos(TRACE_ACTUAL); float ref = get_trace_refpos(TRACE_ACTUAL);
float scale = get_trace_scale(TRACE_ACTUAL);; float scale = get_trace_scale(TRACE_ACTUAL);;
for (int i = 0; i < NGRIDY; i++){ for (int i = 0; i < NGRIDY; i++){
@ -2208,11 +2211,11 @@ static void cell_draw_marker_info(int x0, int y0)
#endif #endif
int k = 0; int k = 0;
if (i == active_marker) { if (i == active_marker) {
// ili9341_set_foreground(DEFAULT_BG_COLOR); // ili9341_set_foreground(LCD_BG_COLOR);
// ili9341_set_background(marker_color(markers[i].mtype)); // ili9341_set_background(marker_color(markers[i].mtype));
buf[k++] = S_SARROW[0]; buf[k++] = S_SARROW[0];
} else { } else {
// ili9341_set_background(DEFAULT_BG_COLOR); // ili9341_set_background(LCD_BG_COLOR);
// ili9341_set_foreground(marker_color(markers[i].mtype)); // ili9341_set_foreground(marker_color(markers[i].mtype));
buf[k++] = ' '; buf[k++] = ' ';
// buf[k++] = ' '; // buf[k++] = ' ';
@ -2228,12 +2231,12 @@ static void cell_draw_marker_info(int x0, int y0)
buf[k++] = 'N'; buf[k++] = 'N';
buf[k++] = ' '; buf[k++] = ' ';
// buf[k++] = 0; // buf[k++] = 0;
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
uint16_t color; uint16_t color;
if ((!setting.subtract_stored) && // Disabled when normalized if ((!setting.subtract_stored) && // Disabled when normalized
((setting.mode == M_LOW && temppeakLevel - get_attenuation() + setting.offset > -10) || ((setting.mode == M_LOW && temppeakLevel - get_attenuation() + setting.offset > -10) ||
(setting.mode == M_HIGH && temppeakLevel - get_attenuation()+ setting.offset > -29) )) (setting.mode == M_HIGH && temppeakLevel - get_attenuation()+ setting.offset > -29) ))
color = BRIGHT_COLOR_RED; color = LCD_BRIGHT_COLOR_RED;
else else
color = marker_color(markers[i].mtype); color = marker_color(markers[i].mtype);
ili9341_set_foreground(color); ili9341_set_foreground(color);
@ -2285,9 +2288,9 @@ draw_frequencies(void)
plot_printf(buf2, sizeof(buf2), "STOP %Fs (%Fm)", time_of_index(sweep_points-1), distance_of_index(sweep_points-1)); plot_printf(buf2, sizeof(buf2), "STOP %Fs (%Fm)", time_of_index(sweep_points-1), distance_of_index(sweep_points-1));
} }
#endif #endif
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(0, FREQUENCIES_YPOS, LCD_WIDTH, FONT_GET_HEIGHT, DEFAULT_BG_COLOR); ili9341_fill(0, FREQUENCIES_YPOS, LCD_WIDTH, FONT_GET_HEIGHT);
if (uistat.lever_mode == LM_CENTER) if (uistat.lever_mode == LM_CENTER)
buf1[0] = S_SARROW[0]; buf1[0] = S_SARROW[0];
if (uistat.lever_mode == LM_SPAN) if (uistat.lever_mode == LM_SPAN)
@ -2306,9 +2309,9 @@ draw_cal_status(void)
int x = 0; int x = 0;
int y = 100; int y = 100;
char c[3]; char c[3];
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(0, y, OFFSETX, 6*(FONT_GET_HEIGHT+1), DEFAULT_BG_COLOR); ili9341_fill(0, y, OFFSETX, 6*(FONT_GET_HEIGHT+1), LCD_BG_COLOR);
if (cal_status & CALSTAT_APPLY) { if (cal_status & CALSTAT_APPLY) {
c[0] = cal_status & CALSTAT_INTERPOLATED ? 'c' : 'C'; c[0] = cal_status & CALSTAT_INTERPOLATED ? 'c' : 'C';
c[1] = active_props == &current_props ? '*' : '0' + lastsaveid; c[1] = active_props == &current_props ? '*' : '0' + lastsaveid;
@ -2342,8 +2345,8 @@ static void draw_battery_status(void)
return; return;
uint8_t string_buf[16]; uint8_t string_buf[16];
// Set battery color // Set battery color
ili9341_set_foreground(vbat < BATTERY_WARNING_LEVEL ? DEFAULT_LOW_BAT_COLOR : DEFAULT_NORMAL_BAT_COLOR); ili9341_set_foreground(vbat < BATTERY_WARNING_LEVEL ? LCD_LOW_BAT_COLOR : LCD_NORMAL_BAT_COLOR);
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
// Prepare battery bitmap image // Prepare battery bitmap image
// Battery top // Battery top
@ -2377,7 +2380,7 @@ request_to_redraw_grid(void)
void void
redraw_frame(void) redraw_frame(void)
{ {
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_clear_screen(); ili9341_clear_screen();
draw_frequencies(); draw_frequencies();
draw_cal_status(); draw_cal_status();
@ -2474,7 +2477,8 @@ toggle_waterfall(void)
waterfall = W_OFF; waterfall = W_OFF;
} }
_grid_y = graph_bottom / NGRIDY; _grid_y = graph_bottom / NGRIDY;
ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom, 0); ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom);
request_to_redraw_grid(); request_to_redraw_grid();
} }
void void

@ -624,7 +624,6 @@ VNA_SHELL_FUNCTION(cmd_caloutput)
{ {
static const char cmd[] = "off|30|15|10|4|3|2|1"; static const char cmd[] = "off|30|15|10|4|3|2|1";
if (argc != 1) { if (argc != 1) {
usage:
shell_printf("usage: caloutput %s\r\n", cmd); shell_printf("usage: caloutput %s\r\n", cmd);
return; return;
} }

@ -2017,7 +2017,8 @@ sweep_again: // stay in sweep loop when output mo
scandirty = false; scandirty = false;
if (break_on_operation && operation_requested) { // break loop if needed if (break_on_operation && operation_requested) { // break loop if needed
if (setting.actual_sweep_time_us > ONE_SECOND_TIME && MODE_INPUT(setting.mode)) { if (setting.actual_sweep_time_us > ONE_SECOND_TIME && MODE_INPUT(setting.mode)) {
ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1, 0); // Erase progress bar ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1); // Erase progress bar
} }
return false; return false;
} }
@ -2057,8 +2058,10 @@ sweep_again: // stay in sweep loop when output mo
if (setting.actual_sweep_time_us > ONE_SECOND_TIME && (i & 0x07) == 0) { // if required if (setting.actual_sweep_time_us > ONE_SECOND_TIME && (i & 0x07) == 0) { // if required
int pos = i * (WIDTH+1) / sweep_points; int pos = i * (WIDTH+1) / sweep_points;
ili9341_fill(OFFSETX, CHART_BOTTOM+1, pos, 1, BRIGHT_COLOR_GREEN); // update sweep progress bar ili9341_set_background(LCD_SWEEP_LINE_COLOR);
ili9341_fill(OFFSETX+pos, CHART_BOTTOM+1, WIDTH-pos, 1, 0); ili9341_fill(OFFSETX, CHART_BOTTOM+1, pos, 1); // update sweep progress bar
ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX+pos, CHART_BOTTOM+1, WIDTH-pos, 1);
} }
// ------------------------ do all RSSI calculations from CALC menu ------------------- // ------------------------ do all RSSI calculations from CALC menu -------------------
@ -2559,7 +2562,8 @@ sweep_again: // stay in sweep loop when output mo
// redraw_marker(peak_marker, FALSE); // redraw_marker(peak_marker, FALSE);
// STOP_PROFILE; // STOP_PROFILE;
ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1, 0); ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1);
palSetPad(GPIOB, GPIOB_LED); palSetPad(GPIOB, GPIOB_LED);
return true; return true;
@ -2753,8 +2757,8 @@ void draw_cal_status(void)
if (!UNIT_IS_LINEAR(setting.unit)) if (!UNIT_IS_LINEAR(setting.unit))
rounding = true; rounding = true;
const char * const unit = unit_string[setting.unit]; const char * const unit = unit_string[setting.unit];
ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(0, 0, OFFSETX, CHART_BOTTOM, 0x0000); ili9341_fill(0, 0, OFFSETX, CHART_BOTTOM);
if (MODE_OUTPUT(setting.mode)) { // No cal status during output if (MODE_OUTPUT(setting.mode)) { // No cal status during output
return; return;
} }
@ -2762,7 +2766,7 @@ void draw_cal_status(void)
// if (current_menu_is_form() && !in_selftest) // if (current_menu_is_form() && !in_selftest)
// return; // return;
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
float yMax = setting.reflevel; float yMax = setting.reflevel;
// Top level // Top level
@ -2771,20 +2775,16 @@ void draw_cal_status(void)
else else
plot_printf(buf, BLEN, "%+4.3F", (yMax/setting.unit_scale)); plot_printf(buf, BLEN, "%+4.3F", (yMax/setting.unit_scale));
if (level_is_calibrated()) { if (level_is_calibrated())
if (setting.auto_reflevel) color = setting.auto_reflevel ? LCD_FG_COLOR : LCD_BRIGHT_COLOR_GREEN;
color = DEFAULT_FG_COLOR;
else
color = BRIGHT_COLOR_GREEN;
}
else else
color = BRIGHT_COLOR_RED; color = LCD_BRIGHT_COLOR_RED;
ili9341_set_foreground(color); ili9341_set_foreground(color);
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
// Unit // Unit
#if 0 #if 0
color = DEFAULT_FG_COLOR; color = LCD_FG_COLOR;
ili9341_set_foreground(color); ili9341_set_foreground(color);
if (setting.auto_reflevel){ if (setting.auto_reflevel){
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
@ -2796,7 +2796,7 @@ void draw_cal_status(void)
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
// Scale // Scale
color = DEFAULT_FG_COLOR; color = LCD_FG_COLOR;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP + YSTEP/2; y += YSTEP + YSTEP/2;
#if 1 #if 1
@ -2815,20 +2815,20 @@ void draw_cal_status(void)
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
if (is_paused()) { if (is_paused()) {
color = BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("PAUSED", x, y); ili9341_drawstring("PAUSED", x, y);
} }
if (setting.trigger == T_SINGLE || setting.trigger == T_NORMAL ) { if (setting.trigger == T_SINGLE || setting.trigger == T_NORMAL ) {
color = BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("ARMED", x, y); ili9341_drawstring("ARMED", x, y);
} }
if (signal_is_AM) { if (signal_is_AM) {
color = BRIGHT_COLOR_RED; color = LCD_BRIGHT_COLOR_RED;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("AM", x, y); ili9341_drawstring("AM", x, y);
@ -2837,9 +2837,9 @@ void draw_cal_status(void)
// if (setting.mode == M_LOW) { // if (setting.mode == M_LOW) {
// Attenuation // Attenuation
if (setting.auto_attenuation) if (setting.auto_attenuation)
color = DEFAULT_FG_COLOR; color = LCD_FG_COLOR;
else else
color = BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Atten:", x, y); ili9341_drawstring("Atten:", x, y);
@ -2850,7 +2850,7 @@ void draw_cal_status(void)
// Average // Average
if (setting.average>0) { if (setting.average>0) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Calc:", x, y); ili9341_drawstring("Calc:", x, y);
@ -2861,7 +2861,7 @@ void draw_cal_status(void)
// Spur // Spur
#ifdef __SPUR__ #ifdef __SPUR__
if (setting.spur_removal) { if (setting.spur_removal) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Spur:", x, y); ili9341_drawstring("Spur:", x, y);
@ -2870,7 +2870,7 @@ void draw_cal_status(void)
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
} }
if (setting.mirror_masking) { if (setting.mirror_masking) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Mask:", x, y); ili9341_drawstring("Mask:", x, y);
@ -2881,16 +2881,16 @@ void draw_cal_status(void)
#endif #endif
if (setting.subtract_stored) { if (setting.subtract_stored) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Norm.", x, y); ili9341_drawstring("Norm.", x, y);
} }
// RBW // RBW
if (setting.rbw_x10) if (setting.rbw_x10)
color = BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
else else
color = DEFAULT_FG_COLOR; color = LCD_FG_COLOR;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
@ -2903,7 +2903,7 @@ void draw_cal_status(void)
#if 0 #if 0
// VBW // VBW
if (setting.frequency_step > 0) { if (setting.frequency_step > 0) {
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("VBW:", x, y); ili9341_drawstring("VBW:", x, y);
@ -2915,9 +2915,9 @@ void draw_cal_status(void)
#endif #endif
// Sweep time // Sweep time
if (setting.step_delay != 0) if (setting.step_delay != 0)
color = BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
else else
color = DEFAULT_FG_COLOR; color = LCD_FG_COLOR;
ili9341_set_foreground(color); ili9341_set_foreground(color);
@ -2956,7 +2956,7 @@ void draw_cal_status(void)
// Cal output // Cal output
if (setting.refer >= 0) { if (setting.refer >= 0) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Ref:", x, y); ili9341_drawstring("Ref:", x, y);
@ -2968,7 +2968,7 @@ void draw_cal_status(void)
// Offset // Offset
if (setting.offset != 0.0) { if (setting.offset != 0.0) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Amp:", x, y); ili9341_drawstring("Amp:", x, y);
@ -2979,7 +2979,7 @@ void draw_cal_status(void)
// Repeat // Repeat
if (setting.repeat != 1) { if (setting.repeat != 1) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("Repeat:", x, y); ili9341_drawstring("Repeat:", x, y);
@ -2992,9 +2992,9 @@ void draw_cal_status(void)
// Trigger // Trigger
if (setting.trigger != T_AUTO) { if (setting.trigger != T_AUTO) {
if (is_paused() || setting.trigger == T_NORMAL) { if (is_paused() || setting.trigger == T_NORMAL) {
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
} else { } else {
ili9341_set_foreground(BRIGHT_COLOR_RED); ili9341_set_foreground(LCD_BRIGHT_COLOR_RED);
} }
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("TRIG:", x, y); ili9341_drawstring("TRIG:", x, y);
@ -3010,16 +3010,16 @@ void draw_cal_status(void)
// Mode // Mode
if (level_is_calibrated()) if (level_is_calibrated())
color = BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
else else
color = BRIGHT_COLOR_RED; color = LCD_BRIGHT_COLOR_RED;
ili9341_set_foreground(color); ili9341_set_foreground(color);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring_7x13(MODE_LOW(setting.mode) ? "LOW" : "HIGH", x, y); ili9341_drawstring_7x13(MODE_LOW(setting.mode) ? "LOW" : "HIGH", x, y);
// Compact status string // Compact status string
// ili9341_set_background(DEFAULT_FG_COLOR); // ili9341_set_background(LCD_FG_COLOR);
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
strncpy(buf," ",BLEN-1); strncpy(buf," ",BLEN-1);
if (setting.auto_attenuation) if (setting.auto_attenuation)
@ -3053,7 +3053,7 @@ void draw_cal_status(void)
strncpy(buf,&VERSION[8], BLEN-1); strncpy(buf,&VERSION[8], BLEN-1);
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
// ili9341_set_background(DEFAULT_BG_COLOR); // ili9341_set_background(LCD_BG_COLOR);
if (!get_waterfall()) { // Do not draw bottom level if in waterfall mode if (!get_waterfall()) { // Do not draw bottom level if in waterfall mode
// Bottom level // Bottom level
y = area_height - 8 + OFFSETY; y = area_height - 8 + OFFSETY;
@ -3064,11 +3064,11 @@ void draw_cal_status(void)
// buf[5]=0; // buf[5]=0;
if (level_is_calibrated()) if (level_is_calibrated())
if (setting.auto_reflevel) if (setting.auto_reflevel)
color = DEFAULT_FG_COLOR; color = LCD_FG_COLOR;
else else
color = BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
else else
color = BRIGHT_COLOR_RED; color = LCD_BRIGHT_COLOR_RED;
ili9341_set_foreground(color); ili9341_set_foreground(color);
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
} }
@ -3494,7 +3494,7 @@ void self_test(int test)
if (test_step == 2) { if (test_step == 2) {
if (peakLevel < -60) { if (peakLevel < -60) {
test_step = TEST_END; test_step = TEST_END;
ili9341_set_foreground(BRIGHT_COLOR_RED); ili9341_set_foreground(LCD_BRIGHT_COLOR_RED);
ili9341_drawstring_7x13("Signal level too low", 30, 140); ili9341_drawstring_7x13("Signal level too low", 30, 140);
ili9341_drawstring_7x13("Check cable between High and Low connectors", 30, 160); ili9341_drawstring_7x13("Check cable between High and Low connectors", 30, 160);
goto resume2; goto resume2;
@ -3510,7 +3510,7 @@ void self_test(int test)
} }
test_step++; test_step++;
} while (test_case[test_step].kind != TC_END && setting.test_argument == 0 ); } while (test_case[test_step].kind != TC_END && setting.test_argument == 0 );
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
ili9341_drawstring_7x13("Self test complete", 50, 200); ili9341_drawstring_7x13("Self test complete", 50, 200);
ili9341_drawstring_7x13("Touch screen to continue", 50, 215); ili9341_drawstring_7x13("Touch screen to continue", 50, 215);
resume2: resume2:
@ -3758,14 +3758,14 @@ void calibrate(void)
test_acquire(TEST_POWER); // Acquire test test_acquire(TEST_POWER); // Acquire test
local_test_status = test_validate(TEST_POWER); // Validate test local_test_status = test_validate(TEST_POWER); // Validate test
if (peakLevel < -50) { if (peakLevel < -50) {
ili9341_set_foreground(BRIGHT_COLOR_RED); ili9341_set_foreground(LCD_BRIGHT_COLOR_RED);
ili9341_drawstring_7x13("Signal level too low", 30, 140); ili9341_drawstring_7x13("Signal level too low", 30, 140);
ili9341_drawstring_7x13("Check cable between High and Low connectors", 30, 160); ili9341_drawstring_7x13("Check cable between High and Low connectors", 30, 160);
goto quit; goto quit;
} }
// chThdSleepMilliseconds(1000); // chThdSleepMilliseconds(1000);
if (local_test_status != TS_PASS) { if (local_test_status != TS_PASS) {
ili9341_set_foreground(BRIGHT_COLOR_RED); ili9341_set_foreground(LCD_BRIGHT_COLOR_RED);
ili9341_drawstring_7x13("Calibration failed", 30, 140); ili9341_drawstring_7x13("Calibration failed", 30, 140);
goto quit; goto quit;
} else { } else {
@ -3801,7 +3801,7 @@ void calibrate(void)
#endif #endif
config_save(); config_save();
ili9341_set_foreground(BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
ili9341_drawstring_7x13("Calibration complete", 30, 140); ili9341_drawstring_7x13("Calibration complete", 30, 140);
quit: quit:
ili9341_drawstring_7x13("Touch screen to continue", 30, 200); ili9341_drawstring_7x13("Touch screen to continue", 30, 200);

107
ui.c

@ -328,8 +328,8 @@ touch_cal_exec(void)
int x1, x2, y1, y2; int x1, x2, y1, y2;
adc_stop(); adc_stop();
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_clear_screen(); ili9341_clear_screen();
ili9341_line(0, 0, 0, 32); ili9341_line(0, 0, 0, 32);
ili9341_line(0, 0, 32, 0); ili9341_line(0, 0, 32, 0);
@ -369,8 +369,8 @@ touch_draw_test(void)
adc_stop(); adc_stop();
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_clear_screen(); ili9341_clear_screen();
ili9341_drawstring("TOUCH TEST: DRAG PANEL, PRESS BUTTON TO FINISH", OFFSETX, LCD_HEIGHT - FONT_GET_HEIGHT); ili9341_drawstring("TOUCH TEST: DRAG PANEL, PRESS BUTTON TO FINISH", OFFSETX, LCD_HEIGHT - FONT_GET_HEIGHT);
@ -414,8 +414,8 @@ show_version(void)
{ {
int x = 5, y = 5, i = 0; int x = 5, y = 5, i = 0;
adc_stop(); adc_stop();
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_clear_screen(); ili9341_clear_screen();
uint16_t shift = 0b0000010000111110; uint16_t shift = 0b0000010000111110;
@ -440,8 +440,8 @@ enter_dfu(void)
adc_stop(); adc_stop();
int x = 5, y = 5; int x = 5, y = 5;
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
// leave a last message // leave a last message
ili9341_clear_screen(); ili9341_clear_screen();
ili9341_drawstring_7x13("DFU: Device Firmware Update Mode\n" ili9341_drawstring_7x13("DFU: Device Firmware Update Mode\n"
@ -1446,15 +1446,15 @@ static void
draw_button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ui_button_t *b) draw_button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ui_button_t *b)
{ {
uint16_t bw = b->border&BUTTON_BORDER_WIDTH_MASK; uint16_t bw = b->border&BUTTON_BORDER_WIDTH_MASK;
ili9341_fill(x + bw, y + bw, w - (bw * 2), h - (bw * 2), b->bg); ili9341_set_background(b->bg);ili9341_fill(x + bw, y + bw, w - (bw * 2), h - (bw * 2));
if (bw==0) return; if (bw==0) return;
uint16_t br = RGB565(255,255,255); uint16_t br = LCD_RISE_EDGE_COLOR;
uint16_t bd = RGB565(196,196,196); uint16_t bd = LCD_FALLEN_EDGE_COLOR;
uint16_t type = b->border; uint16_t type = b->border;
ili9341_fill(x, y, w, bw, type&BUTTON_BORDER_TOP ? br : bd); // top ili9341_set_background(type&BUTTON_BORDER_TOP ? br : bd);ili9341_fill(x, y, w, bw); // top
ili9341_fill(x + w - bw, y, bw, h, type&BUTTON_BORDER_RIGHT ? br : bd); // right ili9341_set_background(type&BUTTON_BORDER_RIGHT ? br : bd);ili9341_fill(x + w - bw, y, bw, h); // right
ili9341_fill(x, y, bw, h, type&BUTTON_BORDER_LEFT ? br : bd); // left ili9341_set_background(type&BUTTON_BORDER_LEFT ? br : bd);ili9341_fill(x, y, bw, h); // left
ili9341_fill(x, y + h - bw, w, bw, type&BUTTON_BORDER_BOTTOM ? br : bd); // bottom ili9341_set_background(type&BUTTON_BORDER_BOTTOM ? br : bd);ili9341_fill(x, y + h - bw, w, bw); // bottom
} }
static void static void
@ -1462,20 +1462,20 @@ draw_keypad(void)
{ {
int i = 0; int i = 0;
ui_button_t button; ui_button_t button;
button.fg = DEFAULT_MENU_TEXT_COLOR; button.fg = LCD_MENU_TEXT_COLOR;
while (keypads[i].c >= 0) { while (keypads[i].c >= 0) {
button.bg = RGB565(230,230,230);//config.menu_normal_color; button.bg = LCD_MENU_COLOR;
if (i == selection){ if (i == selection){
button.bg = RGB565(210,210,210);//config.menu_active_color; button.bg = LCD_MENU_ACTIVE_COLOR;
button.border = KEYBOARD_BUTTON_BORDER|BUTTON_BORDER_FALLING; button.border = KEYBOARD_BUTTON_BORDER|BUTTON_BORDER_FALLING;
} }
else else
button.border = KEYBOARD_BUTTON_BORDER|BUTTON_BORDER_RISE; button.border = KEYBOARD_BUTTON_BORDER|BUTTON_BORDER_RISE;
ili9341_set_foreground(button.fg);
ili9341_set_background(button.bg);
int x = KP_GET_X(keypads[i].x); int x = KP_GET_X(keypads[i].x);
int y = KP_GET_Y(keypads[i].y); int y = KP_GET_Y(keypads[i].y);
draw_button(x, y, KP_WIDTH, KP_HEIGHT, &button); draw_button(x, y, KP_WIDTH, KP_HEIGHT, &button);
ili9341_set_foreground(button.fg);
ili9341_set_background(button.bg);
if (keypads[i].c < KP_0) { // KP_0 if (keypads[i].c < KP_0) { // KP_0
ili9341_drawfont(keypads[i].c, ili9341_drawfont(keypads[i].c,
x + (KP_WIDTH - NUM_FONT_GET_WIDTH) / 2, x + (KP_WIDTH - NUM_FONT_GET_WIDTH) / 2,
@ -1503,9 +1503,10 @@ menu_is_multiline(const char *label)
static void static void
draw_numeric_area_frame(void) draw_numeric_area_frame(void)
{ {
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT, config.menu_normal_color); ili9341_set_foreground(LCD_INPUT_TEXT_COLOR);
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR); ili9341_set_background(LCD_INPUT_BG_COLOR);
ili9341_set_background(config.menu_normal_color);
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT);
char *name = keypads_mode_tbl[keypad_mode].name; char *name = keypads_mode_tbl[keypad_mode].name;
int lines = menu_is_multiline(name); int lines = menu_is_multiline(name);
ili9341_drawstring_7x13(name, 10, LCD_HEIGHT-NUM_INPUT_HEIGHT + (NUM_INPUT_HEIGHT-lines*bFONT_STR_HEIGHT)/2); ili9341_drawstring_7x13(name, 10, LCD_HEIGHT-NUM_INPUT_HEIGHT + (NUM_INPUT_HEIGHT-lines*bFONT_STR_HEIGHT)/2);
@ -1520,8 +1521,8 @@ draw_numeric_input(const char *buf)
int focused = FALSE; int focused = FALSE;
uint16_t xsim = 0b0010010000000000; uint16_t xsim = 0b0010010000000000;
uint16_t fg = DEFAULT_MENU_TEXT_COLOR; uint16_t fg = LCD_INPUT_TEXT_COLOR;
uint16_t bg = config.menu_normal_color; uint16_t bg = LCD_INPUT_BG_COLOR;
for (i = 0, x = 64; i < 10 && buf[i]; i++, xsim<<=1) { for (i = 0, x = 64; i < 10 && buf[i]; i++, xsim<<=1) {
int c = buf[i]; int c = buf[i];
if (c == '.') if (c == '.')
@ -1538,13 +1539,13 @@ draw_numeric_input(const char *buf)
else if (focused) // c not number, but focused else if (focused) // c not number, but focused
ili9341_drawfont(0, x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4); ili9341_drawfont(0, x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4);
else // erase else // erase
ili9341_fill(x, LCD_HEIGHT-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);
x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2; x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
} }
// erase last // erase last
// 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); // 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);
ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, LCD_WIDTH-x-1, NUM_FONT_GET_WIDTH+2+8, config.menu_normal_color); ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, LCD_WIDTH-x-1, NUM_FONT_GET_WIDTH+2+8);
if (buf[0] == 0 && kp_help_text != NULL) { if (buf[0] == 0 && kp_help_text != NULL) {
ili9341_set_foreground(fg); ili9341_set_foreground(fg);
ili9341_set_background(bg); ili9341_set_background(bg);
@ -1564,24 +1565,24 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
} else if (menu == menu_marker_sel) { } else if (menu == menu_marker_sel) {
if (item < 4) { if (item < 4) {
if (markers[item].enabled) { if (markers[item].enabled) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (item == 5) { } else if (item == 5) {
if (uistat.marker_delta) { if (uistat.marker_delta) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} }
} else if (menu == menu_marker_search) { } else if (menu == menu_marker_search) {
if (item == 4 && uistat.marker_tracking) { if (item == 4 && uistat.marker_tracking) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_marker_smith) { } else if (menu == menu_marker_smith) {
if (marker_smith_format == item) { if (marker_smith_format == item) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_calop) { } else if (menu == menu_calop) {
@ -1591,17 +1592,17 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|| (item == 3 && (cal_status & CALSTAT_ISOLN)) || (item == 3 && (cal_status & CALSTAT_ISOLN))
|| (item == 4 && (cal_status & CALSTAT_THRU))) { || (item == 4 && (cal_status & CALSTAT_THRU))) {
domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_FREQ; domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_FREQ;
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_stimulus) { } else if (menu == menu_stimulus) {
if (item == 5 /* PAUSE */ && !(sweep_mode&SWEEP_ENABLE)) { if (item == 5 /* PAUSE */ && !(sweep_mode&SWEEP_ENABLE)) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_cal) { } else if (menu == menu_cal) {
if (item == 3 /* CORRECTION */ && (cal_status & CALSTAT_APPLY)) { if (item == 3 /* CORRECTION */ && (cal_status & CALSTAT_APPLY)) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_bandwidth) { } else if (menu == menu_bandwidth) {
@ -1615,7 +1616,7 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|| (item == 2 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP) || (item == 2 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP)
|| (item == 3 && (domain_mode & TD_FUNC) == TD_FUNC_BANDPASS) || (item == 3 && (domain_mode & TD_FUNC) == TD_FUNC_BANDPASS)
) { ) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_transform_window) { } else if (menu == menu_transform_window) {
@ -1623,7 +1624,7 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|| (item == 1 && (domain_mode & TD_WINDOW) == TD_WINDOW_NORMAL) || (item == 1 && (domain_mode & TD_WINDOW) == TD_WINDOW_NORMAL)
|| (item == 2 && (domain_mode & TD_WINDOW) == TD_WINDOW_MAXIMUM) || (item == 2 && (domain_mode & TD_WINDOW) == TD_WINDOW_MAXIMUM)
) { ) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = LCD_MENU_TEXT_COLOR;
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} }
@ -1738,16 +1739,16 @@ draw_menu_buttons(const menuitem_t *menu)
button.border = MENU_BUTTON_BORDER; button.border = MENU_BUTTON_BORDER;
if (MT_MASK(menu[i].type) == MT_TITLE) { if (MT_MASK(menu[i].type) == MT_TITLE) {
button.fg = RGB565(255,255,255);//config.menu_normal_color; button.fg = LCD_FG_COLOR;
button.bg = DEFAULT_MENU_TEXT_COLOR; button.bg = LCD_BG_COLOR;
button.border = 0; // no border for title button.border = 0; // no border for title
} else { } else {
button.bg = RGB565(230,230,230); button.bg = LCD_MENU_COLOR;
button.fg = DEFAULT_MENU_TEXT_COLOR; button.fg = LCD_MENU_TEXT_COLOR;
} }
if (i == selection){ if (i == selection){
button.bg = RGB565(210,210,210);//config.menu_active_color; button.bg = LCD_MENU_ACTIVE_COLOR;
button.border|= BUTTON_BORDER_FALLING; button.border|= BUTTON_BORDER_FALLING;
} }
else else
@ -1771,13 +1772,14 @@ draw_menu_buttons(const menuitem_t *menu)
// Prepare button label // Prepare button label
plot_printf(button.text, sizeof button.text, menu[i].label, button.param_1.u, button.param_2.u); plot_printf(button.text, sizeof button.text, menu[i].label, button.param_1.u, button.param_2.u);
ili9341_set_foreground(button.fg);
ili9341_set_background(button.bg);
if (menu[i].type & MT_FORM) { if (menu[i].type & MT_FORM) {
int button_width = MENU_FORM_WIDTH; int button_width = MENU_FORM_WIDTH;
int button_start = (LCD_WIDTH - MENU_FORM_WIDTH)/2; // At center of screen int button_start = (LCD_WIDTH - MENU_FORM_WIDTH)/2; // At center of screen
int button_height = MENU_BUTTON_HEIGHT; int button_height = MENU_BUTTON_HEIGHT;
draw_button(button_start, y, button_width, button_height, &button); draw_button(button_start, y, button_width, button_height, &button);
ili9341_set_foreground(button.fg);
ili9341_set_background(button.bg);
uint16_t text_offs = button_start + 6; uint16_t text_offs = button_start + 6;
if (button.icon >=0){ if (button.icon >=0){
blit8BitWidthBitmap(button_start+3, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]); blit8BitWidthBitmap(button_start+3, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]);
@ -1796,6 +1798,8 @@ draw_menu_buttons(const menuitem_t *menu)
int button_start = LCD_WIDTH - MENU_BUTTON_WIDTH; int button_start = LCD_WIDTH - MENU_BUTTON_WIDTH;
int button_height = MENU_BUTTON_HEIGHT; int button_height = MENU_BUTTON_HEIGHT;
draw_button(button_start, y, button_width, button_height, &button); draw_button(button_start, y, button_width, button_height, &button);
ili9341_set_foreground(button.fg);
ili9341_set_background(button.bg);
uint16_t text_offs = button_start + 7; uint16_t text_offs = button_start + 7;
if (button.icon >=0){ if (button.icon >=0){
blit8BitWidthBitmap(button_start+2, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]); blit8BitWidthBitmap(button_start+2, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]);
@ -1812,8 +1816,9 @@ draw_menu_buttons(const menuitem_t *menu)
y += MENU_BUTTON_HEIGHT; y += MENU_BUTTON_HEIGHT;
} }
// Cleanup other buttons (less flicker) // Cleanup other buttons (less flicker)
ili9341_set_background(LCD_BG_COLOR);
for (; y < MENU_BUTTON_MAX*MENU_BUTTON_HEIGHT; y+=MENU_BUTTON_HEIGHT) for (; y < MENU_BUTTON_MAX*MENU_BUTTON_HEIGHT; y+=MENU_BUTTON_HEIGHT)
ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT, DEFAULT_BG_COLOR); ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT);
} }
static systime_t prev_touch_time = 0; static systime_t prev_touch_time = 0;
@ -1925,11 +1930,11 @@ static void
erase_menu_buttons(void) erase_menu_buttons(void)
{ {
// Not need, screen redraw in all cases // Not need, screen redraw in all cases
// ili9341_fill(area_width, 0, LCD_WIDTH - area_width, area_height, DEFAULT_BG_COLOR); // ili9341_fill(area_width, 0, LCD_WIDTH - area_width, area_height, LCD_BG_COLOR);
// if (current_menu_is_form()) // if (current_menu_is_form())
// ili9341_fill(OFFSETX, 0,LCD_WIDTH-OFFSETX, MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX, DEFAULT_BG_COLOR); // ili9341_fill(OFFSETX, 0,LCD_WIDTH-OFFSETX, MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX, LCD_BG_COLOR);
// else // else
// ili9341_fill(LCD_WIDTH-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, LCD_BG_COLOR);
draw_frequencies(); draw_frequencies();
} }
@ -1937,7 +1942,8 @@ erase_menu_buttons(void)
static void static void
erase_numeric_input(void) erase_numeric_input(void)
{ {
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT, DEFAULT_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT);
} }
#endif #endif
@ -1948,11 +1954,12 @@ leave_ui_mode()
// request_to_draw_cells_behind_menu(); // request_to_draw_cells_behind_menu();
// erase_menu_buttons(); // erase_menu_buttons();
// } // }
ili9341_set_background(LCD_BG_COLOR);
// Erase bottom area (not redraw on area update) // Erase bottom area (not redraw on area update)
if (MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX - area_height > 0) if (MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX - area_height > 0)
ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, area_height, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX - area_height, DEFAULT_BG_COLOR); ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, area_height, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX - area_height);
if (get_waterfall()) if (get_waterfall())
ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom, 0); ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom);
redraw_request|=REDRAW_AREA | REDRAW_FREQUENCY | REDRAW_CAL_STATUS | REDRAW_BATTERY; redraw_request|=REDRAW_AREA | REDRAW_FREQUENCY | REDRAW_CAL_STATUS | REDRAW_BATTERY;
} }

@ -465,7 +465,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_mode_acb)
if (b){ if (b){
if (item == setting.mode) { if (item == setting.mode) {
b->param_1.text = "Return"; b->param_1.text = "Return";
b->bg = RGB565(200,200,200);//config.menu_active_color; b->bg = LCD_MENU_ACTIVE_COLOR;
b->border = BUTTON_BORDER_FALLING | MENU_BUTTON_BORDER; b->border = BUTTON_BORDER_FALLING | MENU_BUTTON_BORDER;
} }
else else

Loading…
Cancel
Save

Powered by TurnKey Linux.