mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-07-29 16:29:17 +02:00
set shortrt and level
This commit is contained in:
+27
-2
@@ -1,5 +1,6 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "rds.h"
|
#include "rds.h"
|
||||||
|
#include "modulator.h"
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "ascii_cmd.h"
|
#include "ascii_cmd.h"
|
||||||
|
|
||||||
@@ -207,10 +208,18 @@ static void handle_eccen(unsigned char *arg) {
|
|||||||
set_rds_ecclic_toggle(arg[0]);
|
set_rds_ecclic_toggle(arg[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_shortrt(unsigned char *arg) {
|
||||||
|
set_rds_shortrt(arg[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_grpseq(unsigned char *arg) {
|
static void handle_grpseq(unsigned char *arg) {
|
||||||
set_rds_grpseq(arg);
|
set_rds_grpseq(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_level(unsigned char *arg) {
|
||||||
|
set_rds_level(strtoul((char *)arg, NULL, 10)/255.0f);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_udg1(unsigned char *arg) {
|
static void handle_udg1(unsigned char *arg) {
|
||||||
uint16_t blocks[8][3];
|
uint16_t blocks[8][3];
|
||||||
int sets = 0;
|
int sets = 0;
|
||||||
@@ -307,7 +316,8 @@ static const command_handler_t commands_eq2[] = {
|
|||||||
static const command_handler_t commands_eq6[] = {
|
static const command_handler_t commands_eq6[] = {
|
||||||
{"PINEN", handle_pinen, 5},
|
{"PINEN", handle_pinen, 5},
|
||||||
{"RT1EN", handle_rt1en, 5},
|
{"RT1EN", handle_rt1en, 5},
|
||||||
{"ECCEN", handle_eccen, 5}
|
{"ECCEN", handle_eccen, 5},
|
||||||
|
{"LEVEL", handle_level, 5}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const command_handler_t commands_eq7[] = {
|
static const command_handler_t commands_eq7[] = {
|
||||||
@@ -316,6 +326,10 @@ static const command_handler_t commands_eq7[] = {
|
|||||||
{"GRPSEQ", handle_grpseq, 6}
|
{"GRPSEQ", handle_grpseq, 6}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const command_handler_t commands_eq7[] = {
|
||||||
|
{"SHORTRT", handle_shortrt, 7}
|
||||||
|
};
|
||||||
|
|
||||||
// Process a command using the appropriate command table
|
// Process a command using the appropriate command table
|
||||||
static bool process_command_table(const command_handler_t *table, int table_size,
|
static bool process_command_table(const command_handler_t *table, int table_size,
|
||||||
unsigned char *cmd, unsigned char *arg) {
|
unsigned char *cmd, unsigned char *arg) {
|
||||||
@@ -397,7 +411,6 @@ void process_ascii_cmd(unsigned char *str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process commands with = delimiter at position 7 (format: XXXXXX=y...)
|
|
||||||
if (cmd_len > 6 && str[6] == '=') {
|
if (cmd_len > 6 && str[6] == '=') {
|
||||||
cmd = str;
|
cmd = str;
|
||||||
cmd[6] = 0;
|
cmd[6] = 0;
|
||||||
@@ -409,4 +422,16 @@ void process_ascii_cmd(unsigned char *str) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd_len > 7 && str[7] == '=') {
|
||||||
|
cmd = str;
|
||||||
|
cmd[7] = 0;
|
||||||
|
arg = str + 8;
|
||||||
|
|
||||||
|
if (process_command_table(commands_eq8,
|
||||||
|
sizeof(commands_eq8) / sizeof(command_handler_t),
|
||||||
|
cmd, arg)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+9
-1
@@ -6,7 +6,11 @@
|
|||||||
static struct rds_t rds;
|
static struct rds_t rds;
|
||||||
static float waveform[2][FILTER_SIZE];
|
static float waveform[2][FILTER_SIZE];
|
||||||
|
|
||||||
|
static float level;
|
||||||
|
|
||||||
void init_rds_objects() {
|
void init_rds_objects() {
|
||||||
|
level = 1.0f;
|
||||||
|
|
||||||
memset(&rds, 0, sizeof(rds));
|
memset(&rds, 0, sizeof(rds));
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 2; i++) {
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
@@ -18,6 +22,10 @@ void init_rds_objects() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_rds_level(float _level) {
|
||||||
|
level = _level;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get an RDS sample. This generates the envelope of the waveform using
|
/* Get an RDS sample. This generates the envelope of the waveform using
|
||||||
* pre-generated elementary waveform samples.
|
* pre-generated elementary waveform samples.
|
||||||
*/
|
*/
|
||||||
@@ -59,5 +67,5 @@ float get_rds_sample() {
|
|||||||
rds.sample_buffer[rds.out_sample_index++] = 0;
|
rds.sample_buffer[rds.out_sample_index++] = 0;
|
||||||
if (rds.out_sample_index == SAMPLE_BUFFER_SIZE)
|
if (rds.out_sample_index == SAMPLE_BUFFER_SIZE)
|
||||||
rds.out_sample_index = 0;
|
rds.out_sample_index = 0;
|
||||||
return sample;
|
return sample*level;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ typedef struct rds_t {
|
|||||||
} rds_t;
|
} rds_t;
|
||||||
|
|
||||||
extern void init_rds_objects();
|
extern void init_rds_objects();
|
||||||
|
extern void set_rds_level(float _level);
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ static struct {
|
|||||||
uint8_t ps_update;
|
uint8_t ps_update;
|
||||||
uint8_t tps_update;
|
uint8_t tps_update;
|
||||||
|
|
||||||
uint8_t rt1_enabled;
|
|
||||||
uint8_t rt_update;
|
uint8_t rt_update;
|
||||||
uint8_t rt_ab;
|
uint8_t rt_ab;
|
||||||
uint8_t rt_segments;
|
uint8_t rt_segments;
|
||||||
@@ -311,7 +310,7 @@ static void get_rds_group(uint16_t *blocks) {
|
|||||||
|
|
||||||
if(grp == '0') good_group = 1;
|
if(grp == '0') good_group = 1;
|
||||||
if(grp == '1' && rds_state.ecclic_enabled) good_group = 1;
|
if(grp == '1' && rds_state.ecclic_enabled) good_group = 1;
|
||||||
if(grp == '2' && rds_state.rt1_enabled) good_group = 1;
|
if(grp == '2' && rds_data.rt1_enabled) good_group = 1;
|
||||||
if(grp == 'A' && rds_state.ptyn_enabled) good_group = 1;
|
if(grp == 'A' && rds_state.ptyn_enabled) good_group = 1;
|
||||||
if(grp == 'X' && rds_data.udg1_len != 0) good_group = 1;
|
if(grp == 'X' && rds_data.udg1_len != 0) good_group = 1;
|
||||||
if(grp == 'Y' && rds_data.udg2_len != 0) good_group = 1;
|
if(grp == 'Y' && rds_data.udg2_len != 0) good_group = 1;
|
||||||
@@ -418,7 +417,8 @@ void init_rds_encoder(struct rds_params_t rds_params) {
|
|||||||
set_rds_pi(rds_params.pi);
|
set_rds_pi(rds_params.pi);
|
||||||
set_rds_ps(rds_params.ps);
|
set_rds_ps(rds_params.ps);
|
||||||
rds_state.rt_ab = 1;
|
rds_state.rt_ab = 1;
|
||||||
set_rds_rt1_enabled(1);
|
set_rds_shortrt(rds_params.shortrt)
|
||||||
|
set_rds_rt1_enabled(rds_params.rt1_enabled);
|
||||||
set_rds_rt1(rds_params.rt1);
|
set_rds_rt1(rds_params.rt1);
|
||||||
set_rds_pty(rds_params.pty);
|
set_rds_pty(rds_params.pty);
|
||||||
rds_state.ptyn_ab = 1;
|
rds_state.ptyn_ab = 1;
|
||||||
@@ -467,8 +467,11 @@ void set_rds_pin(uint8_t day, uint8_t hour, uint8_t minute) {
|
|||||||
rds_data.pin[3] = (minute & INT8_L6);
|
rds_data.pin[3] = (minute & INT8_L6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_rds_shortrt(uint8_t shortrt) {
|
||||||
|
rds_data.shortrt = shortrt & INT8_0;
|
||||||
|
}
|
||||||
void set_rds_rt1_enabled(uint8_t rt1en) {
|
void set_rds_rt1_enabled(uint8_t rt1en) {
|
||||||
rds_state.rt1_enabled = rt1en & INT8_0;
|
rds_data.rt1_enabled = rt1en & INT8_0;
|
||||||
}
|
}
|
||||||
void set_rds_rt1(unsigned char *rt1) {
|
void set_rds_rt1(unsigned char *rt1) {
|
||||||
uint8_t i = 0, len = 0;
|
uint8_t i = 0, len = 0;
|
||||||
@@ -479,7 +482,7 @@ void set_rds_rt1(unsigned char *rt1) {
|
|||||||
while (*rt1 != 0 && len < RT_LENGTH)
|
while (*rt1 != 0 && len < RT_LENGTH)
|
||||||
rds_data.rt1[len++] = *rt1++;
|
rds_data.rt1[len++] = *rt1++;
|
||||||
|
|
||||||
if (len < RT_LENGTH) {
|
if (len < RT_LENGTH && rds_data.shortrt) {
|
||||||
rds_state.rt_segments = 0;
|
rds_state.rt_segments = 0;
|
||||||
|
|
||||||
rds_data.rt1[len++] = '\r';
|
rds_data.rt1[len++] = '\r';
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ typedef struct rds_params_t {
|
|||||||
unsigned char ps[PS_LENGTH];
|
unsigned char ps[PS_LENGTH];
|
||||||
unsigned char tps[PS_LENGTH];
|
unsigned char tps[PS_LENGTH];
|
||||||
|
|
||||||
|
uint8_t shortrt;
|
||||||
|
uint8_t rt1_enabled;
|
||||||
unsigned char rt1[RT_LENGTH];
|
unsigned char rt1[RT_LENGTH];
|
||||||
|
|
||||||
unsigned char ptyn[PTYN_LENGTH];
|
unsigned char ptyn[PTYN_LENGTH];
|
||||||
@@ -242,6 +244,7 @@ extern void set_rds_lic(uint8_t lic);
|
|||||||
extern void set_rds_ecclic_toggle(uint8_t toggle);
|
extern void set_rds_ecclic_toggle(uint8_t toggle);
|
||||||
extern void set_rds_pin_enabled(uint8_t enabled);
|
extern void set_rds_pin_enabled(uint8_t enabled);
|
||||||
extern void set_rds_pin(uint8_t day, uint8_t hour, uint8_t minute);
|
extern void set_rds_pin(uint8_t day, uint8_t hour, uint8_t minute);
|
||||||
|
extern void set_rds_shortrt(uint8_t shortrt);
|
||||||
extern void set_rds_rt1_enabled(uint8_t rt1en);
|
extern void set_rds_rt1_enabled(uint8_t rt1en);
|
||||||
extern void set_rds_rt1(unsigned char *rt1);
|
extern void set_rds_rt1(unsigned char *rt1);
|
||||||
extern void set_rds_ps(unsigned char *ps);
|
extern void set_rds_ps(unsigned char *ps);
|
||||||
|
|||||||
+3
-1
@@ -68,7 +68,9 @@ int main(int argc, char **argv) {
|
|||||||
.pi = 0x305F,
|
.pi = 0x305F,
|
||||||
.ecc = 0xE2,
|
.ecc = 0xE2,
|
||||||
.lps = "radio95 - Radio Nowotomyskie",
|
.lps = "radio95 - Radio Nowotomyskie",
|
||||||
.grp_sqc = "00012222FFR"
|
.grp_sqc = "00012222FFR",
|
||||||
|
.shortrt = 1,
|
||||||
|
.rt1_enabled = 1
|
||||||
};
|
};
|
||||||
/* PASIMPLE */
|
/* PASIMPLE */
|
||||||
pa_simple *device;
|
pa_simple *device;
|
||||||
|
|||||||
Reference in New Issue
Block a user