flashing the LEDs in different ways

Started by franticspider, September 12, 2016, 08:49:27 AM

Previous topic - Next topic

franticspider

Hi Paul,

I want to experiment with the LED patterns that the miniATM displays so that I can get quicker feedback about what is going on. I have a couple of ideas in this area:

1: instead of showing the control / number combination in the usual way, I'd like to alternate between flashing *both* LEDs with the current digital function colour, alternating with using *both* LEDs to show the pattern number in base 4 (using the four most easily distinguishable colours that the LED can make) . Can you tell me where I'd look in the code to try this please?

2: I'm really enjoying my miniATM, using it mainly via MIDI. I'd like to hack the software further now, so that when pattern '0' is selected (i.e. no sequence is playing), I can use the LEDs to show when a MIDI message has been received. I think I need to hack minEngine.cpp to call a function that flashes an LED when MIDI signals come in - but I don't know what functions to call!

Any tips would be greatly appreciated. Thanks,

Simon


paulsoulsby

Hi Simon,
Yes all of this is possible and not too tricky with a bit of C/C++ knowledge. I'll be able to look at this properly tomorrow to help - I wanna make sure I give you the right info when I've got the code in front of me!  Best that I don't try and do it from memory!
Paul

paulsoulsby

Hi,
Had a chance to check the code! 
1)  Goto Min.cpp, then
void Min::engineValueChanged(unsigned char func, unsigned char val, bool opt)
This shows the code for setting the LED when the func is changed
The code for showing the value via flashes is just below in:
void Min::refreshValueLed()
You'll want to leave this blank, so it doesn't overwrite your new code in engineValueChanged

2)
The quickest way is at the bottom of Min.cpp in:
void Min::hardwareMidiReceived(unsigned char data)

However this code doesn't know what the message type is, it'll just allow a generic flash for any message received.  If you want to do different flashes for different messages you'll need to go to:
MinEngineBase.h
and add a callback called something like:
virtual void engineMidiReceive(unsigned char status, unsigned char data1, unsigned char data2) = 0;
Then add the relevant calls to it that you want in MinEngine.cpp (e.g. in void MinEngine::midiNoteOnReceived(unsigned char note, unsigned char velocity))
Then add it to bottom of Min.h
Then add it to Min.cpp with the required code for setting the LEDs.
A bit more complex, but you can find examples all over the Atmegatron libraries for using these base classes for callbacks.  Just copy an example where you find a "base_->" in the code.

hope this helps!