@@ -100,8 +100,19 @@ void RSSI::paint(Painter& painter) {
100
100
const Rect r5{r.left () + peak - 3 , r.top (), 3 , r.height ()};
101
101
painter.fill_rectangle (
102
102
r5,
103
- Theme::getInstance ()->fg_green ->foreground );
103
+ Theme::getInstance ()->fg_orange ->foreground );
104
104
}
105
+
106
+ // dB - x
107
+ constexpr int db_min = -80 ;
108
+ constexpr int db_max = 10 ;
109
+ constexpr int db_delta = db_max - db_min;
110
+ const range_t <int > x_db_range{0 , r.width () - 1 };
111
+ const int16_t x_db = x_db_range.clip ((db_ - db_min) * r.width () / db_delta);
112
+
113
+ const Rect r_db{r.left () + x_db, r.top (), 1 , r.height ()};
114
+
115
+ if (db_) painter.fill_rectangle (r_db, Color::green ());
105
116
} else {
106
117
// vertical bottom to top level meters
107
118
const range_t <int > y_avg_range{0 , r.height () - 1 };
@@ -115,7 +126,7 @@ void RSSI::paint(Painter& painter) {
115
126
116
127
// y_min
117
128
const Rect r0{r.left (), r.bottom () - y_min, r.width (), y_min};
118
- painter.fill_rectangle (
129
+ painter.fill_rectangle ( // TODO: the blue plot is broken in vertical bars, not from the dB PR (#2403)
119
130
r0,
120
131
Color::blue ());
121
132
@@ -149,8 +160,18 @@ void RSSI::paint(Painter& painter) {
149
160
const Rect r5{r.left (), r.bottom () - peak - 3 , r.width (), 3 };
150
161
painter.fill_rectangle (
151
162
r5,
152
- Color::green ());
163
+ Color::orange ());
153
164
}
165
+
166
+ // dB - y
167
+ constexpr int db_min = -80 ;
168
+ constexpr int db_max = 10 ;
169
+ constexpr int db_delta = db_max - db_min;
170
+ const range_t <int > y_db_range{0 , r.height () - 1 };
171
+ const int16_t y_db = y_db_range.clip ((db_ - db_min) * r.height () / db_delta);
172
+
173
+ const Rect r_db{r.left (), r.bottom () - y_db, r.width (), 3 };
174
+ if (db_) painter.fill_rectangle (r_db, Color::green ());
154
175
}
155
176
if (pitch_rssi_enabled) {
156
177
baseband::set_pitch_rssi ((avg_ - raw_min) * 2000 / raw_delta, true );
@@ -159,7 +180,7 @@ void RSSI::paint(Painter& painter) {
159
180
const Rect r6{r.left (), r.top (), r.width (), r.height ()};
160
181
painter.draw_rectangle (
161
182
r6,
162
- Color::white ());
183
+ Color::white ()); // TODO this and all the following Color struct call should satisfy the new "theme" system ref
163
184
}
164
185
}
165
186
@@ -500,4 +521,8 @@ bool RSSI::on_touch(const TouchEvent event) {
500
521
return false ;
501
522
}
502
523
}
524
+
525
+ void RSSI::set_db (int16_t db) {
526
+ db_ = db;
527
+ }
503
528
} /* namespace ui */
0 commit comments