mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 12:32:05 +01:00
compress the udg commands a bit
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": 1742832216228,
|
||||
"time": 1742842630343,
|
||||
"version": "0.0.3"
|
||||
}
|
||||
@@ -285,7 +285,7 @@ static void handle_rdsgen(char *arg, RDSModulator* mod, char* output) {
|
||||
strcpy(output, "+\0");
|
||||
}
|
||||
|
||||
static void handle_udg1(char *arg, RDSModulator* mod, char* output) {
|
||||
static void handle_udg(char *arg, char *pattern, RDSModulator* mod, char* output) {
|
||||
uint8_t all_scanned = 1, bad_format = 0;
|
||||
uint16_t blocks[8][3];
|
||||
int sets = 0;
|
||||
@@ -314,43 +314,15 @@ static void handle_udg1(char *arg, RDSModulator* mod, char* output) {
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&(mod->enc->data[mod->enc->program].udg1), &blocks, sets * sizeof(uint16_t[3]));
|
||||
mod->enc->data[mod->enc->program].udg1_len = sets;
|
||||
if(bad_format) strcpy(output, "-\0");
|
||||
else if(all_scanned) strcpy(output, "+\0");
|
||||
else strcpy(output, "/\0");
|
||||
}
|
||||
static void handle_udg2(char *arg, RDSModulator* mod, char* output) {
|
||||
uint8_t all_scanned = 1, bad_format = 0;
|
||||
uint16_t blocks[8][3];
|
||||
int sets = 0;
|
||||
char *ptr = arg;
|
||||
|
||||
while (sets < 8) {
|
||||
int count = sscanf((char *)ptr, "%4hx%4hx%4hx",
|
||||
&blocks[sets][0], &blocks[sets][1], &blocks[sets][2]);
|
||||
|
||||
if (count != 3) {
|
||||
all_scanned = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
sets++;
|
||||
|
||||
while (*ptr && *ptr != ',') {
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (*ptr == ',') {
|
||||
ptr++;
|
||||
} else {
|
||||
bad_format = 1;
|
||||
break;
|
||||
}
|
||||
if (strcmp(pattern, "1") == 0) {
|
||||
memcpy(&(mod->enc->data[mod->enc->program].udg1), &blocks, sets * sizeof(uint16_t[3]));
|
||||
mod->enc->data[mod->enc->program].udg1_len = sets;
|
||||
} else if(strcmp(pattern, "2") == 0) {
|
||||
memcpy(&(mod->enc->data[mod->enc->program].udg2), &blocks, sets * sizeof(uint16_t[3]));
|
||||
mod->enc->data[mod->enc->program].udg2_len = sets;
|
||||
} else {
|
||||
strcpy(output, "!\0");
|
||||
}
|
||||
|
||||
memcpy(&(mod->enc->data[mod->enc->program].udg2), &blocks, sets * sizeof(uint16_t[3]));
|
||||
mod->enc->data[mod->enc->program].udg2_len = sets;
|
||||
if(bad_format) strcpy(output, "-\0");
|
||||
else if(all_scanned) strcpy(output, "+\0");
|
||||
else strcpy(output, "/\0");
|
||||
@@ -522,8 +494,6 @@ static const command_handler_t commands_eq5[] = {
|
||||
{"TEXT", handle_rt1, 4},
|
||||
{"PTYN", handle_ptyn, 4},
|
||||
{"AFCH", handle_afch, 4},
|
||||
{"UDG1", handle_udg1, 4},
|
||||
{"UDG2", handle_udg2, 4},
|
||||
{"DPTY", handle_dpty, 4},
|
||||
};
|
||||
|
||||
@@ -569,6 +539,7 @@ static const pattern_command_handler_t pattern_commands[] = {
|
||||
{"EON", "AFCH", handle_eonafch},
|
||||
{"PSN", "", handle_psn},
|
||||
{"DSN", "", handle_dsn},
|
||||
{"UDG", "", handle_udg},
|
||||
};
|
||||
|
||||
static bool process_command_table(const command_handler_t *table, int table_size,
|
||||
|
||||
Reference in New Issue
Block a user