Unclever first attempt at display sleep.

This commit is contained in:
Jared Boone 2016-01-27 20:33:54 -08:00
parent 1caf6952d8
commit 894d4b955c
6 changed files with 48 additions and 12 deletions

View File

@ -99,6 +99,7 @@ void EventDispatcher::dispatch(const eventmask_t events) {
handle_rtc_tick();
}
if( !display_sleep ) {
if( events & EVT_MASK_LCD_FRAME_SYNC ) {
handle_lcd_frame_sync();
}
@ -115,6 +116,7 @@ void EventDispatcher::dispatch(const eventmask_t events) {
handle_touch();
}
}
}
void EventDispatcher::handle_application_queue() {
std::array<uint8_t, Message::MAX_SIZE> message_buffer;

View File

@ -27,6 +27,8 @@
#include "ui_widget.hpp"
#include "ui_painter.hpp"
#include "portapack.hpp"
#include "message.hpp"
#include "touch.hpp"
@ -53,6 +55,11 @@ public:
void run();
void request_stop();
void set_display_sleep(bool new_value) {
portapack::io.lcd_backlight(false);
display_sleep = new_value;
};
static inline void events_flag(const eventmask_t events) {
if( thread_event_loop ) {
chEvtSignal(thread_event_loop, events);
@ -80,6 +87,7 @@ private:
uint32_t encoder_last = 0;
bool is_running = true;
bool sd_card_present = false;
bool display_sleep = false;
eventmask_t wait();
void dispatch(const eventmask_t events);

View File

@ -81,6 +81,11 @@ int main(void) {
event_dispatcher.request_stop();
}
);
EventDispatcher::message_map().register_handler(Message::ID::DisplaySleep,
[&event_dispatcher](const Message* const) {
event_dispatcher.set_display_sleep(true);
}
);
m4_init(portapack::spi_flash::baseband, portapack::memory::map::m4_code);

View File

@ -22,6 +22,7 @@
#include "ui_navigation.hpp"
#include "portapack.hpp"
#include "event_m0.hpp"
#include "receiver_model.hpp"
#include "ui_setup.hpp"
@ -42,6 +43,7 @@ SystemStatusView::SystemStatusView() {
add_children({ {
&button_back,
&title,
&button_sleep,
&sd_card_status_view,
} });
sd_card_status_view.set_parent_rect({ 28 * 8, 0 * 16, 2 * 8, 1 * 16 });
@ -51,6 +53,11 @@ SystemStatusView::SystemStatusView() {
this->on_back();
}
};
button_sleep.on_select = [this](Button&) {
DisplaySleepMessage message;
EventDispatcher::message_map().send(&message);
};
}
void SystemStatusView::set_back_visible(bool new_value) {

View File

@ -59,6 +59,11 @@ private:
default_title,
};
Button button_sleep {
{ 25 * 8, 0, 2 * 8, 1 * 16 },
"ZZ",
};
SDCardStatusView sd_card_status_view;
};

View File

@ -58,6 +58,7 @@ public:
AMConfigure = 13,
ChannelSpectrumConfig = 14,
SpectrumStreamingConfig = 15,
DisplaySleep = 16,
MAX
};
@ -165,6 +166,14 @@ struct AudioStatistics {
}
};
class DisplaySleepMessage : public Message {
public:
constexpr DisplaySleepMessage(
) : Message { ID::DisplaySleep }
{
}
};
class AudioStatisticsMessage : public Message {
public:
constexpr AudioStatisticsMessage(