first tests
This commit is contained in:
commit
05ed27c001
30 changed files with 1062 additions and 0 deletions
5
Hairless MIDI Serial Bridge.url
Normal file
5
Hairless MIDI Serial Bridge.url
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[{000214A0-0000-0000-C000-000000000046}]
|
||||||
|
Prop3=19,2
|
||||||
|
[InternetShortcut]
|
||||||
|
IDList=
|
||||||
|
URL=http://projectgus.github.io/hairless-midiserial/
|
1
miditest/.gitignore
vendored
Normal file
1
miditest/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.pio
|
67
miditest/.travis.yml
Normal file
67
miditest/.travis.yml
Normal file
|
@ -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
|
57
miditest/.vscode/c_cpp_properties.json
vendored
Normal file
57
miditest/.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -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
|
||||||
|
}
|
7
miditest/.vscode/extensions.json
vendored
Normal file
7
miditest/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"platformio.platformio-ide"
|
||||||
|
]
|
||||||
|
}
|
32
miditest/.vscode/launch.json
vendored
Normal file
32
miditest/.vscode/launch.json
vendored
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
39
miditest/include/README
Normal file
39
miditest/include/README
Normal file
|
@ -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
|
46
miditest/lib/README
Normal file
46
miditest/lib/README
Normal file
|
@ -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 <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
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
|
14
miditest/platformio.ini
Normal file
14
miditest/platformio.ini
Normal file
|
@ -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
|
90
miditest/src/main.cpp
Normal file
90
miditest/src/main.cpp
Normal file
|
@ -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
|
1
miditoservo/.gitignore
vendored
Normal file
1
miditoservo/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.pio
|
67
miditoservo/.travis.yml
Normal file
67
miditoservo/.travis.yml
Normal file
|
@ -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
|
5
miditoservo/.vscode/arduino.json
vendored
Normal file
5
miditoservo/.vscode/arduino.json
vendored
Normal file
|
@ -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"
|
||||||
|
}
|
62
miditoservo/.vscode/c_cpp_properties.json
vendored
Normal file
62
miditoservo/.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -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
|
||||||
|
}
|
7
miditoservo/.vscode/extensions.json
vendored
Normal file
7
miditoservo/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"platformio.platformio-ide"
|
||||||
|
]
|
||||||
|
}
|
32
miditoservo/.vscode/launch.json
vendored
Normal file
32
miditoservo/.vscode/launch.json
vendored
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
39
miditoservo/include/README
Normal file
39
miditoservo/include/README
Normal file
|
@ -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
|
46
miditoservo/lib/README
Normal file
46
miditoservo/lib/README
Normal file
|
@ -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 <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
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
|
18
miditoservo/platformio.ini
Normal file
18
miditoservo/platformio.ini
Normal file
|
@ -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
|
77
miditoservo/src/main.cpp
Normal file
77
miditoservo/src/main.cpp
Normal file
|
@ -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.h>
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
1
miditoservo_cont/.gitignore
vendored
Normal file
1
miditoservo_cont/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.pio
|
67
miditoservo_cont/.travis.yml
Normal file
67
miditoservo_cont/.travis.yml
Normal file
|
@ -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
|
5
miditoservo_cont/.vscode/arduino.json
vendored
Normal file
5
miditoservo_cont/.vscode/arduino.json
vendored
Normal file
|
@ -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"
|
||||||
|
}
|
59
miditoservo_cont/.vscode/c_cpp_properties.json
vendored
Normal file
59
miditoservo_cont/.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -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
|
||||||
|
}
|
7
miditoservo_cont/.vscode/extensions.json
vendored
Normal file
7
miditoservo_cont/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"platformio.platformio-ide"
|
||||||
|
]
|
||||||
|
}
|
32
miditoservo_cont/.vscode/launch.json
vendored
Normal file
32
miditoservo_cont/.vscode/launch.json
vendored
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
39
miditoservo_cont/include/README
Normal file
39
miditoservo_cont/include/README
Normal file
|
@ -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
|
46
miditoservo_cont/lib/README
Normal file
46
miditoservo_cont/lib/README
Normal file
|
@ -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 <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
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
|
18
miditoservo_cont/platformio.ini
Normal file
18
miditoservo_cont/platformio.ini
Normal file
|
@ -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
|
76
miditoservo_cont/src/main.cpp
Normal file
76
miditoservo_cont/src/main.cpp
Normal file
|
@ -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.h>
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue