Comments (3)
my mf64 stuff is based on djtt mf64 stuff
this repo is pretty dead
from teensy-underlights.
my mf64 stuff is based on djtt mf64 stuff this repo is pretty dead
Can you check this code react like a midi fighter?
#include "MIDIUSB.h"
#include <Adafruit_NeoPixel.h>
#define NEO_PIN 10
#define NUM_PXL 32
// Color palette from the first code
const byte _R[128] = {0, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 45, 93, 142, 223, 190, 28, 61, 93, 190, 125, 12, 28, 45, 158, 61, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 12, 28, 45, 158, 61, 28, 61, 93, 190, 125, 45, 93, 142, 223, 190, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 36, 73, 109, 146, 182, 219, 255};
const byte _G[128] = {0, 0, 0, 0, 125, 0, 12, 28, 45, 158, 61, 28, 61, 93, 190, 125, 45, 93, 142, 223, 190, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 45, 93, 142, 223, 190, 28, 61, 93, 190, 125, 12, 28, 45, 158, 61, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 36, 73, 109, 146, 182, 219, 255};
const byte _B[128] = {0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 12, 28, 45, 158, 61, 28, 61, 93, 190, 125, 45, 93, 142, 223, 190, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 61, 125, 190, 255, 255, 45, 93, 142, 223, 190, 28, 61, 93, 190, 125, 12, 28, 45, 158, 61, 36, 73, 109, 146, 182, 219, 255};
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PXL, NEO_PIN, NEO_GRB + NEO_KHZ800);
// Define AddressMatrix template
template <size_t ROWS, size_t COLS>
class AddressMatrix {
public:
uint8_t matrix[ROWS][COLS];
// Constructor
AddressMatrix(uint8_t data[ROWS][COLS]) {
for (size_t i = 0; i < ROWS; i++) {
for (size_t j = 0; j < COLS; j++) {
matrix[i][j] = data[i][j];
}
}
}
};
// Define NoteButtonMatrix template
template <size_t ROWS, size_t COLS>
class NoteButtonMatrix {
public:
uint8_t row_pins[ROWS];
uint8_t col_pins[COLS];
AddressMatrix<ROWS, COLS> address_matrix;
uint8_t channel;
// Constructor
NoteButtonMatrix(uint8_t row_pins[ROWS], uint8_t col_pins[COLS], AddressMatrix<ROWS, COLS> address_matrix, uint8_t channel)
: address_matrix(address_matrix) {
for (size_t i = 0; i < ROWS; i++) {
this->row_pins[i] = row_pins[i];
}
for (size_t j = 0; j < COLS; j++) {
this->col_pins[j] = col_pins[j];
}
this->channel = channel;
}
int read() {
// Implement your button read logic here
// Return the button states as an integer
return 0;
}
};
// The note numbers corresponding to the buttons in the matrix
const uint8_t button_addresses[4][4] = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15, 16},
};
// Define your NoteButtonMatrix object
uint8_t row_pins[4] = {2, 3, 4, 5}; // row pins
uint8_t col_pins[4] = {6, 7, 8, 9}; // column pins
NoteButtonMatrix<4, 4> buttonmatrix(row_pins, col_pins, AddressMatrix<4, 4>(button_addresses), 1);
void noteOn(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOn);
}
void noteOff(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOff);
}
void setPixels(int pinStates){
for(int i=0; i<16; i++){
if(bitRead(pinStates, i)){ // Button down
byte velocity = 127; // Maximum velocity when button is pressed
noteOn(0, (36+i), velocity); // Send MIDI note on
pixels.setPixelColor((i*2), pixels.Color(_R[velocity], _G[velocity], _B[velocity])); // Set LED color based on velocity
pixels.setPixelColor((i*2)+1, pixels.Color(_R[velocity], _G[velocity], _B[velocity]));
} else { // Button up
byte velocity = 0; // Velocity 0 when button is released
noteOff(0, (36+i), velocity); // Send MIDI note off
pixels.setPixelColor((i*2), pixels.Color(_R[velocity], _G[velocity], _B[velocity])); // Set LED color based on velocity
pixels.setPixelColor((i*2)+1, pixels.Color(_R[velocity], _G[velocity], _B[velocity]));
}
}
pixels.show();
}
void setup() {
pixels.begin();
Serial.begin(115200);
}
void loop(){
int pinStates = buttonmatrix.read();
// Check for button state changes
setPixels(pinStates);
}
from teensy-underlights.
how would i know
from teensy-underlights.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teensy-underlights.