feat(color): show ambient light sensor on analog debug pages (#7030)

This commit is contained in:
philmoz
2026-01-26 18:16:13 +10:00
committed by GitHub
parent 0ee753dea5
commit ae4d747cb6
+41 -33
View File
@@ -26,9 +26,9 @@
#include "hal/adc_driver.h" #include "hal/adc_driver.h"
#include "static.h" #include "static.h"
// #if defined(IMU_LSM6DS33) #if defined(LUMINOSITY_SENSOR)
// #include "imu_lsm6ds33.h" #include "luminosity_sensor.h"
// #endif #endif
#define STATSDEPTH 8 // ideally a value of power of 2 #define STATSDEPTH 8 // ideally a value of power of 2
@@ -62,8 +62,6 @@ class AnaViewWindow : public Window
padLeft(PAD_SMALL); padLeft(PAD_SMALL);
padRight(PAD_SMALL); padRight(PAD_SMALL);
setFlexLayout(); setFlexLayout();
line = newLine(grid);
} }
virtual void build() virtual void build()
@@ -79,12 +77,15 @@ class AnaViewWindow : public Window
continue; continue;
#if LANDSCAPE #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 #else
line = newLine(grid); line = newLine(grid);
lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN);
#endif #endif
lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN);
if (((adcGetInputMask() & (1 << i)) != 0) && i < adcGetMaxInputs(ADC_INPUT_MAIN)) if (((adcGetInputMask() & (1 << i)) != 0) && i < adcGetMaxInputs(ADC_INPUT_MAIN))
sprintf(s, "D%d :", i + 1); sprintf(s, "D%d :", i + 1);
else else
@@ -92,23 +93,18 @@ class AnaViewWindow : public Window
new StaticText(line, rect_t{}, s); new StaticText(line, rect_t{}, s);
auto lbl = new DynamicText(line, rect_t{}, auto lbl = new DynamicNumber<int16_t>(line, rect_t{},
[=]() { [=]() { return calibratedAnalogs[i] * 25 / 256; },
return std::to_string((int16_t)calibratedAnalogs[i] * 25 / 256); COLOR_THEME_PRIMARY1_INDEX, RIGHT);
}, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
lbl = new DynamicText(line, rect_t{}, lbl = new DynamicNumber<int16_t>(line, rect_t{},
[=]() { [=]() { return column3(i); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
return std::to_string((int16_t)column3(i));
}, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
if (column4size() > 0) { if (column4size() > 0) {
lbl = new DynamicText( lbl = new DynamicNumber<int16_t>(line, rect_t{},
line, rect_t{}, [=]() { return column4(i); },
[=]() { COLOR_THEME_PRIMARY1_INDEX, (column4size() == 2) ? 0 : RIGHT,
return std::string(column4prefix()) + column4prefix());
std::to_string((int16_t)column4(i));
}, COLOR_THEME_PRIMARY1_INDEX, (column4size() == 2) ? 0 : RIGHT);
#if LANDSCAPE #if LANDSCAPE
lv_obj_set_grid_cell(lbl->getLvObj(), LV_GRID_ALIGN_STRETCH, lv_obj_set_grid_cell(lbl->getLvObj(), LV_GRID_ALIGN_STRETCH,
3 + (i & 1) * 5, column4size(), 3 + (i & 1) * 5, column4size(),
@@ -122,9 +118,7 @@ class AnaViewWindow : public Window
} }
if (column5size() > 0) { if (column5size() > 0) {
lbl = new DynamicText( lbl = new DynamicNumber<int16_t>(line, rect_t{}, [=]() { return column5(i); });
line, rect_t{},
[=]() { return std::to_string((int16_t)column5(i)); });
} else { } else {
grid.nextCell(); grid.nextCell();
} }
@@ -134,21 +128,34 @@ class AnaViewWindow : public Window
line = newLine(grid); line = newLine(grid);
lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN); lv_obj_set_style_pad_column(line->getLvObj(), PAD_SMALL, LV_PART_MAIN);
grid.setColSpan(2);
new StaticText(line, rect_t{}, "Tilt X"); new StaticText(line, rect_t{}, "Tilt X");
new DynamicText( grid.setColSpan(1);
line, rect_t{}, new DynamicNumber<int16_t>(line, rect_t{},
[=]() { [=]() { return gyro.scaledX(); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
return std::to_string((int16_t) gyro.scaledX());
}, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
for (int i = 0; i < 3; i++) {grid.nextCell();} 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 StaticText(line, rect_t{}, "Tilt Y");
new DynamicText( grid.setColSpan(1);
new DynamicNumber<int16_t>(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<uint16_t>(
line, rect_t{}, line, rect_t{},
[=]() { [=]() { return getLuxSensorValue(); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
return std::to_string((int16_t) gyro.scaledY());
}, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
#endif #endif
} }
@@ -441,6 +448,7 @@ class AnaMinMaxViewWindow : public AnaViewWindow
adcGetMaxInputs(ADC_INPUT_MAIN) + adcGetMaxInputs(ADC_INPUT_FLEX); adcGetMaxInputs(ADC_INPUT_MAIN) + adcGetMaxInputs(ADC_INPUT_FLEX);
for (uint8_t i = 0; i < max_inputs; i++) minmax[i].clear(); for (uint8_t i = 0; i < max_inputs; i++) minmax[i].clear();
checkEvents();
} }
void build() override void build() override