mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-11 09:09:29 +00:00
Remove unused _previous_frequency member from BigFrequency and remove paint() guard
Co-authored-by: gullradriel <3157857+gullradriel@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
824b53f7d4
commit
1fcd87756e
@@ -564,12 +564,8 @@ void LiveDateTime::set_seconds_enabled(bool new_value) {
|
|||||||
|
|
||||||
/* BigFrequency **********************************************************/
|
/* BigFrequency **********************************************************/
|
||||||
|
|
||||||
BigFrequency::BigFrequency(
|
BigFrequency::BigFrequency(Rect parent_rect, rf::Frequency frequency)
|
||||||
Rect parent_rect,
|
: Widget{parent_rect}, _frequency{frequency} {}
|
||||||
rf::Frequency frequency)
|
|
||||||
: Widget{parent_rect},
|
|
||||||
_frequency{frequency} {
|
|
||||||
}
|
|
||||||
|
|
||||||
void BigFrequency::set(const rf::Frequency frequency) {
|
void BigFrequency::set(const rf::Frequency frequency) {
|
||||||
_frequency = frequency;
|
_frequency = frequency;
|
||||||
@@ -583,63 +579,59 @@ void BigFrequency::paint(Painter& painter) {
|
|||||||
Point digit_pos;
|
Point digit_pos;
|
||||||
ui::Color segment_color;
|
ui::Color segment_color;
|
||||||
|
|
||||||
if (_frequency != _previous_frequency) {
|
rf::Frequency frequency{_frequency};
|
||||||
_previous_frequency = _frequency;
|
const auto rect = screen_rect(); // why not use screen_rect() directly for width, ...? it may be too small, but ...
|
||||||
|
|
||||||
rf::Frequency frequency{_frequency};
|
// Erase
|
||||||
const auto rect = screen_rect(); // why not use screen_rect() directly for width, ...? it may be too small, but ...
|
painter.fill_rectangle(
|
||||||
|
{{0, rect.location().y()}, {screen_width, 52}},
|
||||||
|
Theme::getInstance()->bg_darkest->background);
|
||||||
|
|
||||||
// Erase
|
// Prepare digits
|
||||||
painter.fill_rectangle(
|
if (!frequency) {
|
||||||
{{0, rect.location().y()}, {screen_width, 52}},
|
digits.fill(10); // ----.---
|
||||||
Theme::getInstance()->bg_darkest->background);
|
digit_pos = {(screen_width - ((7 * digit_width) + 8)) / 2, rect.location().y()};
|
||||||
|
} else {
|
||||||
|
frequency /= 1000; // GMMM.KKK(uuu)
|
||||||
|
|
||||||
// Prepare digits
|
for (i = 0; i < 7; i++) {
|
||||||
if (!frequency) {
|
digits[6 - i] = frequency % 10;
|
||||||
digits.fill(10); // ----.---
|
frequency /= 10;
|
||||||
digit_pos = {(screen_width - ((7 * digit_width) + 8)) / 2, rect.location().y()};
|
|
||||||
} else {
|
|
||||||
frequency /= 1000; // GMMM.KKK(uuu)
|
|
||||||
|
|
||||||
for (i = 0; i < 7; i++) {
|
|
||||||
digits[6 - i] = frequency % 10;
|
|
||||||
frequency /= 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove leading zeros
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
if (!digits[i])
|
|
||||||
digits[i] = 16; // "Don't draw" code
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
digit_pos = {(Coord)(screen_width - ((7 * digit_width) + 8) - (i * digit_width)) / 2, rect.location().y()};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
segment_color = style().foreground;
|
// Remove leading zeros
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
if (!digits[i])
|
||||||
|
digits[i] = 16; // "Don't draw" code
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw
|
digit_pos = {(Coord)(screen_width - ((7 * digit_width) + 8) - (i * digit_width)) / 2, rect.location().y()};
|
||||||
for (i = 0; i < 7; i++) {
|
}
|
||||||
digit = digits[i];
|
|
||||||
|
|
||||||
if (digit < 16) {
|
segment_color = style().foreground;
|
||||||
digit_def = segment_font[(uint8_t)digit];
|
|
||||||
|
|
||||||
for (size_t s = 0; s < 7; s++) {
|
// Draw
|
||||||
if (digit_def & 1)
|
for (i = 0; i < 7; i++) {
|
||||||
painter.fill_rectangle({digit_pos + segments[s].location(), segments[s].size()}, segment_color);
|
digit = digits[i];
|
||||||
digit_def >>= 1;
|
|
||||||
}
|
if (digit < 16) {
|
||||||
|
digit_def = segment_font[(uint8_t)digit];
|
||||||
|
|
||||||
|
for (size_t s = 0; s < 7; s++) {
|
||||||
|
if (digit_def & 1)
|
||||||
|
painter.fill_rectangle({digit_pos + segments[s].location(), segments[s].size()}, segment_color);
|
||||||
|
digit_def >>= 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (i == 3) {
|
if (i == 3) {
|
||||||
// Dot
|
// Dot
|
||||||
painter.fill_rectangle({digit_pos + Point(34, 48), {4, 4}}, segment_color);
|
painter.fill_rectangle({digit_pos + Point(34, 48), {4, 4}}, segment_color);
|
||||||
digit_pos += {(digit_width + 8), 0};
|
digit_pos += {(digit_width + 8), 0};
|
||||||
} else {
|
} else {
|
||||||
digit_pos += {digit_width, 0};
|
digit_pos += {digit_width, 0};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,7 +297,6 @@ class BigFrequency : public Widget {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
rf::Frequency _frequency;
|
rf::Frequency _frequency;
|
||||||
rf::Frequency _previous_frequency{~0LL};
|
|
||||||
|
|
||||||
static constexpr Dim digit_width = 32;
|
static constexpr Dim digit_width = 32;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user