Added carrier wake up in Xylos TX and cute icons

This commit is contained in:
furrtek
2016-05-27 06:48:04 +02:00
parent 7a90eab407
commit 6a0816ba56
31 changed files with 636 additions and 285 deletions
+89 -72
View File
@@ -43,7 +43,8 @@
using namespace portapack;
namespace ui {
/*
void XylosRXView::talk() {
uint8_t c;
@@ -79,15 +80,6 @@ XylosRXView::~XylosRXView() {
receiver_model.disable();
}
/*VirtualTimer vt;
void XylosRXView::do_something(void *p) {
//p.set(xylos_voice_filenames[xylos_voice_phrase[p_idx]]);
//p_idx++;
//} while (xylos_voice_phrase[p_idx] != 0xFF);
text_dbg.set("Done :)");
}*/
void XylosRXView::on_show() {
//chVTSet(&vt, MS2ST(1000), do_something, NULL);
}
@@ -116,7 +108,7 @@ XylosRXView::XylosRXView(
};
}
*/
@@ -143,10 +135,12 @@ void XylosView::upd_message() {
ccirmessage[4] = (city_code.value() / 10) + 0x30;
ccirmessage[5] = (city_code.value() % 10) + 0x30;
ccirmessage[6] = family_code.value() + 0x30;
if (checkbox_wcsubfamily.value() == false)
ccirmessage[7] = subfamily_code.value() + 0x30;
else
ccirmessage[7] = 'A';
if (checkbox_wcid.value() == false) {
ccirmessage[8] = (receiver_code.value() / 10) + 0x30;
ccirmessage[9] = (receiver_code.value() % 10) + 0x30;
@@ -160,7 +154,7 @@ void XylosView::upd_message() {
ccirmessage[11] = options_ra.selected_index() + 0x30;
ccirmessage[12] = options_rb.selected_index() + 0x30;
ccirmessage[13] = options_rc.selected_index() + 0x30;
ccirmessage[14] = '0';
ccirmessage[14] = options_rd.selected_index() + 0x30;
ccirmessage[15] = 'B';
@@ -177,7 +171,7 @@ void XylosView::upd_message() {
ccirmessage[20] = 0;
// Display as text
text_debug.set(ccirmessage);
text_message.set(ccirmessage);
// ASCII to frequency LUT index
for (c=0; c<20; c++) {
@@ -190,19 +184,7 @@ void XylosView::upd_message() {
ccirmessage[20] = 0xFF;
}
void XylosView::journuit() {
uint8_t sr;
chThdSleepMilliseconds(1000);
// Invert relay states
sr = options_ra.selected_index();
if (sr > 0) options_ra.set_selected_index(sr ^ 3);
sr = options_rb.selected_index();
if (sr > 0) options_rb.set_selected_index(sr ^ 3);
sr = options_rc.selected_index();
if (sr > 0) options_rc.set_selected_index(sr ^ 3);
void XylosView::start_tx() {
upd_message();
audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max);
@@ -215,18 +197,6 @@ XylosView::XylosView(
NavigationView& nav
)
{
static constexpr Style style_val {
.font = font::fixed_8x16,
.background = Color::green(),
.foreground = Color::black(),
};
static constexpr Style style_cancel {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black(),
};
transmitter_model.set_baseband_configuration({
.mode = 2,
.sampling_rate = 1536000,
@@ -234,7 +204,7 @@ XylosView::XylosView(
});
add_children({ {
&text_title,
&checkbox_hinc,
&button_txtest,
&text_header,
&header_code_a,
@@ -251,17 +221,17 @@ XylosView::XylosView(
&checkbox_wcid,
&text_freq,
&options_freq,
&text_ra,
&text_relais,
&options_ra,
&text_rb,
&options_rb,
&text_rc,
&options_rc,
&text_progress,
&text_debug,
&options_rd,
&progress,
&text_message,
&button_transmit,
&checkbox_cligno,
&button_exit
&tempo_cligno,
&text_cligno
} });
city_code.set_value(18);
@@ -271,6 +241,9 @@ XylosView::XylosView(
header_code_a.set_value(0);
header_code_b.set_value(0);
options_freq.set_selected_index(5);
tempo_cligno.set_value(5);
options_ra.set_selected_index(1); // R1 OFF
checkbox_wcsubfamily.set_value(true);
checkbox_wcid.set_value(true);
@@ -299,20 +272,34 @@ XylosView::XylosView(
(void)v;
XylosView::upd_message();
};
subfamily_code.hidden(true);
text_subfamily.set_style(&style_grey);
checkbox_wcsubfamily.on_select = [this](Checkbox&) {
if (checkbox_wcsubfamily.value() == true)
if (checkbox_wcsubfamily.value() == true) {
subfamily_code.hidden(true);
else
text_subfamily.set_style(&style_grey);
} else {
subfamily_code.hidden(false);
text_subfamily.set_style(&style());
}
XylosView::upd_message();
};
receiver_code.hidden(true);
text_receiver.set_style(&style_grey);
checkbox_wcid.on_select = [this](Checkbox&) {
if (checkbox_wcid.value() == true)
if (checkbox_wcid.value() == true) {
receiver_code.hidden(true);
else
text_receiver.set_style(&style_grey);
} else {
receiver_code.hidden(false);
text_receiver.set_style(&style());
}
receiver_code.set_dirty();
XylosView::upd_message();
};
options_ra.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n;
(void)v;
@@ -328,13 +315,18 @@ XylosView::XylosView(
(void)v;
XylosView::upd_message();
};
options_rd.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n;
(void)v;
XylosView::upd_message();
};
button_transmit.set_style(&style_val);
XylosView::upd_message();
button_txtest.on_select = [this](Button&) {
const uint8_t ccirtest[21] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,13,12,11,0xFF };
const uint8_t ccirtest[21] = { 11, 13, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 14, 12, 10, 12, 14, 0, 9, 0xFF };
if (txing == false) {
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
@@ -345,8 +337,8 @@ XylosView::XylosView(
audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
transmitter_model.disable();
txing = false;
button_txtest.set_style(&style_val);
button_txtest.set_text("TX TEST");
button_txtest.set_style(&style());
button_txtest.set_text("TEST");
}
}
);
@@ -367,36 +359,65 @@ XylosView::XylosView(
};
button_transmit.on_select = [this](Button&) {
if (txing == false) {
upd_message();
if (checkbox_hinc.value())
inc_cnt = 3;
else
inc_cnt = 0;
header_init = header_code_b.value();
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this](Message* const p) {
uint8_t c;
char progress[21];
uint8_t sr;
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n == 25) {
audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
transmitter_model.disable();
for (c=0;c<20;c++)
progress[c] = ' ';
progress[20] = 0;
text_progress.set(progress);
if (checkbox_cligno.value() == false) {
txing = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
progress.set_value(0);
if (inc_cnt) {
chThdSleepMilliseconds(1000);
header_code_b.set_value(header_code_b.value() + 1);
upd_message();
start_tx();
inc_cnt--;
} else {
journuit();
header_code_b.set_value(header_init);
if (checkbox_cligno.value() == false) {
txing = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
} else {
if (checkbox_hinc.value())
inc_cnt = 3;
else
inc_cnt = 0;
chThdSleepMilliseconds(tempo_cligno.value() * 1000);
// Invert relay states
sr = options_ra.selected_index();
if (sr > 0) options_ra.set_selected_index(sr ^ 3);
sr = options_rb.selected_index();
if (sr > 0) options_rb.set_selected_index(sr ^ 3);
sr = options_rc.selected_index();
if (sr > 0) options_rc.set_selected_index(sr ^ 3);
sr = options_rd.selected_index();
if (sr > 0) options_rd.set_selected_index(sr ^ 3);
upd_message();
start_tx();
}
}
} else {
for (c=0;c<message->n;c++) // Todo: Use progressbar !
progress[c] = ' ';
progress[c] = '.';
progress[++c] = 0;
text_progress.set(progress);
progress.set_value((message->n + 1) * 5);
}
}
);
@@ -414,10 +435,6 @@ XylosView::XylosView(
transmitter_model.enable();
}
};
button_exit.on_select = [&nav](Button&){
nav.pop();
};
}