mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 19:54:39 +00:00
Started fixing RDS and adding more group types
This commit is contained in:
parent
9c3e3bddad
commit
ceced96673
@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ui_closecall.hpp"
|
#include "ui_closecall.hpp"
|
||||||
#include "ui_receiver.hpp"
|
|
||||||
#include "msgpack.hpp"
|
#include "msgpack.hpp"
|
||||||
|
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
* Copyright (C) 2016 Furrtek
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@ -47,7 +48,7 @@ RDSView::~RDSView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string to_string_bin(const uint32_t n, const uint8_t l) {
|
std::string to_string_bin(const uint32_t n, const uint8_t l) {
|
||||||
char p[32];
|
char p[33];
|
||||||
for (uint8_t c = 0; c < l; c++) {
|
for (uint8_t c = 0; c < l; c++) {
|
||||||
if ((n << c) & (1 << l))
|
if ((n << c) & (1 << l))
|
||||||
p[c] = '1';
|
p[c] = '1';
|
||||||
@ -71,35 +72,65 @@ uint32_t makeblock(uint32_t blockdata, uint16_t offset) {
|
|||||||
return (blockdata << 10) | (CRC ^ offset);
|
return (blockdata << 10) | (CRC ^ offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo:
|
||||||
// Make PI
|
// Make PI
|
||||||
// Set frequency
|
// Set frequency
|
||||||
// TA/TP flags
|
// TA/TP flags
|
||||||
// Group selection
|
// Group selection
|
||||||
//RST SNCF
|
|
||||||
//Jammer
|
uint8_t RDSView::b2b(const bool in) {
|
||||||
//Microphone troll
|
if (in)
|
||||||
//CTCSS
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RDSView::make_0B_group(uint32_t group[], const uint16_t PI_code, const bool TP, const uint8_t PTY, const bool TA,
|
||||||
|
const bool MS, const bool DI, const uint8_t C, char * chars) {
|
||||||
|
|
||||||
|
group[0] = PI_code;
|
||||||
|
group[1] = (0x0 << 12) | (1 << 11) | (b2b(TP) << 10) | (PTY << 5) | (b2b(TA) << 4) | (b2b(MS) << 3) | (b2b(DI) << 2) | (C & 3);
|
||||||
|
group[2] = PI_code;
|
||||||
|
group[3] = (chars[0] << 8) | chars[1];
|
||||||
|
}
|
||||||
|
|
||||||
void RDSView::paint(Painter& painter) {
|
void RDSView::paint(Painter& painter) {
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
|
uint32_t group[4][4] = { 0 };
|
||||||
|
|
||||||
uint32_t group[4][4] = {
|
make_0B_group(&group[0][0], 0xF849, true, 7, false, true, false, 0, &psname[0]);
|
||||||
{0b1111100001001001, //PI
|
make_0B_group(&group[1][0], 0xF849, true, 7, false, true, false, 1, &psname[2]);
|
||||||
|
make_0B_group(&group[2][0], 0xF849, true, 7, false, true, false, 2, &psname[4]);
|
||||||
|
make_0B_group(&group[3][0], 0xF849, true, 7, false, true, false, 3, &psname[6]);
|
||||||
|
|
||||||
|
/*uint32_t group[4][4] = {
|
||||||
|
{
|
||||||
|
0b1111100001001001, //PI
|
||||||
0b0000110011101000, //Address
|
0b0000110011101000, //Address
|
||||||
0b1111100001001001, //PI
|
0b1111100001001001, //PI
|
||||||
0b0000000000000000}, //Replaced
|
0b0000000000000000 //Replaced
|
||||||
{0b1111100001001001, //PI
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
0b1111100001001001, //PI
|
||||||
0b0000110011101001, //Address
|
0b0000110011101001, //Address
|
||||||
0b1111100001001001, //PI
|
0b1111100001001001, //PI
|
||||||
0b0000000000000000}, //Replaced
|
0b0000000000000000 //Replaced
|
||||||
{0b1111100001001001, //PI
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
0b1111100001001001, //PI
|
||||||
0b0000110011101010, //Address
|
0b0000110011101010, //Address
|
||||||
0b1111100001001001, //PI
|
0b1111100001001001, //PI
|
||||||
0b0000000000000000}, //Replaced
|
0b0000000000000000 //Replaced
|
||||||
{0b1111100001001001, //PI
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
0b1111100001001001, //PI
|
||||||
0b0000110011101011, //Address
|
0b0000110011101011, //Address
|
||||||
0b1111100001001001, //PI
|
0b1111100001001001, //PI
|
||||||
0b0000000000000000}, //Replaced
|
0b0000000000000000 //Replaced
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
//Insert PSN data in groups
|
//Insert PSN data in groups
|
||||||
@ -107,13 +138,14 @@ void RDSView::paint(Painter& painter) {
|
|||||||
group[1][3] = (psname[2] << 8) | psname[3];
|
group[1][3] = (psname[2] << 8) | psname[3];
|
||||||
group[2][3] = (psname[4] << 8) | psname[5];
|
group[2][3] = (psname[4] << 8) | psname[5];
|
||||||
group[3][3] = (psname[6] << 8) | psname[7];
|
group[3][3] = (psname[6] << 8) | psname[7];
|
||||||
|
*/
|
||||||
|
|
||||||
//Generate checkbits
|
//Generate checkbits
|
||||||
for (c = 0; c < 4; c++) {
|
for (c = 0; c < 4; c++) {
|
||||||
group[c][0] = makeblock(group[c][0], 0b0011111100);
|
group[c][0] = makeblock(group[c][0], RDS_OFFSET_A);
|
||||||
group[c][1] = makeblock(group[c][1], 0b0110011000);
|
group[c][1] = makeblock(group[c][1], RDS_OFFSET_B);
|
||||||
group[c][2] = makeblock(group[c][2], 0b1101010000); //C'
|
group[c][2] = makeblock(group[c][2], RDS_OFFSET_Cp); //C'
|
||||||
group[c][3] = makeblock(group[c][3], 0b0110110100);
|
group[c][3] = makeblock(group[c][3], RDS_OFFSET_D);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Point offset = {
|
const Point offset = {
|
||||||
@ -137,21 +169,35 @@ RDSView::RDSView(
|
|||||||
NavigationView& nav
|
NavigationView& nav
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
transmitter_model.set_tuning_frequency(93000000);
|
|
||||||
strcpy(psname, "TEST1234");
|
strcpy(psname, "TEST1234");
|
||||||
|
|
||||||
add_children({ {
|
add_children({ {
|
||||||
&text_title,
|
&field_frequency,
|
||||||
|
&options_pty,
|
||||||
&button_setpsn,
|
&button_setpsn,
|
||||||
&button_transmit,
|
&button_transmit,
|
||||||
&button_exit
|
&button_exit
|
||||||
} });
|
} });
|
||||||
|
|
||||||
button_setpsn.on_select = [this,&nav](Button&){
|
field_frequency.set_value(transmitter_model.tuning_frequency());
|
||||||
nav.push<AlphanumView>(psname, 8);
|
field_frequency.set_step(100000);
|
||||||
|
field_frequency.on_edit = [this, &nav]() {
|
||||||
|
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.tuning_frequency());
|
||||||
|
new_view->on_changed = [this](rf::Frequency f) {
|
||||||
|
this->field_frequency.set_value(f);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
button_transmit.on_select = [&transmitter_model](Button&){
|
options_pty.set_selected_index(0);
|
||||||
|
|
||||||
|
button_setpsn.on_select = [this,&nav](Button&){
|
||||||
|
auto an_view = nav.push<AlphanumView>(psname, 8);
|
||||||
|
an_view->on_changed = [this](char *value) {
|
||||||
|
memcpy(psname, value, 9);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
button_transmit.on_select = [this](Button&){
|
||||||
transmitter_model.enable();
|
transmitter_model.enable();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
* Copyright (C) 2016 Furrtek
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@ -20,11 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ui.hpp"
|
#include "ui.hpp"
|
||||||
#include "ui_widget.hpp"
|
|
||||||
#include "ui_painter.hpp"
|
|
||||||
#include "ui_menu.hpp"
|
#include "ui_menu.hpp"
|
||||||
#include "ui_navigation.hpp"
|
#include "ui_navigation.hpp"
|
||||||
#include "ui_font_fixed_8x16.hpp"
|
#include "ui_font_fixed_8x16.hpp"
|
||||||
|
#include "ui_receiver.hpp"
|
||||||
#include "clock_manager.hpp"
|
#include "clock_manager.hpp"
|
||||||
#include "message.hpp"
|
#include "message.hpp"
|
||||||
#include "rf_path.hpp"
|
#include "rf_path.hpp"
|
||||||
@ -32,62 +32,19 @@
|
|||||||
#include "volume.hpp"
|
#include "volume.hpp"
|
||||||
#include "transmitter_model.hpp"
|
#include "transmitter_model.hpp"
|
||||||
|
|
||||||
|
#define RDS_OFFSET_A 0b0011111100
|
||||||
|
#define RDS_OFFSET_B 0b0110011000
|
||||||
|
#define RDS_OFFSET_C 0b0101101000
|
||||||
|
#define RDS_OFFSET_Cp 0b1101010000
|
||||||
|
#define RDS_OFFSET_D 0b0110110100
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
/*
|
|
||||||
class AlphanumView : public View {
|
|
||||||
public:
|
|
||||||
std::function<void(char *)> on_changed;
|
|
||||||
|
|
||||||
AlphanumView(NavigationView& nav, char txt[], uint8_t max_len);
|
|
||||||
|
|
||||||
void focus() override;
|
|
||||||
|
|
||||||
char * value();
|
|
||||||
|
|
||||||
uint8_t txtidx;
|
|
||||||
|
|
||||||
//void set_value(char * new_txtinput);
|
|
||||||
void char_add(const char c);
|
|
||||||
void char_delete();
|
|
||||||
|
|
||||||
//rf::Frequency value() const;
|
|
||||||
//void set_value(const rf::Frequency new_value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint8_t _max_len;
|
|
||||||
bool _lowercase = false;
|
|
||||||
static constexpr size_t button_w = 240 / 5;
|
|
||||||
static constexpr size_t button_h = 28;
|
|
||||||
char txtinput[9];
|
|
||||||
|
|
||||||
void set_lowercase();
|
|
||||||
void set_uppercase();
|
|
||||||
|
|
||||||
Text text_input {
|
|
||||||
{ 88, 0, 240, 16 }
|
|
||||||
};
|
|
||||||
|
|
||||||
std::array<Button, 40> buttons;
|
|
||||||
|
|
||||||
Button button_lowercase {
|
|
||||||
{ 88+64+16, 270, 32, 24 },
|
|
||||||
"UC"
|
|
||||||
};
|
|
||||||
|
|
||||||
Button button_done {
|
|
||||||
{ 88, 270, 64, 24 },
|
|
||||||
"Done"
|
|
||||||
};
|
|
||||||
|
|
||||||
void on_button(Button& button);
|
|
||||||
|
|
||||||
void update_text();
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
class RDSView : public View {
|
class RDSView : public View {
|
||||||
public:
|
public:
|
||||||
RDSView(NavigationView& nav);
|
RDSView(NavigationView& nav);
|
||||||
~RDSView();
|
~RDSView();
|
||||||
|
std::string title() const override { return "RDS transmit"; };
|
||||||
|
|
||||||
void focus() override;
|
void focus() override;
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
@ -95,9 +52,51 @@ public:
|
|||||||
private:
|
private:
|
||||||
char psname[9];
|
char psname[9];
|
||||||
|
|
||||||
Text text_title {
|
uint8_t b2b(const bool in);
|
||||||
{ 76, 16, 88, 16 },
|
void make_0B_group(uint32_t group[], const uint16_t PI_code, const bool TP, const uint8_t PTY, const bool TA,
|
||||||
"RDS toolbox"
|
const bool MS, const bool DI, const uint8_t C, char * TWOCHARs);
|
||||||
|
|
||||||
|
FrequencyField field_frequency {
|
||||||
|
{ 1 * 8, 1 * 16 },
|
||||||
|
};
|
||||||
|
|
||||||
|
OptionsField options_pty {
|
||||||
|
{ 1 * 8, 3 * 16 },
|
||||||
|
32,
|
||||||
|
{
|
||||||
|
{ "None ", 0 },
|
||||||
|
{ "News ", 1 },
|
||||||
|
{ "Affairs ", 2 },
|
||||||
|
{ "Info ", 3 },
|
||||||
|
{ "Sport ", 4 },
|
||||||
|
{ "Educate ", 5 },
|
||||||
|
{ "Drama ", 6 },
|
||||||
|
{ "Culture ", 7 },
|
||||||
|
{ "Science ", 8 },
|
||||||
|
{ "Varied ", 9 },
|
||||||
|
{ "Pop ", 10 },
|
||||||
|
{ "Rock ", 11 },
|
||||||
|
{ "Easy ", 12 },
|
||||||
|
{ "Light ", 13 },
|
||||||
|
{ "Classics", 14 },
|
||||||
|
{ "Other ", 15 },
|
||||||
|
{ "Weather ", 16 },
|
||||||
|
{ "Finance ", 17 },
|
||||||
|
{ "Children", 18 },
|
||||||
|
{ "Social ", 19 },
|
||||||
|
{ "Religion", 20 },
|
||||||
|
{ "PhoneIn ", 21 },
|
||||||
|
{ "Travel ", 22 },
|
||||||
|
{ "Leisure ", 23 },
|
||||||
|
{ "Jazz ", 24 },
|
||||||
|
{ "Country ", 25 },
|
||||||
|
{ "National", 26 },
|
||||||
|
{ "Oldies ", 27 },
|
||||||
|
{ "Folk ", 28 },
|
||||||
|
{ "Docs ", 29 },
|
||||||
|
{ "AlarmTst", 30 },
|
||||||
|
{ "Alarm ", 31 }
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Button button_setpsn {
|
Button button_setpsn {
|
||||||
|
@ -163,7 +163,7 @@ void XylosView::upd_message() {
|
|||||||
ccirmessage[18] = '0';
|
ccirmessage[18] = '0';
|
||||||
ccirmessage[19] = '0';
|
ccirmessage[19] = '0';
|
||||||
|
|
||||||
// Stuffing
|
// Repeats elimination
|
||||||
for (c = 1; c < 20; c++) {
|
for (c = 1; c < 20; c++) {
|
||||||
if (ccirmessage[c] == ccirmessage[c - 1]) ccirmessage[c] = 'E';
|
if (ccirmessage[c] == ccirmessage[c - 1]) ccirmessage[c] = 'E';
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user