diff --git a/ControlBox/ControlBox.ino b/ControlBox/ControlBox.ino index fdf0ed3..6aff87e 100644 --- a/ControlBox/ControlBox.ino +++ b/ControlBox/ControlBox.ino @@ -1,8 +1,3 @@ -#include "setting.h" -#include "serial.h" -#include "midi.h" -#include "lcd.h" -#include "input.h" #include #include #include @@ -15,14 +10,14 @@ LiquidCrystal_I2C lcd(0x27, 16, 2);//set the LCD address to 0x27 for a 16 chars and 2 line display -const boolean DEBUG_MODE = false; +const bool DEBUG_MODE = false; void setup() { initializeInputs(); initializeLCD(); printHomeScreen(); - Serial1.begin(500000); + Serial1.begin(38400); //send all data to ESP32 for initializationv sendAllSettings(); @@ -33,4 +28,4 @@ void loop() checkForInput(); checkSchedule(); checkForMidiUSB(); -} \ No newline at end of file +} diff --git a/ControlBox/ControlBox.vcxproj b/ControlBox/ControlBox.vcxproj index 908bb55..e7fd689 100644 --- a/ControlBox/ControlBox.vcxproj +++ b/ControlBox/ControlBox.vcxproj @@ -131,7 +131,7 @@ - + \ No newline at end of file diff --git a/ControlBox/__vm/Compile.vmps.xml b/ControlBox/__vm/Compile.vmps.xml new file mode 100644 index 0000000..94644eb --- /dev/null +++ b/ControlBox/__vm/Compile.vmps.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ControlBox/__vm/Configuration.Debug.vmps.xml b/ControlBox/__vm/Configuration.Debug.vmps.xml new file mode 100644 index 0000000..b7b6dc7 --- /dev/null +++ b/ControlBox/__vm/Configuration.Debug.vmps.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ControlBox/input.cpp b/ControlBox/input.cpp index 35e4473..c1b6d67 100644 --- a/ControlBox/input.cpp +++ b/ControlBox/input.cpp @@ -1,8 +1,11 @@ +#include #include "input.h" #include "lcd.h" #include "serial.h" #include "setting.h" +void handleInput(int inputPin); + extern const int UP_PIN = 4; extern const int DOWN_PIN = 6; extern const int LEFT_PIN = 7; diff --git a/ControlBox/input.h b/ControlBox/input.h index d5143ed..113f5d4 100644 --- a/ControlBox/input.h +++ b/ControlBox/input.h @@ -1,6 +1,8 @@ #ifndef INPUT_H #define INPUT_H +#include + extern unsigned long lastPressedOverall; extern int lastAnalog; diff --git a/ControlBox/lcd.cpp b/ControlBox/lcd.cpp index f15e63b..450822b 100644 --- a/ControlBox/lcd.cpp +++ b/ControlBox/lcd.cpp @@ -1,7 +1,11 @@ +#include +#include #include "lcd.h" #include "input.h" #include "setting.h" +extern LiquidCrystal_I2C lcd; + const String MENU_NAMES[] ={ "Handle Notes", "Schedule Notes", @@ -57,7 +61,7 @@ void updateDisplay() lcd.setCursor(0, 1); //see if the current menu is true or false or just a number if(currentMenu != static_cast(SettingID::SCHEDULE_NOTES) && - currentMenu != static_cast(SettingID::HANDLE_NOTES)) //if current menu is not a boolean menu + currentMenu != static_cast(SettingID::HANDLE_NOTES)) //if current menu is not a bool menu lcd.print(EEPROM.read(currentMenu)); else { diff --git a/ControlBox/lcd.h b/ControlBox/lcd.h index 50dab01..7c58a77 100644 --- a/ControlBox/lcd.h +++ b/ControlBox/lcd.h @@ -1,6 +1,8 @@ #ifndef LCD_H #define LCD_H +#include + enum class MenuStates { WELCOME, diff --git a/ControlBox/midi.cpp b/ControlBox/midi.cpp index 094955f..a0260a4 100644 --- a/ControlBox/midi.cpp +++ b/ControlBox/midi.cpp @@ -1,3 +1,9 @@ +#include +#include "midi.h" +#include "serial.h" + +void decodeMidi(uint8_t header, uint8_t byte1, uint8_t byte2, uint8_t byte3); + void checkForMidiUSB() { midiEventPacket_t rx; //midi data struct from midiUSB libray diff --git a/ControlBox/midi.h b/ControlBox/midi.h index 6d7ad6e..4cab924 100644 --- a/ControlBox/midi.h +++ b/ControlBox/midi.h @@ -1,6 +1,8 @@ #ifndef MIDI_H #define MIDI_H +#include + void checkForMidiUSB(); #endif \ No newline at end of file diff --git a/ControlBox/serial.h b/ControlBox/serial.h index 313019a..707e59d 100644 --- a/ControlBox/serial.h +++ b/ControlBox/serial.h @@ -1,6 +1,8 @@ #ifndef SERIAL_H #define SERIAL_H +#include + namespace SerialConstants { extern const uint8_t NOTE_HEADER; diff --git a/ControlBox/setting.cpp b/ControlBox/setting.cpp index 87dedf9..ab50b21 100644 --- a/ControlBox/setting.cpp +++ b/ControlBox/setting.cpp @@ -1,3 +1,5 @@ +#include +#include "setting.h" #include "lcd.h" #include "serial.h" #include "input.h" @@ -5,10 +7,10 @@ void changeSetting(int changeBy) { if(currentMenu != static_cast(SettingID::SCHEDULE_NOTES) && - currentMenu != static_cast(SettingID::HANDLE_NOTES)) //if current menu is not a boolean menu + currentMenu != static_cast(SettingID::HANDLE_NOTES)) //if current menu is not a bool menu EEPROM.write(currentMenu, EEPROM.read(currentMenu) + changeBy); else - EEPROM.write(currentMenu, !(static_cast(EEPROM.read(currentMenu)))); + EEPROM.write(currentMenu, !(static_cast(EEPROM.read(currentMenu)))); } void sendAllSettings() diff --git a/ControlBox/setting.h b/ControlBox/setting.h index 4a4a152..039be30 100644 --- a/ControlBox/setting.h +++ b/ControlBox/setting.h @@ -1,6 +1,8 @@ #ifndef SETTING_H #define SETTING_H +#include + enum class SettingID //same order as menus { HANDLE_NOTES, diff --git a/ESP32/ESP32.ino b/ESP32/ESP32.ino index 9970563..bbb22d6 100644 --- a/ESP32/ESP32.ino +++ b/ESP32/ESP32.ino @@ -1,17 +1,18 @@ -//#pragma GCC diagnostic push -//#pragma GCC diagnostic warning "-fpermissive" +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-fpermissive" +#include +#include +#include +#include #include "sustain.h" #include "settings.h" #include "serial.h" #include "note.h" #include "midi.h" -#include -#include -#include -#include -#include -//#pragma GCC diagnostic pop -const boolean DEBUG_MODE = false; +#include "bluetooth.h" +#include "main.h" +#pragma GCC diagnostic pop +const bool DEBUG_MODE = false; void resetAll() { @@ -76,4 +77,4 @@ void loop() resetAll(); nextReset = millis() + Setting::autoResetMs; } -} \ No newline at end of file +} diff --git a/ESP32/ESP32.vcxproj b/ESP32/ESP32.vcxproj index 7943958..807d4ec 100644 --- a/ESP32/ESP32.vcxproj +++ b/ESP32/ESP32.vcxproj @@ -113,6 +113,7 @@ + @@ -133,7 +134,7 @@ - + \ No newline at end of file diff --git a/ESP32/ESP32.vcxproj.filters b/ESP32/ESP32.vcxproj.filters index dd87934..eb40aec 100644 --- a/ESP32/ESP32.vcxproj.filters +++ b/ESP32/ESP32.vcxproj.filters @@ -36,6 +36,9 @@ Header Files + + Header Files + diff --git a/ESP32/__vm/Compile.vmps.xml b/ESP32/__vm/Compile.vmps.xml new file mode 100644 index 0000000..b26727b --- /dev/null +++ b/ESP32/__vm/Compile.vmps.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ESP32/__vm/Configuration.Debug.vmps.xml b/ESP32/__vm/Configuration.Debug.vmps.xml new file mode 100644 index 0000000..0e29f25 --- /dev/null +++ b/ESP32/__vm/Configuration.Debug.vmps.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ESP32/__vm/Upload.vmps.xml b/ESP32/__vm/Upload.vmps.xml new file mode 100644 index 0000000..b26727b --- /dev/null +++ b/ESP32/__vm/Upload.vmps.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ESP32/bluetooth.cpp b/ESP32/bluetooth.cpp index 316c958..726c3b4 100644 --- a/ESP32/bluetooth.cpp +++ b/ESP32/bluetooth.cpp @@ -1,9 +1,11 @@ -#include "bluetooth.h" -#include "midi.h" #include #include #include #include +#include +#include "bluetooth.h" +#include "midi.h" +#include "main.h" uint8_t attrStr[] ={ 0x00 }; //value range of a characteristic esp_attr_value_t gattsAttrVal = @@ -85,7 +87,7 @@ static void gattsEventHandler(esp_gatts_cb_event_t event, esp_gatt_if_t gattsInt break; case ESP_GATTS_WRITE_EVT: //when main device sends data - extern boolean acceptMidi; + extern bool acceptMidi; if(acceptMidi) decodeBluetooth(params->write.len, params->write.value); break; @@ -100,14 +102,14 @@ static void gattsEventHandler(esp_gatts_cb_event_t event, esp_gatt_if_t gattsInt break; case ESP_GATTS_CONNECT_EVT: //connection - esp_ble_conn_update_params_t conn_params ={ 0 }; + esp_ble_conn_update_params_t conn_params; memcpy(conn_params.bda, params->connect.remote_bda, sizeof(esp_bd_addr_t)); conn_params.latency = 0; conn_params.max_int = 0x30; conn_params.min_int = 0x20; conn_params.timeout = 500; esp_ble_gap_update_conn_params(&conn_params); - if(DEBUG_MODE) flashLED(); + //if(DEBUG_MODE) flashLED(); break; default: diff --git a/ESP32/bluetooth.h b/ESP32/bluetooth.h index fcabaad..97e3f3f 100644 --- a/ESP32/bluetooth.h +++ b/ESP32/bluetooth.h @@ -1,6 +1,8 @@ #ifndef BLUETOOTH_H #define BLUETOOTH_H +#include + void initializeBluetooth(); #endif \ No newline at end of file diff --git a/ESP32/main.h b/ESP32/main.h new file mode 100644 index 0000000..00b4df7 --- /dev/null +++ b/ESP32/main.h @@ -0,0 +1,8 @@ +#ifndef MAIN_H +#define MAIN_H + +extern const bool DEBUG_MODE; +void resetAll(); +void flashLED(); + +#endif \ No newline at end of file diff --git a/ESP32/midi.cpp b/ESP32/midi.cpp index a8a603b..9b6300a 100644 --- a/ESP32/midi.cpp +++ b/ESP32/midi.cpp @@ -2,6 +2,9 @@ #include "note.h" #include "sustain.h" #include "settings.h" +#include "main.h" + +void sendBluetoothToSerial(int lengthM, uint8_t* message); void decodeBluetooth(int lengthM, uint8_t* message) { diff --git a/ESP32/midi.h b/ESP32/midi.h index fcc933a..57af23d 100644 --- a/ESP32/midi.h +++ b/ESP32/midi.h @@ -1,6 +1,8 @@ #ifndef MIDI_H #define MIDI_H +#include + void decodeBluetooth(int lengthM, uint8_t* message); #endif \ No newline at end of file diff --git a/ESP32/note.cpp b/ESP32/note.cpp index 87baadb..eb4ffb0 100644 --- a/ESP32/note.cpp +++ b/ESP32/note.cpp @@ -1,7 +1,6 @@ #include "note.h" -#include "note.h" -#include "settings.h" #include "serial.h" +#include "main.h" Note notes[88]; @@ -233,7 +232,7 @@ void Note::calculateVolume(uint8_t& velocity) } } -void Note::updateInstance(boolean state) +void Note::updateInstance(bool state) { if(id < 44) { diff --git a/ESP32/note.h b/ESP32/note.h index 8e041b6..cd406da 100644 --- a/ESP32/note.h +++ b/ESP32/note.h @@ -1,6 +1,10 @@ #ifndef NOTE_H #define NOTE_H +#include +#include +#include "settings.h" + class Note { private: @@ -27,7 +31,7 @@ private: void scheduleNote(uint8_t velocity); void calculateVolume(uint8_t& volume); - void updateInstance(boolean state); + void updateInstance(bool state); void sendScheduleToSerial(); bool canBeScheduled(); public: diff --git a/ESP32/serial.cpp b/ESP32/serial.cpp index 16ab5a5..c9fe41c 100644 --- a/ESP32/serial.cpp +++ b/ESP32/serial.cpp @@ -2,6 +2,9 @@ #include "note.h" #include "sustain.h" #include "settings.h" +#include "main.h" + +void sendMidiToProMicro(byte note, byte velocity); //serial is always handled in bytes, not uint8_t because serial is dumb extern const byte NOTE_HEADER = 201; diff --git a/ESP32/serial.h b/ESP32/serial.h index 4b3a38a..58e6d68 100644 --- a/ESP32/serial.h +++ b/ESP32/serial.h @@ -1,6 +1,8 @@ #ifndef SERIAL_H #define SERIAL_H +#include + void checkForSerial(); void sendMidiToProMicro(byte note, byte velocity); void customSerialToProMicro(byte header, byte note, byte velocity); diff --git a/ESP32/settings.cpp b/ESP32/settings.cpp index bb91a50..1972264 100644 --- a/ESP32/settings.cpp +++ b/ESP32/settings.cpp @@ -5,14 +5,14 @@ //settings within the program int fullDelay = 0; -boolean acceptMidi = false; +bool acceptMidi = false; unsigned long nextReset = 0; //first reset will happen immediately //settings changed by the control box namespace Setting { - boolean handleNotes = true; - boolean scheduleNotes = true; + bool handleNotes = true; + bool scheduleNotes = true; int minNoteVelocity = 4; int minStartupMs = 18; int maxStartupMs = 18; diff --git a/ESP32/settings.h b/ESP32/settings.h index ef6a992..fc27a3a 100644 --- a/ESP32/settings.h +++ b/ESP32/settings.h @@ -1,6 +1,8 @@ #ifndef SETTINGS_H #define SETTINGS_H +#include + namespace SettingID //so a using statement can be used in the switch statement { enum SettingID @@ -26,13 +28,13 @@ namespace SettingID //so a using statement can be used in the switch statement } extern int fullDelay; -extern boolean acceptMidi; +extern bool acceptMidi; extern unsigned long nextReset; namespace Setting { - extern boolean handleNotes; - extern boolean scheduleNotes; + extern bool handleNotes; + extern bool scheduleNotes; extern int minNoteVelocity; extern int minSolenoidPWM; extern int minStartupMs; diff --git a/ESP32/sustain.cpp b/ESP32/sustain.cpp index 7fba116..64f7339 100644 --- a/ESP32/sustain.cpp +++ b/ESP32/sustain.cpp @@ -82,7 +82,7 @@ void Sustain::resetSchedule() ledcWrite(0, 0); } -void Sustain::scheduleSustain(boolean state) +void Sustain::scheduleSustain(bool state) { unsigned long ms = millis(); unsigned long msAndDelay = ms + fullDelay; diff --git a/ESP32/sustain.h b/ESP32/sustain.h index fe3cd60..b9ee162 100644 --- a/ESP32/sustain.h +++ b/ESP32/sustain.h @@ -1,6 +1,9 @@ #ifndef SUSTAIN_H #define SUSTAIN_H +#include +#include + class Sustain { private: @@ -16,7 +19,7 @@ private: int instances = 0; unsigned long timeSinceActivation = 0; - void scheduleSustain(boolean state); + void scheduleSustain(bool state); public: Sustain(); void prepareToSchedule(uint8_t velocity); diff --git a/ProMicro/ProMicro.ino b/ProMicro/ProMicro.ino index a3f8e5d..4fe9926 100644 --- a/ProMicro/ProMicro.ino +++ b/ProMicro/ProMicro.ino @@ -1,21 +1,9 @@ -//Latchpin: Pin 10 goes to second register input -//Datapin: Pin 16 goes to first register input -//Clockpin: Pin 15 goes to third register input -const int ShiftPWM_latchPin=18; //values assigned before includes -const bool ShiftPWM_invertOutputs = false; -const bool ShiftPWM_balanceLoad = false; +#include #include "shiftRegister.h" #include "serial.h" #include "midi.h" -#include -#include -#include -#include -#include -#include -#include -const bool DEBUG_MODE = false; +extern const bool DEBUG_MODE = false; void setup() { diff --git a/ProMicro/ProMicro.vcxproj b/ProMicro/ProMicro.vcxproj index b499c6b..cdd2310 100644 --- a/ProMicro/ProMicro.vcxproj +++ b/ProMicro/ProMicro.vcxproj @@ -80,7 +80,7 @@ $(ProjectDir)..\ProMicro;$(ProjectDir)..\..\..\..\Arduino\libraries\ShiftPWM-master;$(ProjectDir)..\..\..\..\Arduino\libraries\MIDIUSB-master\src;C:\Program Files (x86)\Arduino\libraries;$(ProjectDir)..\..\..\..\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\leonardo;C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include;C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\avr;C:\Program Files (x86)\Arduino\hardware\tools\avr\lib\gcc\avr\4.8.1\include;C:\Program Files (x86)\Arduino\hardware\tools\avr\lib\gcc\avr\4.9.2\include;C:\Program Files (x86)\Arduino\hardware\tools\avr\lib\gcc\avr\4.9.3\include;%(AdditionalIncludeDirectories) $(ProjectDir)__vm\.ProMicro.vsarduino.h;%(ForcedIncludeFiles) true - __AVR_atmega32u4__;__AVR_ATmega32U4__;__AVR_ATmega32u4__;F_CPU=16000000L;ARDUINO=10809;ARDUINO_AVR_LEONARDO;ARDUINO_ARCH_AVR;USB_VID=0x2341;USB_PID=0x8036;__cplusplus=201103L;_VMICRO_INTELLISENSE;%(PreprocessorDefinitions) + __AVR_atmega32u4__;__AVR_ATmega32U4__;__AVR_ATmega32u4__;_VMDEBUG=1;F_CPU=16000000L;ARDUINO=10809;ARDUINO_AVR_LEONARDO;ARDUINO_ARCH_AVR;USB_VID=0x2341;USB_PID=0x8036;__cplusplus=201103L;_VMICRO_INTELLISENSE;%(PreprocessorDefinitions) true diff --git a/ProMicro/__vm/.ProMicro.vsarduino.h b/ProMicro/__vm/.ProMicro.vsarduino.h index 9b9c09b..fd5fbe5 100644 --- a/ProMicro/__vm/.ProMicro.vsarduino.h +++ b/ProMicro/__vm/.ProMicro.vsarduino.h @@ -16,6 +16,7 @@ #define __AVR_atmega32u4__ #define __AVR_ATmega32U4__ #define __AVR_ATmega32u4__ +#define _VMDEBUG 1 #define F_CPU 16000000L #define ARDUINO 10809 #define ARDUINO_AVR_LEONARDO diff --git a/ProMicro/__vm/Compile.vmps.xml b/ProMicro/__vm/Compile.vmps.xml new file mode 100644 index 0000000..54fab9b --- /dev/null +++ b/ProMicro/__vm/Compile.vmps.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + 55 delay(500); //give pro micro time to inititalize before giving power to shift registers +56 pinMode(SHIFT_REGISTER_POWER_PIN, OUTPUT); +57 digitalWrite(SHIFT_REGISTER_POWER_PIN, HIGH); +58 +59 std::vector<unsigned long> testy[6]; +60 } +61 +-->62 void loop() +63 { +64 checkForSerial(); +65 +66 for(int noteIndex = 0; noteIndex < 88; noteIndex++) +67 { +68 notes[noteIndex].checkSchedule(); +69 notes[noteIndex].checkForErrors(); +70 } +71 sustain.checkSchedule(); + + + + + + + + \ No newline at end of file diff --git a/ProMicro/__vm/Configuration.Debug.vmps.xml b/ProMicro/__vm/Configuration.Debug.vmps.xml new file mode 100644 index 0000000..d045ed5 --- /dev/null +++ b/ProMicro/__vm/Configuration.Debug.vmps.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ProMicro/midi.cpp b/ProMicro/midi.cpp index ef519b8..703d8f3 100644 --- a/ProMicro/midi.cpp +++ b/ProMicro/midi.cpp @@ -1,5 +1,11 @@ +#include #include "midi.h" #include "shiftRegister.h" +#include "serial.h" + +void decodeMidi(uint8_t header, uint8_t byte1, uint8_t byte2, uint8_t byte3); + +extern const bool DEBUG_MODE; void checkForMidiUSB() { diff --git a/ProMicro/midi.h b/ProMicro/midi.h index 6d7ad6e..4cab924 100644 --- a/ProMicro/midi.h +++ b/ProMicro/midi.h @@ -1,6 +1,8 @@ #ifndef MIDI_H #define MIDI_H +#include + void checkForMidiUSB(); #endif \ No newline at end of file diff --git a/ProMicro/serial.cpp b/ProMicro/serial.cpp index 8543eb9..4598bb2 100644 --- a/ProMicro/serial.cpp +++ b/ProMicro/serial.cpp @@ -1,6 +1,7 @@ #include "serial.h" #include "shiftRegister.h" +extern const bool DEBUG_MODE; extern const uint8_t SUSTAIN_HEADER = 202; void checkForSerial() diff --git a/ProMicro/serial.h b/ProMicro/serial.h index 015f9dd..26e1b87 100644 --- a/ProMicro/serial.h +++ b/ProMicro/serial.h @@ -1,6 +1,8 @@ #ifndef SERIAL_H #define SERIAL_H +#include + void checkForSerial(); void sendSerialToMain(byte header, byte setting, byte value); void sendSerialToUSB(String* message, int lengthOfMessage); diff --git a/ProMicro/shiftRegister.cpp b/ProMicro/shiftRegister.cpp index 5df5cf5..74c8790 100644 --- a/ProMicro/shiftRegister.cpp +++ b/ProMicro/shiftRegister.cpp @@ -1,5 +1,15 @@ +//Latchpin: Pin 10 goes to second register input +//Datapin: Pin 16 goes to first register input +//Clockpin: Pin 15 goes to third register input +const int ShiftPWM_latchPin=18; //values assigned before includes +const bool ShiftPWM_invertOutputs = false; +const bool ShiftPWM_balanceLoad = false; +#include +#include #include "shiftRegister.h" +void conformVelocity(uint8_t& velocity); + extern uint8_t pwmPercent = 45; const char MAX_PWM = 235; diff --git a/ProMicro/shiftRegister.h b/ProMicro/shiftRegister.h index 8b4f882..1351335 100644 --- a/ProMicro/shiftRegister.h +++ b/ProMicro/shiftRegister.h @@ -1,6 +1,8 @@ #ifndef SHIFT_REGISTER_H #define SHIFT_REGISTER_H +#include + extern uint8_t pwmPercent; void intitializeRegisters();