Added Bias-T toggle confirmation

Backlight setting save bugfix
Updated binary
This commit is contained in:
furrtek 2018-01-08 03:47:37 +00:00
parent 3193c6ee99
commit f0c912be2e
13 changed files with 206 additions and 173 deletions

View File

@ -216,8 +216,6 @@ void SetPlayDeadView::focus() {
} }
SetUIView::SetUIView(NavigationView& nav) { SetUIView::SetUIView(NavigationView& nav) {
uint32_t ui_config;
add_children({ add_children({
&checkbox_login, &checkbox_login,
&checkbox_bloff, &checkbox_bloff,
@ -226,24 +224,26 @@ SetUIView::SetUIView(NavigationView& nav) {
&button_ok &button_ok
}); });
ui_config = portapack::persistent_memory::ui_config(); checkbox_showsplash.set_value(persistent_memory::config_splash());
checkbox_login.set_value(persistent_memory::config_login());
if (ui_config & 1) checkbox_showsplash.set_value(true); uint32_t backlight_timer = persistent_memory::config_backlight_timer();
if (ui_config & 2) checkbox_bloff.set_value(true);
if (ui_config & 16) checkbox_login.set_value(true);
options_bloff.set_selected_index((ui_config >> 5) & 7);
button_ok.on_select = [&nav, &ui_config, this](Button&) { if (backlight_timer) {
ui_config &= ~0b10011; checkbox_bloff.set_value(true);
options_bloff.set_by_value(backlight_timer);
if (checkbox_login.value()) { } else {
portapack::persistent_memory::set_playing_dead(0x5920C1DF); // Enable options_bloff.set_selected_index(0);
ui_config |= (1 << 4);
} }
if (checkbox_showsplash.value()) ui_config |= (1 << 0);
if (checkbox_bloff.value()) ui_config |= (1 << 1);
portapack::persistent_memory::set_ui_config(ui_config); button_ok.on_select = [&nav, this](Button&) {
if (checkbox_bloff.value())
persistent_memory::set_config_backlight_timer(options_bloff.selected_index() + 1);
else
persistent_memory::set_config_backlight_timer(0);
persistent_memory::set_config_splash(checkbox_showsplash.value());
persistent_memory::set_config_login(checkbox_login.value());
nav.pop(); nav.pop();
}; };
} }

View File

@ -247,11 +247,11 @@ private:
{ 52, 6 * 16 + 8 }, { 52, 6 * 16 + 8 },
10, 10,
{ {
{ "5 seconds", 0 }, { "5 seconds", 5 },
{ "15 seconds", 1 }, { "15 seconds", 15 },
{ "1 minute", 2 }, { "1 minute", 60 },
{ "5 minutes", 3 }, { "5 minutes", 300 },
{ "10 minutes", 4 } { "10 minutes", 600 }
} }
}; };

View File

