added back FSK

pull/202/head
alanbjohnston 3 years ago committed by GitHub
parent 1b4000fa9d
commit 9540e24458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -483,7 +483,7 @@ void transmit_on() {
digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(MAIN_LED_BLUE, HIGH);
digitalWrite(PTT_PIN, LOW); digitalWrite(PTT_PIN, LOW);
} }
else if (mode == BPSK) { else if ((mode == BPSK) || (mode == FSK)) {
if (debug_mode) if (debug_mode)
Serial.println("Transmit on!!!"); Serial.println("Transmit on!!!");
// pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5); // pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5);
@ -504,7 +504,7 @@ void transmit_off() {
Serial.println("Transmit off!"); Serial.println("Transmit off!");
digitalWrite(MAIN_LED_BLUE, LOW); digitalWrite(MAIN_LED_BLUE, LOW);
// ITimer0.stopTimer(); // stop BPSK ISR timer // ITimer0.stopTimer(); // stop BPSK ISR timer
if (mode == BPSK) { if ((mode == BPSK) || (mode = FSK)) {
digitalWrite(BPSK_CONTROL_A, LOW); digitalWrite(BPSK_CONTROL_A, LOW);
digitalWrite(BPSK_CONTROL_B, LOW); digitalWrite(BPSK_CONTROL_B, LOW);
// pwm_set_gpio_level(BPSK_PWM_A_PIN, 0); // pwm_set_gpio_level(BPSK_PWM_A_PIN, 0);
@ -534,7 +534,7 @@ void config_telem() {
if (mode == FSK) { if (mode == FSK) {
Serial.println("Configuring for FSK\n"); Serial.println("Configuring for FSK\n");
bitRate = 200; bitRate = 200;
delay_time = (1.0 / 200.0); delay_time = 1E6 / bitRate;
rsFrames = 1; rsFrames = 1;
payloads = 1; payloads = 1;
rsFrameLen = 64; rsFrameLen = 64;
@ -563,7 +563,7 @@ void config_telem() {
Serial.println("Configuring for BPSK\n"); Serial.println("Configuring for BPSK\n");
bitRate = 1200; bitRate = 1200;
// delay_time = (1.0 / 1200.0); // delay_time = (1.0 / 1200.0);
delay_time = (1.0 / 200.0); delay_time = 1E6 / bitRate;
rsFrames = 3; rsFrames = 3;
payloads = 6; payloads = 6;
rsFrameLen = 159; rsFrameLen = 159;
@ -1282,19 +1282,14 @@ void get_tlm_fox() {
data = val & 1 << (bit - 1); data = val & 1 << (bit - 1);
// printf ("%d i: %d new frame %d sync bit %d = %d \n", // printf ("%d i: %d new frame %d sync bit %d = %d \n",
// ctr/SAMPLES, i, frames, bit, (data > 0) ); // ctr/SAMPLES, i, frames, bit, (data > 0) );
if (mode == FSK) { /// if (mode == FSK) {
phase = ((data != 0) * 2) - 1; /// phase = ((data != 0) * 2) - 1;
// printf("Sending a %d\n", phase); // printf("Sending a %d\n", phase);
} else { /// } else {
if (data == 0) { if (data == 0) {
phase *= -1; phase *= -1;
// if ((ctr - smaller) > 0) {
// for (int j = 1; j <= smaller; j++)
// buffer[ctr - j] = buffer[ctr - j] * 0.4;
// }
// flip_ctr = ctr;
} }
} /// }
} }
} }
/// #ifdef DEBUG_LOGGING /// #ifdef DEBUG_LOGGING
@ -1314,10 +1309,10 @@ void get_tlm_fox() {
// ctr/SAMPLES, i, frames, symbol, val, bit, (data > 0) ); // ctr/SAMPLES, i, frames, symbol, val, bit, (data > 0) );
// Serial.print(data, BIN); // Debugging print!!! // Serial.print(data, BIN); // Debugging print!!!
// Serial.print(" "); // Serial.print(" ");
if (mode == FSK) { /// if (mode == FSK) {
phase = ((data != 0) * 2) - 1; /// phase = ((data != 0) * 2) - 1;
// printf("Sending a %d\n", phase); // printf("Sending a %d\n", phase);
} else { /// } else {
if (data == 0) { if (data == 0) {
phase *= -1; phase *= -1;
// if ((ctr - smaller) > 0) { // if ((ctr - smaller) > 0) {
@ -1326,7 +1321,7 @@ void get_tlm_fox() {
// } // }
// flip_ctr = ctr; // flip_ctr = ctr;
} }
} /// }
// Serial.println("AA"); // Serial.println("AA");
} }
// Serial.println("BB"); // Serial.println("BB");
@ -1347,36 +1342,15 @@ void get_tlm_fox() {
//void write_wave(int i, short int *buffer) //void write_wave(int i, short int *buffer)
void write_wave(int i, byte *buffer) void write_wave(int i, byte *buffer)
{ {
if (mode == FSK) buffer[ctr++] = (byte)(phase == 1);
{ if (ctr > bufLen) {
// if ((ctr - flip_ctr) < smaller) // No wave shaping ctr = ctr - bufLen;
// buffer[ctr++] = (short int)(0.1 * phase * (ctr - flip_ctr) / smaller); if (debug_mode) {
// else Serial.print("\r");
buffer[ctr++] = (byte)(0.25 * amplitude * phase); Serial.print(" ");
// Serial.print(buffer[ctr - 1]); Serial.println(millis());
// Serial.print(" ");
}
else
{
// if ((ctr - flip_ctr) < smaller)
// buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
// buffer[ctr++] = (short int)(phase * sin_map[ctr % sin_samples] / 2);
// else
// buffer[ctr++] = (short int)(amplitude * 0.4 * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE))); buffer[ctr++] = (short int)(amplitude * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
// buffer[ctr++] = (short int)(phase * sin_map[ctr % sin_samples]); }
buffer[ctr++] = (byte)(phase == 1);
}
// printf("%d %d \n", i, buffer[ctr - 1]);
// if (ctr > BUFFER_SIZE) {
// ctr = ctr - BUFFER_SIZE;
if (ctr > bufLen) {
ctr = ctr - bufLen;
if (debug_mode) {
Serial.print("\r");
Serial.print(" ");
Serial.println(millis());
}
} }
}
// Serial.printf(" b: %d ", buffer[ctr - 1]); // Serial.printf(" b: %d ", buffer[ctr - 1]);
} }
@ -3198,10 +3172,9 @@ void process_pushbutton() {
pb_value = digitalRead(MAIN_PB_PIN); pb_value = digitalRead(MAIN_PB_PIN);
if ((pb_value == RELEASED) && (release == FALSE)) { if ((pb_value == RELEASED) && (release == FALSE)) {
Serial.println("PB: FSK not supported"); Serial.println("PB: Switch to FSK");
release = TRUE; release = TRUE;
// new_mode = FSK; new_mode = FSK;
// setup();
} }
if (release == FALSE) { if (release == FALSE) {
@ -3296,10 +3269,9 @@ void process_bootsel() {
// pb_value = digitalRead(MAIN_PB_PIN); // pb_value = digitalRead(MAIN_PB_PIN);
if ((!BOOTSEL) && (release == FALSE)) { if ((!BOOTSEL) && (release == FALSE)) {
Serial.println("BOOTSEL: FSK not supported"); Serial.println("BOOTSEL: Switch to FSK");
release = TRUE; release = TRUE;
// new_mode = FSK; new_mode = FSK;
// setup();
} }
if (release == FALSE) { if (release == FALSE) {
@ -3445,12 +3417,13 @@ bool TimerHandler0(struct repeating_timer *t) {
// digitalWrite(STEM_LED_GREEN, !green_led_counter++); // digitalWrite(STEM_LED_GREEN, !green_led_counter++);
if (mode == BPSK) { // only do this if BPSK mode. Should turn off timer interrupt when not BPSK in future if ((mode == BPSK) || (mode == FSK)) { // only do this if BPSK mode. Should turn off timer interrupt when not BPSK in future
// Serial.print("l1 "); // Serial.print("l1 ");
// Serial.print(wav_position); // Serial.print(wav_position);
// Serial.print(" "); // Serial.print(" ");
while ((micros() - micro_timer2) < 832) { } while ((micros() - micro_timer2) < delay_time) { }
busy_wait_at_least_cycles(51); // 300 ns if (mode == BPSK)
busy_wait_at_least_cycles(51); // 300 ns
// if ((micros() - micro_timer2) > 834) // if ((micros() - micro_timer2) > 834)
// Serial.println(micros() - micro_timer2); // Serial.println(micros() - micro_timer2);
micro_timer2 = micros(); micro_timer2 = micros();
@ -3491,7 +3464,7 @@ bool TimerHandler0(struct repeating_timer *t) {
// Serial.print(" "); // Serial.print(" ");
// Serial.println(millis()); // Serial.println(millis());
/**/ /**/
if ((micros() - micro_timer)/bufLen > 835) { if ((micros() - micro_timer)/bufLen > (delay_time + 10)) {
if (bufLen != 0) { if (bufLen != 0) {
Serial.print("R Microseconds: "); Serial.print("R Microseconds: ");
Serial.println((float)(micros() - micro_timer)/(float)bufLen); Serial.println((float)(micros() - micro_timer)/(float)bufLen);
@ -3530,7 +3503,9 @@ void start_isr() {
// if (ITimer0.attachInterruptInterval(833, TimerHandler0)) // if (ITimer0.attachInterruptInterval(833, TimerHandler0))
// if (ITimer0.attachInterruptInterval(804, TimerHandler0)) // if (ITimer0.attachInterruptInterval(804, TimerHandler0))
if (ITimer0.attachInterruptInterval(800, TimerHandler0)) // was 800 // was was 828 (841) and 828 // if (ITimer0.attachInterruptInterval(800, TimerHandler0)) // was 800 // was was 828 (841) and 828
if (ITimer0.attachInterruptInterval(delay_time - 32, TimerHandler0)) // was 800 // was was 828 (841) and 828
// if (ITimer0.attachInterruptInterval(1667, TimerHandler0)) // if (ITimer0.attachInterruptInterval(1667, TimerHandler0))
{ {
if (debug_mode) if (debug_mode)

Loading…
Cancel
Save

Powered by TurnKey Linux.