mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-25 15:37:49 +00:00
Scanner: Added last locked frequencies list
Added back squelch to NFM receiver Scanner: cleanup Widgets: VU-meter cleanup
This commit is contained in:
@@ -821,11 +821,13 @@ public:
|
||||
};
|
||||
|
||||
// TODO: use streaming buffer instead
|
||||
// TODO: rename (not only used for requests)
|
||||
class RequestSignalMessage : public Message {
|
||||
public:
|
||||
enum class Signal : char {
|
||||
FillRequest = 1,
|
||||
BeepRequest = 2,
|
||||
Squelched = 3
|
||||
};
|
||||
|
||||
constexpr RequestSignalMessage(
|
||||
|
@@ -457,12 +457,16 @@ ProgressBar::ProgressBar(
|
||||
}
|
||||
|
||||
void ProgressBar::set_max(const uint32_t max) {
|
||||
if (max == _max) return;
|
||||
|
||||
_value = 0;
|
||||
_max = max;
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void ProgressBar::set_value(const uint32_t value) {
|
||||
if (value == _value) return;
|
||||
|
||||
if (value > _max)
|
||||
_value = _max;
|
||||
else
|
||||
@@ -1450,37 +1454,45 @@ void Waveform::paint(Painter& painter) {
|
||||
|
||||
VuMeter::VuMeter(
|
||||
Rect parent_rect,
|
||||
uint32_t LEDs
|
||||
uint32_t LEDs,
|
||||
bool show_max
|
||||
) : Widget { parent_rect },
|
||||
LEDs_ { LEDs },
|
||||
height { parent_rect.size().height() }
|
||||
show_max_ { show_max }
|
||||
{
|
||||
//set_focusable(false);
|
||||
LED_height = height / LEDs;
|
||||
LED_height = parent_rect.size().height() / LEDs;
|
||||
split = 256 / LEDs;
|
||||
}
|
||||
|
||||
void VuMeter::set_value(const uint8_t new_value) {
|
||||
value_ = new_value;
|
||||
set_dirty();
|
||||
void VuMeter::set_value(const uint32_t new_value) {
|
||||
if ((new_value != value_) && (new_value < 256)) {
|
||||
value_ = new_value;
|
||||
set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
void VuMeter::set_mark(const uint8_t new_mark) {
|
||||
if (new_mark != mark) {
|
||||
void VuMeter::set_mark(const uint32_t new_mark) {
|
||||
if ((new_mark != mark) && (new_mark < 256)) {
|
||||
mark = new_mark;
|
||||
set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
void VuMeter::paint(Painter& painter) {
|
||||
uint32_t bar;
|
||||
Color color;
|
||||
bool lit = false;
|
||||
uint32_t bar_level;
|
||||
Point pos = screen_rect().location();
|
||||
Dim width = screen_rect().size().width() - 4;
|
||||
Dim width = screen_rect().size().width() - 4;
|
||||
Dim height = screen_rect().size().height();
|
||||
Dim bottom = pos.y() + height;
|
||||
Coord marks_x = pos.x() + width;
|
||||
|
||||
if (value_ != prev_value) {
|
||||
uint32_t bar;
|
||||
Color color;
|
||||
bool lit = false;
|
||||
uint32_t bar_level = LEDs_ - ((value_ + 1) / split);
|
||||
bar_level = LEDs_ - ((value_ + 1) / split);
|
||||
|
||||
// Draw LEDs
|
||||
for (bar = 0; bar < LEDs_; bar++) {
|
||||
if (bar >= bar_level)
|
||||
@@ -1501,33 +1513,34 @@ void VuMeter::paint(Painter& painter) {
|
||||
}
|
||||
|
||||
// Update max level
|
||||
if (value_ > max) {
|
||||
max = value_;
|
||||
hold_timer = 30; // 0.5s @ 60Hz
|
||||
} else {
|
||||
if (hold_timer) {
|
||||
hold_timer--;
|
||||
if (show_max_) {
|
||||
if (value_ > max) {
|
||||
max = value_;
|
||||
hold_timer = 30; // 0.5s @ 60Hz
|
||||
} else {
|
||||
if (max) max--; // Let it drop
|
||||
if (hold_timer) {
|
||||
hold_timer--;
|
||||
} else {
|
||||
if (max) max--; // Let it drop
|
||||
}
|
||||
}
|
||||
|
||||
// Draw max level
|
||||
if (max != prev_max) {
|
||||
painter.draw_hline({ marks_x, bottom - (height * prev_max) / 256 }, 8, Color::black());
|
||||
painter.draw_hline({ marks_x, bottom - (height * max) / 256 }, 8, Color::white());
|
||||
if (prev_max == mark)
|
||||
prev_mark = 0; // Force mark refresh
|
||||
prev_max = max;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw max level
|
||||
if (max != prev_max) {
|
||||
painter.draw_hline({ pos.x() + width, pos.y() + height - (height * prev_max) / 256 }, 8, Color::black());
|
||||
painter.draw_hline({ pos.x() + width, pos.y() + height - (height * max) / 256 }, 8, Color::white());
|
||||
if (prev_max == mark)
|
||||
prev_mark = 0; // Force mark refresh
|
||||
}
|
||||
|
||||
// Draw mark
|
||||
if ((mark != prev_mark) && (mark)) {
|
||||
painter.draw_hline({ pos.x() + width, pos.y() + height - (height * prev_mark) / 256 }, 8, Color::black());
|
||||
painter.draw_hline({ pos.x() + width, pos.y() + height - (height * mark) / 256 }, 8, Color::grey());
|
||||
painter.draw_hline({ marks_x, bottom - (height * prev_mark) / 256 }, 8, Color::black());
|
||||
painter.draw_hline({ marks_x, bottom - (height * mark) / 256 }, 8, Color::grey());
|
||||
prev_mark = mark;
|
||||
}
|
||||
|
||||
prev_max = max;
|
||||
prev_mark = mark;
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
@@ -575,19 +575,19 @@ private:
|
||||
class VuMeter : public Widget {
|
||||
public:
|
||||
|
||||
VuMeter(Rect parent_rect, uint32_t LEDs);
|
||||
VuMeter(Rect parent_rect, uint32_t LEDs, bool show_max);
|
||||
|
||||
void set_value(const uint8_t new_value);
|
||||
void set_mark(const uint8_t new_mark);
|
||||
void set_value(const uint32_t new_value);
|
||||
void set_mark(const uint32_t new_mark);
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
private:
|
||||
uint32_t LEDs_, LED_height { 0 };
|
||||
uint32_t value_ { 0 }, prev_value { 0 };
|
||||
uint32_t value_ { 0 }, prev_value { 255 }; // Forces painting on first display
|
||||
uint32_t split { 0 };
|
||||
uint16_t max { 0 }, prev_max { 0 }, hold_timer { 0 }, mark { 0 }, prev_mark { 0 };
|
||||
int height;
|
||||
bool show_max_;
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
Reference in New Issue
Block a user