commit 05ed27c0013380c2252dfdb928a5219c5b08f11a Author: Philipp Kramer Date: Wed May 13 15:53:03 2020 +0200 first tests diff --git a/Hairless MIDI Serial Bridge.url b/Hairless MIDI Serial Bridge.url new file mode 100644 index 0000000..654b7b5 --- /dev/null +++ b/Hairless MIDI Serial Bridge.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,2 +[InternetShortcut] +IDList= +URL=http://projectgus.github.io/hairless-midiserial/ diff --git a/miditest/.gitignore b/miditest/.gitignore new file mode 100644 index 0000000..03f4a3c --- /dev/null +++ b/miditest/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/miditest/.travis.yml b/miditest/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/miditest/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/miditest/.vscode/c_cpp_properties.json b/miditest/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..7856870 --- /dev/null +++ b/miditest/.vscode/c_cpp_properties.json @@ -0,0 +1,57 @@ +{ + "configurations": [ + { + "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags" + }, + { + "name": "Win32", + "includePath": [ + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/hairless-midiserial/miditest/include", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/hairless-midiserial/miditest/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "C:/Users/philipp.kramer/.platformio/packages/tool-unity", + "" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "path": [ + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/hairless-midiserial/miditest/include", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/hairless-midiserial/miditest/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "C:/Users/philipp.kramer/.platformio/packages/tool-unity", + "" + ] + }, + "defines": [ + "PLATFORMIO=40303", + "ARDUINO_AVR_PRO", + "F_CPU=16000000L", + "ARDUINO_ARCH_AVR", + "ARDUINO=10808", + "__AVR_ATmega328P__", + "" + ], + "intelliSenseMode": "clang-x64", + "cStandard": "c11", + "cppStandard": "c++11", + "compilerPath": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe", + "compilerArgs": [ + "-mmcu=atmega328p", + "" + ] + } + ], + "version": 4 +} diff --git a/miditest/.vscode/extensions.json b/miditest/.vscode/extensions.json new file mode 100644 index 0000000..e80666b --- /dev/null +++ b/miditest/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/miditest/.vscode/launch.json b/miditest/.vscode/launch.json new file mode 100644 index 0000000..09c0fd7 --- /dev/null +++ b/miditest/.vscode/launch.json @@ -0,0 +1,32 @@ +// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY + +// PIO Unified Debugger +// +// Documentation: https://docs.platformio.org/page/plus/debugging.html +// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html + +{ + "version": "0.2.0", + "configurations": [ + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug", + "executable": "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/hairless-midiserial/miditest/.pio/build/pro16MHzatmega328/firmware.elf", + "toolchainBinDir": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin", + "preLaunchTask": { + "type": "PlatformIO", + "task": "Pre-Debug" + }, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug (skip Pre-Debug)", + "executable": "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/hairless-midiserial/miditest/.pio/build/pro16MHzatmega328/firmware.elf", + "toolchainBinDir": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} \ No newline at end of file diff --git a/miditest/include/README b/miditest/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/miditest/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/miditest/lib/README b/miditest/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/miditest/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/miditest/platformio.ini b/miditest/platformio.ini new file mode 100644 index 0000000..2199eda --- /dev/null +++ b/miditest/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:pro16MHzatmega328] +platform = atmelavr +board = pro16MHzatmega328 +framework = arduino diff --git a/miditest/src/main.cpp b/miditest/src/main.cpp new file mode 100644 index 0000000..ef32e99 --- /dev/null +++ b/miditest/src/main.cpp @@ -0,0 +1,90 @@ +#include "Arduino.h" + + + +#define CODE_RECEIVETEST + +#ifdef CODE_SENDTEST + +//https://elektro.turanis.de/html/prj151/index.html +void MIDImessage(byte command, byte data1, byte data2); + +byte noteON = 144; // note on command + +void setup() +{ + // set "Hairless MIDI" to the same baud rate in the preferences + Serial.begin(115200); +} + +void loop() +{ + MIDImessage(noteON, 60, 100); // turn note on + delay(300); + MIDImessage(noteON, 60, 0); // turn note off (note on with velocity 0) + delay(200); +} + +void MIDImessage(byte command, byte data1, byte data2) +{ + Serial.write(command); + Serial.write(data1); + Serial.write(data2); +} + +#endif + +#ifdef CODE_RECEIVETEST + +// https://www.instructables.com/id/Send-and-Receive-...> + + + +byte commandByte; +byte noteByte; +byte velocityByte; + +byte noteOn = 144; + +//light up led at pin 13 when receiving noteON message with note = 60 + +void checkMIDI(); + +void setup(){ + Serial.begin(115200); + pinMode(13,OUTPUT); + + digitalWrite(13,HIGH); + delay(500); + digitalWrite(13,LOW); +} + +void loop(){ + checkMIDI(); + delay(100); + digitalWrite(13,LOW);//turn led off +} + +void checkMIDI(){ + do{ + if (Serial.available()){ + commandByte = Serial.read();//read first byte + noteByte = Serial.read();//read next byte + velocityByte = Serial.read();//read final byte + if (commandByte == noteOn){//if note on message + //check if note == 60 and velocity > 0 + if (noteByte == 60 && velocityByte > 0){ + digitalWrite(13,HIGH);//turn on led + } + } + } + } + while (Serial.available() > 2);//when at least three bytes available +} + + + + + + +#endif \ No newline at end of file diff --git a/miditoservo/.gitignore b/miditoservo/.gitignore new file mode 100644 index 0000000..03f4a3c --- /dev/null +++ b/miditoservo/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/miditoservo/.travis.yml b/miditoservo/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/miditoservo/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/miditoservo/.vscode/arduino.json b/miditoservo/.vscode/arduino.json new file mode 100644 index 0000000..7370046 --- /dev/null +++ b/miditoservo/.vscode/arduino.json @@ -0,0 +1,5 @@ +{ + "board": "esp8266:esp8266:d1", + "configuration": "xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600", + "port": "COM5" +} \ No newline at end of file diff --git a/miditoservo/.vscode/c_cpp_properties.json b/miditoservo/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..531d196 --- /dev/null +++ b/miditoservo/.vscode/c_cpp_properties.json @@ -0,0 +1,62 @@ +{ + "configurations": [ + { + "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags" + }, + { + "name": "Win32", + "includePath": [ + "C:\\Users\\philipp.kramer\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**", + "C:\\Users\\philipp.kramer\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.3\\**", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/include", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/src", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/.pio/libdeps/pro16MHzatmega328/Servo_ID883/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "C:/Users/philipp.kramer/.platformio/packages/tool-unity", + "" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "path": [ + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/include", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/src", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/.pio/libdeps/pro16MHzatmega328/Servo_ID883/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "C:/Users/philipp.kramer/.platformio/packages/tool-unity", + "" + ] + }, + "defines": [ + "PLATFORMIO=40303", + "ARDUINO_AVR_PRO", + "F_CPU=16000000L", + "ARDUINO_ARCH_AVR", + "ARDUINO=10808", + "__AVR_ATmega328P__", + "" + ], + "intelliSenseMode": "clang-x64", + "cStandard": "c11", + "cppStandard": "c++11", + "compilerPath": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe", + "compilerArgs": [ + "-mmcu=atmega328p", + "" + ], + "forcedInclude": [] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/miditoservo/.vscode/extensions.json b/miditoservo/.vscode/extensions.json new file mode 100644 index 0000000..e80666b --- /dev/null +++ b/miditoservo/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/miditoservo/.vscode/launch.json b/miditoservo/.vscode/launch.json new file mode 100644 index 0000000..532afdf --- /dev/null +++ b/miditoservo/.vscode/launch.json @@ -0,0 +1,32 @@ +// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY + +// PIO Unified Debugger +// +// Documentation: https://docs.platformio.org/page/plus/debugging.html +// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html + +{ + "version": "0.2.0", + "configurations": [ + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug", + "executable": "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/.pio/build/pro16MHzatmega328/firmware.elf", + "toolchainBinDir": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin", + "preLaunchTask": { + "type": "PlatformIO", + "task": "Pre-Debug" + }, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug (skip Pre-Debug)", + "executable": "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo/.pio/build/pro16MHzatmega328/firmware.elf", + "toolchainBinDir": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} \ No newline at end of file diff --git a/miditoservo/include/README b/miditoservo/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/miditoservo/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/miditoservo/lib/README b/miditoservo/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/miditoservo/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/miditoservo/platformio.ini b/miditoservo/platformio.ini new file mode 100644 index 0000000..f040cf7 --- /dev/null +++ b/miditoservo/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:pro16MHzatmega328] +platform = atmelavr +board = pro16MHzatmega328 +framework = arduino + +lib_deps = + # Using library Id + 883 \ No newline at end of file diff --git a/miditoservo/src/main.cpp b/miditoservo/src/main.cpp new file mode 100644 index 0000000..3219a38 --- /dev/null +++ b/miditoservo/src/main.cpp @@ -0,0 +1,77 @@ +#include "Arduino.h" + + + +// https://www.instructables.com/id/Send-and-Receive-...> + + + +byte commandByte; +byte noteByte; +byte velocityByte; + +byte noteOn = 144; +byte noteOff = 128; + +byte control = 176; + +//light up led at pin 13 when receiving noteON message with note = 60 + +void checkMIDI(); + + +#include + +Servo myservo; // create servo object to control a servo + +int val; // variable to read the value from the analog pin + +void setup(){ + Serial.begin(115200); + pinMode(13,OUTPUT); + + myservo.attach(9); // attaches the servo on pin 9 to the servo object + + digitalWrite(13,HIGH); + delay(500); + digitalWrite(13,LOW); +} + +void loop(){ + checkMIDI(); + delay(10); +} + +// commands https://www.midi.org/specifications-old/item/table-2-expanded-messages-list-status-bytes + +void checkMIDI(){ + do{ + if (Serial.available()){ + commandByte = Serial.read();//read first byte + noteByte = Serial.read();//read next byte + velocityByte = Serial.read();//read final byte + if (commandByte == noteOn){//if note on message + //check if note == 60 and velocity > 0 + if (noteByte == 60 && velocityByte > 0){ + digitalWrite(13,HIGH);//turn on led + val = 180; + myservo.write(val); // sets the servo position according to the scaled value + } + }else if (commandByte == noteOff){ + if (noteByte == 60){ + digitalWrite(13,LOW);//turn off led + val = 0; + myservo.write(val); + } + }else if (commandByte == control){ + if (noteByte == 1){ + digitalWrite(13,!digitalRead(13));//turn off led + val = map(velocityByte, 0,127,0,180); + myservo.write(val); + } + } + } + } + while (Serial.available() > 2);//when at least three bytes available +} + diff --git a/miditoservo_cont/.gitignore b/miditoservo_cont/.gitignore new file mode 100644 index 0000000..03f4a3c --- /dev/null +++ b/miditoservo_cont/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/miditoservo_cont/.travis.yml b/miditoservo_cont/.travis.yml new file mode 100644 index 0000000..7c486f1 --- /dev/null +++ b/miditoservo_cont/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/miditoservo_cont/.vscode/arduino.json b/miditoservo_cont/.vscode/arduino.json new file mode 100644 index 0000000..7370046 --- /dev/null +++ b/miditoservo_cont/.vscode/arduino.json @@ -0,0 +1,5 @@ +{ + "board": "esp8266:esp8266:d1", + "configuration": "xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600", + "port": "COM5" +} \ No newline at end of file diff --git a/miditoservo_cont/.vscode/c_cpp_properties.json b/miditoservo_cont/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..4db7468 --- /dev/null +++ b/miditoservo_cont/.vscode/c_cpp_properties.json @@ -0,0 +1,59 @@ +{ + "configurations": [ + { + "name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags" + }, + { + "name": "Win32", + "includePath": [ + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/include", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/src", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/.pio/libdeps/pro16MHzatmega328/Servo_ID883/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "C:/Users/philipp.kramer/.platformio/packages/tool-unity", + "" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "path": [ + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/include", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/src", + "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/.pio/libdeps/pro16MHzatmega328/Servo_ID883/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "C:/Users/philipp.kramer/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "C:/Users/philipp.kramer/.platformio/packages/tool-unity", + "" + ] + }, + "defines": [ + "PLATFORMIO=40303", + "ARDUINO_AVR_PRO", + "F_CPU=16000000L", + "ARDUINO_ARCH_AVR", + "ARDUINO=10808", + "__AVR_ATmega328P__", + "" + ], + "intelliSenseMode": "clang-x64", + "cStandard": "c11", + "cppStandard": "c++11", + "compilerPath": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe", + "compilerArgs": [ + "-mmcu=atmega328p", + "" + ] + } + ], + "version": 4 +} diff --git a/miditoservo_cont/.vscode/extensions.json b/miditoservo_cont/.vscode/extensions.json new file mode 100644 index 0000000..e80666b --- /dev/null +++ b/miditoservo_cont/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/miditoservo_cont/.vscode/launch.json b/miditoservo_cont/.vscode/launch.json new file mode 100644 index 0000000..423c8f9 --- /dev/null +++ b/miditoservo_cont/.vscode/launch.json @@ -0,0 +1,32 @@ +// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY + +// PIO Unified Debugger +// +// Documentation: https://docs.platformio.org/page/plus/debugging.html +// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html + +{ + "version": "0.2.0", + "configurations": [ + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug", + "executable": "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/.pio/build/pro16MHzatmega328/firmware.elf", + "toolchainBinDir": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin", + "preLaunchTask": { + "type": "PlatformIO", + "task": "Pre-Debug" + }, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug (skip Pre-Debug)", + "executable": "c:/Users/philipp.kramer/OneDrive - Akademie für Theater und Digitalität/Akademie/midi-arduino/miditoservo_cont/.pio/build/pro16MHzatmega328/firmware.elf", + "toolchainBinDir": "C:/Users/philipp.kramer/.platformio/packages/toolchain-atmelavr/bin", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} \ No newline at end of file diff --git a/miditoservo_cont/include/README b/miditoservo_cont/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/miditoservo_cont/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/miditoservo_cont/lib/README b/miditoservo_cont/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/miditoservo_cont/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/miditoservo_cont/platformio.ini b/miditoservo_cont/platformio.ini new file mode 100644 index 0000000..f040cf7 --- /dev/null +++ b/miditoservo_cont/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:pro16MHzatmega328] +platform = atmelavr +board = pro16MHzatmega328 +framework = arduino + +lib_deps = + # Using library Id + 883 \ No newline at end of file diff --git a/miditoservo_cont/src/main.cpp b/miditoservo_cont/src/main.cpp new file mode 100644 index 0000000..8fad35b --- /dev/null +++ b/miditoservo_cont/src/main.cpp @@ -0,0 +1,76 @@ +#include "Arduino.h" + + + +// https://www.instructables.com/id/Send-and-Receive-...> + + + +byte commandByte; +byte noteByte; +byte velocityByte; + +byte noteOn = 144; +byte noteOff = 128; + +byte control = 176; + +//light up led at pin 13 when receiving noteON message with note = 60 + +void checkMIDI(); + + +#include + +Servo myservo; // create servo object to control a servo + +int servocenter = 90; +int servospeed = 50; + +void setup(){ + Serial.begin(115200); + pinMode(13,OUTPUT); + + myservo.attach(9); // attaches the servo on pin 9 to the servo object + + digitalWrite(13,HIGH); + delay(500); + digitalWrite(13,LOW); +} + +void loop(){ + checkMIDI(); + delay(10); +} + +// commands https://www.midi.org/specifications-old/item/table-2-expanded-messages-list-status-bytes + +void checkMIDI(){ + do{ + if (Serial.available()){ + commandByte = Serial.read();//read first byte + noteByte = Serial.read();//read next byte + velocityByte = Serial.read();//read final byte + if (commandByte == noteOn){//if note on message + //check if note == 60 and velocity > 0 + if (noteByte == 60 && velocityByte > 0){ + digitalWrite(13,HIGH);//turn on led + myservo.write(servocenter+servospeed); // sets the servo position according to the scaled value + } + }else if (commandByte == noteOff){ + if (noteByte == 60){ + digitalWrite(13,LOW);//turn off led + myservo.write(servocenter); + } + }else if (commandByte == control){ + if (noteByte == 1){ + digitalWrite(13,!digitalRead(13));//turn off led + servocenter = 90 + map(velocityByte, 0,127,-40,40); + myservo.write(servocenter); + } + } + } + } + while (Serial.available() > 2);//when at least three bytes available +} +