Added AFSK BW and repeat parameters

This commit is contained in:
furrtek 2015-09-16 15:43:43 +02:00
parent 00ee78f533
commit ff96464efe
9 changed files with 67 additions and 12 deletions

View File

@ -70,6 +70,7 @@ AFSKSetupView::AFSKSetupView(
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
{
uint8_t rpt;
add_children({ {
&text_title,
@ -79,6 +80,10 @@ AFSKSetupView::AFSKSetupView(
&field_mark,
&text_space,
&field_space,
&text_bw,
&field_bw,
&text_repeat,
&field_repeat,
&checkbox_lsb,
&checkbox_parity,
&checkbox_datasize,
@ -93,7 +98,11 @@ AFSKSetupView::AFSKSetupView(
field_mark.set_value(persistent_memory::afsk_mark_freq()*100);
field_space.set_value(persistent_memory::afsk_space_freq()*100);
field_bw.set_value(persistent_memory::afsk_bw());
rpt = (persistent_memory::afsk_config() >> 8) & 0xFF;
if (rpt > 99) rpt = 5;
field_repeat.set_value(rpt);
button_setfreq.on_select = [this,&nav](Button&){
auto new_view = new FrequencyKeypadView { nav, this->transmitter_model.tuning_frequency() };
new_view->on_changed = [this](rf::Frequency f) {
@ -119,14 +128,16 @@ AFSKSetupView::AFSKSetupView(
};
button_done.on_select = [this,&nav](Button&){
uint8_t afsk_config = 0;
uint32_t afsk_config = 0;
persistent_memory::set_afsk_mark(field_mark.value()/100);
persistent_memory::set_afsk_space(field_space.value()/100);
persistent_memory::set_afsk_bw(field_bw.value());
if (checkbox_lsb.value() == true) afsk_config |= 1;
if (checkbox_parity.value() == true) afsk_config |= 2;
if (checkbox_datasize.value() == true) afsk_config |= 4;
afsk_config |= (field_repeat.value() << 8);
persistent_memory::set_afsk_config(afsk_config);
nav.pop();

View File

@ -67,7 +67,7 @@ private:
{ 64, 104 },
5,
{ 100, 32000 },
100,
25,
' '
};
@ -79,7 +79,31 @@ private:
{ 64, 120 },
5,
{ 100, 32000 },
100,
25,
' '
};
Text text_bw {
{ 140, 104, 80, 16 },
"BW: kHz"
};
NumberField field_bw {
{ 172, 104 },
3,
{ 1, 40 },
1,
' '
};
Text text_repeat {
{ 140, 120, 64, 16 },
"Repeat: "
};
NumberField field_repeat {
{ 204, 120 },
2,
{ 1, 99 },
1,
' '
};

View File

@ -283,17 +283,19 @@ LCRView::LCRView(
shared_memory.afsk_phase_inc_mark = persistent_memory::afsk_mark_freq()*(65536*1024)/2280;
shared_memory.afsk_phase_inc_space = persistent_memory::afsk_space_freq()*(65536*1024)/2280;
shared_memory.afsk_fmmod = persistent_memory::afsk_bw()*33; // ?
memset(shared_memory.lcrdata, 0, 256);
memcpy(shared_memory.lcrdata, lcrframe_f, 256);
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5; // DEFAULT
shared_memory.afsk_repeat = ((persistent_memory::afsk_config() >> 8) & 0xFF);
context().message_map[Message::ID::TXDone] = [this, &transmitter_model](const Message* const p) {
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n > 0) {
char str[8] = "0/5... ";
str[0] = hexify(5-message->n);
char str[8] = "0... ";
str[0] = hexify(message->n);
text_status.set(str);
} else {
text_status.set("Done ! ");
@ -301,7 +303,7 @@ LCRView::LCRView(
}
};
text_status.set("0/5... ");
text_status.set("0... ");
transmitter_model.enable();
};

View File

@ -149,9 +149,9 @@ SystemView::SystemView(
// Initial view.
// TODO: Restore from non-volatile memory?
if (persistent_memory::playing_dead() == 0x59)
navigation_view.push(new PlayDeadView { navigation_view, true });
else
//if (persistent_memory::playing_dead() == 0x59)
// navigation_view.push(new PlayDeadView { navigation_view, true });
//else
navigation_view.push(new BMPView { navigation_view });
}

View File

@ -826,7 +826,7 @@ public:
sample = sintab[(aphase & 0x03FF0000)>>16];
//FM
frq = sample * 500;
frq = sample * shared_memory.afsk_fmmod;
phase = (phase + frq);
sphase = phase + (256<<16);

View File

@ -64,6 +64,10 @@ using afsk_bitrate_range_t = range_t<int32_t>;
constexpr afsk_bitrate_range_t afsk_bitrate_range { 600, 9600 };
constexpr int32_t afsk_bitrate_reset_value { 1200 };
using afsk_bw_range_t = range_t<int32_t>;
constexpr afsk_bw_range_t afsk_bw_range { 1, 40 };
constexpr int32_t afsk_bw_reset_value { 15 };
/* struct must pack the same way on M4 and M0 cores. */
struct data_t {
// General config
@ -74,6 +78,7 @@ struct data_t {
int32_t afsk_mark_freq;
int32_t afsk_space_freq; // Todo: optimize size, only 256 bytes of NVRAM !
int32_t afsk_bitrate;
int32_t afsk_bw;
uint32_t afsk_config;
// Play dead unlock
@ -130,6 +135,15 @@ void set_afsk_bitrate(const int32_t new_value) {
data->afsk_bitrate = afsk_bitrate_range.clip(new_value);
}
int32_t afsk_bw() {
afsk_bw_range.reset_if_outside(data->afsk_bw, afsk_bw_reset_value);
return data->afsk_bw;
}
void set_afsk_bw(const int32_t new_value) {
data->afsk_bw = afsk_bw_range.clip(new_value);
}
uint32_t afsk_config() {
return data->afsk_config;
}

View File

@ -49,6 +49,9 @@ void set_afsk_bitrate(const int32_t new_value);
uint32_t afsk_config();
void set_afsk_config(const uint32_t new_value);
int32_t afsk_bw();
void set_afsk_bw(const int32_t new_value);
uint32_t playing_dead();
void set_playing_dead(const uint32_t new_value);

View File

@ -48,6 +48,7 @@ struct SharedMemory {
uint32_t afsk_phase_inc_mark;
uint32_t afsk_phase_inc_space;
uint8_t afsk_repeat;
uint32_t afsk_fmmod;
bool afsk_transmit_done;
};

Binary file not shown.