reworked basic demo
led comes on when connected, noteOn turns it off, NoteOff turn it back on
This commit is contained in:
		
							parent
							
								
									4aee6708ca
								
							
						
					
					
						commit
						f4927cd4ea
					
				|  | @ -1,7 +1,7 @@ | |||
| #include <BLEMIDI_Transport.h> | ||||
| 
 | ||||
| #include <hardware/BLEMIDI_ESP32_NimBLE.h> | ||||
| //#include <hardware/BLEMIDI_ESP32.h>
 | ||||
| //#include <hardware/BLEMIDI_ESP32_NimBLE.h>
 | ||||
| #include <hardware/BLEMIDI_ESP32.h> | ||||
| //#include <hardware/BLEMIDI_nRF52.h>
 | ||||
| //#include <hardware/BLEMIDI_ArduinoBLE.h>
 | ||||
| 
 | ||||
|  | @ -20,11 +20,22 @@ void setup() | |||
|   pinMode(LED_BUILTIN, OUTPUT); | ||||
|   digitalWrite(LED_BUILTIN, LOW); | ||||
| 
 | ||||
|   BLEMIDI.setHandleConnected(OnConnected); | ||||
|   BLEMIDI.setHandleDisconnected(OnDisconnected); | ||||
|   BLEMIDI.setHandleConnected([]() { | ||||
|     isConnected = true; | ||||
|     digitalWrite(LED_BUILTIN, HIGH); | ||||
|   }); | ||||
| 
 | ||||
|   MIDI.setHandleNoteOn(OnNoteOn); | ||||
|   MIDI.setHandleNoteOff(OnNoteOff); | ||||
|   BLEMIDI.setHandleDisconnected([]() { | ||||
|     isConnected = false; | ||||
|     digitalWrite(LED_BUILTIN, LOW); | ||||
|   }); | ||||
| 
 | ||||
|   MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) { | ||||
|     digitalWrite(LED_BUILTIN, LOW); | ||||
|   }); | ||||
|   MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) { | ||||
|     digitalWrite(LED_BUILTIN, HIGH); | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
|  | @ -41,35 +52,3 @@ void loop() | |||
|     MIDI.sendNoteOn (60, 100, 1); // note 60, velocity 127 on channel 1
 | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| // ====================================================================================
 | ||||
| // Event handlers for incoming MIDI messages
 | ||||
| // ====================================================================================
 | ||||
| 
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| // Device connected
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| void OnConnected() { | ||||
|   isConnected = true; | ||||
|   digitalWrite(LED_BUILTIN, HIGH); | ||||
| } | ||||
| 
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| // Device disconnected
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| void OnDisconnected() { | ||||
|   isConnected = false; | ||||
|   digitalWrite(LED_BUILTIN, LOW); | ||||
| } | ||||
| 
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| // Received note on
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| void OnNoteOn(byte channel, byte note, byte velocity) { | ||||
| } | ||||
| 
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| // Received note off
 | ||||
| // -----------------------------------------------------------------------------
 | ||||
| void OnNoteOff(byte channel, byte note, byte velocity) { | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 lathoub
						lathoub