0
1
mirror of https://github.com/radio95-rnt/rds95.git synced 2026-02-27 04:43:52 +01:00

optimize the udg

This commit is contained in:
2025-03-14 17:54:17 +01:00
parent a0d3ba04e7
commit 996b72c665
3 changed files with 16 additions and 10 deletions

View File

@@ -237,7 +237,7 @@ static void handle_udg1(unsigned char *arg) {
} }
} }
set_rds_udg1(blocks); set_rds_udg1(sets, blocks);
} }
static void handle_udg2(unsigned char *arg) { static void handle_udg2(unsigned char *arg) {
uint16_t blocks[8][3]; // Up to 8 sets of 3 blocks each uint16_t blocks[8][3]; // Up to 8 sets of 3 blocks each
@@ -266,7 +266,7 @@ static void handle_udg2(unsigned char *arg) {
} }
} }
set_rds_udg2(blocks); set_rds_udg2(sets, blocks);
} }
// Command tables organized by delimiter position and command length // Command tables organized by delimiter position and command length

View File

@@ -313,6 +313,8 @@ static void get_rds_group(uint16_t *blocks) {
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_state.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 == 'Y' && rds_data.udg2_len != 0) good_group = 1;
if(grp == 'R' && rtplus_cfg.enabled) good_group = 1; if(grp == 'R' && rtplus_cfg.enabled) good_group = 1;
if(grp == '3' && oda_state.count != 0) good_group = 1; if(grp == '3' && oda_state.count != 0) good_group = 1;
if(grp == 'F' && rds_data.lps[0] != '\0') good_group = 1; if(grp == 'F' && rds_data.lps[0] != '\0') good_group = 1;
@@ -358,11 +360,11 @@ static void get_rds_group(uint16_t *blocks) {
// TODO: Add EON // TODO: Add EON
case 'X': case 'X':
for(int i = 0; i < 3; i++) blocks[i] = rds_data.udg1[rds_state.udg_idxs[0]++][i];; for(int i = 0; i < 3; i++) blocks[i] = rds_data.udg1[rds_state.udg_idxs[0]++][i];;
if(rds_state.udg_idxs[0] == 8) rds_state.udg_idxs[0] = 0; if(rds_state.udg_idxs[0] == rds_data.udg1_len) rds_state.udg_idxs[0] = 0;
goto group_coded; goto group_coded;
case 'Y': case 'Y':
for(int i = 0; i < 3; i++) blocks[i+1] = rds_data.udg2[rds_state.udg_idxs[1]++][i]; for(int i = 0; i < 3; i++) blocks[i+1] = rds_data.udg2[rds_state.udg_idxs[1]++][i];
if(rds_state.udg_idxs[1] == 8) rds_state.udg_idxs[1] = 0; if(rds_state.udg_idxs[1] == rds_data.udg2_len) rds_state.udg_idxs[1] = 0;
goto group_coded; goto group_coded;
case 'R': case 'R':
if(rds_state.rtp_oda == 0) { if(rds_state.rtp_oda == 0) {
@@ -426,8 +428,8 @@ void init_rds_encoder(struct rds_params_t rds_params) {
set_rds_ms(1); set_rds_ms(1);
set_rds_di(DI_STEREO | DI_DPTY); set_rds_di(DI_STEREO | DI_DPTY);
set_rds_grpseq(rds_params.grp_sqc); set_rds_grpseq(rds_params.grp_sqc);
set_rds_udg1(rds_params.udg1); set_rds_udg1(rds_params.udg1_len, rds_params.udg1);
set_rds_udg2(rds_params.udg2); set_rds_udg2(rds_params.udg2_len, rds_params.udg2);
init_rtplus(GROUP_11A); init_rtplus(GROUP_11A);
@@ -617,10 +619,12 @@ void set_rds_grpseq(unsigned char* grpseq) {
rds_data.grp_sqc[len++] = *grpseq++; rds_data.grp_sqc[len++] = *grpseq++;
} }
void set_rds_udg1(uint16_t (*groups)[3]) { void set_rds_udg1(uint8_t len, uint16_t (*groups)[3]) {
rds_data.udg1_len = len;
memcpy(&rds_data.udg1, &groups, sizeof(groups)); memcpy(&rds_data.udg1, &groups, sizeof(groups));
} }
void set_rds_udg2(uint16_t (*groups)[3]) { void set_rds_udg2(uint8_t len, uint16_t (*groups)[3]) {
rds_data.udg2_len = len;
memcpy(&rds_data.udg2, &groups, sizeof(groups)); memcpy(&rds_data.udg2, &groups, sizeof(groups));
} }

View File

@@ -60,6 +60,8 @@ typedef struct rds_params_t {
unsigned char grp_sqc[24]; unsigned char grp_sqc[24];
uint8_t udg1_len;
uint8_t udg2_len;
uint16_t udg1[8][3]; uint16_t udg1[8][3];
uint16_t udg2[8][3]; uint16_t udg2[8][3];
} rds_params_t; } rds_params_t;
@@ -260,7 +262,7 @@ extern void set_rds_di(uint8_t di);
extern float get_rds_sample(); extern float get_rds_sample();
extern void set_rds_cg(uint16_t* blocks); extern void set_rds_cg(uint16_t* blocks);
extern void set_rds_grpseq(unsigned char* grpseq); extern void set_rds_grpseq(unsigned char* grpseq);
extern void set_rds_udg1(uint16_t (*groups)[3]); extern void set_rds_udg1(uint8_t len, uint16_t (*groups)[3]);
extern void set_rds_udg2(uint16_t (*groups)[3]); extern void set_rds_udg2(uint8_t len, uint16_t (*groups)[3]);
#endif /* RDS_H */ #endif /* RDS_H */