From 90641bbeb521614dec3bf58453cf104acf387efa Mon Sep 17 00:00:00 2001 From: Kuba <132459354+KubaPro010@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:42:18 +0000 Subject: [PATCH] trying to get ppm back --- src/pifmrds/control_pipe.c | 6 ++++++ src/pifmrds/control_pipe.h | 1 + src/pifmrds/pi_fm_rds.cpp | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/pifmrds/control_pipe.c b/src/pifmrds/control_pipe.c index 2682e4b..5bd2dc4 100644 --- a/src/pifmrds/control_pipe.c +++ b/src/pifmrds/control_pipe.c @@ -193,6 +193,12 @@ ResultAndArg poll_control_pipe() { printf("\n"); resarg.res = CONTROL_PIPE_PILVOL_SET; resarg.arg = arg; + } else if(fifo[0] == 'P' && fifo[1] == 'P' && fifo[2] == 'M') { + printf("Set PPM to "); + printf(arg); + printf("\n"); + resarg.res = CONTROL_PIPE_PILVOL_SET; + resarg.arg = arg; } } return resarg; diff --git a/src/pifmrds/control_pipe.h b/src/pifmrds/control_pipe.h index 7e019f3..bdd9a22 100644 --- a/src/pifmrds/control_pipe.h +++ b/src/pifmrds/control_pipe.h @@ -24,6 +24,7 @@ #define CONTROL_PIPE_RDSVOL_SET 17 #define CONTROL_PIPE_PAUSE_SET 18 #define CONTROL_PIPE_PILVOL_SET 19 //fitting +#define CONTROL_PIPE_PPM_SET 20 typedef struct { int res; diff --git a/src/pifmrds/pi_fm_rds.cpp b/src/pifmrds/pi_fm_rds.cpp index a7730ea..8209e57 100644 --- a/src/pifmrds/pi_fm_rds.cpp +++ b/src/pifmrds/pi_fm_rds.cpp @@ -81,7 +81,7 @@ static volatile void *map_peripheral(uint32_t base, uint32_t len) return vaddr; } -int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int enablecompressor, int rds_ct_enabled, float rds_volume, float pilot_volume) { +int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim, float compressor_decay, float compressor_attack, float compressor_max_gain_recip, int enablecompressor, int rds_ct_enabled, float rds_volume, float pilot_volume, clkgpio clk) { // Catch all signals possible - it is vital we kill the DMA engine // on process exit! // for (int i = 0; i < 64; i++) { @@ -225,6 +225,8 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, paused = pollResult.arg_int; } else if(pollResult.res == CONTROL_PIPE_PILVOL_SET) { pilot_volume = std::stof(pollResult.arg); + } else if(pollResult.res == CONTROL_PIPE_PPM_SET) { + clk->Setppm(std::stof(pollResult.arg)); } } @@ -274,7 +276,7 @@ int main(int argc, char **argv) { double preemp = 50e-6; //eu int deviation = 75000; int alternative_freq[100] = {}; - // float ppm = 0; this is useless as the ppm isnt used anywhere anyway + float ppm = 0; int bypassfreqrange = 0; int ct = 1; float cutofffreq = 15700; @@ -300,6 +302,9 @@ int main(int argc, char **argv) { } else if(strcmp("-rt", arg)==0 && param != NULL) { i++; rt = param; + } else if(strcmp("-ppm", arg)==0 && param != NULL) { + i++; + ppm = atof(param); } else if(strcmp("-compressordecay", arg)==0 && param != NULL) { i++; compressor_decay = atof(param); @@ -402,7 +407,7 @@ int main(int argc, char **argv) { } else { fatal("Unrecognised argument: %s.\n" - "Syntax: pi_fm_rds [-freq freq] [-audio file] [-pi pi_code]\n" + "Syntax: pi_fm_rds [-freq freq] [-ppm clock error] [-audio file] [-pi pi_code]\n" " [-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); } } @@ -416,6 +421,10 @@ int main(int argc, char **argv) { int FifoSize=DATA_SIZE*2; //fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin); //you can mod fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false); - int errcode = tx(carrier_freq, audio_file, pi, ps, rt, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain, compressor_decay, compressor_attack, compressor_max_gain_recip, enable_compressor, ct, rds_volume, pilot_volume); + clkgpio *clk=new clkgpio; + if(ppm != 0) { + clk->Setppm(ppm); + } + int errcode = tx(carrier_freq, audio_file, pi, ps, rt, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain, compressor_decay, compressor_attack, compressor_max_gain_recip, enable_compressor, ct, rds_volume, pilot_volume, clk); terminate(errcode); }