trying somthing

This commit is contained in:
Kuba 2023-10-30 19:35:23 +00:00
parent e3202b5c4d
commit cc8b97ca79
3 changed files with 26 additions and 7 deletions

View File

@ -47,18 +47,21 @@ int open_control_pipe(char *filename, volatile uint32_t *padreg)
* Polls the control file (pipe), non-blockingly, and if a command is received,
* processes it and updates the RDS data.
*/
int poll_control_pipe() {
ResultAndArg poll_control_pipe() {
ResultAndArg resarg;
int res = -1;
static char buf[CTL_BUFFER_SIZE];
char *fifo = fgets(buf, CTL_BUFFER_SIZE, f_ctl);
if(fifo == NULL) {
return res;
resarg.res = -1;
return resarg;
}
if(strlen(fifo) > 3 && fifo[2] == ' ') {
char *arg = fifo+3;
resarg.arg = arg;
if(arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = 0;
if(fifo[0] == 'P' && fifo[1] == 'S') {
arg[8] = 0;
@ -109,6 +112,7 @@ int poll_control_pipe() {
}
} else if(strlen(fifo) > 4 && fifo[3] == ' ') {
char *arg = fifo+4;
resarg.arg = arg;
if(arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = 0;
if(fifo[0] == 'P' && fifo[1] == 'T' && fifo[2] == 'Y') {
int pty = atoi(arg);
@ -138,8 +142,8 @@ int poll_control_pipe() {
res = CONTROL_PIPE_RT_SET;
}
}
return res;
resarg.res = res;
return resarg;
}
int close_control_pipe() {

View File

@ -15,6 +15,11 @@
#define CONTROL_PIPE_PI_SET 8
#define CONTROL_PIPE_PWR_SET 9
typedef struct {
int res;
char arg[70];
} ResultAndArg;
extern int open_control_pipe(char *filename, volatile uint32_t *padreg);
extern int close_control_pipe();
extern int poll_control_pipe();
extern ResultAndArg poll_control_pipe();

View File

@ -183,8 +183,11 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
}
}
if(control_pipe && poll_control_pipe() == CONTROL_PIPE_PS_SET) {
varying_ps = 0;
if(control_pipe) {
ResultAndArg pollResult = poll_control_pipe();
if(pollResult.res == CONTROL_PIPE_PS_SET) {
varying_ps = 0;
}
}
if( fm_mpx_get_samples(data, drds, compressor_decay, compressor_attack, compressor_max_gain_recip) < 0 ) {
@ -226,6 +229,7 @@ int main(int argc, char **argv) {
float gain = 1;
int rawSampleRate = 44100;
int rawChannels = 2;
int compressorchanges = 0;
double preemp = 50e-6; //eu
int deviation = 75000;
int alternative_freq[100] = {};
@ -260,12 +264,15 @@ int main(int argc, char **argv) {
} else if(strcmp("-compressordecay", arg)==0 && param != NULL) {
i++;
compressor_decay = atof(param);
compressorchanges = 1;
} else if(strcmp("-compressorattack", arg)==0 && param != NULL) {
i++;
compressor_attack = atof(param);
compressorchanges = 1;
} else if(strcmp("-compressormaxgainrecip", arg)==0 && param != NULL) {
i++;
compressor_max_gain_recip = atof(param);
compressorchanges = 1;
} else if(strcmp("-pty", arg)==0 && param != NULL) {
i++;
pty = atoi(param);
@ -345,6 +352,9 @@ int main(int argc, char **argv) {
" [-ps ps_text] [-rt rt_text] [-ctl control_pipe] [-pty program_type] [-raw play raw audio from stdin] [-disablerds] [-af alt freq] [-preemphasis us] [-rawchannels when using the raw option you can change this] [-rawsamplerate same business] [-deviation the deviation, default is 75000, there are 2 predefined other cases: ukf (for old radios such as the UNITRA Jowita), nfm] [-tp] [-ta]\n", arg);
}
}
if(compressorchanges) {
printf("You've changed the compressor settings, just don't set it too low, so the deviation won't go crazy\n");
}
alternative_freq[0] = af_size;
int FifoSize=DATA_SIZE*2;
fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin);