Checkboxes, more AFSK options

This commit is contained in:
furrtek 2015-09-05 20:17:43 +02:00
parent 70a646ca60
commit f1166205b0
10 changed files with 317 additions and 61 deletions

View file

@ -50,7 +50,7 @@ using namespace hackrf::one;
namespace ui {
void LCRView::focus() {
button_setam_a.focus();
button_setrgsb.focus();
}
LCRView::~LCRView() {
@ -58,40 +58,56 @@ LCRView::~LCRView() {
}
void LCRView::make_frame() {
char eom[3] = { 3, 0, 0 };
uint8_t i;
char eom[3] = { 3, 0, 0 }; // EOM and space for checksum
uint8_t i, pm;
uint16_t dp;
uint8_t cp, pp, cur_byte, new_byte;
// Testing: 7 char pad for litterals
// Pad litterals right to 7 chars (not required ?)
for (i = 0; i < 5; i++) {
while (strlen(litteral[i]) < 7) {
strcat(litteral[i], " ");
}
}
// Recreate LCR frame
// Make LCR frame
memset(lcrframe, 0, 256);
lcrframe[0] = 127;
lcrframe[0] = 127; // Modem sync
lcrframe[1] = 127;
lcrframe[2] = 127;
lcrframe[3] = 127;
lcrframe[4] = 127;
lcrframe[5] = 127;
lcrframe[6] = 127;
lcrframe[7] = 15;
lcrframe[7] = 15; // SOM
strcat(lcrframe, rgsb);
strcat(lcrframe, "PA AM=1 AF=\"");
strcat(lcrframe, litteral[0]);
strcat(lcrframe, "\" CL=0 AM=2 AF=\"");
strcat(lcrframe, litteral[1]);
strcat(lcrframe, "\" CL=0 AM=3 AF=\"");
strcat(lcrframe, litteral[2]);
strcat(lcrframe, "\" CL=0 AM=4 AF=\"");
strcat(lcrframe, litteral[3]);
strcat(lcrframe, "\" CL=0 AM=5 AF=\"");
strcat(lcrframe, litteral[4]);
strcat(lcrframe, "\" CL=0 EC=A SAB=0"); //TODO: EC=A,J,N
strcat(lcrframe, "PA ");
if (checkbox_am_a.value() == true) {
strcat(lcrframe, "AM=1 AF=\"");
strcat(lcrframe, litteral[0]);
strcat(lcrframe, "\" CL=0 ");
}
if (checkbox_am_b.value() == true) {
strcat(lcrframe, "AM=2 AF=\"");
strcat(lcrframe, litteral[1]);
strcat(lcrframe, "\" CL=0 ");
}
if (checkbox_am_c.value() == true) {
strcat(lcrframe, "AM=3 AF=\"");
strcat(lcrframe, litteral[2]);
strcat(lcrframe, "\" CL=0 ");
}
if (checkbox_am_d.value() == true) {
strcat(lcrframe, "AM=4 AF=\"");
strcat(lcrframe, litteral[3]);
strcat(lcrframe, "\" CL=0 ");
}
if (checkbox_am_e.value() == true) {
strcat(lcrframe, "AM=5 AF=\"");
strcat(lcrframe, litteral[4]);
strcat(lcrframe, "\" CL=0 ");
}
strcat(lcrframe, "EC=A SAB=0"); //TODO: EC=A,J,N
memcpy(lcrstring, lcrframe, 256);
@ -102,21 +118,47 @@ void LCRView::make_frame() {
checksum ^= lcrframe[i];
i++;
}
checksum ^= 3;
checksum ^= eom[0]; // EOM
checksum &= 0x7F;
eom[1] = checksum;
strcat(lcrframe, eom);
for (dp=0;dp<strlen(lcrframe);dp++) {
pp = 0;
new_byte = 0;
cur_byte = lcrframe[dp];
for (cp=0;cp<7;cp++) {
if ((cur_byte>>cp)&1) pp++;
new_byte |= ((cur_byte>>cp)&1)<<(7-cp);
if (persistent_memory::afsk_config() & 2)
pm = 0; // Even parity
else
pm = 1; // Odd parity
if (persistent_memory::afsk_config() & 1) {
// LSB first
for (dp=0;dp<strlen(lcrframe);dp++) {
pp = pm;
new_byte = 0;
cur_byte = lcrframe[dp];
for (cp=0;cp<7;cp++) {
if ((cur_byte>>cp)&1) pp++;
new_byte |= ((cur_byte>>cp)&1)<<(6-cp);
}
// 8/7 bit
if (persistent_memory::afsk_config() & 4)
lcrframe_f[dp] = new_byte;
else
lcrframe_f[dp] = (new_byte<<1)|(pp&1);
}
} else {
// MSB first
for (dp=0;dp<strlen(lcrframe);dp++) {
pp = pm;
cur_byte = lcrframe[dp];
for (cp=0;cp<7;cp++) {
if ((cur_byte>>cp)&1) pp++;
}
// 8/7 bit
if (persistent_memory::afsk_config() & 4)
lcrframe_f[dp] = cur_byte;
else
lcrframe_f[dp] = (cur_byte<<1)|(pp&1);
}
lcrframe_f[dp] = new_byte|(pp&1);
}
}
@ -128,7 +170,7 @@ void LCRView::paint(Painter& painter) {
};
Point offset = {
static_cast<Coord>(72),
static_cast<Coord>(104),
static_cast<Coord>(72)
};
@ -195,10 +237,15 @@ LCRView::LCRView(
&text_recap,
&button_setrgsb,
&button_txsetup,
&checkbox_am_a,
&button_setam_a,
&checkbox_am_b,
&button_setam_b,
&checkbox_am_c,
&button_setam_c,
&checkbox_am_d,
&button_setam_d,
&checkbox_am_e,
&button_setam_e,
&text_status,
&button_lcrdebug,
@ -207,6 +254,12 @@ LCRView::LCRView(
&button_exit
} });
checkbox_am_a.set_value(true);
checkbox_am_b.set_value(true);
checkbox_am_c.set_value(true);
checkbox_am_d.set_value(true);
checkbox_am_e.set_value(true);
// Recap: tx freq @ bps
auto fstr = to_string_dec_int(persistent_memory::tuned_frequency() / 1000, 6);
auto bstr = to_string_dec_int(persistent_memory::afsk_bitrate(), 4);