mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-27 04:43:52 +01:00
adjust speed and add quenned text
This commit is contained in:
@@ -78,6 +78,18 @@ static void handle_dps1mod(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_scrlspd(char *arg, RDSModulator* mod, char* output) {
|
||||
arg[1] = 0;
|
||||
mod->enc->data[mod->enc->program].dps_speed = strtoul((char *)arg, NULL, 10);
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_dps1enq(char *arg, RDSModulator* mod, char* output) {
|
||||
arg[127 * 2] = 0;
|
||||
set_rds_next_dps1(mod->enc, xlat(arg));
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_pty(char *arg, RDSModulator* mod, char* output) {
|
||||
arg[2] = 0;
|
||||
mod->enc->data[mod->enc->program].pty = strtoul((char *)arg, NULL, 10);
|
||||
@@ -403,7 +415,8 @@ static const command_handler_t commands_eq4[] = {
|
||||
{"LIC", handle_lic, 3},
|
||||
{"RTP", handle_rtp, 3},
|
||||
{"LPS", handle_lps, 3},
|
||||
{"PIN", handle_pin, 3}
|
||||
{"PIN", handle_pin, 3},
|
||||
{"DPS", handle_dps1, 3},
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq5[] = {
|
||||
@@ -440,6 +453,11 @@ static const command_handler_t commands_eq8[] = {
|
||||
{"SHORTRT", handle_shortrt, 7},
|
||||
{"PROGRAM", handle_program, 7},
|
||||
{"DPS1MOD", handle_dps1mod, 7},
|
||||
{"SCRLSPD", handle_scrlspd, 7},
|
||||
{"DPS1ENQ", handle_dps1enq, 7},
|
||||
};
|
||||
static const command_handler_t commands_eq10[] = {
|
||||
{"PS_SCROLL", handle_dps1enq, 9},
|
||||
};
|
||||
|
||||
static const command_handler_t commands_exact[] = {
|
||||
@@ -563,4 +581,15 @@ void process_ascii_cmd(RDSModulator* mod, char *str) {
|
||||
cmd, arg, output, mod)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd_len > 9 && str[9] == '=') {
|
||||
cmd = str;
|
||||
cmd[9] = 0;
|
||||
arg = str + 10;
|
||||
|
||||
if (process_command_table(commands_eq10,
|
||||
sizeof(commands_eq10) / sizeof(command_handler_t),
|
||||
cmd, arg, output, mod)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
80
src/rds.c
80
src/rds.c
@@ -235,9 +235,9 @@ static void get_rds_ps_group(RDSEncoder* enc, uint16_t *blocks) {
|
||||
enc->state[enc->program].static_ps_period = 0;
|
||||
enc->state[enc->program].dynamic_ps_position = 0;
|
||||
}
|
||||
} else {
|
||||
} else if(enc->state[enc->program].dynamic_ps_state == 1) {
|
||||
if(enc->data[enc->program].dps1_len > PS_LENGTH) {
|
||||
uint8_t scroll_threshold = (enc->data[enc->program].dps_speed == 0) ? 2 : 1;
|
||||
uint8_t scroll_threshold = (enc->data[enc->program].dps_speed == 0) ? 4 : 2;
|
||||
|
||||
if(enc->state[enc->program].dynamic_ps_scroll_counter >= scroll_threshold) {
|
||||
if(enc->state[enc->program].dynamic_ps_position >= enc->data[enc->program].dps1_len) {
|
||||
@@ -245,13 +245,23 @@ static void get_rds_ps_group(RDSEncoder* enc, uint16_t *blocks) {
|
||||
enc->state[enc->program].dps1_repeat_count++;
|
||||
|
||||
if(enc->state[enc->program].dps1_repeat_count >= enc->data[enc->program].dps1_numberofrepeats) {
|
||||
enc->state[enc->program].dynamic_ps_state = 0;
|
||||
enc->state[enc->program].dynamic_ps_period = 0;
|
||||
enc->state[enc->program].dps1_repeat_count = 0;
|
||||
enc->state[enc->program].dynamic_ps_scroll_counter = 0;
|
||||
enc->state[enc->program].static_ps_period = 0;
|
||||
memcpy(enc->state[enc->program].ps_text, enc->data[enc->program].ps, PS_LENGTH);
|
||||
goto encode;
|
||||
if(enc->state[enc->program].dps1_nexttext_update && enc->state[enc->program].dps1_nexttext_len != 0) {
|
||||
enc->state[enc->program].dps1_nexttext_update = 0;
|
||||
|
||||
enc->state[enc->program].dynamic_ps_state = 2; // DPS1 nexttext
|
||||
enc->state[enc->program].dynamic_ps_period = 0;
|
||||
enc->state[enc->program].dps1_repeat_count = 0;
|
||||
enc->state[enc->program].dynamic_ps_scroll_counter = 0;
|
||||
enc->state[enc->program].static_ps_period = 0;
|
||||
} else {
|
||||
enc->state[enc->program].dynamic_ps_state = 0;
|
||||
enc->state[enc->program].dynamic_ps_period = 0;
|
||||
enc->state[enc->program].dps1_repeat_count = 0;
|
||||
enc->state[enc->program].dynamic_ps_scroll_counter = 0;
|
||||
enc->state[enc->program].static_ps_period = 0;
|
||||
memcpy(enc->state[enc->program].ps_text, enc->data[enc->program].ps, PS_LENGTH);
|
||||
goto encode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,6 +283,49 @@ static void get_rds_ps_group(RDSEncoder* enc, uint16_t *blocks) {
|
||||
memcpy(enc->state[enc->program].ps_text, enc->state[enc->program].dps1_text, PS_LENGTH);
|
||||
enc->state[enc->program].dynamic_ps_period++;
|
||||
|
||||
if(enc->state[enc->program].dynamic_ps_period >= enc->data[enc->program].dps_label_period) {
|
||||
enc->state[enc->program].dynamic_ps_state = 0;
|
||||
enc->state[enc->program].dynamic_ps_period = 0;
|
||||
}
|
||||
}
|
||||
} else if(enc->state[enc->program].dynamic_ps_state == 2) {
|
||||
if(enc->data[enc->program].dps1_len > PS_LENGTH) {
|
||||
uint8_t scroll_threshold = (enc->data[enc->program].dps_speed == 0) ? 4 : 2;
|
||||
|
||||
if(enc->state[enc->program].dynamic_ps_scroll_counter >= scroll_threshold) {
|
||||
if(enc->state[enc->program].dynamic_ps_position >= enc->state[enc->program].dps1_nexttext_len) {
|
||||
enc->state[enc->program].dynamic_ps_position = 0;
|
||||
enc->state[enc->program].dps1_repeat_count++;
|
||||
|
||||
if(enc->state[enc->program].dps1_repeat_count >= enc->data[enc->program].dps1_numberofrepeats) {
|
||||
enc->state[enc->program].dynamic_ps_state = 0;
|
||||
enc->state[enc->program].dynamic_ps_period = 0;
|
||||
enc->state[enc->program].dps1_repeat_count = 0;
|
||||
enc->state[enc->program].dynamic_ps_scroll_counter = 0;
|
||||
enc->state[enc->program].static_ps_period = 0;
|
||||
memcpy(enc->state[enc->program].ps_text, enc->data[enc->program].ps, PS_LENGTH);
|
||||
goto encode;
|
||||
}
|
||||
}
|
||||
|
||||
switch(enc->data[enc->program].dps1_mode) {
|
||||
case 0:
|
||||
memcpy(enc->state[enc->program].ps_text, &(enc->state[enc->program].dps1_nexttext[enc->state[enc->program].dynamic_ps_position]), PS_LENGTH);
|
||||
enc->state[enc->program].dynamic_ps_position += PS_LENGTH;
|
||||
break;
|
||||
case 1:
|
||||
memcpy(enc->state[enc->program].ps_text, &(enc->state[enc->program].dps1_nexttext[enc->state[enc->program].dynamic_ps_position]), PS_LENGTH);
|
||||
enc->state[enc->program].dynamic_ps_position++;
|
||||
break;
|
||||
}
|
||||
enc->state[enc->program].dynamic_ps_scroll_counter = 0;
|
||||
} else {
|
||||
enc->state[enc->program].dynamic_ps_scroll_counter++;
|
||||
}
|
||||
} else {
|
||||
memcpy(enc->state[enc->program].ps_text, enc->state[enc->program].dps1_nexttext, PS_LENGTH);
|
||||
enc->state[enc->program].dynamic_ps_period++;
|
||||
|
||||
if(enc->state[enc->program].dynamic_ps_period >= enc->data[enc->program].dps_label_period) {
|
||||
enc->state[enc->program].dynamic_ps_state = 0;
|
||||
enc->state[enc->program].dynamic_ps_period = 0;
|
||||
@@ -702,6 +755,15 @@ void set_rds_dps1(RDSEncoder* enc, char *dps1) {
|
||||
enc->state[enc->program].dynamic_ps_scroll_counter = 0;
|
||||
}
|
||||
|
||||
void set_rds_next_dps1(RDSEncoder* enc, char *dps1) {
|
||||
uint8_t len = 0;
|
||||
|
||||
enc->state[enc->program].dps1_nexttext_update = 1;
|
||||
memset(enc->state[enc->program].dps1_nexttext, ' ', 127);
|
||||
while (*dps1 != 0 && len < 127) enc->state[enc->program].dps1_nexttext[len++] = *dps1++;
|
||||
enc->state[enc->program].dps1_nexttext_len = len;
|
||||
}
|
||||
|
||||
void set_rds_tps(RDSEncoder* enc, char *tps) {
|
||||
uint8_t len = 0;
|
||||
|
||||
|
||||
@@ -155,6 +155,8 @@ typedef struct {
|
||||
|
||||
uint8_t dps1_update : 1;
|
||||
uint8_t dps2_update : 1;
|
||||
uint8_t dps1_nexttext_update : 1;
|
||||
uint8_t dps1_nexttext_len;
|
||||
char dps1_text[DPS_LENGTH];
|
||||
char dps1_nexttext[127];
|
||||
char dps2_text[DPS_LENGTH];
|
||||
@@ -306,6 +308,7 @@ void init_rds_encoder(RDSEncoder* enc);
|
||||
void get_rds_bits(RDSEncoder* enc, uint8_t *bits);
|
||||
void set_rds_rt1(RDSEncoder* enc, char *rt1);
|
||||
void set_rds_dps1(RDSEncoder* enc, char *dps1);
|
||||
void set_rds_next_dps1(RDSEncoder* enc, char *dps1);
|
||||
void set_rds_ps(RDSEncoder* enc, char *ps);
|
||||
void set_rds_tps(RDSEncoder* enc, char *tps);
|
||||
void set_rds_lps(RDSEncoder* enc, char *lps);
|
||||
|
||||
Reference in New Issue
Block a user