implement disabling serial

This commit is contained in:
Valentin Boettcher 2021-08-27 18:55:28 +02:00
parent 0664fdeafb
commit 21523c3b4d
3 changed files with 14 additions and 6 deletions

View file

@ -1,2 +1,3 @@
FQBN = arduino:avr:micro
PORT = /dev/ttyACM0
DEBUG_SERIAL = false

View file

@ -12,7 +12,7 @@ ELF = $(B_PATH)/$(PRG).ino.elf
ARDLIBS = USB-MIDI@1.1.2
$(HEX): $(SRCS)
$(ARDCLI) compile --fqbn $(FQBN) --build-path $(B_PATH) $(CURDIR)
$(ARDCLI) compile --build-property build.extra_flags="-DDEBUG_SERIAL=$(DEBUG_SERIAL)" --fqbn $(FQBN) --build-path $(B_PATH) $(CURDIR)
upload: $(HEX)
sudo $(ARDCLI) upload -v --fqbn $(FQBN) --input-dir $(B_PATH) -p $(PORT) $(CURDIR)
@ -22,7 +22,7 @@ deps:
clean:
$(RM) $(HEX) $(ELF)
$(RM) $(B_PATH)
$(RM) -r $(B_PATH)
.PHONY: all upload deps clean

View file

@ -1,6 +1,11 @@
#include <USB-MIDI.h>
#if DEBUG_SERIAL
#define Sprintln(...) (Serial.println(__VA_ARGS__))
#define Sprint(...) (Serial.print(__VA_ARGS__))
#else
#define Sprintln(...)
#define Sprint(...)
#endif
/*****************************************************************************/
/* Pins */
@ -44,8 +49,8 @@ constexpr midi::Channel channel = 1;
/*****************************************************************************/
/* Velocity */
/*****************************************************************************/
constexpr double min_velocity = 0.00001;
constexpr double max_velocity = 0.00024;
constexpr double min_velocity = 0.000001;
constexpr double max_velocity = 0.00015;
/*****************************************************************************/
/* Keyscanning */
@ -116,7 +121,9 @@ void setup() {
/***************************************************************************/
/* Serial */
/***************************************************************************/
#if DEBUG_SERIAL
Serial.begin(115200);
#endif
/***************************************************************************/
/* Pins */
@ -166,10 +173,10 @@ void send_note_up(int key) {
void send_pedal(bool down) {
if (down) {
Sprintln("SSTE DOWN");
MIDI.sendControlChange(64, 64, 1);
MIDI.sendControlChange(64, 127, 1);
} else {
Sprintln("SSTE UP");
MIDI.sendControlChange(64, 63, 1);
MIDI.sendControlChange(64, 0, 1);
}
}