From 59998eeffe02a5233a62957663cf61397e38a3fa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Wed, 6 Jul 2022 13:22:11 -0400 Subject: [PATCH] added setup1 and loop1 --- cubesatsim/cubesatsim.ino | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 63b8329a..83eabdd0 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -93,7 +93,8 @@ void setup() { config_radio(); // start pwm - start_pwm(); +// start_pwm(); + transmit_on(); @@ -2226,3 +2227,37 @@ void pwm_interrupt_handler() { } } + +void setup1() { + + pinMode(AUDIO_OUT_PIN, OUTPUT); +} + +void loop1() { + + if (pwm_counter > pwm_counter_max) { + pwm_counter -= pwm_counter_max; + + pwm_rnd_bit = (buffer[wav_position] > 0) ? HIGH: LOW; + digitalWrite(AUDIO_OUT_PIN, pwm_rnd_bit); +/* + pwm_rnd_bit = (buffer[wav_position] > 0) ? 1 : 0; + + if ((pwm_value == (128 - pwm_amplitude)) && (pwm_rnd_bit == 1)) { + pwm_value = 128 + pwm_amplitude; +// Serial.print("-"); + } + else { + pwm_value = 128 - pwm_amplitude; +// Serial.print("_"); + } + pwm_set_gpio_level(AUDIO_OUT_PIN, pwm_value); +// Serial.println("wav_position: "); +// Serial.println(wav_position); +*/ + if (wav_position++ > BUFFER_SIZE) { // 300) { + wav_position = wav_position - BUFFER_SIZE; +// Serial.print("R"); + } + delay(5); +}