@ -810,44 +810,44 @@ static constexpr Bitmap bitmap_icon_keyfob {
}; };
static constexpr uint8_t bitmap_icon_biast_off_data[] = { static constexpr uint8_t bitmap_icon_biast_off_data[] = {
0xFF, 0xFF,
0xFF, 0xFF,
0x80, 0x01,
0x80, 0x01,
0x80, 0x01,
0x00, 0x00,
0x00, 0x00,
0x20, 0x04,
0x60, 0x06,
0xC0, 0x03,
0x80, 0x01,
0xC0, 0x03,
0x60, 0x06,
0x20, 0x04,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xFC, 0x3F,
0x00, 0x02,
0x00, 0x0E,
0x00, 0x18,
0x00, 0x10,
0x88, 0x18,
0xD8, 0x0E,
0x70, 0x18,
0x20, 0x10,
0x70, 0x18,
0xD8, 0x0E,
0x88, 0x18,
0x00, 0x10,
0x00, 0x18,
0x00, 0x0E,
}; };
static constexpr Bitmap bitmap_icon_biast_off { static constexpr Bitmap bitmap_icon_biast_off {
{ 16, 16 }, bitmap_icon_biast_off_data { 16, 16 }, bitmap_icon_biast_off_data
}; };
static constexpr uint8_t bitmap_icon_biast_on_data[] = { static constexpr uint8_t bitmap_icon_biast_on_data[] = {
0xFF, 0xFF, 0x00, 0x00,
0xFF, 0xFF, 0xFE, 0x7F,
0x80, 0x01, 0x00, 0x02,
0x80, 0x03, 0x00, 0x0E,
0x08, 0x06, 0x20, 0x18,
0x08, 0x04, 0x20, 0x10,
0x0C, 0x06, 0x30, 0x18,
0x84, 0x03, 0x10, 0x0E,
0x0E, 0x06, 0x38, 0x18,
0x3E, 0x04, 0xF8, 0x10,
0x38, 0x06, 0xE0, 0x18,
0x90, 0x03, 0x40, 0x0E,
0x18, 0x06, 0x60, 0x18,
0x08, 0x04, 0x20, 0x10,
0x08, 0x06, 0x20, 0x18,
0x80, 0x03, 0x00, 0x0E,
}; };
static constexpr Bitmap bitmap_icon_biast_on { static constexpr Bitmap bitmap_icon_biast_on {
{ 16, 16 }, bitmap_icon_biast_on_data { 16, 16 }, bitmap_icon_biast_on_data

View File

@ -222,15 +222,13 @@ void EventDispatcher::handle_local_queue() {
} }
void EventDispatcher::handle_rtc_tick() { void EventDispatcher::handle_rtc_tick() {
uint16_t bloff;
sd_card::poll_inserted(); sd_card::poll_inserted();
portapack::temperature_logger.second_tick(); portapack::temperature_logger.second_tick();
bloff = portapack::persistent_memory::ui_config_bloff(); uint32_t backlight_timer = portapack::persistent_memory::config_backlight_timer();
if (bloff) { if (backlight_timer) {
if (portapack::bl_tick_counter == bloff) if (portapack::bl_tick_counter == backlight_timer)
set_display_sleep(true); set_display_sleep(true);
else else
portapack::bl_tick_counter++; portapack::bl_tick_counter++;

View File

@ -82,7 +82,10 @@ namespace ui {
/* SystemStatusView ******************************************************/ /* SystemStatusView ******************************************************/
SystemStatusView::SystemStatusView() { SystemStatusView::SystemStatusView(
NavigationView& nav
) : nav_ (nav)
{
static constexpr Style style_systemstatus { static constexpr Style style_systemstatus {
.font = font::fixed_8x16, .font = font::fixed_8x16,
.background = Color::dark_grey(), .background = Color::dark_grey(),
@ -97,7 +100,7 @@ SystemStatusView::SystemStatusView() {
//&button_textentry, //&button_textentry,
&button_camera, &button_camera,
&button_sleep, &button_sleep,
&image_bias_tee, &button_bias_tee,
&sd_card_status_view, &sd_card_status_view,
}); });
@ -112,6 +115,8 @@ SystemStatusView::SystemStatusView() {
else else
button_textentry.set_bitmap(&bitmap_icon_unistroke);*/ button_textentry.set_bitmap(&bitmap_icon_unistroke);*/
refresh();
button_back.on_select = [this](ImageButton&){ button_back.on_select = [this](ImageButton&){
if (this->on_back) if (this->on_back)
this->on_back(); this->on_back();
@ -121,6 +126,10 @@ SystemStatusView::SystemStatusView() {
this->on_stealth(); this->on_stealth();
}; };
button_bias_tee.on_select = [this](ImageButton&) {
this->on_bias_tee();
};
/*button_textentry.on_select = [this](ImageButton&) { /*button_textentry.on_select = [this](ImageButton&) {
this->on_textentry(); this->on_textentry();
};*/ };*/
@ -137,11 +146,11 @@ SystemStatusView::SystemStatusView() {
void SystemStatusView::refresh() { void SystemStatusView::refresh() {
if (receiver_model.antenna_bias()) { if (receiver_model.antenna_bias()) {
image_bias_tee.set_bitmap(&bitmap_icon_biast_on); button_bias_tee.set_bitmap(&bitmap_icon_biast_on);
image_bias_tee.set_foreground(ui::Color::green()); button_bias_tee.set_foreground(ui::Color::yellow());
} else { } else {
image_bias_tee.set_bitmap(&bitmap_icon_biast_off); button_bias_tee.set_bitmap(&bitmap_icon_biast_off);
image_bias_tee.set_foreground(ui::Color::light_grey()); button_bias_tee.set_foreground(ui::Color::light_grey());
} }
} }
@ -159,12 +168,11 @@ void SystemStatusView::set_title(const std::string new_value) {
} }
void SystemStatusView::on_stealth() { void SystemStatusView::on_stealth() {
bool cfg; bool mode = not portapack::persistent_memory::stealth_mode();
cfg = portapack::persistent_memory::stealth_mode(); portapack::persistent_memory::set_stealth_mode(mode);
portapack::persistent_memory::set_stealth_mode(not cfg);
if (!cfg) if (mode)
button_stealth.set_foreground(ui::Color::green()); button_stealth.set_foreground(ui::Color::green());
else else
button_stealth.set_foreground(ui::Color::light_grey()); button_stealth.set_foreground(ui::Color::light_grey());
@ -172,6 +180,23 @@ void SystemStatusView::on_stealth() {
button_stealth.set_dirty(); button_stealth.set_dirty();
} }
void SystemStatusView::on_bias_tee() {
bool antenna_bias = receiver_model.antenna_bias();
if (!antenna_bias) {
nav_.display_modal("Bias voltage", "Enable DC voltage on\nantenna connector ?", YESNO, [this](bool v) {
if (v) {
receiver_model.set_antenna_bias(true);
refresh();
}
});
} else {
receiver_model.set_antenna_bias(false);
refresh();
}
}
/*void SystemStatusView::on_textentry() { /*void SystemStatusView::on_textentry() {
uint8_t cfg; uint8_t cfg;
@ -434,7 +459,7 @@ SystemView::SystemView(
(portapack::persistent_memory::ui_config() & 16)) { // Login option (portapack::persistent_memory::ui_config() & 16)) { // Login option
navigation_view.push<PlayDeadView>(); navigation_view.push<PlayDeadView>();
} else {*/ } else {*/
if (portapack::persistent_memory::ui_config() & 1) if (portapack::persistent_memory::config_splash())
navigation_view.push<BMPView>(); navigation_view.push<BMPView>();
else else
navigation_view.push<SystemMenuView>(); navigation_view.push<SystemMenuView>();

View File

@ -53,11 +53,50 @@ enum modal_t {
ABORT ABORT
}; };
class NavigationView : public View {
public:
std::function<void(const View&)> on_view_changed { };
NavigationView() = default;
NavigationView(const NavigationView&) = delete;
NavigationView(NavigationView&&) = delete;
NavigationView& operator=(const NavigationView&) = delete;
NavigationView& operator=(NavigationView&&) = delete;
bool is_top() const;
template<class T, class... Args>
T* push(Args&&... args) {
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
}
void push(View* v);
void pop();
void pop_modal();
void display_modal(const std::string& title, const std::string& message);
void display_modal(const std::string& title, const std::string& message, const modal_t type, const std::function<void(bool)> on_choice = nullptr);
void focus() override;
private:
std::vector<std::unique_ptr<View>> view_stack { };
Widget* modal_view { nullptr };
Widget* view() const;
void free_view();
void update_view();
View* push_view(std::unique_ptr<View> new_view);
};
class SystemStatusView : public View { class SystemStatusView : public View {
public: public:
std::function<void(void)> on_back { }; std::function<void(void)> on_back { };
SystemStatusView(); SystemStatusView(NavigationView& nav);
void set_back_enabled(bool new_value); void set_back_enabled(bool new_value);
void set_title(const std::string new_value); void set_title(const std::string new_value);
@ -65,6 +104,8 @@ public:
private: private:
static constexpr auto default_title = "PortaPack|Havoc"; static constexpr auto default_title = "PortaPack|Havoc";
NavigationView& nav_;
Rectangle backdrop { Rectangle backdrop {
{ 0 * 8, 0 * 16, 240, 16 }, { 0 * 8, 0 * 16, 240, 16 },
Color::dark_grey() Color::dark_grey()
@ -110,8 +151,8 @@ private:
Color::dark_grey() Color::dark_grey()
}; };
Image image_bias_tee { ImageButton button_bias_tee {
{ 26 * 8, 0, 2 * 8, 1 * 16 }, { 26 * 8, 0, 12, 1 * 16 },
&bitmap_icon_biast_off, &bitmap_icon_biast_off,
Color::light_grey(), Color::light_grey(),
Color::dark_grey() Color::dark_grey()
@ -122,6 +163,7 @@ private:
}; };
void on_stealth(); void on_stealth();
void on_bias_tee();
//void on_textentry(); //void on_textentry();
void on_camera(); void on_camera();
void refresh(); void refresh();
@ -135,45 +177,6 @@ private:
}; };
}; };
class NavigationView : public View {
public:
std::function<void(const View&)> on_view_changed { };
NavigationView() = default;
NavigationView(const NavigationView&) = delete;
NavigationView(NavigationView&&) = delete;
NavigationView& operator=(const NavigationView&) = delete;
NavigationView& operator=(NavigationView&&) = delete;
bool is_top() const;
template<class T, class... Args>
T* push(Args&&... args) {
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
}
void push(View* v);
void pop();
void pop_modal();
void display_modal(const std::string& title, const std::string& message);
void display_modal(const std::string& title, const std::string& message, const modal_t type, const std::function<void(bool)> on_choice = nullptr);
void focus() override;
private:
std::vector<std::unique_ptr<View>> view_stack { };
Widget* modal_view { nullptr };
Widget* view() const;
void free_view();
void update_view();
View* push_view(std::unique_ptr<View> new_view);
};
class BMPView : public View { class BMPView : public View {
public: public:
BMPView(NavigationView& nav); BMPView(NavigationView& nav);
@ -227,7 +230,7 @@ public:
Context& context() const override; Context& context() const override;
private: private:
SystemStatusView status_view { }; SystemStatusView status_view { navigation_view };
NavigationView navigation_view { }; NavigationView navigation_view { };
Context& context_; Context& context_;
}; };

View File

@ -24,6 +24,8 @@
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include "string_format.hpp" #include "string_format.hpp"
using namespace portapack;
namespace ui { namespace ui {
void PlayDeadView::focus() { void PlayDeadView::focus() {
@ -31,10 +33,10 @@ void PlayDeadView::focus() {
} }
void PlayDeadView::paint(Painter& painter) { void PlayDeadView::paint(Painter& painter) {
if (!(portapack::persistent_memory::ui_config() & 16)) { if (persistent_memory::config_login()) {
// Blank the whole display // Blank the whole display
painter.fill_rectangle( painter.fill_rectangle(
portapack::display.screen_rect(), display.screen_rect(),
style().background style().background
); );
} }
@ -43,7 +45,7 @@ void PlayDeadView::paint(Painter& painter) {
PlayDeadView::PlayDeadView(NavigationView& nav) { PlayDeadView::PlayDeadView(NavigationView& nav) {
rtc::RTC datetime; rtc::RTC datetime;
portapack::persistent_memory::set_playing_dead(0x5920C1DF); // Enable persistent_memory::set_playing_dead(0x5920C1DF); // Enable
add_children({ add_children({
&text_playdead1, &text_playdead1,
@ -64,9 +66,9 @@ PlayDeadView::PlayDeadView(NavigationView& nav) {
}; };
button_seq_entry.on_select = [this, &nav](Button&){ button_seq_entry.on_select = [this, &nav](Button&){
if (sequence == portapack::persistent_memory::playdead_sequence()) { if (sequence == persistent_memory::playdead_sequence()) {
portapack::persistent_memory::set_playing_dead(0x82175E23); // Disable persistent_memory::set_playing_dead(0x82175E23); // Disable
if (!(portapack::persistent_memory::ui_config() & 16)) { if (persistent_memory::config_login()) {
text_playdead3.hidden(false); text_playdead3.hidden(false);
} else { } else {
nav.pop(); nav.pop();

View File

@ -80,6 +80,7 @@ struct data_t {
uint32_t playing_dead; uint32_t playing_dead;
uint32_t playdead_sequence; uint32_t playdead_sequence;
// UI
uint32_t ui_config; uint32_t ui_config;
uint32_t pocsag_last_address; uint32_t pocsag_last_address;
@ -203,49 +204,50 @@ void set_playdead_sequence(const uint32_t new_value) {
} }
bool stealth_mode() { bool stealth_mode() {
return ((data->ui_config >> 3) & 1) ? true : false; return (data->ui_config & 0x20000000UL) ? true : false;
} }
void set_stealth_mode(const bool new_value) { void set_stealth_mode(const bool v) {
data->ui_config = (data->ui_config & ~0b1000) | ((new_value & 1) << 3); data->ui_config = (data->ui_config & ~0x20000000UL) | (v << 29);
} }
uint32_t ui_config() { bool config_splash() {
uint8_t bloff_value; return (data->ui_config & 0x80000000UL) ? true : false;
// Cap value
bloff_value = (data->ui_config >> 5) & 7;
if (bloff_value > 4) bloff_value = 1; // 15s default
data->ui_config = (data->ui_config & 0x1F) | (bloff_value << 5);
return data->ui_config;
} }
uint16_t ui_config_bloff() { bool config_login() {
uint8_t bloff_value; return (data->ui_config & 0x40000000UL) ? true : false;
uint16_t bloff_seconds[5] = { 5, 15, 60, 300, 600 };
if (!(data->ui_config & 2)) return 0;
// Cap value
bloff_value = (data->ui_config >> 5) & 7;
if (bloff_value > 4) bloff_value = 1;
return bloff_seconds[bloff_value];
} }
void set_config_textentry(uint8_t new_value) { uint32_t config_backlight_timer() {
const uint32_t timer_seconds[8] = { 0, 5, 15, 60, 300, 600, 600, 600 };
return timer_seconds[data->ui_config & 0x00000007UL];
}
void set_config_splash(bool v) {
data->ui_config = (data->ui_config & ~0x80000000UL) | (v << 31);
}
void set_config_login(bool v) {
data->ui_config = (data->ui_config & ~0x40000000UL) | (v << 30);
}
void set_config_backlight_timer(uint32_t i) {
data->ui_config = (data->ui_config & ~0x00000007UL) | (i & 7);
}
/*void set_config_textentry(uint8_t new_value) {
data->ui_config = (data->ui_config & ~0b100) | ((new_value & 1) << 2); data->ui_config = (data->ui_config & ~0b100) | ((new_value & 1) << 2);
} }
uint8_t ui_config_textentry() { uint8_t ui_config_textentry() {
return ((data->ui_config >> 2) & 1); return ((data->ui_config >> 2) & 1);
} }*/
void set_ui_config(const uint32_t new_value) { /*void set_ui_config(const uint32_t new_value) {
data->ui_config = new_value; data->ui_config = new_value;
} }*/
uint32_t pocsag_last_address() { uint32_t pocsag_last_address() {
return data->pocsag_last_address; return data->pocsag_last_address;

View File

@ -69,15 +69,18 @@ uint32_t playdead_sequence();
void set_playdead_sequence(const uint32_t new_value); void set_playdead_sequence(const uint32_t new_value);
bool stealth_mode(); bool stealth_mode();
void set_stealth_mode(const bool new_value); void set_stealth_mode(const bool v);
uint32_t ui_config(); bool config_splash();
void set_ui_config(const uint32_t new_value); bool config_login();
uint32_t config_backlight_timer();
uint16_t ui_config_bloff(); void set_config_splash(bool v);
void set_config_login(bool v);
void set_config_backlight_timer(uint32_t i);
uint8_t ui_config_textentry(); //uint8_t ui_config_textentry();
void set_config_textentry(uint8_t new_value); //void set_config_textentry(uint8_t new_value);
uint32_t pocsag_last_address(); uint32_t pocsag_last_address();
void set_pocsag_last_address(uint32_t address); void set_pocsag_last_address(uint32_t address);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 B

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

View File

@ -64,7 +64,7 @@ def convert_png(file):
data = 0 data = 0
f.write("\n") f.write("\n")
if i < rgb_im.size[0] - 1: if i < rgb_im.size[1] - 1:
f.write(' ') # Tab f.write(' ') # Tab
f.write("};\n") f.write("};\n")