Replace LCD size constants

tinySA-v0.2
erikkaashoek 6 years ago
parent 8584158b58
commit 3b61c73a11

@ -27,8 +27,8 @@ uint16_t foreground_color = 0;
uint16_t background_color = 0; uint16_t background_color = 0;
// Display width and height definition // Display width and height definition
#define ILI9341_WIDTH 320 #define ILI9341_WIDTH LCD_WIDTH
#define ILI9341_HEIGHT 240 #define ILI9341_HEIGHT LCD_HEIGHT
// Display commands list // Display commands list
#define ILI9341_NOP 0x00 #define ILI9341_NOP 0x00
@ -726,15 +726,15 @@ void ili9341_test(int mode)
switch (mode) { switch (mode) {
default: default:
#if 1 #if 1
ili9341_fill(0, 0, 320, 240, 0); ili9341_fill(0, 0, LCD_WIDTH, LCD_HEIGHT, 0);
for (y = 0; y < 240; y++) { for (y = 0; y < LCD_HEIGHT; y++) {
ili9341_fill(0, y, 320, 1, RGB(240-y, y, (y + 120) % 256)); ili9341_fill(0, y, LCD_WIDTH, 1, RGB(LCD_HEIGHT-y, y, (y + 120) % 256));
} }
break; break;
case 1: case 1:
ili9341_fill(0, 0, 320, 240, 0); ili9341_fill(0, 0, LCD_WIDTH, LCD_HEIGHT, 0);
for (y = 0; y < 240; y++) { for (y = 0; y < LCD_HEIGHT; y++) {
for (x = 0; x < 320; x++) { for (x = 0; x < LCD_WIDTH; x++) {
ili9341_pixel(x, y, (y<<8)|x); ili9341_pixel(x, y, (y<<8)|x);
} }
} }

@ -771,15 +771,15 @@ VNA_SHELL_FUNCTION(cmd_capture)
(void)argc; (void)argc;
(void)argv; (void)argv;
int i, y; 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" #error "Low size of spi_buffer for cmd_capture"
#endif #endif
// read 2 row pixel time (read buffer limit by 2/3 + 1 from spi_buffer size) // 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 // use uint16_t spi_buffer[2048] (defined in ili9341) for read buffer
uint8_t *buf = (uint8_t *)spi_buffer; uint8_t *buf = (uint8_t *)spi_buffer;
ili9341_read_memory(0, y, 320, 2, 2 * 320, spi_buffer); ili9341_read_memory(0, y, LCD_WIDTH, 2, 2 * LCD_WIDTH, spi_buffer);
for (i = 0; i < 4 * 320; i++) { for (i = 0; i < 4 * LCD_WIDTH; i++) {
streamPut(shell_stream, *buf++); streamPut(shell_stream, *buf++);
} }
} }

@ -482,6 +482,9 @@ extern volatile uint8_t redraw_request;
// 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 1024 #define SPI_BUFFER_SIZE 1024
#define LCD_WIDTH 320
#define LCD_HEIGHT 240
#define DEFAULT_FG_COLOR RGB565(255,255,255) #define DEFAULT_FG_COLOR RGB565(255,255,255)
#define DEFAULT_BG_COLOR RGB565( 0, 0, 0) #define DEFAULT_BG_COLOR RGB565( 0, 0, 0)
#define DARK_GREY RGB565(140,140,140) #define DARK_GREY RGB565(140,140,140)

