Sammy1Am / Moppy2

The evolution of the Musical flOPPY controller
Other
311 stars 51 forks source link

Added EasyDriver/A3967 support and more #105

Closed tobiasfrck closed 4 years ago

tobiasfrck commented 4 years ago

Added support for 3 EasyDrivers and expanded the arrays in MoppyInstrument.h with more notes. To switch to EasyDriver mode, please refer to the MoppyCore.cpp file.

Sammy1Am commented 4 years ago

Looks awesome! I've been meaning (for quite some time) to get around to updating the code a bit, and I'll try to pull this as soon as I do (hopefully August sometime :P ).

The only potential hitch is: the reason many of the notes were missing period values was to prevent the floppy drives from attempting to play notes that they don't support (too low or high result in awful noises, skipping stepper motors, or both). A better solution is probably to allow instruments to specify a maximum and minimum note, so that the arrays can have all the values.

I'll probably just merge this code as is and then add the max/min notes to all the instruments.

Thanks for this!

Sammy1Am commented 4 years ago

Oh, also, I just noticed you mentioned that reset was disabled because it took too long. I don't think that'll really cause any issues, but I'm curious as to what it took too long for? Like was it just taking too long because it reset automatically all the time and was annoying, or took so long that the song started before it was finished?

There might be some options for keeping reset available by default, but working around those issues.

tobiasfrck commented 4 years ago

Looks awesome! I've been meaning (for quite some time) to get around to updating the code a bit, and I'll try to pull this as soon as I do (hopefully August sometime :P ).

Thanks👍

The only potential hitch is: the reason many of the notes were missing period values was to prevent the floppy drives from attempting to play notes that they don't support (too low or high result in awful noises, skipping stepper motors, or both). A better solution is probably to allow instruments to specify a maximum and minimum note, so that the arrays can have all the values.

I'll probably just merge this code as is and then add the max/min notes to all the instruments.

Oh yeah, I didn't think about that. A minimum note limit would be good.

Oh, also, I just noticed you mentioned that reset was disabled because it took too long. I don't think that'll really cause any issues, but I'm curious as to what it took too long for? Like was it just taking too long because it reset automatically all the time and was annoying, or took so long that the song started before it was finished?

There might be some options for keeping reset available by default, but working around those issues.

For one, the scanner-head moved too slowly (for my taste) back and the max_position isn't as big as it would be necessary to get from one end to the other. Then there is the time in which the arduino is still trying to reset the other disconnected drivers while it does not move the connected driver because it already is in its default position. It would be better if the reset function resets the amount of drivers actually connected and ending the for-loop when all drivers are in their default position. The other problem, i think there was, is that the reset takes so long that the controlgui deletes the device from the list until the reset is finished.

Ideas: I changed the end of the for-loop for the resetAll() function to MAX_SUB_ADDRESS and it saved a whopping 1 second (from 36 seconds per reset to 35 seconds) :D A real benefit would be to exclude drivers that have been reseted so the for-loop is stopped when either the max_position is reached or all drivers are in the default position. Maybe some sort of list where each driver is deleted when its in its default position.

I'd like to test that but my controlgui won't start anymore. I deleted some other programs and temp files on my pc and since then I get "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException". I'll open another issue for that.

Sammy1Am commented 4 years ago

A real benefit would be to exclude drivers that have been reseted so the for-loop is stopped when either the max_position is reached or all drivers are in the default position. Maybe some sort of list where each driver is deleted when its in its default position.

Lists are hard in the C/C++ that's available for micro-controllers, but I'm like 85% sure most of the time is being taken by digitalWrite (it's a slow process). It's possible to use Port Manipulation to toggle pins faster (and simultaneously if you want to do the bit-math ahead of time). This might allow you to step faster (cutting down on that 35 seconds time), and step all the drives simultaneously (instead of one at at time in a loop) so that the reset would take the same amount of time for 1 or 8 drives.

Might be a fair bit of work if not-resetting is a valid solution for you, but if you're looking for a fun challenge ;P I did end up using PortManipulation successfully in the ShiftedFloppyDrives code in the experimental branch though, so that's one of the improvements I might try bringing back to mainline when I get back into things.