Improved Smeter rendering in MACRO menu

This commit is contained in:
Niccolò Izzo 2021-02-01 23:33:49 +01:00
parent 6fdb6b8890
commit 7e0500d3a5
4 changed files with 20 additions and 12 deletions

View File

@ -246,7 +246,8 @@ void gfx_drawBattery(point_t start, uint16_t width, uint16_t height, float perce
* @param height: Smeter height
* @param rssi: rssi level in dBm
* @param squelch: squelch level in percentage
* @param color: color of the squelch and smeter bar
*/
void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, float squelch);
void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, float squelch, color_t color);
#endif /* GRAPHICS_H */

View File

@ -459,7 +459,7 @@ void gfx_drawBattery(point_t start, uint16_t width, uint16_t height, float perce
* Width (px)
*
*/
void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, float squelch) {
void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, float squelch, color_t color) {
color_t white = {255, 255, 255, 255};
color_t yellow = {250, 180, 19 , 255};
color_t red = {255, 0, 0 , 255};
@ -483,11 +483,11 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi,
float s_level = (127.0f + rssi) / 6.0f;
uint16_t rssi_width = (s_level < 0.0f) ? 0 : (s_level * (width - 1) / 11);
point_t rssi_pos = { start.x, start.y + 1 };
gfx_drawRect(rssi_pos, rssi_width, rssi_height, white, true);
gfx_drawRect(rssi_pos, rssi_width, rssi_height, color, true);
// Squelch bar
uint16_t squelch_height = height / 3 - 1;
uint16_t squelch_width = width * squelch;
point_t squelch_pos = { start.x, start.y + 1 + rssi_height };
gfx_drawRect(squelch_pos, squelch_width, squelch_height, white, true);
gfx_drawRect(squelch_pos, squelch_width, squelch_height, color, true);
}

View File

@ -160,7 +160,7 @@ void _ui_drawBottom()
layout.status_v_pad +
layout.text_v_offset -
layout.bottom_h };
gfx_drawSmeter(smeter_pos, SCREEN_WIDTH, layout.bottom_h - 1, rssi, squelch);
gfx_drawSmeter(smeter_pos, SCREEN_WIDTH, layout.bottom_h - 1, rssi, squelch, color_white);
}
void _ui_drawMainVFO()

View File

@ -410,12 +410,19 @@ bool _ui_drawMacroMenu() {
yellow_fab413);
gfx_print(layout.line3_pos, "Sav", layout.top_font, TEXT_ALIGN_RIGHT,
color_white);
// Squelch bar
uint16_t squelch_width = SCREEN_WIDTH / 16 * last_state.sqlLevel;
point_t squelch_pos = { layout.bottom_pos.x, layout.bottom_pos.y +
layout.status_v_pad +
layout.text_v_offset -
layout.bottom_h };
gfx_drawRect(squelch_pos, squelch_width, layout.bottom_h, color_white, true);
// Smeter bar
float rssi = last_state.rssi;
float squelch = last_state.sqlLevel / 16.0f;
point_t smeter_pos = { 0, layout.bottom_pos.y +
layout.status_v_pad +
layout.text_v_offset -
layout.bottom_h };
gfx_drawSmeter(smeter_pos,
SCREEN_WIDTH,
layout.bottom_h - 1,
rssi,
squelch,
yellow_fab413);
return true;
}