Sammy1Am / Moppy2

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

Input from Arduino to start play #67

Open wnycomputerguy opened 5 years ago

wnycomputerguy commented 5 years ago

Got an easy one (I think...) but my Java coding skills are rudimentary at best: I'd like to be able to Pause/Play the Moppy Control via input from the Arduino. Let's say for the sake of argument I set a pin as an input pullup, and when it goes low a signal is sent via MoppySerial (?) to trigger play/Pause. I'm not terribly concerned with any logic reversal issues that could occur if, say, it's already playing and the trigger pauses it. I just want a simple method of toggling play/pause if that's possible within the scope of the MoppySerial framework. Thx!

Sammy1Am commented 5 years ago

Currently there's not a lot of messages that flow from the Arduino to the PC, but there is at least one (the Pong response) so you wouldn't need to start from scratch.

In the MoppyGUI there's an acceptNetworkMessage method that handles any messages sent from the Arduino. Right now, it's only expecting Pong messages (see design docs for details of the message format), but you should be able to add an else if clause to that Java method to look for your custom message types.

On the Arduino side, you'll need to make sure you send bytes that correspond to the Moppy protocol outlined in the design docs linked above, but provide your own command byte (instead of 0x81 for Pong for example)