mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 20:33:53 +01:00
remove dps
This commit is contained in:
2
.vscode/.server-controller-port.log
vendored
2
.vscode/.server-controller-port.log
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"port": 13452,
|
||||
"time": 1742722294785,
|
||||
"time": 1742754117510,
|
||||
"version": "0.0.3"
|
||||
}
|
||||
@@ -70,7 +70,6 @@ static void handle_tps(char *arg, RDSModulator* mod, char* output) {
|
||||
static void handle_rt1(char *arg, RDSModulator* mod, char* output) {
|
||||
arg[RT_LENGTH * 2] = 0;
|
||||
set_rds_rt1(mod->enc, xlat(arg));
|
||||
if(mod->enc->data[mod->enc->program].eqtext1) set_rds_dps1(mod->enc, xlat(arg));
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
@@ -80,28 +79,6 @@ static void handle_rt2(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_dps1(char *arg, RDSModulator* mod, char* output) {
|
||||
arg[DPS_LENGTH * 2] = 0;
|
||||
set_rds_dps1(mod->enc, xlat(arg));
|
||||
if(mod->enc->data[mod->enc->program].eqtext1) set_rds_rt1(mod->enc, xlat(arg));
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
static void handle_dps1mod(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].dps1_mode = atoi(arg);
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_scrlspd(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].dps_speed = atoi(arg);
|
||||
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) {
|
||||
mod->enc->data[mod->enc->program].pty = atoi(arg);
|
||||
strcpy(output, "+\0");
|
||||
@@ -236,22 +213,6 @@ static void handle_rtper(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_dps1en(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].dps1_enabled = atoi(arg);
|
||||
mod->enc->state[mod->enc->program].ps_update = 1;
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_labper(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].dps_label_period = atoi(arg);
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_spsper(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].static_ps_period = atoi(arg);
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_ptynen(char *arg, RDSModulator* mod, char* output) {
|
||||
mod->enc->data[mod->enc->program].ptyn_enabled = atoi(arg);
|
||||
strcpy(output, "+\0");
|
||||
@@ -543,12 +504,10 @@ static const command_handler_t commands_eq4[] = {
|
||||
{"ECC", handle_ecc, 3},
|
||||
{"RTP", handle_rtp, 3},
|
||||
{"LPS", handle_lps, 3},
|
||||
{"DPS", handle_dps1, 3},
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq5[] = {
|
||||
{"TEXT", handle_rt1, 4},
|
||||
{"DPS1", handle_dps1, 4},
|
||||
{"PTYN", handle_ptyn, 4},
|
||||
{"AFCH", handle_afch, 4},
|
||||
{"UDG1", handle_udg1, 4},
|
||||
@@ -572,22 +531,12 @@ static const command_handler_t commands_eq7[] = {
|
||||
{"RTPRUN", handle_rtprun, 6},
|
||||
{"GRPSEQ", handle_grpseq, 6},
|
||||
{"RDSGEN", handle_rdsgen, 6},
|
||||
{"DPS1EN", handle_dps1en, 6},
|
||||
{"LABPER", handle_labper, 6},
|
||||
{"SPSPER", handle_spsper, 6},
|
||||
{"RTTYPE", handle_rttype, 6},
|
||||
};
|
||||
|
||||
static const command_handler_t commands_eq8[] = {
|
||||
{"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[] = {
|
||||
{"INIT", handle_init, 4},
|
||||
{"VER", handle_ver, 3},
|
||||
@@ -772,15 +721,4 @@ void process_ascii_cmd(RDSModulator* mod, char *str) {
|
||||
cmd, arg, output, mod)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd_len > 9 && str[9] == '=') {
|
||||
cmd = upper_str;
|
||||
cmd[9] = 0;
|
||||
arg = str + 10;
|
||||
|
||||
if (process_command_table(commands_eq10,
|
||||
sizeof(commands_eq10) / sizeof(command_handler_t),
|
||||
cmd, arg, output, mod)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
128
src/rds.c
128
src/rds.c
@@ -46,16 +46,6 @@ void saveToFile(RDSEncoder *emp, const char *option) {
|
||||
tempEncoder.data[emp->program].ecc = emp->data[emp->program].ecc;
|
||||
} else if (strcmp(option, "TPS") == 0) {
|
||||
memcpy(tempEncoder.data[emp->program].tps, emp->data[emp->program].tps, PS_LENGTH);
|
||||
} else if (strcmp(option, "DPS1") == 0) {
|
||||
memcpy(tempEncoder.data[emp->program].dps1, emp->data[emp->program].dps1, DPS_LENGTH);
|
||||
tempEncoder.data[emp->program].dps1_enabled = emp->data[emp->program].dps1_enabled;
|
||||
tempEncoder.data[emp->program].dps1_numberofrepeats = emp->data[emp->program].dps1_numberofrepeats;
|
||||
} else if (strcmp(option, "DPS1EN") == 0) {
|
||||
tempEncoder.data[emp->program].dps1_enabled = emp->data[emp->program].dps1_enabled;
|
||||
} else if (strcmp(option, "DPS1MOD") == 0) {
|
||||
tempEncoder.data[emp->program].dps1_mode = emp->data[emp->program].dps1_mode;
|
||||
} else if (strcmp(option, "LABPER") == 0) {
|
||||
tempEncoder.data[emp->program].dps_label_period = emp->data[emp->program].dps_label_period;
|
||||
} else if (strcmp(option, "SPSPER") == 0) {
|
||||
tempEncoder.data[emp->program].static_ps_period = emp->data[emp->program].static_ps_period;
|
||||
} else if (strcmp(option, "LPS") == 0) {
|
||||
@@ -200,89 +190,18 @@ static uint16_t get_next_af(RDSEncoder* enc) {
|
||||
|
||||
// #region Group encoding
|
||||
static void get_rds_ps_group(RDSEncoder* enc, uint16_t *blocks) {
|
||||
uint8_t dps1_on = (enc->data[enc->program].dps1_enabled && enc->state[enc->program].dps1_len != 0);
|
||||
get_ps:
|
||||
if(enc->state[enc->program].ps_csegment == 0) {
|
||||
if(enc->state[enc->program].ps_update && !dps1_on) {
|
||||
if(enc->state[enc->program].ps_update) {
|
||||
memcpy(enc->state[enc->program].ps_text, enc->data[enc->program].ps, PS_LENGTH);
|
||||
enc->state[enc->program].ps_update = 0;
|
||||
}
|
||||
|
||||
if(enc->state[enc->program].tps_update && !dps1_on) {
|
||||
if(enc->state[enc->program].tps_update) {
|
||||
memcpy(enc->state[enc->program].tps_text, enc->data[enc->program].tps, PS_LENGTH);
|
||||
enc->state[enc->program].tps_update = 0;
|
||||
}
|
||||
|
||||
if(enc->state[enc->program].dps1_update && dps1_on) {
|
||||
memcpy(enc->state[enc->program].dps1_text, enc->data[enc->program].dps1, DPS_LENGTH);
|
||||
enc->state[enc->program].dps1_update = 0;
|
||||
enc->state[enc->program].dps1_repeat_count = 0;
|
||||
}
|
||||
|
||||
if(dps1_on) {
|
||||
char ps_text[PS_LENGTH];
|
||||
strncpy(ps_text, (enc->data[enc->program].ta) ? enc->data[enc->program].tps : enc->data[enc->program].ps, PS_LENGTH);
|
||||
ps_text[PS_LENGTH - 1] = '\0';
|
||||
|
||||
if(enc->state[enc->program].dynamic_ps_state == 0) {
|
||||
memcpy(enc->state[enc->program].ps_text, ps_text, PS_LENGTH);
|
||||
|
||||
if(enc->state[enc->program].static_ps_period >= enc->data[enc->program].static_ps_period) {
|
||||
enc->state[enc->program].dynamic_ps_state = 1;
|
||||
enc->state[enc->program].static_ps_period = 0;
|
||||
enc->state[enc->program].dynamic_ps_position = 0;
|
||||
}
|
||||
} else if(enc->state[enc->program].dynamic_ps_state == 1) {
|
||||
uint8_t scroll_threshold = (enc->data[enc->program].dps_speed == 0) ? 4 : 2;
|
||||
if(enc->data[enc->program].dps1_mode == 0) scroll_threshold = enc->data[enc->program].dps_label_period;
|
||||
|
||||
if(enc->state[enc->program].dynamic_ps_scroll_counter >= scroll_threshold) {
|
||||
if(enc->state[enc->program].dynamic_ps_position >= enc->state[enc->program].dps1_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) {
|
||||
if(enc->state[enc->program].dps1_nexttext_len != 0 && enc->state[enc->program].dps1_len < 128 && enc->state[enc->program].dps1_nexttext_update) {
|
||||
enc->state[enc->program].dps1_nexttext_update = 0;
|
||||
enc->state[enc->program].dynamic_ps_state = 1;
|
||||
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].dps1_text, enc->state[enc->program].dps1_nexttext, PS_LENGTH);
|
||||
enc->state[enc->program].dps1_len = enc->state[enc->program].dps1_nexttext_len;
|
||||
goto get_ps;
|
||||
} 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, ps_text, 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_text[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_text[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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
encode:
|
||||
blocks[1] |= enc->data[enc->program].ta << 4;
|
||||
blocks[1] |= 1 << 3; // MS was removed from the standard, this is to keep compatibility with old receivers
|
||||
blocks[1] |= ((enc->data[enc->program].di >> (3 - enc->state[enc->program].ps_csegment)) & 1) << 2;
|
||||
@@ -638,22 +557,7 @@ static void get_rds_group(RDSEncoder* enc, uint16_t *blocks, uint8_t stream) {
|
||||
default:
|
||||
case '0':
|
||||
if(enc->state[enc->program].grp_seq_idx[1] < 4) enc->state[enc->program].grp_seq_idx[0]--;
|
||||
else {
|
||||
enc->state[enc->program].grp_seq_idx[1] = 0;
|
||||
|
||||
if(enc->data[enc->program].dps1_enabled || enc->data[enc->program].dps2_enabled) {
|
||||
switch (enc->state[enc->program].dynamic_ps_state)
|
||||
{
|
||||
case 0:
|
||||
enc->state[enc->program].static_ps_period++;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
enc->state[enc->program].dynamic_ps_period++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else enc->state[enc->program].grp_seq_idx[1] = 0;
|
||||
|
||||
enc->state[enc->program].grp_seq_idx[1]++;
|
||||
get_rds_ps_group(enc, blocks);
|
||||
@@ -734,7 +638,6 @@ void reset_rds_state(RDSEncoder* enc, uint8_t program) {
|
||||
set_rds_rt1(&tempCoder, enc->data[program].rt1);
|
||||
set_rds_rt2(&tempCoder, enc->data[program].rt2);
|
||||
set_rds_ps(&tempCoder, enc->data[program].ps);
|
||||
set_rds_dps1(&tempCoder, enc->data[program].dps1);
|
||||
set_rds_tps(&tempCoder, enc->data[program].tps);
|
||||
set_rds_ptyn(&tempCoder, enc->data[program].ptyn);
|
||||
set_rds_lps(&tempCoder, enc->data[program].lps);
|
||||
@@ -777,8 +680,6 @@ void set_rds_defaults(RDSEncoder* enc, uint8_t program) {
|
||||
memset(enc->data[program].rt1, ' ', 59);
|
||||
|
||||
enc->data[program].static_ps_period = 10;
|
||||
enc->data[program].dps_label_period = 8;
|
||||
enc->data[program].dps1_numberofrepeats = 1;
|
||||
|
||||
enc->data[program].rt_type = 2;
|
||||
|
||||
@@ -866,29 +767,6 @@ void set_rds_ps(RDSEncoder* enc, char *ps) {
|
||||
while (*ps != 0 && len < PS_LENGTH) enc->data[enc->program].ps[len++] = *ps++;
|
||||
}
|
||||
|
||||
void set_rds_dps1(RDSEncoder* enc, char *dps1) {
|
||||
uint8_t len = 0;
|
||||
|
||||
enc->state[enc->program].dps1_update = 1;
|
||||
memset(enc->data[enc->program].dps1, ' ', DPS_LENGTH);
|
||||
while (*dps1 != 0 && len < DPS_LENGTH) enc->data[enc->program].dps1[len++] = *dps1++;
|
||||
enc->state[enc->program].dps1_len = len;
|
||||
|
||||
enc->state[enc->program].dynamic_ps_position = 0;
|
||||
enc->state[enc->program].dynamic_ps_period = 0;
|
||||
enc->state[enc->program].static_ps_period = 0;
|
||||
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;
|
||||
|
||||
|
||||
45
src/rds.h
45
src/rds.h
@@ -18,7 +18,6 @@
|
||||
|
||||
#define RT_LENGTH 64
|
||||
#define PS_LENGTH 8
|
||||
#define DPS_LENGTH 255
|
||||
#define PTYN_LENGTH 8
|
||||
#define LPS_LENGTH 32
|
||||
#define DEFAULT_GRPSQC "002222XY"
|
||||
@@ -50,17 +49,6 @@ typedef struct {
|
||||
char ps[8];
|
||||
RDSAFs af;
|
||||
} RDSEON;
|
||||
typedef struct {
|
||||
uint8_t destination : 4;
|
||||
char text[255];
|
||||
} RDSMessage;
|
||||
typedef struct {
|
||||
uint8_t dps2msg : 7;
|
||||
uint8_t dps2msg_auto : 1;
|
||||
uint8_t rt2msg : 7;
|
||||
uint8_t rt2msg_auto : 1;
|
||||
RDSMessage messages[100];
|
||||
} RDSMessages;
|
||||
typedef struct
|
||||
{
|
||||
uint8_t days : 7; // let's say that here it will be stored by bits, so 0b1000000 is monday and so on
|
||||
@@ -92,20 +80,6 @@ typedef struct {
|
||||
|
||||
char tps[PS_LENGTH];
|
||||
|
||||
uint8_t eqtext1 : 1;
|
||||
uint8_t dps1_enabled : 1;
|
||||
uint8_t dps2_enabled : 1;
|
||||
char dps1[DPS_LENGTH];
|
||||
char dps2[DPS_LENGTH];
|
||||
uint8_t dps1_mode : 2;
|
||||
uint8_t dps2_mode : 2;
|
||||
uint8_t dps1_numberofrepeats : 8; // last bit will be clear
|
||||
uint8_t dps2_numberofrepeats;
|
||||
uint8_t dps_label_period;
|
||||
uint8_t dps_restart : 1;
|
||||
uint8_t dps_speed : 1;
|
||||
uint8_t static_ps_period;
|
||||
|
||||
uint8_t rt1_enabled : 1;
|
||||
uint8_t rt2_enabled : 1;
|
||||
uint8_t rt_type : 2;
|
||||
@@ -142,23 +116,6 @@ typedef struct {
|
||||
char tps_text[PS_LENGTH];
|
||||
uint8_t ps_csegment : 4;
|
||||
|
||||
uint8_t dps1_update : 1;
|
||||
uint8_t dps2_update : 1;
|
||||
uint8_t dps1_len;
|
||||
uint8_t dps2_len;
|
||||
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];
|
||||
uint8_t dps1_repeat_count;
|
||||
uint8_t dps2_repeat_count;
|
||||
uint8_t static_ps_period;
|
||||
uint8_t dynamic_ps_period;
|
||||
uint8_t dynamic_ps_position;
|
||||
uint8_t dynamic_ps_state : 2;
|
||||
uint8_t dynamic_ps_scroll_counter : 7;
|
||||
|
||||
char rt_text[RT_LENGTH];
|
||||
uint8_t rt_state : 5;
|
||||
uint8_t rt_update : 1;
|
||||
@@ -328,8 +285,6 @@ void init_rds_encoder(RDSEncoder* enc);
|
||||
void get_rds_bits(RDSEncoder* enc, uint8_t *bits, uint8_t stream);
|
||||
void set_rds_rt1(RDSEncoder* enc, char *rt1);
|
||||
void set_rds_rt2(RDSEncoder* enc, char *rt2);
|
||||
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);
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
AF
|
||||
AFCH
|
||||
DI
|
||||
DPS1
|
||||
DPS1EN
|
||||
- DPS2EN
|
||||
DPS1ENQ
|
||||
- DPS2
|
||||
DPS1MOD (partial)
|
||||
- DPS2MOD
|
||||
- DPS1REP
|
||||
- DPS2REP
|
||||
- DTTMOUT
|
||||
- EQTEXT1
|
||||
LABPER
|
||||
LPS - P232 Only
|
||||
MS
|
||||
PI
|
||||
PS
|
||||
PTY
|
||||
PTYN
|
||||
PTYNEN
|
||||
RT1 | TEXT
|
||||
RT1EN
|
||||
RT2
|
||||
RT2EN
|
||||
RTPER
|
||||
RTTYPE
|
||||
- RSTDPS
|
||||
SCRLSPD
|
||||
SPSPER
|
||||
TA
|
||||
- TATMOUT
|
||||
TP
|
||||
TPS
|
||||
INIT
|
||||
ALL
|
||||
- HELP
|
||||
EON*
|
||||
- MSG*
|
||||
- DPS2MSG
|
||||
- RT2MSG
|
||||
- SLIST
|
||||
- SEN
|
||||
- Sxx*
|
||||
(COMSPD) - No COM
|
||||
CT
|
||||
(DATE) - Date is taken from system time
|
||||
- ECHO
|
||||
(EXTSYNC) - No Sync
|
||||
LEVEL
|
||||
(LTO) - Time is taken from system
|
||||
(PHASE) - No phase control
|
||||
(MJD) - Data is taken...
|
||||
(PILOT) - No info
|
||||
- PSNMAIN
|
||||
- RDS2MOD
|
||||
RDSGEN - Partial
|
||||
RESET
|
||||
- SETFEAT
|
||||
(SPEED) - No COM
|
||||
- STATUS, ??
|
||||
(TIME) - Time is taken...
|
||||
VER
|
||||
- ADR *ADR
|
||||
- CC
|
||||
DSN*
|
||||
ECCEN
|
||||
G - Partial
|
||||
GRPSEQ
|
||||
LIC
|
||||
- NOHDR
|
||||
PIN
|
||||
PINEN
|
||||
PROGRAM
|
||||
PSN*
|
||||
(PSW) - Could be
|
||||
RTP
|
||||
RTPRUN
|
||||
- SETSPY
|
||||
SHORTRT
|
||||
- SEL
|
||||
- SITE *SITE
|
||||
- STORE
|
||||
UDG1
|
||||
UDG2
|
||||
- UECP
|
||||
- XCMD
|
||||
Reference in New Issue
Block a user