diff --git a/data/webui/device_specific/BUILD_COCO/dw3doscc1.bin b/data/webui/device_specific/BUILD_COCO/dw3doscc1.bin deleted file mode 100644 index 47e2eab4d..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/dw3doscc1.bin and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/dw3doscc1.wav b/data/webui/device_specific/BUILD_COCO/dw3doscc1.wav deleted file mode 100644 index f24be10e5..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/dw3doscc1.wav and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/dw3doscc2.bin b/data/webui/device_specific/BUILD_COCO/dw3doscc2.bin deleted file mode 100644 index 5f8cf671a..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/dw3doscc2.bin and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/dw3doscc2.wav b/data/webui/device_specific/BUILD_COCO/dw3doscc2.wav deleted file mode 100644 index 6db222a1b..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/dw3doscc2.wav and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/dw3doscc3.bin b/data/webui/device_specific/BUILD_COCO/dw3doscc3.bin deleted file mode 100644 index 70e71dc62..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/dw3doscc3.bin and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/dw3doscc3.wav b/data/webui/device_specific/BUILD_COCO/dw3doscc3.wav deleted file mode 100644 index cbcd8e103..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/dw3doscc3.wav and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/hdbcc1.wav b/data/webui/device_specific/BUILD_COCO/hdbcc1.wav deleted file mode 100644 index 2f2ac8d05..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/hdbcc1.wav and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/hdbcc2.wav b/data/webui/device_specific/BUILD_COCO/hdbcc2.wav deleted file mode 100644 index 772250b3d..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/hdbcc2.wav and /dev/null differ diff --git a/data/webui/device_specific/BUILD_COCO/hdbcc3.wav b/data/webui/device_specific/BUILD_COCO/hdbcc3.wav deleted file mode 100644 index 6cf4f466a..000000000 Binary files a/data/webui/device_specific/BUILD_COCO/hdbcc3.wav and /dev/null differ diff --git a/lib/bus/drivewire/drivewire.cpp b/lib/bus/drivewire/drivewire.cpp index ec780210e..ae083256e 100755 --- a/lib/bus/drivewire/drivewire.cpp +++ b/lib/bus/drivewire/drivewire.cpp @@ -80,6 +80,10 @@ void systemBus::_drivewire_process_queue() */ void systemBus::service() { + // Handle cassette play if MOTOR pin active. + if (_cassetteDev) + if (motorActive) + _cassetteDev->play(); } // Setup DRIVEWIRE bus @@ -101,6 +105,8 @@ void systemBus::setup() .intr_type = GPIO_INTR_POSEDGE // interrupt on positive edge }; + _cassetteDev = new drivewireCassette(); + //configure GPIO with the given settings gpio_config(&io_conf); gpio_isr_handler_add((gpio_num_t)PIN_CASS_MOTOR, drivewire_isr_handler, (void*) PIN_CASS_MOTOR); diff --git a/lib/device/drivewire/cassette.cpp b/lib/device/drivewire/cassette.cpp index b2ed8bae0..b369a1c64 100755 --- a/lib/device/drivewire/cassette.cpp +++ b/lib/device/drivewire/cassette.cpp @@ -3,18 +3,81 @@ #include "cassette.h" #include +#include #include "../../include/debug.h" #include "fnSystem.h" #include "fnUART.h" #include "fnFsSD.h" +#include "fnFsSPIFFS.h" #include "led.h" +#define SAMPLE_DELAY_US 89 + +/** + * @brief since cassette isn't a DW device, we don't handle it here. + */ void drivewireCassette::drivewire_process(uint32_t commanddata, uint8_t checksum) { - // Not really used at the moment. + // Not really used... +} + +/** + * @brief Handle when motor active, and send tape via DAC + * @note This routine stays active until tape is done streaming. + */ +void drivewireCassette::play() +{ + casf = fsFlash.file_open("/hdbcc2.raw","r"); + + if (!casf) + { + Debug_printv("Could not open cassette file. Aborting."); + casf = NULL; + return; + } + else + { + Debug_printv("cassette file opened."); + } + + Debug_printv("Enabling DAC.") + dac_output_enable(DAC_CHANNEL_1); + + // Send silence + Debug_printv("sending silence"); + for (unsigned long i=0;i<1000000UL;i++) + { + dac_output_voltage(DAC_CHANNEL_1,0); + esp_rom_delay_us(5); + } + + Debug_printv("sending data."); + + while (!feof(casf)) + { + uint8_t b = fgetc(casf); + dac_output_voltage(DAC_CHANNEL_1,b); + esp_rom_delay_us(SAMPLE_DELAY_US); + } + + Debug_printv("Disabling DAC."); + + dac_output_disable(DAC_CHANNEL_1); + + fclose(casf); + + Debug_printv("Tape done."); +} + +void drivewireCassette::setup() +{ +} + +void drivewireCassette::shutdown() +{ } #endif /* BUILD_COCO */ \ No newline at end of file diff --git a/lib/device/drivewire/cassette.h b/lib/device/drivewire/cassette.h index f2e5a4c9f..5623662f5 100755 --- a/lib/device/drivewire/cassette.h +++ b/lib/device/drivewire/cassette.h @@ -12,10 +12,18 @@ class drivewireCassette : public virtualDevice public: +virtual void setup(); virtual void drivewire_process(uint32_t commanddata, uint8_t checksum); +virtual void shutdown(); +void play(); private: +/** + * @brief The file pointer used by the cassette + */ +FILE *casf = NULL; + }; #endif \ No newline at end of file diff --git a/lib/device/drivewire/fuji.cpp b/lib/device/drivewire/fuji.cpp index 828de0b94..4ccafbfe6 100755 --- a/lib/device/drivewire/fuji.cpp +++ b/lib/device/drivewire/fuji.cpp @@ -1651,6 +1651,7 @@ void drivewireFuji::setup(systemBus *drivewirebus) // cassette()->set_buttons(Config.get_cassette_buttons()); // cassette()->set_pulldown(Config.get_cassette_pulldown()); + cassette()->setup(); } diff --git a/src/main.cpp b/src/main.cpp index ff0f9e53a..e2d500527 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,6 @@ #include "fnFsSD.h" #include "httpService.h" -#include #ifdef BLUETOOTH_SUPPORT #include "fnBluetooth.h"