2626#include " hal/adc_driver.h"
2727#include " static.h"
2828
29- // #if defined(IMU_LSM6DS33 )
30- // #include "imu_lsm6ds33 .h"
31- // #endif
29+ #if defined(LUMINOSITY_SENSOR )
30+ #include " luminosity_sensor .h"
31+ #endif
3232
3333#define STATSDEPTH 8 // ideally a value of power of 2
3434
@@ -62,8 +62,6 @@ class AnaViewWindow : public Window
6262 padLeft (PAD_SMALL);
6363 padRight (PAD_SMALL);
6464 setFlexLayout ();
65-
66- line = newLine (grid);
6765 }
6866
6967 virtual void build ()
@@ -79,36 +77,34 @@ class AnaViewWindow : public Window
7977 continue ;
8078
8179#if LANDSCAPE
82- if ((i & 1 ) == 0 ) line = newLine (grid);
80+ if ((i & 1 ) == 0 ) {
81+ line = newLine (grid);
82+ lv_obj_set_style_pad_column (line->getLvObj (), PAD_SMALL, LV_PART_MAIN);
83+ }
8384#else
8485 line = newLine (grid);
86+ lv_obj_set_style_pad_column (line->getLvObj (), PAD_SMALL, LV_PART_MAIN);
8587#endif
8688
87- lv_obj_set_style_pad_column (line->getLvObj (), PAD_SMALL, LV_PART_MAIN);
8889 if (((adcGetInputMask () & (1 << i)) != 0 ) && i < adcGetMaxInputs (ADC_INPUT_MAIN))
8990 sprintf (s, " D%d :" , i + 1 );
9091 else
9192 sprintf (s, " %02d :" , i + 1 );
9293
9394 new StaticText (line, rect_t {}, s);
9495
95- auto lbl = new DynamicText (line, rect_t {},
96- [=]() {
97- return std::to_string ((int16_t )calibratedAnalogs[i] * 25 / 256 );
98- }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
96+ auto lbl = new DynamicNumber<int16_t >(line, rect_t {},
97+ [=]() { return calibratedAnalogs[i] * 25 / 256 ; },
98+ COLOR_THEME_PRIMARY1_INDEX, RIGHT);
9999
100- lbl = new DynamicText (line, rect_t {},
101- [=]() {
102- return std::to_string ((int16_t )column3 (i));
103- }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
100+ lbl = new DynamicNumber<int16_t >(line, rect_t {},
101+ [=]() { return column3 (i); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
104102
105103 if (column4size () > 0 ) {
106- lbl = new DynamicText (
107- line, rect_t {},
108- [=]() {
109- return std::string (column4prefix ()) +
110- std::to_string ((int16_t )column4 (i));
111- }, COLOR_THEME_PRIMARY1_INDEX, (column4size () == 2 ) ? 0 : RIGHT);
104+ lbl = new DynamicNumber<int16_t >(line, rect_t {},
105+ [=]() { return column4 (i); },
106+ COLOR_THEME_PRIMARY1_INDEX, (column4size () == 2 ) ? 0 : RIGHT,
107+ column4prefix ());
112108#if LANDSCAPE
113109 lv_obj_set_grid_cell (lbl->getLvObj (), LV_GRID_ALIGN_STRETCH,
114110 3 + (i & 1 ) * 5 , column4size (),
@@ -122,9 +118,7 @@ class AnaViewWindow : public Window
122118 }
123119
124120 if (column5size () > 0 ) {
125- lbl = new DynamicText (
126- line, rect_t {},
127- [=]() { return std::to_string ((int16_t )column5 (i)); });
121+ lbl = new DynamicNumber<int16_t >(line, rect_t {}, [=]() { return column5 (i); });
128122 } else {
129123 grid.nextCell ();
130124 }
@@ -134,21 +128,34 @@ class AnaViewWindow : public Window
134128 line = newLine (grid);
135129 lv_obj_set_style_pad_column (line->getLvObj (), PAD_SMALL, LV_PART_MAIN);
136130
131+ grid.setColSpan (2 );
137132 new StaticText (line, rect_t {}, " Tilt X" );
138- new DynamicText (
139- line, rect_t {},
140- [=]() {
141- return std::to_string ((int16_t ) gyro.scaledX ());
142- }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
133+ grid.setColSpan (1 );
134+ new DynamicNumber<int16_t >(line, rect_t {},
135+ [=]() { return gyro.scaledX (); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
143136
144137 for (int i = 0 ; i < 3 ; i++) {grid.nextCell ();}
145138
139+ line = newLine (grid);
140+ lv_obj_set_style_pad_column (line->getLvObj (), PAD_SMALL, LV_PART_MAIN);
141+
142+ grid.setColSpan (2 );
146143 new StaticText (line, rect_t {}, " Tilt Y" );
147- new DynamicText (
144+ grid.setColSpan (1 );
145+ new DynamicNumber<int16_t >(line, rect_t {},
146+ [=]() { return gyro.scaledY (); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
147+ #endif
148+
149+ #if defined(LUMINOSITY_SENSOR)
150+ line = newLine (grid);
151+ lv_obj_set_style_pad_column (line->getLvObj (), PAD_SMALL, LV_PART_MAIN);
152+
153+ grid.setColSpan (2 );
154+ new StaticText (line, rect_t {}, STR_SRC_LIGHT);
155+ grid.setColSpan (1 );
156+ new DynamicNumber<uint16_t >(
148157 line, rect_t {},
149- [=]() {
150- return std::to_string ((int16_t ) gyro.scaledY ());
151- }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
158+ [=]() { return getLuxSensorValue (); }, COLOR_THEME_PRIMARY1_INDEX, RIGHT);
152159#endif
153160 }
154161
@@ -441,6 +448,7 @@ class AnaMinMaxViewWindow : public AnaViewWindow
441448 adcGetMaxInputs (ADC_INPUT_MAIN) + adcGetMaxInputs (ADC_INPUT_FLEX);
442449
443450 for (uint8_t i = 0 ; i < max_inputs; i++) minmax[i].clear ();
451+ checkEvents ();
444452 }
445453
446454 void build () override
0 commit comments