Module 17 UI: layout and main screen
This commit is contained in:
parent
e3b66f6a4b
commit
22e9d8ce48
|
|
@ -133,6 +133,8 @@ typedef struct layout_t
|
|||
uint16_t line1_h;
|
||||
uint16_t line2_h;
|
||||
uint16_t line3_h;
|
||||
uint16_t line4_h;
|
||||
uint16_t line5_h;
|
||||
uint16_t menu_h;
|
||||
uint16_t bottom_h;
|
||||
uint16_t bottom_pad;
|
||||
|
|
@ -143,11 +145,15 @@ typedef struct layout_t
|
|||
point_t line1_pos;
|
||||
point_t line2_pos;
|
||||
point_t line3_pos;
|
||||
point_t line4_pos;
|
||||
point_t line5_pos;
|
||||
point_t bottom_pos;
|
||||
fontSize_t top_font;
|
||||
fontSize_t line1_font;
|
||||
fontSize_t line2_font;
|
||||
fontSize_t line3_font;
|
||||
fontSize_t line4_font;
|
||||
fontSize_t line5_font;
|
||||
fontSize_t bottom_font;
|
||||
fontSize_t input_font;
|
||||
fontSize_t menu_font;
|
||||
|
|
|
|||
|
|
@ -192,51 +192,16 @@ layout_t _ui_calculateLayout()
|
|||
// Compensate for fonts printing below the start position
|
||||
const uint16_t text_v_offset = 1;
|
||||
|
||||
// Calculate UI layout depending on vertical resolution
|
||||
// Tytera MD380, MD-UV380
|
||||
#if SCREEN_HEIGHT > 127
|
||||
|
||||
// Height and padding shown in diagram at beginning of file
|
||||
const uint16_t top_h = 16;
|
||||
const uint16_t top_pad = 4;
|
||||
const uint16_t line1_h = 20;
|
||||
const uint16_t line2_h = 20;
|
||||
const uint16_t line3_h = 40;
|
||||
const uint16_t menu_h = 16;
|
||||
const uint16_t bottom_h = 23;
|
||||
const uint16_t bottom_pad = top_pad;
|
||||
const uint16_t status_v_pad = 2;
|
||||
const uint16_t small_line_v_pad = 2;
|
||||
const uint16_t big_line_v_pad = 6;
|
||||
const uint16_t horizontal_pad = 4;
|
||||
|
||||
// Top bar font: 8 pt
|
||||
const fontSize_t top_font = FONT_SIZE_8PT;
|
||||
// Text line font: 8 pt
|
||||
const fontSize_t line1_font = FONT_SIZE_8PT;
|
||||
const fontSize_t line2_font = FONT_SIZE_8PT;
|
||||
// Frequency line font: 16 pt
|
||||
const fontSize_t line3_font = FONT_SIZE_16PT;
|
||||
// Bottom bar font: 8 pt
|
||||
const fontSize_t bottom_font = FONT_SIZE_8PT;
|
||||
// TimeDate/Frequency input font
|
||||
const fontSize_t input_font = FONT_SIZE_12PT;
|
||||
// Menu font
|
||||
const fontSize_t menu_font = FONT_SIZE_8PT;
|
||||
// Mode screen frequency font: 12 pt
|
||||
const fontSize_t mode_font_big = FONT_SIZE_12PT;
|
||||
// Mode screen details font: 9 pt
|
||||
const fontSize_t mode_font_small = FONT_SIZE_9PT;
|
||||
|
||||
// Radioddity GD-77
|
||||
#elif SCREEN_HEIGHT > 63
|
||||
// Calculate UI layout for the Module 17
|
||||
|
||||
// Height and padding shown in diagram at beginning of file
|
||||
const uint16_t top_h = 11;
|
||||
const uint16_t top_pad = 1;
|
||||
const uint16_t line1_h = 10;
|
||||
const uint16_t line2_h = 10;
|
||||
const uint16_t line3_h = 16;
|
||||
const uint16_t line3_h = 10;
|
||||
const uint16_t line4_h = 10;
|
||||
const uint16_t line5_h = 10;
|
||||
const uint16_t menu_h = 10;
|
||||
const uint16_t bottom_h = 15;
|
||||
const uint16_t bottom_pad = 0;
|
||||
|
|
@ -250,7 +215,9 @@ layout_t _ui_calculateLayout()
|
|||
// Middle line fonts: 5, 8, 8 pt
|
||||
const fontSize_t line1_font = FONT_SIZE_6PT;
|
||||
const fontSize_t line2_font = FONT_SIZE_6PT;
|
||||
const fontSize_t line3_font = FONT_SIZE_10PT;
|
||||
const fontSize_t line3_font = FONT_SIZE_6PT;
|
||||
const fontSize_t line4_font = FONT_SIZE_6PT;
|
||||
const fontSize_t line5_font = FONT_SIZE_6PT;
|
||||
// Bottom bar font: 6 pt
|
||||
const fontSize_t bottom_font = FONT_SIZE_6PT;
|
||||
// TimeDate/Frequency input font
|
||||
|
|
@ -262,49 +229,13 @@ layout_t _ui_calculateLayout()
|
|||
// Mode screen details font: 6 pt
|
||||
const fontSize_t mode_font_small = FONT_SIZE_6PT;
|
||||
|
||||
// Radioddity RD-5R
|
||||
#elif SCREEN_HEIGHT > 47
|
||||
|
||||
// Height and padding shown in diagram at beginning of file
|
||||
const uint16_t top_h = 11;
|
||||
const uint16_t top_pad = 1;
|
||||
const uint16_t line1_h = 0;
|
||||
const uint16_t line2_h = 10;
|
||||
const uint16_t line3_h = 18;
|
||||
const uint16_t menu_h = 10;
|
||||
const uint16_t bottom_h = 0;
|
||||
const uint16_t bottom_pad = 0;
|
||||
const uint16_t status_v_pad = 1;
|
||||
const uint16_t small_line_v_pad = 1;
|
||||
const uint16_t big_line_v_pad = 0;
|
||||
const uint16_t horizontal_pad = 4;
|
||||
|
||||
// Top bar font: 8 pt
|
||||
const fontSize_t top_font = FONT_SIZE_6PT;
|
||||
// Middle line fonts: 16, 16
|
||||
const fontSize_t line2_font = FONT_SIZE_6PT;
|
||||
const fontSize_t line3_font = FONT_SIZE_12PT;
|
||||
// TimeDate/Frequency input font
|
||||
const fontSize_t input_font = FONT_SIZE_8PT;
|
||||
// Menu font
|
||||
const fontSize_t menu_font = FONT_SIZE_6PT;
|
||||
// Mode screen frequency font: 9 pt
|
||||
const fontSize_t mode_font_big = FONT_SIZE_9PT;
|
||||
// Mode screen details font: 6 pt
|
||||
const fontSize_t mode_font_small = FONT_SIZE_6PT;
|
||||
// Not present on this resolution
|
||||
const fontSize_t line1_font = 0;
|
||||
const fontSize_t bottom_font = 0;
|
||||
|
||||
#else
|
||||
#error Unsupported vertical resolution!
|
||||
#endif
|
||||
|
||||
// Calculate printing positions
|
||||
point_t top_pos = {horizontal_pad, top_h - status_v_pad - text_v_offset};
|
||||
point_t line1_pos = {horizontal_pad, top_h + top_pad + line1_h - small_line_v_pad - text_v_offset};
|
||||
point_t line2_pos = {horizontal_pad, top_h + top_pad + line1_h + line2_h - small_line_v_pad - text_v_offset};
|
||||
point_t line3_pos = {horizontal_pad, top_h + top_pad + line1_h + line2_h + line3_h - big_line_v_pad - text_v_offset};
|
||||
point_t line4_pos = {horizontal_pad, top_h + top_pad + line1_h + line2_h + line3_h + line4_h - big_line_v_pad - text_v_offset};
|
||||
point_t line5_pos = {horizontal_pad, top_h + top_pad + line1_h + line2_h + line3_h + line4_h + line5_h - big_line_v_pad - text_v_offset};
|
||||
point_t bottom_pos = {horizontal_pad, SCREEN_HEIGHT - bottom_pad - status_v_pad - text_v_offset};
|
||||
|
||||
layout_t new_layout =
|
||||
|
|
@ -314,6 +245,8 @@ layout_t _ui_calculateLayout()
|
|||
line1_h,
|
||||
line2_h,
|
||||
line3_h,
|
||||
line4_h,
|
||||
line5_h,
|
||||
menu_h,
|
||||
bottom_h,
|
||||
bottom_pad,
|
||||
|
|
@ -324,11 +257,15 @@ layout_t _ui_calculateLayout()
|
|||
line1_pos,
|
||||
line2_pos,
|
||||
line3_pos,
|
||||
line4_pos,
|
||||
line5_pos,
|
||||
bottom_pos,
|
||||
top_font,
|
||||
line1_font,
|
||||
line2_font,
|
||||
line3_font,
|
||||
line4_font,
|
||||
line5_font,
|
||||
bottom_font,
|
||||
input_font,
|
||||
menu_font,
|
||||
|
|
|
|||
|
|
@ -43,34 +43,10 @@ void _ui_drawMainTop()
|
|||
color_white, "%02d:%02d:%02d", local_time.hour,
|
||||
local_time.minute, local_time.second);
|
||||
#endif
|
||||
// If the radio has no built-in battery, print input voltage
|
||||
#ifdef BAT_NONE
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||
color_white,"%.1fV", last_state.v_bat);
|
||||
#else
|
||||
// Otherwise print battery icon on top bar, use 4 px padding
|
||||
uint16_t bat_width = SCREEN_WIDTH / 9;
|
||||
uint16_t bat_height = layout.top_h - (layout.status_v_pad * 2);
|
||||
point_t bat_pos = {SCREEN_WIDTH - bat_width - layout.horizontal_pad,
|
||||
layout.status_v_pad};
|
||||
gfx_drawBattery(bat_pos, bat_width, bat_height, last_state.charge);
|
||||
#endif
|
||||
// Print radio mode on top bar
|
||||
switch(last_state.channel.mode)
|
||||
{
|
||||
case OPMODE_FM:
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||
color_white, "FM");
|
||||
break;
|
||||
case OPMODE_DMR:
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||
color_white, "DMR");
|
||||
break;
|
||||
case OPMODE_M17:
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||
color_white, "M17");
|
||||
break;
|
||||
}
|
||||
|
||||
// Print the source callsign on top bar
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
|
||||
color_white, state.settings.callsign);
|
||||
}
|
||||
|
||||
void _ui_drawBankChannel()
|
||||
|
|
@ -125,15 +101,24 @@ void _ui_drawModeInfo(ui_state_t* ui_state)
|
|||
break;
|
||||
case OPMODE_M17:
|
||||
{
|
||||
// Print M17 Destination ID on line 3 of 3
|
||||
char *dst = NULL;
|
||||
|
||||
if(ui_state->edit_mode)
|
||||
dst = ui_state->new_callsign;
|
||||
else
|
||||
dst = (!strnlen(cfg.destination_address, 10)) ?
|
||||
"Broadcast" : cfg.destination_address;
|
||||
"--" : cfg.destination_address;
|
||||
// Print CAN
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||
color_white, "CAN %02d", state.m17_data.can);
|
||||
gfx_print(layout.line2_pos, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "#%s", dst);
|
||||
color_white, "LAST");
|
||||
// Print M17 Destination ID on line 2
|
||||
gfx_print(layout.line3_pos, layout.line3_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "%s", dst);
|
||||
// Menu
|
||||
gfx_print(layout.line5_pos, layout.line5_font, TEXT_ALIGN_RIGHT,
|
||||
color_white, "Menu");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -234,11 +219,11 @@ void _ui_drawMainBottom()
|
|||
mic_level);
|
||||
break;
|
||||
case OPMODE_M17:
|
||||
gfx_drawSmeterLevel(meter_pos,
|
||||
/*gfx_drawSmeterLevel(meter_pos,
|
||||
meter_width,
|
||||
meter_height,
|
||||
rssi,
|
||||
mic_level);
|
||||
mic_level);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -248,7 +233,7 @@ void _ui_drawMainVFO(ui_state_t* ui_state)
|
|||
gfx_clearScreen();
|
||||
_ui_drawMainTop();
|
||||
_ui_drawModeInfo(ui_state);
|
||||
_ui_drawFrequency();
|
||||
//_ui_drawFrequency(); //has to be replaced with Line 1 and Line 2
|
||||
_ui_drawMainBottom();
|
||||
}
|
||||
|
||||
|
|
@ -266,6 +251,6 @@ void _ui_drawMainMEM(ui_state_t* ui_state)
|
|||
_ui_drawMainTop();
|
||||
_ui_drawBankChannel();
|
||||
_ui_drawModeInfo(ui_state);
|
||||
_ui_drawFrequency();
|
||||
//_ui_drawFrequency(); //has to be replaced with Line 1 and Line 2
|
||||
_ui_drawMainBottom();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,30 +217,26 @@ int _ui_getInfoValueName(char *buf, uint8_t max_len, uint8_t index)
|
|||
break;
|
||||
case 1: // Battery voltage
|
||||
{
|
||||
// Compute integer part and mantissa of voltage value, adding 50mV
|
||||
// to mantissa for rounding to nearest integer
|
||||
uint16_t volt = (last_state.v_bat + 50) / 1000;
|
||||
uint16_t mvolt = ((last_state.v_bat - volt * 1000) + 50) / 100;
|
||||
snprintf(buf, max_len, "%d.%dV", volt, mvolt);
|
||||
snprintf(buf, max_len, "-.-V");
|
||||
}
|
||||
break;
|
||||
case 2: // Battery charge
|
||||
snprintf(buf, max_len, "%d%%", last_state.charge);
|
||||
snprintf(buf, max_len, "No batt");
|
||||
break;
|
||||
case 3: // RSSI
|
||||
snprintf(buf, max_len, "%.1fdBm", last_state.rssi);
|
||||
snprintf(buf, max_len, "N/A");
|
||||
break;
|
||||
case 4: // Heap usage
|
||||
snprintf(buf, max_len, "%dB", getHeapSize() - getCurrentFreeHeap());
|
||||
break;
|
||||
case 5: // Band
|
||||
snprintf(buf, max_len, "%s %s", hwinfo->vhf_band ? "VHF" : "", hwinfo->uhf_band ? "UHF" : "");
|
||||
snprintf(buf, max_len, "N/A");
|
||||
break;
|
||||
case 6: // VHF
|
||||
snprintf(buf, max_len, "%d - %d", hwinfo->vhf_minFreq, hwinfo->vhf_maxFreq);
|
||||
snprintf(buf, max_len, "N/A");
|
||||
break;
|
||||
case 7: // UHF
|
||||
snprintf(buf, max_len, "%d - %d", hwinfo->uhf_minFreq, hwinfo->uhf_maxFreq);
|
||||
snprintf(buf, max_len, "N/A");
|
||||
break;
|
||||
case 8: // LCD Type
|
||||
snprintf(buf, max_len, "%d", hwinfo->lcd_type);
|
||||
|
|
|
|||
Loading…
Reference in New Issue