portage under control surface lib done
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
-I/home/nathan/.platformio/packages/framework-arduinoavr/cores/arduino
|
||||
-I/home/nathan/.platformio/packages/framework-arduinoavr/variants/micro
|
||||
-I/home/nathan/.platformio/lib/MIDI controller/src
|
||||
-I/home/nathan/.platformio/lib/MIDIUSB_ID1104/src
|
||||
-I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SoftwareSerial/src
|
||||
-I/home/nathan/.platformio/lib/ArduinoJson_ID64/src
|
||||
-I/home/nathan/.platformio/lib/Keypad_ID165/src
|
||||
-I/home/nathan/.platformio/lib/PubSubClient_ID89/src
|
||||
-I/home/nathan/.platformio/lib/Tone_ID1420
|
||||
-I/home/nathan/.platformio/lib/WifiManager_ID567
|
||||
-I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/EEPROM/src
|
||||
-I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/HID/src
|
||||
-I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SPI/src
|
||||
-I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/Wire/src
|
||||
-I/home/nathan/.platformio/packages/toolchain-atmelavr/avr/include
|
||||
-I/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed
|
||||
-I/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include
|
||||
-I/home/nathan/.platformio/packages/tool-unity
|
||||
-I/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/include
|
||||
-I/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/src
|
||||
-DPLATFORMIO=40000
|
||||
-DARDUINO_AVR_MICRO
|
||||
-DF_CPU=16000000L
|
||||
-DARDUINO_ARCH_AVR
|
||||
-DARDUINO=10805
|
||||
-DUSB_VID=0x2341
|
||||
-DUSB_PID=0x0037
|
||||
-DUSB_PRODUCT="Arduino Micro"
|
||||
-DUSB_MANUFACTURER="Arduino"
|
||||
-D__AVR_ATmega32U4__
|
||||
@@ -1,6 +0,0 @@
|
||||
[Dolphin]
|
||||
Timestamp=2019,2,5,20,24,51
|
||||
Version=4
|
||||
|
||||
[Settings]
|
||||
HiddenFilesShown=true
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"execPath": "/home/nathan/.platformio/packages/toolchain-atmelavr/bin/avr-g++",
|
||||
"gccDefaultCFlags": "-fsyntax-only -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega32u4 -DPLATFORMIO=40000 -DARDUINO_AVR_MICRO -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=10805 -DUSB_VID=0x2341 -DUSB_PID=0x0037 -DUSB_PRODUCT=\"Arduino Micro\" -DUSB_MANUFACTURER=\"Arduino\" -D__AVR_ATmega32U4__",
|
||||
"gccDefaultCppFlags": "-fsyntax-only -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega32u4 -DPLATFORMIO=40000 -DARDUINO_AVR_MICRO -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=10805 -DUSB_VID=0x2341 -DUSB_PID=0x0037 -DUSB_PRODUCT=\"Arduino Micro\" -DUSB_MANUFACTURER=\"Arduino\" -D__AVR_ATmega32U4__",
|
||||
"gccErrorLimit": 15,
|
||||
"gccIncludePaths": "/home/nathan/.platformio/packages/framework-arduinoavr/cores/arduino,/home/nathan/.platformio/packages/framework-arduinoavr/variants/micro,/home/nathan/.platformio/lib/MIDI controller/src,/home/nathan/.platformio/lib/MIDIUSB_ID1104/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SoftwareSerial/src,/home/nathan/.platformio/lib/ArduinoJson_ID64/src,/home/nathan/.platformio/lib/Keypad_ID165/src,/home/nathan/.platformio/lib/PubSubClient_ID89/src,/home/nathan/.platformio/lib/Tone_ID1420,/home/nathan/.platformio/lib/WifiManager_ID567,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/EEPROM/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/HID/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SPI/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/Wire/src,/home/nathan/.platformio/packages/toolchain-atmelavr/avr/include,/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed,/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include,/home/nathan/.platformio/packages/tool-unity,/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/include,/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/src",
|
||||
"gccSuppressWarnings": false
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
Processing micro (platform: atmelavr; board: micro; framework: arduino)
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Verbose mode can be enabled via `-v, --verbose` option
|
||||
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/micro.html
|
||||
PLATFORM: Atmel AVR > Arduino Micro
|
||||
HARDWARE: ATMEGA32U4 16MHz 2.50KB RAM (28KB Flash)
|
||||
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
|
||||
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
|
||||
Collected 12 compatible libraries
|
||||
Scanning dependencies...
|
||||
Dependency Graph
|
||||
|-- <MIDI controller> 3.1.0 #e895a51
|
||||
| |-- <MIDIUSB> 1.0.3
|
||||
| |-- <SoftwareSerial> 1.0
|
||||
Compiling .pioenvs/micro/src/main.cpp.o
|
||||
Compiling .pioenvs/micro/lib7af/MIDI controller/MIDI_Outputs/Digital.cpp.o
|
||||
Compiling .pioenvs/micro/lib7af/MIDI controller/MIDI_Outputs/DigitalCC.cpp.o
|
||||
Compiling .pioenvs/micro/lib7af/MIDI controller/MIDI_Outputs/DigitalLatch.cpp.o
|
||||
+12
-3
@@ -9,11 +9,13 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
default_envs = micro_debug
|
||||
default_envs = micro
|
||||
|
||||
[env]
|
||||
build_flags = -Wall
|
||||
lib_deps =
|
||||
SPI
|
||||
Adafruit MPR121
|
||||
Control Surface
|
||||
MIDIUSB
|
||||
|
||||
@@ -21,8 +23,15 @@ lib_deps =
|
||||
platform = atmelavr
|
||||
board = micro
|
||||
framework = arduino
|
||||
board_build.f_cpu = 16000000L
|
||||
|
||||
[env:micro_debug]
|
||||
[env:debug]
|
||||
platform = atmelavr
|
||||
build_type = debug
|
||||
extends = env:micro
|
||||
build_flags = -D DEBUG_MAIN
|
||||
|
||||
[env:matrix]
|
||||
platform = atmelavr
|
||||
build_type = debug
|
||||
extends = env:micro
|
||||
build_flags = -D DEBUG_MATRIX
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 633 KiB |
Binary file not shown.
Binary file not shown.
+142
-188
@@ -1,18 +1,22 @@
|
||||
#include <Arduino.h>
|
||||
#include <Control_Surface.h>
|
||||
#include <Adafruit_MPR121.h>
|
||||
|
||||
#define s * 1000
|
||||
#ifndef DEBUG_MAIN
|
||||
#include <Control_Surface.h>
|
||||
|
||||
#define NOTE_ON_CMD 0x90
|
||||
#define NOTE_OFF_CMD 0x80
|
||||
#define NOTE_VELOCITY 127
|
||||
#define ON 127
|
||||
#define OFF 0
|
||||
|
||||
|
||||
#ifndef __PLATFORMIO_BUILD_DEBUG__
|
||||
// Instantiate a MIDI Interface to use
|
||||
// USBMIDI_Interface midi;
|
||||
USBMIDI_Interface midi;
|
||||
#else /* __PLATFORMIO_BUILD_DEBUG__ */
|
||||
// Instantiate a MIDI Interface to use
|
||||
USBDebugMIDI_Interface midi{115200};
|
||||
#endif /* __PLATFORMIO_BUILD_DEBUG__ */
|
||||
|
||||
Channel channel{CHANNEL_2};
|
||||
|
||||
/* Pins */
|
||||
/* GPIO (I2C) */
|
||||
@@ -33,209 +37,159 @@ const uint8_t shift_clock{1};
|
||||
const uint8_t keyboard_in[KEYBOARD_INSIZE]{4, 5, 6, 7, 8, 9};
|
||||
|
||||
/* Components */
|
||||
/* CapaSensor (I2C) */
|
||||
Adafruit_MPR121 capa_sensor = Adafruit_MPR121();
|
||||
/* GPIO (I2C) */
|
||||
/* Multiplexer */
|
||||
CD74HC4067 multiplexer{mux_sig, mux_addr, mux_en};
|
||||
/* ShiftRegister (OUT) */
|
||||
ShiftRegisterOut<2> shiftRegister(shift_data, shift_clock, shift_latch, MSBFIRST);
|
||||
// ShiftRegisterOut<2> shiftRegister(shift_data, shift_clock, shift_latch, MSBFIRST);
|
||||
/* keyboard (IN) */
|
||||
|
||||
/* Midi links */
|
||||
// USBDebugMIDI_Interface midiInterface(115200);
|
||||
|
||||
CCPotentiometer potentiometers[] = {
|
||||
{multiplexer.pin(0), {MIDI_CC::Channel_Volume, CHANNEL_1}},
|
||||
{multiplexer.pin(1), {MIDI_CC::Channel_Volume, CHANNEL_2}},
|
||||
{multiplexer.pin(2), {MIDI_CC::Channel_Volume, CHANNEL_3}},
|
||||
{multiplexer.pin(3), {MIDI_CC::Channel_Volume, CHANNEL_4}},
|
||||
{multiplexer.pin(4), {MIDI_CC::Channel_Volume, CHANNEL_5}},
|
||||
{multiplexer.pin(5), {MIDI_CC::Channel_Volume, CHANNEL_6}},
|
||||
{multiplexer.pin(6), {MIDI_CC::Channel_Volume, CHANNEL_7}},
|
||||
{multiplexer.pin(7), {MIDI_CC::Channel_Volume, CHANNEL_8}},
|
||||
{multiplexer.pin(8), {MIDI_CC::Channel_Volume, CHANNEL_9}},
|
||||
{multiplexer.pin(9), {MIDI_CC::Channel_Volume, CHANNEL_10}},
|
||||
{multiplexer.pin(0), {1, channel}},
|
||||
{multiplexer.pin(1), {2, channel}},
|
||||
{multiplexer.pin(2), {3, channel}},
|
||||
{multiplexer.pin(3), {4, channel}},
|
||||
{multiplexer.pin(4), {5, channel}},
|
||||
{multiplexer.pin(5), {6, channel}},
|
||||
{multiplexer.pin(6), {7, channel}},
|
||||
{multiplexer.pin(7), {8, channel}},
|
||||
{multiplexer.pin(8), {9, channel}},
|
||||
{multiplexer.pin(9), {10, channel}},
|
||||
};
|
||||
|
||||
byte matrix[16][6][2] = {
|
||||
/*00*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*01*/ {{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}},
|
||||
/*02*/ {{1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}},
|
||||
/*03*/ {{1, 18}, {1, 19}, {1, 20}, {1, 21}, {1, 22}, {1, 23}},
|
||||
/*04*/ {{1, 47}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*05*/ {{1, 41}, {1, 42}, {1, 43}, {1, 44}, {1, 45}, {1, 46}},
|
||||
/*06*/ {{1, 36}, {1, 37}, {1, 38}, {1, 39}, {1, 40}, {1, 40}},
|
||||
/*07*/ {{1, 30}, {1, 31}, {1, 32}, {1, 33}, {1, 34}, {1, 35}},
|
||||
/*08*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*09*/ {{1, 24}, {1, 25}, {1, 26}, {1, 27}, {1, 28}, {1, 29}},
|
||||
/*10*/ {{1, 12}, {1, 13}, {1, 14}, {1, 15}, {1, 16}, {1, 17}},
|
||||
/*11*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*12*/ {{2, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*13*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*14*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*15*/ {{2, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/* 0 | 1 | 2 | 3 | 4 | 5 */
|
||||
/*0*/ {{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}},
|
||||
/*1*/ {{1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}},
|
||||
/*2*/ {{1, 18}, {1, 19}, {1, 20}, {1, 21}, {1, 22}, {1, 23}},
|
||||
/*3*/ {{1, 48}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*4*/ {{1, 42}, {1, 43}, {1, 44}, {1, 45}, {1, 46}, {1, 47}},
|
||||
/*5*/ {{1, 36}, {1, 37}, {1, 38}, {1, 39}, {1, 40}, {1, 41}},
|
||||
/*6*/ {{1, 30}, {1, 31}, {1, 32}, {1, 33}, {1, 34}, {1, 35}},
|
||||
/*7*/ {{1, 24}, {1, 25}, {1, 26}, {1, 27}, {1, 28}, {1, 29}},
|
||||
/*8*/ {{1, 12}, {1, 13}, {1, 14}, {1, 15}, {1, 16}, {1, 17}},
|
||||
/*a*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*b*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*c*/ {{2, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*d*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*e*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
/*f*/ {{2, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
|
||||
};
|
||||
|
||||
bool ref[6*16];
|
||||
bool ref[16][6] = {{false}};
|
||||
|
||||
unsigned char shift = 0;
|
||||
|
||||
void setup() {
|
||||
// Serial.begin(31250);
|
||||
// while (Serial.available() == 0){
|
||||
// delay(.5 s);
|
||||
// }
|
||||
|
||||
// Serial.print("Serial OK");
|
||||
|
||||
midi.begin();
|
||||
|
||||
for (size_t i = 0; i < KEYBOARD_INSIZE; ++i) {
|
||||
ExtIO::pinMode(keyboard_in[i], INPUT);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 6*16; ++i) {
|
||||
ref[i] = false;
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
for (size_t j = 0; j < 6; j++)
|
||||
{
|
||||
ref[i][j] = false;
|
||||
}
|
||||
}
|
||||
// ExtIO::pinMode(shift_data, OUTPUT);
|
||||
// ExtIO::pinMode(shift_latch, OUTPUT);
|
||||
// ExtIO::pinMode(shift_clock, OUTPUT);
|
||||
shiftRegister.begin();
|
||||
|
||||
pinMode(shift_data, OUTPUT);
|
||||
pinMode(shift_latch, OUTPUT);
|
||||
pinMode(shift_clock, OUTPUT);
|
||||
|
||||
capa_sensor.begin(0x5A);
|
||||
|
||||
Control_Surface.begin();
|
||||
}
|
||||
|
||||
void scanPin(int pin);
|
||||
|
||||
void button_matrix_mgt(void);
|
||||
|
||||
void capa_sensor_mgt(void);
|
||||
|
||||
void loop()
|
||||
{
|
||||
button_matrix_mgt();
|
||||
|
||||
capa_sensor_mgt();
|
||||
|
||||
Control_Surface.loop();
|
||||
}
|
||||
|
||||
void button_matrix_mgt(void) {
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
scanPin(i);
|
||||
uint8_t rowValue[KEYBOARD_INSIZE];
|
||||
for (size_t j = 0; j < 6; ++j) {
|
||||
if ((rowValue[i] = ExtIO::digitalRead(keyboard_in[j])) == HIGH) {
|
||||
if (!ref[i][j]) {
|
||||
#ifndef DEBUG_MATRIX
|
||||
byte type = matrix[i][j][0];
|
||||
byte key = matrix[i][j][1];
|
||||
if (type == 1) {
|
||||
midi.sendNoteOn({key + shift, channel}, NOTE_VELOCITY);
|
||||
} else if (type == 2) {
|
||||
// todo : note off
|
||||
if (key == 0 && shift >= 12) {
|
||||
shift -= 12;
|
||||
} else if (key == 1 && shift <= 0xFF - 47 - 12) {
|
||||
shift += 12;
|
||||
}
|
||||
}
|
||||
#else /* DEBUG_MATRIX */
|
||||
midi.sendNoteOn(i, j);
|
||||
#endif /* DEBUG_MATRIX */
|
||||
ref[i][j] = true;
|
||||
}
|
||||
} else {
|
||||
if (ref[i][j]) {
|
||||
#ifndef DEBUG_MATRIX
|
||||
if (matrix[i][j][0] == 1) {
|
||||
midi.sendNoteOff({matrix[i][j][1] + shift, channel}, NOTE_VELOCITY);
|
||||
}
|
||||
#else /* DEBUG_MATRIX */
|
||||
midi.sendNoteOff(i, j);
|
||||
#endif /* DEBUG_MATRIX*/
|
||||
ref[i][j] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void capa_sensor_mgt(void) {
|
||||
// Get the currently touched pads
|
||||
int static lasttouched;
|
||||
int currtouched = capa_sensor.touched();
|
||||
|
||||
for (uint8_t i = 0; i < 12; i++)
|
||||
{
|
||||
// it if *is* touched and *wasnt* touched before, alert!
|
||||
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i))) {
|
||||
midi.sendCC({i, channel}, ON);
|
||||
}
|
||||
// if it *was* touched and now *isnt*, alert!
|
||||
if (!(currtouched & _BV(i)) && (lasttouched & _BV(i))) {
|
||||
midi.sendCC({i, channel}, OFF);
|
||||
}
|
||||
}
|
||||
|
||||
// reset our state
|
||||
lasttouched = currtouched;
|
||||
}
|
||||
|
||||
void scanPin(int pin) {
|
||||
ExtIO::digitalWrite(shift_latch, LOW);
|
||||
if (pin < 8) {
|
||||
byte bitsToSend = 0b00000001 << pin;
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend);
|
||||
} else {
|
||||
byte bitsToSend = 0b00000001 << (pin - 8);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
}
|
||||
ExtIO::digitalWrite(shift_latch, HIGH);
|
||||
}
|
||||
|
||||
|
||||
void init_shift() {
|
||||
ExtIO::digitalWrite(shift_latch, LOW);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000001);
|
||||
ExtIO::digitalWrite(shift_latch, HIGH);
|
||||
}
|
||||
|
||||
void next_shift() {
|
||||
ExtIO::digitalWrite(shift_data, LOW);
|
||||
ExtIO::digitalWrite(shift_latch, LOW);
|
||||
ExtIO::digitalWrite(shift_clock, HIGH);
|
||||
ExtIO::digitalWrite(shift_clock, LOW);
|
||||
ExtIO::digitalWrite(shift_latch, HIGH);
|
||||
}
|
||||
|
||||
void noteOn(byte note);
|
||||
|
||||
void noteOff(byte note);
|
||||
|
||||
void loop() {
|
||||
init_shift();
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
// shiftRegister.digitalWrite(i, HIGH);
|
||||
uint8_t rowValue[KEYBOARD_INSIZE];
|
||||
bool pressed = false;
|
||||
for (size_t j = 0; j < 6; ++j) {
|
||||
if ((rowValue[i] = ExtIO::digitalRead(keyboard_in[j])) == HIGH) {
|
||||
if (!ref[j * 16 + i]) {
|
||||
byte type = matrix[i][j][0];
|
||||
byte key = matrix[i][j][1];
|
||||
if (type == 1) {
|
||||
noteOn(key);
|
||||
} else if (type == 2) {
|
||||
if (key == 0 && shift >= 12) {
|
||||
shift -= 12;
|
||||
} else if (key == 1 && shift <= 0xFF - 47 - 12) {
|
||||
shift += 12;
|
||||
}
|
||||
}
|
||||
ref[j * 16 + i] = true;
|
||||
}
|
||||
} else {
|
||||
if (ref[j * 16 + i]) {
|
||||
if (matrix[i][j][0] == 1) {
|
||||
noteOff(matrix[i][j][1]);
|
||||
}
|
||||
ref[j * 16 + i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
next_shift();
|
||||
// shiftRegister.digitalWrite(i, LOW);
|
||||
// delay(3 s);
|
||||
}
|
||||
|
||||
// for (uint8_t i = 0; i < 8; ++i) {
|
||||
// byte bitsToSend = 0b00000001 << i;
|
||||
// ExtIO::digitalWrite(shift_latch, LOW);
|
||||
// // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend);
|
||||
// // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
// ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b11111111);
|
||||
// ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b11111111);
|
||||
// ExtIO::digitalWrite(shift_latch, HIGH);
|
||||
// Serial.print(" ");
|
||||
// Serial.print(bitsToSend, BIN);
|
||||
// Serial.println(" HIGH");
|
||||
// delay(4 s);
|
||||
// //bitWrite(bitsToSend, i, LOW);
|
||||
// ExtIO::digitalWrite(shift_latch, LOW);
|
||||
// ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
// ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
// ExtIO::digitalWrite(shift_latch, HIGH);
|
||||
// Serial.print(i);
|
||||
// Serial.println(" LOW");
|
||||
// delay(4 s);
|
||||
// }
|
||||
|
||||
// analogWrite(9, val[0] * 256 / 1024);
|
||||
|
||||
midi.update();
|
||||
// MIDI_Controller.refresh();
|
||||
// lastLoop = millis() - start;
|
||||
// loopAverage = (loopAverage + lastLoop) / 2;
|
||||
//delay(.5 s);
|
||||
}
|
||||
|
||||
|
||||
void noteOn(byte note) {
|
||||
// MIDI_Controller.MIDI()->send(NOTE_ON_CMD, 0, note + shift, NOTE_VELOCITY);
|
||||
// Serial.write(NOTE_ON_CMD);
|
||||
// Serial.write(note + shift);
|
||||
// Serial.write(NOTE_VELOCITY);
|
||||
midi.sendNoteOn(note, NOTE_VELOCITY);
|
||||
}
|
||||
|
||||
void noteOff(byte note) {
|
||||
// MIDI_Controller.MIDI()->send(NOTE_OFF_CMD, 0, note + shift, NOTE_VELOCITY);
|
||||
// Serial.write(NOTE_OFF_CMD);
|
||||
// Serial.write(note + shift);
|
||||
// Serial.write(NOTE_VELOCITY);
|
||||
midi.sendNoteOff(note, NOTE_VELOCITY);
|
||||
}
|
||||
|
||||
#else /* DEBUG_MAIN */
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (Serial.available() == 0){
|
||||
delay(.5 s);
|
||||
}
|
||||
|
||||
Serial.print("Serial OK");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
while (Serial.available() != 0) {
|
||||
char c = Serial.read();
|
||||
Serial.print(c);
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG_MAIN */
|
||||
ExtIO::digitalWrite(shift_latch, LOW);
|
||||
if (pin < 8) {
|
||||
byte bitsToSend = 0b00000001 << pin;
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend);
|
||||
} else {
|
||||
byte bitsToSend = 0b00000001 << (pin - 8);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend);
|
||||
ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000);
|
||||
}
|
||||
ExtIO::digitalWrite(shift_latch, HIGH);
|
||||
}
|
||||
Reference in New Issue
Block a user