Skip to content

Commit

Permalink
[coco] first pass of motor controlled tape.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschak909 committed Dec 6, 2023
1 parent 4827b05 commit 8fef9db
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 2 deletions.
Binary file removed data/webui/device_specific/BUILD_COCO/dw3doscc1.bin
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/dw3doscc1.wav
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/dw3doscc2.bin
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/dw3doscc2.wav
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/dw3doscc3.bin
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/dw3doscc3.wav
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/hdbcc1.wav
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/hdbcc2.wav
Binary file not shown.
Binary file removed data/webui/device_specific/BUILD_COCO/hdbcc3.wav
Binary file not shown.
6 changes: 6 additions & 0 deletions lib/bus/drivewire/drivewire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
65 changes: 64 additions & 1 deletion lib/device/drivewire/cassette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,81 @@
#include "cassette.h"

#include <cstring>
#include <driver/dac.h>

#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 */
8 changes: 8 additions & 0 deletions lib/device/drivewire/cassette.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions lib/device/drivewire/fuji.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}

Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "fnFsSD.h"

#include "httpService.h"
#include <driver/dac.h>

#ifdef BLUETOOTH_SUPPORT
#include "fnBluetooth.h"
Expand Down

0 comments on commit 8fef9db

Please sign in to comment.