Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PinDetect USBDevice_STM32F103 mbed-STM32F103C8T6
midiswitch.cpp@7:553836a26221, 2017-08-04 (annotated)
- Committer:
- SpotlightKid
- Date:
- Fri Aug 04 04:20:37 2017 +0200
- Revision:
- 7:553836a26221
- Parent:
- 6:2f804d29cbb0
- Child:
- 8:75c5ec68765e
Fix controller number; use internal pin pull-ups
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| SpotlightKid |
7:553836a26221 | 1 | #include "mbed.h" |
| SpotlightKid |
3:8b8cb5392fa0 | 2 | #include "midiswitch.h" |
| SpotlightKid |
3:8b8cb5392fa0 | 3 | |
| SpotlightKid |
3:8b8cb5392fa0 | 4 | SwitchHandler::SwitchHandler(EventQueue * queue, MIDI_CB cb, SwitchConfig * sw) : |
| SpotlightKid |
3:8b8cb5392fa0 | 5 | queue(queue), write_cb(cb), btn(sw->pin), control(sw->control), channel(sw->channel), on_value(sw->on_value), off_value(sw->off_value) { |
| SpotlightKid |
7:553836a26221 | 6 | btn.mode(Pullup); |
| SpotlightKid |
7:553836a26221 | 7 | btn.setAssertValue(0); |
| SpotlightKid |
3:8b8cb5392fa0 | 8 | btn.attach_asserted(this, &SwitchHandler::handle_pressed); |
| SpotlightKid |
3:8b8cb5392fa0 | 9 | btn.attach_deasserted(this, &SwitchHandler::handle_released); |
| SpotlightKid |
3:8b8cb5392fa0 | 10 | btn.setSampleFrequency(); |
| SpotlightKid |
3:8b8cb5392fa0 | 11 | }; |
| SpotlightKid |
3:8b8cb5392fa0 | 12 | |
| SpotlightKid |
3:8b8cb5392fa0 | 13 | void SwitchHandler::handle_pressed(void) { |
| SpotlightKid |
3:8b8cb5392fa0 | 14 | queue->call(write_cb, MIDIMessage::ControlChange((int) control, (int) on_value, (int) (channel - 1))); |
| SpotlightKid |
3:8b8cb5392fa0 | 15 | }; |
| SpotlightKid |
3:8b8cb5392fa0 | 16 | |
| SpotlightKid |
3:8b8cb5392fa0 | 17 | void SwitchHandler::handle_released(void) { |
| SpotlightKid |
3:8b8cb5392fa0 | 18 | queue->call(write_cb, MIDIMessage::ControlChange((int) control, (int) off_value, (int) (channel - 1))); |
| SpotlightKid |
3:8b8cb5392fa0 | 19 | }; |