Put a nice header bar on spectrum

This commit is contained in:
3djc
2019-12-07 15:18:00 +01:00
parent 5a1109b064
commit fd564d8222
2 changed files with 16 additions and 1 deletions
@@ -86,6 +86,12 @@ class ScaleWindow: public Window
{ {
dc->drawSolidFilledRect(0, 0, width(), height(), CURVE_AXIS_COLOR); dc->drawSolidFilledRect(0, 0, width(), height(), CURVE_AXIS_COLOR);
// Draw tracker
int offset = reusableBuffer.spectrumAnalyser.track - (reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2);
int x = limit<int>(0, offset / reusableBuffer.spectrumAnalyser.step, width() - 1);
dc->drawSolidVerticalLine(x, 0, height(), BLACK);
// Draw text scale
for (uint32_t frequency = for (uint32_t frequency =
((reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2) / 10000000) * 10000000 + 10000000;; frequency += 10000000) { ((reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2) / 10000000) * 10000000 + 10000000;; frequency += 10000000) {
int offset = frequency - (reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2); int offset = frequency - (reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2);
@@ -93,7 +99,7 @@ class ScaleWindow: public Window
if (x >= LCD_W - 1) if (x >= LCD_W - 1)
break; break;
if ((frequency / 1000000) % 2 == 0) { if ((frequency / 1000000) % 2 == 0) {
dc->drawNumber(x, 2, frequency / 1000000, FONT(XS) | CENTERED); dc->drawNumber(x, 3, frequency / 1000000, FONT(XS) | CENTERED);
} }
} }
} }
@@ -128,6 +134,7 @@ class SpectrumWindow : public Window
#endif #endif
coord_t SCALE_TOP = height() - MENU_FOOTER_HEIGHT; coord_t SCALE_TOP = height() - MENU_FOOTER_HEIGHT;
// Draw fixed part (scale,..) // Draw fixed part (scale,..)
for (uint32_t frequency = ((reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2) / 10000000) * 10000000 + 10000000; ; frequency += 10000000) { for (uint32_t frequency = ((reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2) / 10000000) * 10000000 + 10000000; ; frequency += 10000000) {
int offset = frequency - (reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2); int offset = frequency - (reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2);
@@ -176,14 +183,21 @@ class SpectrumWindow : public Window
}; };
RadioSpectrumAnalyser::RadioSpectrumAnalyser(uint8_t moduleIdx) : RadioSpectrumAnalyser::RadioSpectrumAnalyser(uint8_t moduleIdx) :
Page(ICON_RADIO_TOOLS), Page(ICON_RADIO_TOOLS),
moduleIdx(moduleIdx) moduleIdx(moduleIdx)
{ {
start(); start();
buildHeader(&header);
buildBody(&body); buildBody(&body);
} }
void RadioSpectrumAnalyser::buildHeader(Window * window)
{
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + 10, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, STR_MENU_SPECTRUM_ANALYSER, 0, MENU_COLOR);
}
void RadioSpectrumAnalyser::buildBody(FormWindow * window) void RadioSpectrumAnalyser::buildBody(FormWindow * window)
{ {
new SpectrumWindow(window, {0, 0, LCD_W, SPECTRUM_HEIGHT}); new SpectrumWindow(window, {0, 0, LCD_W, SPECTRUM_HEIGHT});
@@ -29,6 +29,7 @@ class RadioSpectrumAnalyser: public Page
RadioSpectrumAnalyser(uint8_t moduleIdx); RadioSpectrumAnalyser(uint8_t moduleIdx);
protected: protected:
void buildHeader(Window * window);
void buildBody(FormWindow * window); void buildBody(FormWindow * window);
void start(); void start();
void stop(); void stop();