Added command line option for frequency deviation.

This commit is contained in:
zeitbinder 2014-11-08 23:32:46 +01:00
parent f8613175ae
commit 300414ef5e
2 changed files with 9 additions and 5 deletions

View File

@ -56,6 +56,7 @@ All arguments are optional:
* `-rt` specifies the radiotext (RT) to be transmitted. Limit: 64 characters. Example: `-rt 'Hello, world!'`.
* `-ctl` specifies a named pipe (FIFO) to use as a control channel to change PS and RT at run-time (see below).
* `-ppm` specifies your Raspberry Pi's oscillator error in parts per million (ppm), see below.
* `-dev` specifies the frequency deviation (in KHz). Example `-dev 25.0`.
By default the PS changes back and forth between `Pi-FmRds` and a sequence number, starting at `00000000`. The PS changes around one time per second.

View File

@ -156,7 +156,6 @@
// The deviation specifies how wide the signal is. Use 25.0 for WBFM
// (broadcast radio) and about 3.5 for NBFM (walkie-talkie style radio)
#define DEVIATION 25.0
typedef struct {
@ -271,7 +270,7 @@ map_peripheral(uint32_t base, uint32_t len)
#define DATA_SIZE 5000
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe) {
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe, float deviation) {
int i, fd, pid;
char pagemap_fn[64];
@ -492,7 +491,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
data_index = 0;
}
float dval = data[data_index] * (DEVIATION / 10.);
float dval = data[data_index] * (deviation / 10.);
data_index++;
data_len--;
@ -521,6 +520,7 @@ int main(int argc, char **argv) {
char *rt = "PiFmRds: live FM-RDS transmission from the RaspberryPi";
uint16_t pi = 0x1234;
float ppm = 0;
float deviation = 25.0;
// Parse command-line arguments
@ -553,14 +553,17 @@ int main(int argc, char **argv) {
} else if(strcmp("-ctl", arg)==0 && param != NULL) {
i++;
control_pipe = param;
} else if(strcmp("-dev", arg)==0 && param != NULL) {
i++;
deviation = atof(param);
} else {
fatal("Unrecognised argument: %s\n"
"Syntax: pi_fm_rds [-freq freq] [-audio file] [-ppm ppm_error] [-pi pi_code]\n"
" [-ps ps_text] [-rt rt_text] [-ctl control_pipe]\n", arg);
" [-ps ps_text] [-rt rt_text] [-ctl control_pipe] [-dev deviation]\n", arg);
}
}
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe);
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe, deviation);
terminate(errcode);
}