From ae4d747cb6fa1bcf27277dc00a29577f7861fbea Mon Sep 17 00:00:00 2001 From: philmoz Date: Mon, 26 Jan 2026 19:16:13 +1100 Subject: [PATCH] feat(color): show ambient light sensor on analog debug pages (#7030) --- .../src/gui/colorlcd/radio/radio_diaganas.cpp | 74 ++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/radio/src/gui/colorlcd/radio/radio_diaganas.cpp b/radio/src/gui/colorlcd/radio/radio_diaganas.cpp index 700998b91..a2396fc7b 100644 --- a/radio/src/gui/colorlcd/radio/radio_diaganas.cpp +++ b/radio/src/gui/colorlcd/radio/radio_diaganas.cpp @@ -26,9 +26,9 @@ #include "hal/adc_driver.h" #include "static.h" -// #if defined(IMU_LSM6DS33) -// #include "imu_lsm6ds33.h" -// #endif +#if defined(LUMINOSITY_SENSOR) +#include "luminosity_sensor.h" +#endif #define STATSDEPTH 8 // ideally a value of power of 2 @@ -62,8 +62,6 @@ class AnaViewWindow : public Window padLeft(PAD_SMALL); padRight(PAD_SMALL); setFlexLayout(); - - line = newLine(grid); } virtual void build() @@ -79,12 +77,15 @@ class AnaViewWindow : public Window continue; #if LANDSCAPE - if ((i & 1) == 0) line = newLine(grid); + if ((i & 1) == 0) { + line = newLine(grid); + lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN); + } #else line = newLine(grid); + lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN); #endif - lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN); if (((adcGetInputMask() & (1 << i)) != 0) && i < adcGetMaxInputs(ADC_INPUT_MAIN)) sprintf(s, "D%d :", i + 1); else @@ -92,23 +93,18 @@ class AnaViewWindow : public Window new StaticText(line, rect_t{}, s); - auto lbl = new DynamicText(line, rect_t{}, - [=]() { - return std::to_string((int16_t)calibratedAnalogs[i] * 25 / 256); - }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); + auto lbl = new DynamicNumber(line, rect_t{}, + [=]() { return calibratedAnalogs[i] * 25 / 256; }, + COLOR_THEME_PRIMARY1_INDEX, RIGHT); - lbl = new DynamicText(line, rect_t{}, - [=]() { - return std::to_string((int16_t)column3(i)); - }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); + lbl = new DynamicNumber(line, rect_t{}, + [=]() { return column3(i); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); if (column4size() > 0) { - lbl = new DynamicText( - line, rect_t{}, - [=]() { - return std::string(column4prefix()) + - std::to_string((int16_t)column4(i)); - }, COLOR_THEME_PRIMARY1_INDEX, (column4size() == 2) ? 0 : RIGHT); + lbl = new DynamicNumber(line, rect_t{}, + [=]() { return column4(i); }, + COLOR_THEME_PRIMARY1_INDEX, (column4size() == 2) ? 0 : RIGHT, + column4prefix()); #if LANDSCAPE lv_obj_set_grid_cell(lbl->getLvObj(), LV_GRID_ALIGN_STRETCH, 3 + (i & 1) * 5, column4size(), @@ -122,9 +118,7 @@ class AnaViewWindow : public Window } if (column5size() > 0) { - lbl = new DynamicText( - line, rect_t{}, - [=]() { return std::to_string((int16_t)column5(i)); }); + lbl = new DynamicNumber(line, rect_t{}, [=]() { return column5(i); }); } else { grid.nextCell(); } @@ -134,21 +128,34 @@ class AnaViewWindow : public Window line = newLine(grid); lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN); + grid.setColSpan(2); new StaticText(line, rect_t{}, "Tilt X"); - new DynamicText( - line, rect_t{}, - [=]() { - return std::to_string((int16_t) gyro.scaledX()); - }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); + grid.setColSpan(1); + new DynamicNumber(line, rect_t{}, + [=]() { return gyro.scaledX(); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); for (int i = 0; i < 3; i++) {grid.nextCell();} + line = newLine(grid); + lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN); + + grid.setColSpan(2); new StaticText(line, rect_t{}, "Tilt Y"); - new DynamicText( + grid.setColSpan(1); + new DynamicNumber(line, rect_t{}, + [=]() { return gyro.scaledY(); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); +#endif + +#if defined(LUMINOSITY_SENSOR) + line = newLine(grid); + lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN); + + grid.setColSpan(2); + new StaticText(line, rect_t{}, STR_SRC_LIGHT); + grid.setColSpan(1); + new DynamicNumber( line, rect_t{}, - [=]() { - return std::to_string((int16_t) gyro.scaledY()); - }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); + [=]() { return getLuxSensorValue(); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT); #endif } @@ -441,6 +448,7 @@ class AnaMinMaxViewWindow : public AnaViewWindow adcGetMaxInputs(ADC_INPUT_MAIN) + adcGetMaxInputs(ADC_INPUT_FLEX); for (uint8_t i = 0; i < max_inputs; i++) minmax[i].clear(); + checkEvents(); } void build() override