@ -52,8 +52,8 @@ pixel_t *cell_buffer = (pixel_t *)spi_buffer;
#endif #endif
// indicate dirty cells (not redraw if cell data not changed) // indicate dirty cells (not redraw if cell data not changed)
#define MAX_MARKMAP_X ((320+CELLWIDTH-1)/CELLWIDTH) #define MAX_MARKMAP_X ((LCD_WIDTH+CELLWIDTH-1)/CELLWIDTH)
#define MAX_MARKMAP_Y ((240+CELLHEIGHT-1)/CELLHEIGHT) #define MAX_MARKMAP_Y ((LCD_HEIGHT+CELLHEIGHT-1)/CELLHEIGHT)
// Define markmap mask size // Define markmap mask size
#if MAX_MARKMAP_X <= 8 #if MAX_MARKMAP_X <= 8
typedef uint8_t map_t; typedef uint8_t map_t;
@ -1725,9 +1725,9 @@ request_to_draw_cells_behind_menu(void)
{ {
// Values Hardcoded from ui.c // Values Hardcoded from ui.c
if (current_menu_is_form()) if (current_menu_is_form())
invalidate_rect(25, 0, 319, 239); invalidate_rect(25, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
else else
invalidate_rect(320-60 - 25, 0, 319, 239); invalidate_rect(LCD_WIDTH-60 - 25, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
redraw_request |= REDRAW_CELLS; redraw_request |= REDRAW_CELLS;
} }
@ -1735,7 +1735,7 @@ void
request_to_draw_cells_behind_numeric_input(void) request_to_draw_cells_behind_numeric_input(void)
{ {
// Values Hardcoded from ui.c // 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; redraw_request |= REDRAW_CELLS;
} }
@ -2153,14 +2153,14 @@ draw_frequencies(void)
#endif #endif
ili9341_set_foreground(DEFAULT_FG_COLOR); ili9341_set_foreground(DEFAULT_FG_COLOR);
ili9341_set_background(DEFAULT_BG_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) 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)
buf2[0] = S_SARROW[0]; buf2[0] = S_SARROW[0];
int p2 = FREQUENCIES_XPOS2; int p2 = FREQUENCIES_XPOS2;
if (FREQ_IS_CW()) { if (FREQ_IS_CW()) {
p2 = 320 - 7*strlen(buf2); p2 = LCD_WIDTH - 7*strlen(buf2);
} }
ili9341_drawstring(buf1, FREQUENCIES_XPOS1, FREQUENCIES_YPOS); ili9341_drawstring(buf1, FREQUENCIES_XPOS1, FREQUENCIES_YPOS);
ili9341_drawstring(buf2, p2, FREQUENCIES_YPOS); ili9341_drawstring(buf2, p2, FREQUENCIES_YPOS);
@ -2256,7 +2256,7 @@ toggle_waterfall(void)
{ {
if (!waterfall) { if (!waterfall) {
_height = HEIGHT_SCROLL; _height = HEIGHT_SCROLL;
ili9341_fill(5*5, HEIGHT, 320 - 5*5, 236-HEIGHT, 0); ili9341_fill(5*5, HEIGHT, LCD_WIDTH - 5*5, 236-HEIGHT, 0);
waterfall = true; waterfall = true;
fullscreen = false; fullscreen = false;
w_min = (int)min_level; w_min = (int)min_level;

62
ui.c

@ -329,8 +329,8 @@ touch_cal_exec(void)
y1 = last_touch_y; y1 = last_touch_y;
ili9341_clear_screen(); ili9341_clear_screen();
ili9341_line(320-1, 240-1, 320-1, 240-32); ili9341_line(LCD_WIDTH-1, LCD_HEIGHT-1, LCD_WIDTH-1, LCD_HEIGHT-32);
ili9341_line(320-1, 240-1, 320-32, 240-1); ili9341_line(LCD_WIDTH-1, LCD_HEIGHT-1, LCD_WIDTH-32, LCD_HEIGHT-1);
ili9341_drawstring("TOUCH LOWER RIGHT", 230, 220); ili9341_drawstring("TOUCH LOWER RIGHT", 230, 220);
touch_wait_release(); touch_wait_release();
@ -339,8 +339,8 @@ touch_cal_exec(void)
config.touch_cal[0] = x1; config.touch_cal[0] = x1;
config.touch_cal[1] = y1; config.touch_cal[1] = y1;
config.touch_cal[2] = (x2 - x1) * 16 / 320; config.touch_cal[2] = (x2 - x1) * 16 / LCD_WIDTH;
config.touch_cal[3] = (y2 - y1) * 16 / 240; config.touch_cal[3] = (y2 - y1) * 16 / LCD_HEIGHT;
//redraw_all(); //redraw_all();
touch_start_watchdog(); touch_start_watchdog();
@ -1107,9 +1107,9 @@ const menuitem_t menu_top[] = {
#define MENU_BUTTON_WIDTH 60 #define MENU_BUTTON_WIDTH 60
#define MENU_BUTTON_START (320-MENU_BUTTON_WIDTH) #define MENU_BUTTON_START (LCD_WIDTH-MENU_BUTTON_WIDTH)
#define MENU_FORM_WIDTH 295 #define MENU_FORM_WIDTH 295
#define MENU_FORM_START (320 - MENU_FORM_WIDTH) #define MENU_FORM_START (LCD_WIDTH - MENU_FORM_WIDTH)
#define MENU_BUTTON_HEIGHT 30 #define MENU_BUTTON_HEIGHT 30
#define NUM_INPUT_HEIGHT 30 #define NUM_INPUT_HEIGHT 30
@ -1252,7 +1252,7 @@ menu_invoke(int item)
#define KP_WIDTH 48 #define KP_WIDTH 48
#define KP_HEIGHT 48 #define KP_HEIGHT 48
// Key x, y position (0 - 15) on screen // 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 ) #define KP_GET_Y(posy) ((posy)*KP_HEIGHT + 12 )
#ifdef __VNA__ #ifdef __VNA__
// Key names // Key names
@ -1401,14 +1401,14 @@ draw_numeric_area_frame(void)
{ {
const char *l1; const char *l1;
const char *l2; const char *l2;
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_foreground(DEFAULT_MENU_TEXT_COLOR);
ili9341_set_background(config.menu_normal_color); ili9341_set_background(config.menu_normal_color);
if (menu_is_multiline(keypad_mode_label[keypad_mode], &l1, &l2)) { if (menu_is_multiline(keypad_mode_label[keypad_mode], &l1, &l2)) {
ili9341_drawstring_7x13(l1, 10, 240-NUM_INPUT_HEIGHT+1); ili9341_drawstring_7x13(l1, 10, LCD_HEIGHT-NUM_INPUT_HEIGHT+1);
ili9341_drawstring_7x13(l2, 10, 240-NUM_INPUT_HEIGHT/2 + 1); ili9341_drawstring_7x13(l2, 10, LCD_HEIGHT-NUM_INPUT_HEIGHT/2 + 1);
} else } else
ili9341_drawstring_7x13(keypad_mode_label[keypad_mode], 10, 240-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2); ili9341_drawstring_7x13(keypad_mode_label[keypad_mode], 10, LCD_HEIGHT-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
//ili9341_drawfont(KP_KEYPAD, 300, 216); //ili9341_drawfont(KP_KEYPAD, 300, 216);
} }
@ -1440,26 +1440,26 @@ draw_numeric_input(const char *buf)
ili9341_set_foreground(fg); ili9341_set_foreground(fg);
ili9341_set_background(bg); ili9341_set_background(bg);
if (c >= 0) // c is number 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 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 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; x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
} }
// erase last // 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);
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, 320-64, NUM_FONT_GET_WIDTH+2+8, config.menu_normal_color); ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, LCD_WIDTH-64, NUM_FONT_GET_WIDTH+2+8, config.menu_normal_color);
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);
const char *l1,*l2; const char *l1,*l2;
if (menu_is_multiline(kp_help_text, &l1, &l2)) { if (menu_is_multiline(kp_help_text, &l1, &l2)) {
ili9341_drawstring_7x13(l1, 64+NUM_FONT_GET_WIDTH+2, 240-NUM_INPUT_HEIGHT+1); ili9341_drawstring_7x13(l1, 64+NUM_FONT_GET_WIDTH+2, LCD_HEIGHT-NUM_INPUT_HEIGHT+1);
ili9341_drawstring_7x13(l2, 64+NUM_FONT_GET_WIDTH+2, 240-NUM_INPUT_HEIGHT/2 + 1); ili9341_drawstring_7x13(l2, 64+NUM_FONT_GET_WIDTH+2, LCD_HEIGHT-NUM_INPUT_HEIGHT/2 + 1);
} else } else
ili9341_drawstring_7x13(kp_help_text, 64+NUM_FONT_GET_WIDTH+2, 240-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2); ili9341_drawstring_7x13(kp_help_text, 64+NUM_FONT_GET_WIDTH+2, LCD_HEIGHT-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
} }
} }
@ -1588,7 +1588,7 @@ draw_menu_buttons(const menuitem_t *menu)
int active_button_start; int active_button_start;
menu_item_modify_attribute(menu, i, &fg, &bg); // before plot_printf to create status text menu_item_modify_attribute(menu, i, &fg, &bg); // before plot_printf to create status text
if (menu[i].type & MT_FORM) { if (menu[i].type & MT_FORM) {
active_button_start = 320 - MENU_FORM_WIDTH; active_button_start = LCD_WIDTH - MENU_FORM_WIDTH;
active_button_width = MENU_FORM_WIDTH - 30; // Shorten at the right active_button_width = MENU_FORM_WIDTH - 30; // Shorten at the right
if (MT_MASK(menu[i].type) == MT_KEYPAD) { // Only keypad retrieves value if (MT_MASK(menu[i].type) == MT_KEYPAD) { // Only keypad retrieves value
keypad_mode = menu[i].data; keypad_mode = menu[i].data;
@ -1598,12 +1598,12 @@ draw_menu_buttons(const menuitem_t *menu)
} }
else { else {
active_button_width = MENU_BUTTON_WIDTH; active_button_width = MENU_BUTTON_WIDTH;
active_button_start = 320 - MENU_BUTTON_WIDTH; active_button_start = LCD_WIDTH - MENU_BUTTON_WIDTH;
} }
ili9341_fill(active_button_start, y, active_button_width, MENU_BUTTON_HEIGHT-4, old_bg); // Set button to unmodified background color ili9341_fill(active_button_start, y, active_button_width, MENU_BUTTON_HEIGHT-4, old_bg); // Set button to unmodified background color
#if 0 #if 0
// 3D button accent // 3D button accent
int bw = 320; int bw = LCD_WIDTH;
if (MT_MASK(menu[i].type) != MT_TITLE) { if (MT_MASK(menu[i].type) != MT_TITLE) {
ili9341_fill(bw-active_button_width, y, 2, MENU_BUTTON_HEIGHT-4, LIGHT_GREY); // Set button to unmodified background color ili9341_fill(bw-active_button_width, y, 2, MENU_BUTTON_HEIGHT-4, LIGHT_GREY); // Set button to unmodified background color
@ -1620,7 +1620,7 @@ draw_menu_buttons(const menuitem_t *menu)
ili9341_drawstring_size(text, active_button_start+6, y+6, 2); ili9341_drawstring_size(text, active_button_start+6, y+6, 2);
#ifdef __ICONS__ #ifdef __ICONS__
if (menu[i].type & MT_ICON) { if (menu[i].type & MT_ICON) {
blit16BitWidthBitmap(240,y+6,16,16,&left_icons[((menu[i].data >>4)&0xf)*16]); blit16BitWidthBitmap(LCD_HEIGHT,y+6,16,16,&left_icons[((menu[i].data >>4)&0xf)*16]);
blit16BitWidthBitmap(256,y+6,16,16,&right_icons[((menu[i].data >>0)&0xf)*16]); blit16BitWidthBitmap(256,y+6,16,16,&right_icons[((menu[i].data >>0)&0xf)*16]);
} }
#endif #endif
@ -1685,7 +1685,7 @@ menu_apply_touch(void)
else else
active_button_width = MENU_BUTTON_WIDTH; active_button_width = MENU_BUTTON_WIDTH;
if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && 320-active_button_width < touch_x) { if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && LCD_WIDTH-active_button_width < touch_x) {
menu_select_touch(i); menu_select_touch(i);
return; return;
} }
@ -1706,18 +1706,18 @@ draw_menu(void)
static void static void
erase_menu_buttons(void) erase_menu_buttons(void)
{ {
// ili9341_fill(area_width, 0, 320 - area_width, area_height, DEFAULT_BG_COLOR); // ili9341_fill(area_width, 0, LCD_WIDTH - area_width, area_height, DEFAULT_BG_COLOR);
if (current_menu_is_form()) if (current_menu_is_form())
ili9341_fill(5*5, 0,320-5*5, MENU_BUTTON_HEIGHT*8, DEFAULT_BG_COLOR); ili9341_fill(5*5, 0,LCD_WIDTH-5*5, MENU_BUTTON_HEIGHT*8, DEFAULT_BG_COLOR);
else else
ili9341_fill(320-MENU_BUTTON_WIDTH, 0, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*8, DEFAULT_BG_COLOR); ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, 0, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*8, DEFAULT_BG_COLOR);
draw_frequencies(); draw_frequencies();
} }
static void static void
erase_numeric_input(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 static void
@ -1850,7 +1850,7 @@ ui_mode_numeric(int _keypad_mode)
keypad_mode = _keypad_mode; keypad_mode = _keypad_mode;
ui_mode = UI_NUMERIC; ui_mode = UI_NUMERIC;
area_width = AREA_WIDTH_NORMAL; 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(); draw_numeric_area_frame();
fetch_numeric_target(); fetch_numeric_target();
@ -2204,7 +2204,7 @@ numeric_apply_touch(void)
return; return;
} }
if (touch_y > 240-40) { if (touch_y > LCD_HEIGHT-40) {
int n = 9 - (touch_x - 64) / 20; int n = 9 - (touch_x - 64) / 20;
uistat.digit = n; uistat.digit = n;
uistat.digit_mode = TRUE; uistat.digit_mode = TRUE;
@ -2448,7 +2448,7 @@ touch_marker_select(void)
int selected_marker = 0; int selected_marker = 0;
int touch_x, touch_y; int touch_x, touch_y;
touch_position(&touch_x, &touch_y); touch_position(&touch_x, &touch_y);
if (current_menu_is_form() || touch_x > 320-MENU_BUTTON_WIDTH || touch_x < 25 || touch_y > 30) if (current_menu_is_form() || touch_x > LCD_WIDTH-MENU_BUTTON_WIDTH || touch_x < 25 || touch_y > 30)
return FALSE; return FALSE;
if (touch_y > 15) if (touch_y > 15)
selected_marker = 2; selected_marker = 2;

@ -285,7 +285,7 @@ enum {
#define KP_X(x) (48*(x) + 2 + (320-BUTTON_WIDTH-192)) #define KP_X(x) (48*(x) + 2 + (LCD_WIDTH-BUTTON_WIDTH-192))
#define KP_Y(y) (48*(y) + 2) #define KP_Y(y) (48*(y) + 2)

Loading…
Cancel
Save

Powered by TurnKey Linux.