ability to set power while transmitting and fix af
This commit is contained in:
parent
abd7a1a8f0
commit
0a01200fc6
Binary file not shown.
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -16,6 +15,10 @@
|
|||
#include "control_pipe.h"
|
||||
|
||||
#define CTL_BUFFER_SIZE 70
|
||||
#define GPIO_PAD_0_27 (0x2C/4)
|
||||
#define GPIO_PAD_28_45 (0x30/4)
|
||||
|
||||
static volatile uint32_t *pad_reg;
|
||||
|
||||
int fd;
|
||||
FILE *f_ctl;
|
||||
|
|
@ -23,7 +26,9 @@ FILE *f_ctl;
|
|||
/*
|
||||
* Opens a file (pipe) to be used to control the RDS coder, in non-blocking mode.
|
||||
*/
|
||||
int open_control_pipe(char *filename) {
|
||||
int open_control_pipe(char *filename, volatile uint32_t *padreg)
|
||||
{
|
||||
pad_reg = padreg;
|
||||
fd = open(filename, O_RDWR | O_NONBLOCK);
|
||||
if(fd == -1) return -1;
|
||||
|
||||
|
|
@ -37,7 +42,20 @@ int open_control_pipe(char *filename) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
//for bad rds, as most rds decoders won't decode these
|
||||
void removeDiacritics(char *str) {
|
||||
char diacritics[] = "ąćęłńóśźżĄĆĘŁŃÓŚŹŻ";
|
||||
char replacements[] = "acelnoszzACELNOSZZ";
|
||||
|
||||
for (size_t i = 0; i < strlen(str); i++) {
|
||||
for (size_t j = 0; j < strlen(diacritics); j++) {
|
||||
if (str[i] == diacritics[j]) {
|
||||
str[i] = replacements[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Polls the control file (pipe), non-blockingly, and if a command is received,
|
||||
|
|
@ -119,6 +137,18 @@ int poll_control_pipe() {
|
|||
printf("Wrong PTY identifier! The PTY range is 0 - 31.\n");
|
||||
}
|
||||
res = CONTROL_PIPE_PTY_SET;
|
||||
} else if(fifo[0] == 'U' && fifo[1] == 'R' && fifo[2] == 'T') {
|
||||
arg[64] = 0;
|
||||
removeDiacritics(arg);
|
||||
set_rds_rt(arg);
|
||||
printf("RT set to: \"%s\"\n", arg);
|
||||
res = CONTROL_PIPE_RT_SET;
|
||||
} else if(fifo[0] == 'P' && fifo[1] == 'W' && fifo[2] == 'R') {
|
||||
arg[1] = 0;
|
||||
pad_reg[GPIO_PAD_0_27] = 0x5a000018 + atoi(arg);
|
||||
pad_reg[GPIO_PAD_28_45] = 0x5a000018 + atoi(arg);
|
||||
printf("POWER set to: \"%s\"\n", arg);
|
||||
res = CONTROL_PIPE_PWR_SET;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
See https://github.com/Miegl/PiFmAdv
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#define CONTROL_PIPE_PS_SET 1
|
||||
#define CONTROL_PIPE_RT_SET 2
|
||||
#define CONTROL_PIPE_TA_SET 3
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
#define CONTROL_PIPE_MS_SET 6
|
||||
#define CONTROL_PIPE_AB_SET 7
|
||||
#define CONTROL_PIPE_PI_SET 8
|
||||
#define CONTROL_PIPE_PWR_SET 9
|
||||
|
||||
extern int open_control_pipe(char *filename);
|
||||
extern int open_control_pipe(char *filename, volatile uint32_t *padreg);
|
||||
extern int close_control_pipe();
|
||||
extern int poll_control_pipe();
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ int fm_mpx_get_samples(float *mpx_buffer, int drds) {
|
|||
else
|
||||
{
|
||||
mpx_buffer[i] =
|
||||
mpx_buffer[i] + // RDS data samples are currently in mpx_buffer :to be Remove in NBFM
|
||||
mpx_buffer[i] + // RDS data samples are currently in mpx_buffer :to be Remove in NFM
|
||||
9.0*out_left; // Unmodulated monophonic signal
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
set_rds_rt(rt);
|
||||
set_rds_pty(pty);
|
||||
set_rds_ab(0);
|
||||
set_rds_ms(0);
|
||||
set_rds_ms(1);
|
||||
set_rds_tp(0);
|
||||
set_rds_ta(0);
|
||||
uint16_t count = 0;
|
||||
|
|
@ -149,7 +149,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
|
||||
// Initialize the control pipe reader
|
||||
if(control_pipe) {
|
||||
if(open_control_pipe(control_pipe) == 0) {
|
||||
if(open_control_pipe(control_pipe, pad_reg) == 0) {
|
||||
printf("Reading control commands on %s.\n", control_pipe);
|
||||
} else {
|
||||
printf("Failed to open control pipe: %s.\n", control_pipe);
|
||||
|
|
@ -301,7 +301,7 @@ int main(int argc, char **argv) {
|
|||
} else if(strcmp("-af", arg)==0 && param != NULL) {
|
||||
i++;
|
||||
af_size++;
|
||||
alternative_freq[af_size] = (int)(10*atof(optarg))-875;
|
||||
alternative_freq[af_size] = (int)(10*atof(param))-875;
|
||||
if(alternative_freq[af_size] < 1 || alternative_freq[af_size] > 204)
|
||||
fatal("Alternative Frequency has to be set in range of 87.6 Mhz - 107.9 Mhz\n"); //honestly i have no idea why 87.5 and 108 isn't in here, i copied this code, okay?
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue