mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-25 19:47:36 +00:00
"CW generator" and "Whistle" merged in "Signal generator"
Added wave shape selection and tone frequency auto-update Converted color icons to B&W
This commit is contained in:
@@ -87,6 +87,8 @@ public:
|
||||
WidebandSpectrumConfig = 42,
|
||||
FSKConfigure = 43,
|
||||
SSTVConfigure = 44,
|
||||
SigGenConfig = 43,
|
||||
SigGenTone = 44,
|
||||
|
||||
POCSAGPacket = 50,
|
||||
|
||||
@@ -683,6 +685,36 @@ public:
|
||||
const bool ctcss_enabled;
|
||||
};
|
||||
|
||||
class SigGenConfigMessage : public Message {
|
||||
public:
|
||||
constexpr SigGenConfigMessage(
|
||||
const uint32_t bw,
|
||||
const uint32_t shape,
|
||||
const uint32_t duration
|
||||
) : Message { ID::SigGenConfig },
|
||||
bw(bw),
|
||||
shape(shape),
|
||||
duration(duration)
|
||||
{
|
||||
}
|
||||
|
||||
const uint32_t bw;
|
||||
const uint32_t shape;
|
||||
const uint32_t duration;
|
||||
};
|
||||
|
||||
class SigGenToneMessage : public Message {
|
||||
public:
|
||||
constexpr SigGenToneMessage(
|
||||
const uint32_t tone_delta
|
||||
) : Message { ID::SigGenTone },
|
||||
tone_delta(tone_delta)
|
||||
{
|
||||
}
|
||||
|
||||
const uint32_t tone_delta;
|
||||
};
|
||||
|
||||
class AFSKConfigureMessage : public Message {
|
||||
public:
|
||||
constexpr AFSKConfigureMessage(
|
||||
|
@@ -84,6 +84,7 @@ constexpr image_tag_t image_tag_replay { 'P', 'R', 'E', 'P' };
|
||||
constexpr image_tag_t image_tag_fsktx { 'P', 'F', 'S', 'K' };
|
||||
constexpr image_tag_t image_tag_mic_tx { 'P', 'M', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_sstv_tx { 'P', 'S', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_siggen { 'P', 'S', 'I', 'G' };
|
||||
|
||||
constexpr image_tag_t image_tag_noop { 'P', 'N', 'O', 'P' };
|
||||
|
||||
|
@@ -948,10 +948,14 @@ bool ImageButton::on_touch(const TouchEvent event) {
|
||||
/* ImageOptionsField *****************************************************/
|
||||
|
||||
ImageOptionsField::ImageOptionsField(
|
||||
Rect parent_rect,
|
||||
options_t options
|
||||
const Rect parent_rect,
|
||||
const Color foreground,
|
||||
const Color background,
|
||||
const options_t options
|
||||
) : Widget { parent_rect },
|
||||
options { options }
|
||||
options { options },
|
||||
foreground_ { foreground },
|
||||
background_ { background }
|
||||
{
|
||||
set_focusable(true);
|
||||
}
|
||||
@@ -994,14 +998,20 @@ void ImageOptionsField::set_options(options_t new_options) {
|
||||
}
|
||||
|
||||
void ImageOptionsField::paint(Painter& painter) {
|
||||
const auto paint_style = has_focus() ? style().invert() : style();
|
||||
|
||||
if( selected_index() < options.size() ) {
|
||||
const auto bmp_ptr = options[selected_index()].first;
|
||||
painter.fill_rectangle({screen_rect().location(), {screen_rect().size().width() + 4, screen_rect().size().height() + 4}}, ui::Color::black());
|
||||
painter.draw_rectangle({screen_rect().location(), {screen_rect().size().width() + 4, screen_rect().size().height() + 4}}, paint_style.background);
|
||||
portapack::display.drawBMP({screen_pos().x() + 2, screen_pos().y() + 1}, bmp_ptr, true);
|
||||
}
|
||||
const bool selected = (has_focus() || highlighted());
|
||||
const auto paint_style = selected ? style().invert() : style();
|
||||
|
||||
painter.draw_rectangle(
|
||||
{ screen_rect().location(), { screen_rect().size().width() + 4, screen_rect().size().height() + 4 } },
|
||||
paint_style.background
|
||||
);
|
||||
|
||||
painter.draw_bitmap(
|
||||
{screen_pos().x() + 2, screen_pos().y() + 2},
|
||||
*options[selected_index_].first,
|
||||
foreground_,
|
||||
background_
|
||||
);
|
||||
}
|
||||
|
||||
void ImageOptionsField::on_focus() {
|
||||
|
@@ -406,18 +406,22 @@ public:
|
||||
|
||||
class ImageOptionsField : public Widget {
|
||||
public:
|
||||
using image_t = const unsigned char *;
|
||||
using value_t = int32_t;
|
||||
using option_t = std::pair<image_t, value_t>;
|
||||
using option_t = std::pair<const Bitmap*, value_t>;
|
||||
using options_t = std::vector<option_t>;
|
||||
|
||||
std::function<void(size_t, value_t)> on_change { };
|
||||
std::function<void(void)> on_show_options { };
|
||||
|
||||
ImageOptionsField(Rect parent_rect, options_t options);
|
||||
ImageOptionsField(
|
||||
const Rect parent_rect,
|
||||
const Color foreground,
|
||||
const Color background,
|
||||
const options_t options
|
||||
);
|
||||
|
||||
ImageOptionsField(
|
||||
) : ImageOptionsField { { }, { } }
|
||||
) : ImageOptionsField { { }, Color::white(), Color::black(), { } }
|
||||
{
|
||||
}
|
||||
|
||||
@@ -438,6 +442,8 @@ public:
|
||||
private:
|
||||
options_t options;
|
||||
size_t selected_index_ { 0 };
|
||||
Color foreground_;
|
||||
Color background_;
|
||||
};
|
||||
|
||||
class OptionsField : public Widget {
|
||||
|
Reference in New Issue
Block a user