Splash screen and Play Dead functionality

This commit is contained in:
furrtek
2015-09-04 20:37:27 +02:00
parent ec26f587f1
commit 30531a20f2
25 changed files with 1891 additions and 179 deletions
+5
View File
@@ -241,6 +241,11 @@ void ILI9341::fill_rectangle(ui::Rect r, const ui::Color c) {
}
}
void ILI9341::render_line(const ui::Point p, const uint8_t count, const ui::Color* line_buffer) {
lcd_start_ram_write(p, { count, 1 });
io.lcd_write_pixels(line_buffer, count);
}
void ILI9341::draw_line(const ui::Point start, const ui::Point end, const ui::Color color) {
int x0 = start.x;
int y0 = start.y;
+1
View File
@@ -54,6 +54,7 @@ public:
);
void draw_pixel(const ui::Point p, const ui::Color color);
void render_line(const ui::Point p, const uint8_t count, const ui::Color* line_buffer);
template<size_t N>
void draw_pixels(
+9
View File
@@ -42,6 +42,7 @@ public:
FSKConfiguration = 6,
FSKPacket = 7,
TestResults = 8,
TXDone = 9,
MAX
};
@@ -251,6 +252,14 @@ public:
FSKPacket packet;
};
class TXDoneMessage : public Message {
public:
TXDoneMessage(
) : Message { ID::TXDone }
{
}
};
class MessageHandlerMap {
public:
using MessageHandler = std::function<void(const Message* const p)>;
+38 -18
View File
@@ -55,14 +55,14 @@ using ppb_range_t = range_t<ppb_t>;
constexpr ppb_range_t ppb_range { -99000, 99000 };
constexpr ppb_t ppb_reset_value { 0 };
using afsk_freq_range_t = range_t<int16_t>;
constexpr afsk_freq_range_t afsk_freq_range { 100, 32000 };
constexpr int16_t afsk_mark_reset_value { 1200 };
constexpr int16_t afsk_space_reset_value { 2200 };
using afsk_freq_range_t = range_t<int32_t>;
constexpr afsk_freq_range_t afsk_freq_range { 1, 60 };
constexpr int32_t afsk_mark_reset_value { 12 };
constexpr int32_t afsk_space_reset_value { 22 };
using afsk_bitrate_range_t = range_t<int16_t>;
using afsk_bitrate_range_t = range_t<int32_t>;
constexpr afsk_bitrate_range_t afsk_bitrate_range { 600, 9600 };
constexpr int16_t afsk_bitrate_reset_value { 1200 };
constexpr int32_t afsk_bitrate_reset_value { 1200 };
/* struct must pack the same way on M4 and M0 cores. */
struct data_t {
@@ -71,10 +71,14 @@ struct data_t {
int32_t correction_ppb;
// AFSK modem
int16_t afsk_mark_freq;
int16_t afsk_space_freq;
int16_t afsk_bitrate;
int32_t afsk_mark_freq;
int32_t afsk_space_freq;
int32_t afsk_bitrate;
uint8_t afsk_config;
// Play dead unlock
bool playing_dead;
uint32_t playdead_sequence;
};
static_assert(sizeof(data_t) <= 0x100, "Persistent memory structure too large for VBAT-maintained region");
@@ -99,30 +103,30 @@ void set_correction_ppb(const ppb_t new_value) {
data->correction_ppb = ppb_range.clip(new_value);
}
int16_t afsk_mark_freq() {
int32_t afsk_mark_freq() {
afsk_freq_range.reset_if_outside(data->afsk_mark_freq, afsk_mark_reset_value);
return data->correction_ppb;
return data->afsk_mark_freq;
}
void set_afsk_mark(const int16_t new_value) {
void set_afsk_mark(const int32_t new_value) {
data->afsk_mark_freq = afsk_freq_range.clip(new_value);
}
int16_t afsk_space_freq() {
int32_t afsk_space_freq() {
afsk_freq_range.reset_if_outside(data->afsk_space_freq, afsk_space_reset_value);
return data->correction_ppb;
return data->afsk_space_freq;
}
void set_afsk_space(const int16_t new_value) {
void set_afsk_space(const int32_t new_value) {
data->afsk_space_freq = afsk_freq_range.clip(new_value);
}
int16_t afsk_bitrate() {
int32_t afsk_bitrate() {
afsk_bitrate_range.reset_if_outside(data->afsk_bitrate, afsk_bitrate_reset_value);
return data->correction_ppb;
return data->afsk_bitrate;
}
void set_afsk_bitrate(const int16_t new_value) {
void set_afsk_bitrate(const int32_t new_value) {
data->afsk_bitrate = afsk_bitrate_range.clip(new_value);
}
@@ -134,5 +138,21 @@ void set_afsk_config(const uint8_t new_value) {
data->afsk_config = new_value;
}
bool playing_dead() {
return data->playing_dead;
}
void set_playing_dead(const bool new_value) {
data->playing_dead = new_value;
}
uint32_t playdead_sequence() {
return data->playdead_sequence;
}
void set_playdead_sequence(const uint32_t new_value) {
data->playdead_sequence = new_value;
}
} /* namespace persistent_memory */
} /* namespace portapack */
@@ -37,18 +37,24 @@ void set_tuned_frequency(const rf::Frequency new_value);
ppb_t correction_ppb();
void set_correction_ppb(const ppb_t new_value);
int16_t afsk_mark_freq();
void set_afsk_mark(const int16_t new_value);
int32_t afsk_mark_freq();
void set_afsk_mark(const int32_t new_value);
int16_t afsk_space_freq();
void set_afsk_space(const int16_t new_value);
int32_t afsk_space_freq();
void set_afsk_space(const int32_t new_value);
int16_t afsk_bitrate();
void set_afsk_bitrate(const int16_t new_value);
int32_t afsk_bitrate();
void set_afsk_bitrate(const int32_t new_value);
uint8_t afsk_config();
void set_afsk_config(const uint8_t new_value);
bool playing_dead();
void set_playing_dead(const bool new_value);
uint32_t playdead_sequence();
void set_playdead_sequence(const uint32_t new_value);
} /* namespace persistent_memory */
} /* namespace portapack */
@@ -47,6 +47,8 @@ struct SharedMemory {
uint32_t afsk_samples_per_bit;
uint32_t afsk_phase_inc_mark;
uint32_t afsk_phase_inc_space;
uint8_t afsk_repeat;
bool afsk_transmit_done;
};
extern SharedMemory& shared_memory;
+5
View File
@@ -401,6 +401,11 @@ bool Button::on_key(const KeyEvent key) {
on_select(*this);
return true;
}
} else {
if( on_dir ) {
on_dir(*this, key);
return false;
}
}
return false;
+1
View File
@@ -212,6 +212,7 @@ private:
class Button : public Widget {
public:
std::function<void(Button&)> on_select;
std::function<void(Button&,KeyEvent)> on_dir;
Button(
Rect parent_rect,