From 21523c3b4dca76b32c4a46e8a148cabfb9c1d0ef Mon Sep 17 00:00:00 2001 From: Valentin Boettcher Date: Fri, 27 Aug 2021 18:55:28 +0200 Subject: [PATCH] implement disabling serial --- config.mk | 1 + makefile | 4 ++-- midikeys.ino | 15 +++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/config.mk b/config.mk index 1410922..aa782e0 100644 --- a/config.mk +++ b/config.mk @@ -1,2 +1,3 @@ FQBN = arduino:avr:micro PORT = /dev/ttyACM0 +DEBUG_SERIAL = false diff --git a/makefile b/makefile index 816e4b4..30fe3b5 100644 --- a/makefile +++ b/makefile @@ -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 diff --git a/midikeys.ino b/midikeys.ino index 3053820..88b012c 100644 --- a/midikeys.ino +++ b/midikeys.ino @@ -1,6 +1,11 @@ #include +#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); } }