Skip to content

Commit

Permalink
Merge pull request #278 from alanbjohnston/beta-v1.3.2-sstv
Browse files Browse the repository at this point in the history
FM programmed by Pi instead of Pico, battery voltage and current displayed on sstv
  • Loading branch information
alanbjohnston authored Oct 3, 2023
2 parents 1956a15 + 067f0ce commit 3ac74e0
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 10 deletions.
61 changes: 56 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ int main(int argc, char * argv[]) {
}

printf("\n\nCubeSatSim v1.3b starting...\n\n");

wiringPiSetup();

program_radio();

FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r");
pclose(rpitx_stop);
//FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r");
//pclose(rpitx_stop);

FILE * file_deletes = popen("sudo rm /home/pi/CubeSatSim/ready /home/pi/CubeSatSim/cwready > /dev/null", "r");
pclose(file_deletes);
Expand Down Expand Up @@ -172,8 +176,6 @@ int main(int argc, char * argv[]) {
if (strcmp(sim_yes, "yes") == 0)
sim_mode = TRUE;

wiringPiSetup();

if (mode == AFSK)
{
// Check for SPI and AX-5043 Digital Transceiver Board
Expand Down Expand Up @@ -350,6 +352,9 @@ int main(int argc, char * argv[]) {
payload = OFF;

if ((uart_fd = serialOpen("/dev/ttyAMA0", 115200)) >= 0) { // was 9600
printf("Serial opened to Pico\n");
payload = ON;
/*
char c;
int charss = (char) serialDataAvail(uart_fd);
if (charss != 0)
Expand Down Expand Up @@ -390,6 +395,7 @@ int main(int argc, char * argv[]) {
payload = ON;
}
*/
} else {
fprintf(stderr, "Unable to open UART: %s\n -> Did you configure /boot/config.txt and /boot/cmdline.txt?\n", strerror(errno));
}
Expand Down Expand Up @@ -835,7 +841,7 @@ int main(int argc, char * argv[]) {
#endif
FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w");
printf("Writing telem_string.txt\n");
fprintf(fp, "Vbatt = %4.2f\n", batteryVoltage);
fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent);
fclose(fp);

/**/
Expand Down Expand Up @@ -2177,3 +2183,48 @@ int get_payload_serial(int debug_camera) {
fflush(stdout);
return(finished);
}

void program_radio() {
// if (sr_frs_present) {
printf("Programming FM module!\n");

pinMode(28, OUTPUT);
pinMode(29, OUTPUT);
digitalWrite(29, HIGH); // enable SR_FRS
digitalWrite(28, HIGH); // stop transmit

if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600
printf("serial opened 9600\n");
for (int i = 0; i < 5; i++) {
sleep(1); // delay(500);
//#ifdef APRS_VHF
// char vhf_string[] = "AT+DMOSETGROUP=0,144.3900,144.3900,0,3,0,0\r\n";
// serialPrintf(uart_fd, vhf_string);
// mySerial.println("AT+DMOSETGROUP=0,144.3900,144.3900,0,3,0,0\r"); // can change to 144.39 for standard APRS
// mySerial.println("AT+DMOSETGROUP=0,145.0000,145.0000,0,3,0,0\r"); // can change to 145 for testing ASPRS
//#else
char uhf_string[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n";
serialPrintf(uart_fd, uhf_string);
// mySerial.println("AT+DMOSETGROUP=0,435.1000,434.9900,0,3,0,0\r"); // squelch set to 3
//#endif
sleep(1);
char mic_string[] = "AT+DMOSETMIC=8,0\r\n";
serialPrintf(uart_fd, mic_string);
// mySerial.println("AT+DMOSETMIC=8,0\r"); // was 8

}
}
//#ifdef APRS_VHF
// printf("Programming FM tx 144.39, rx on 144.39 MHz\n");
//#else
printf("Programming FM tx 434.9, rx on 435.0 MHz\n");
//#endif
// digitalWrite(PTT_PIN, LOW); // transmit carrier for 0.5 sec
// sleep(0.5);
// digitalWrite(PTT_PIN, HIGH);
digitalWrite(29, LOW); // disable SR_FRS
pinMode(28, INPUT);
pinMode(29, INPUT);

serialClose(uart_fd);
}
1 change: 1 addition & 0 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void update_rs(unsigned char parity[32], unsigned char c);
void write_little_endian(unsigned int word, int num_bytes, FILE *wav_file);
static int init_rf();
extern int Encode_8b10b[][256];
void program_radio();

int socket_open = 0;
int sock = 0;
Expand Down
8 changes: 5 additions & 3 deletions rpitx.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def increment_mode():

file='/home/pi/CubeSatSim/camera_out.jpg'
font1 = ImageFont.truetype('DejaVuSerif.ttf', 20)
font2 = ImageFont.truetype('DejaVuSerif-Bold.ttf', 20)
font2 = ImageFont.truetype('DejaVuSerif-Bold.ttf', 16)

try:
filep = open("/home/pi/CubeSatSim/telem_string.txt")
Expand All @@ -518,8 +518,10 @@ def increment_mode():
draw = ImageDraw.Draw(img)
# draw.text((10, 10), callsign, font=font2, fill='white')
# draw.text((120, 10), telem_string, font=font2, fill='white')
draw.text((10, 10), callsign, font=font2, fill='black')
draw.text((120, 10), telem_string, font=font2, fill='black')
draw.text((12, 12), callsign, font=font1, fill='black')
draw.text((10, 10), callsign, font=font1, fill='white')
draw.text((122, 12), telem_string, font=font2, fill='black')
draw.text((120, 10), telem_string, font=font2, fill='white')
img.save(file)

system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg")
Expand Down
4 changes: 2 additions & 2 deletions stempayload/payload_pico/payload_pico.ino
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void setup() {

Serial.print("Pi Zero present, so running Payload OK code.");
sr_frs_present = true;
program_radio();
// program_radio();
start_payload();

pinMode(15, INPUT_PULLUP);
Expand Down Expand Up @@ -185,7 +185,7 @@ void program_radio() {
mySerial.println("AT+DMOSETGROUP=0,144.3900,144.3900,0,3,0,0\r"); // can change to 144.39 for standard APRS
// mySerial.println("AT+DMOSETGROUP=0,145.0000,145.0000,0,3,0,0\r"); // can change to 145 for testing ASPRS
#else
mySerial.println("AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r"); // squelch set to 3
mySerial.println("AT+DMOSETGROUP=0,435.1000,434.9900,0,3,0,0\r"); // squelch set to 3
#endif
sleep(0.5);
mySerial.println("AT+DMOSETMIC=8,0\r"); // was 8
Expand Down

0 comments on commit 3ac74e0

Please sign in to comment.