diff --git a/openrtx/include/core/graphics.h b/openrtx/include/core/graphics.h index 423c68a1..c13089ee 100644 --- a/openrtx/include/core/graphics.h +++ b/openrtx/include/core/graphics.h @@ -302,13 +302,13 @@ void gfx_drawBattery(point_t start, uint16_t width, uint16_t height, * @param width: Smeter width * @param height: Smeter height * @param rssi: rssi level in dBm - * @param squelch: squelch level in percentage - * @param volume: speaker volume level in percentage + * @param squelch: squelch level in range {0, 15} + * @param volume: speaker volume level in range {0, 255} * @param drawVolume: whether the volume bar should be drawn * @param color: color of the squelch bar */ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, - float squelch, float volume, bool drawVolume, color_t color); + uint8_t squelch, uint8_t volume, bool drawVolume, color_t color); /** * Function to draw Smeter + level meter of arbitrary size. @@ -319,11 +319,11 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, * @param height: Smeter height * @param rssi: rssi level in dBm * @param level: level in range {0, 255} -* @param volume: speaker volume level in percentage -* @param drawVolume: whether the volume bar should be drawn + * @param volume: speaker volume level in range {0, 255} + * @param drawVolume: whether the volume bar should be drawn */ void gfx_drawSmeterLevel(point_t start, uint16_t width, uint16_t height, - float rssi, uint8_t level, float volume, bool drawVolume); + float rssi, uint8_t level, uint8_t volume, bool drawVolume); /** * Function to draw GPS SNR bar graph of arbitrary size. diff --git a/openrtx/src/core/graphics.c b/openrtx/src/core/graphics.c index ce0f449f..295038dd 100644 --- a/openrtx/src/core/graphics.c +++ b/openrtx/src/core/graphics.c @@ -741,7 +741,7 @@ void gfx_drawBattery(point_t start, uint16_t width, uint16_t height, * */ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, - float squelch, float volume, bool drawVolume, color_t color) + uint8_t squelch, uint8_t volume, bool drawVolume, color_t color) { color_t white = {255, 255, 255, 255}; color_t yellow = {250, 180, 19 , 255}; @@ -781,14 +781,14 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, if (drawVolume) { // Speaker Volume Bar - uint16_t volume_width = width * volume; + uint16_t volume_width = (width * volume) / 255; point_t volume_pos = {start.x, (uint8_t) (start.y + 2)}; gfx_drawRect(volume_pos, volume_width, volume_height, white, true); } // Squelch bar uint16_t squelch_height = bar_height * 2 / bar_height_divider ; - uint16_t squelch_width = width * squelch; + uint16_t squelch_width = (width * squelch) / 15; point_t squelch_pos = {start.x, (uint8_t) (start.y + 2 + volume_height)}; gfx_drawRect(squelch_pos, squelch_width, squelch_height, color, true); @@ -827,7 +827,7 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, * */ void gfx_drawSmeterLevel(point_t start, uint16_t width, uint16_t height, float rssi, - uint8_t level, float volume, bool drawVolume) + uint8_t level, uint8_t volume, bool drawVolume) { color_t red = {255, 0, 0 , 255}; color_t green = {0, 255, 0, 255}; @@ -843,7 +843,7 @@ void gfx_drawSmeterLevel(point_t start, uint16_t width, uint16_t height, float r if (drawVolume) { // Speaker Volume Bar - uint16_t volume_width = width * volume; + uint16_t volume_width = (width * volume) / 255; point_t volume_pos = start; gfx_drawRect(volume_pos, volume_width, volume_height, white, true); } @@ -859,7 +859,7 @@ void gfx_drawSmeterLevel(point_t start, uint16_t width, uint16_t height, float r } // Level bar uint16_t level_height = bar_height * 3 / bar_height_divider; - uint16_t level_width = (level / 255.0 * width); + uint16_t level_width = (width * level) / 255; point_t level_pos = { start.x, (uint8_t) (start.y + 2 + volume_height)}; gfx_drawRect(level_pos, level_width, level_height, green, true); // RSSI bar diff --git a/openrtx/src/ui/default/ui_main.c b/openrtx/src/ui/default/ui_main.c index ab1464fb..fc30f7df 100644 --- a/openrtx/src/ui/default/ui_main.c +++ b/openrtx/src/ui/default/ui_main.c @@ -261,8 +261,8 @@ void _ui_drawMainBottom() { // Squelch bar float rssi = last_state.rssi; - float squelch = last_state.settings.sqlLevel / 16.0f; - float volume = platform_getVolumeLevel() / 255.0f; + uint8_t squelch = last_state.settings.sqlLevel; + uint8_t volume = platform_getVolumeLevel(); uint16_t meter_width = CONFIG_SCREEN_WIDTH - 2 * layout.horizontal_pad; uint16_t meter_height = layout.bottom_h; point_t meter_pos = { layout.horizontal_pad,