Compare commits
22 Commits
Author | SHA1 | Date |
---|---|---|
Neale Pickett | ed8d884054 | |
Neale Pickett | 8ccbaaa4b7 | |
Neale Pickett | 195c02748b | |
Neale Pickett | 13825855d3 | |
Neale Pickett | e54595e630 | |
Neale Pickett | 63bd067250 | |
Neale Pickett | 9f0c0711a8 | |
Neale Pickett | efc67e9fe5 | |
Neale Pickett | ce7d6107cf | |
Neale Pickett | 48d2450514 | |
Neale Pickett | 5f44832151 | |
Neale Pickett | da45584955 | |
Neale Pickett | 50ce7c245a | |
Neale Pickett | f767eb6e23 | |
Neale Pickett | 7495bfd20f | |
Neale Pickett | 5fa607d6b0 | |
Neale Pickett | 855ad3ba60 | |
Neale Pickett | 25a917dc81 | |
Neale Pickett | a8d4918e05 | |
Neale Pickett | 544ffa8ced | |
Neale Pickett | a3d8262e01 | |
Neale Pickett | 0ba9c0957a |
|
@ -1,46 +0,0 @@
|
||||||
#! /bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
log () {
|
|
||||||
echo "=== $*"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Make sure we're in the project directory
|
|
||||||
cd $(dirname $0)/..
|
|
||||||
|
|
||||||
mkdir -p out/
|
|
||||||
|
|
||||||
while read variant vid pid flags; do
|
|
||||||
log
|
|
||||||
log "Building $variant ($vid:$pid)"
|
|
||||||
log
|
|
||||||
|
|
||||||
# We can overload build.extra_flags from boards.txt,
|
|
||||||
# so just specify the -D flags to gcc
|
|
||||||
flags="$flags -DUSB_VID=$vid -DUSB_PID=$pid"
|
|
||||||
flags="$flags -DUSB_MANUFACTURER=\"woozle.org\""
|
|
||||||
flags="$flags \"-DUSB_PRODUCT=\"Mockband $variant\"\"" # wtf quoting
|
|
||||||
flags="$flags -DCDC_DISABLED"
|
|
||||||
|
|
||||||
# Arduino gets cranky when it tries to use its own cache
|
|
||||||
rm -rf build/
|
|
||||||
mkdir -p build/cache/
|
|
||||||
|
|
||||||
arduino-builder \
|
|
||||||
-build-path $(pwd)/build/ \
|
|
||||||
-build-cache $(pwd)/build/cache/ \
|
|
||||||
-fqbn arduino:avr:leonardo \
|
|
||||||
-hardware /usr/share/arduino/hardware \
|
|
||||||
-tools /usr/share/arduino/tools \
|
|
||||||
-prefs="build.extra_flags=$flags" \
|
|
||||||
-compile MockBand.ino
|
|
||||||
|
|
||||||
mv build/MockBand.ino.hex out/MockBand.$variant.hex
|
|
||||||
done << EOD
|
|
||||||
guitar 0x1bad 0x0004
|
|
||||||
guitar-wammy 0x1bad 0x0004 -DWAMMY
|
|
||||||
drums 0x1bad 0x3110
|
|
||||||
EOD
|
|
||||||
|
|
||||||
ls -l out/
|
|
|
@ -7,17 +7,21 @@ VERSION=$GITHUB_REF_NAME
|
||||||
|
|
||||||
BASE=$GITHUB_SERVER_URL/api/packages/$GITHUB_ACTOR/generic/$PACKAGE/$VERSION
|
BASE=$GITHUB_SERVER_URL/api/packages/$GITHUB_ACTOR/generic/$PACKAGE/$VERSION
|
||||||
|
|
||||||
|
echo "=== Delete $VERSION"
|
||||||
|
curl \
|
||||||
|
--user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \
|
||||||
|
--request DELETE \
|
||||||
|
$BASE
|
||||||
|
echo
|
||||||
|
|
||||||
for path in "$@"; do
|
for path in "$@"; do
|
||||||
fn=$(basename "$path")
|
fn=$(basename "$path")
|
||||||
echo "=== Upload $VERSION/$fn"
|
echo "=== Upload $VERSION/$fn"
|
||||||
curl \
|
|
||||||
--user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \
|
|
||||||
--request DELETE \
|
|
||||||
$BASE/$fn
|
|
||||||
|
|
||||||
curl \
|
curl \
|
||||||
--fail \
|
--fail \
|
||||||
--user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \
|
--user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \
|
||||||
--upload-file "$path" \
|
--upload-file "$path" \
|
||||||
$BASE/$fn
|
$BASE/$fn
|
||||||
|
echo
|
||||||
done
|
done
|
||||||
|
|
|
@ -9,9 +9,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: check out repository
|
- name: check out repository
|
||||||
run: git clone -b $GITHUB_REF_NAME $GITHUB_SERVER_URL/$GITHUB_REPOSITORY .
|
run: git clone -b $GITHUB_REF_NAME $GITHUB_SERVER_URL/$GITHUB_REPOSITORY .
|
||||||
- name: build
|
- name: build firmwares
|
||||||
run: .gitea/build.sh
|
run: make
|
||||||
|
- name: build zip file
|
||||||
|
run: make dist
|
||||||
- name: publish
|
- name: publish
|
||||||
env:
|
env:
|
||||||
PACKAGE_API_TOKEN: ${{ secrets.PACKAGE_API_TOKEN }}
|
PACKAGE_API_TOKEN: ${{ secrets.PACKAGE_API_TOKEN }}
|
||||||
run: .gitea/publish.sh out/*
|
run: .gitea/publish.sh build/*.zip build/*.hex
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
*.zip
|
*.zip
|
||||||
*.hex
|
*.hex
|
||||||
|
build/
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
DEVICE=/dev/ttyACM0
|
||||||
|
|
||||||
|
all: firmwares
|
||||||
|
|
||||||
|
firmwares: build/MockBand.guitar-wammy.hex
|
||||||
|
build/MockBand.guitar-wammy.hex: VID=0x1bad
|
||||||
|
build/MockBand.guitar-wammy.hex: PID=0x0004
|
||||||
|
build/MockBand.guitar-wammy.hex: FLAGS=-DWAMMY
|
||||||
|
|
||||||
|
firmwares: build/MockBand.guitar.hex
|
||||||
|
build/MockBand.guitar.hex: VID=0x1bad
|
||||||
|
build/MockBand.guitar.hex: PID=0x0004
|
||||||
|
|
||||||
|
firmwares: build/MockBand.drums.hex
|
||||||
|
build/MockBand.drums.hex: VID=0x1bad
|
||||||
|
build/MockBand.drums.hex: PID=0x3110
|
||||||
|
|
||||||
|
firmwares: build/MockBand.drums1.hex
|
||||||
|
build/MockBand.drums1.hex: VID=0x1bad
|
||||||
|
build/MockBand.drums1.hex: PID=00005
|
||||||
|
|
||||||
|
|
||||||
|
build/MockBand.%.hex: MockBand.ino
|
||||||
|
mkdir -p build/cache
|
||||||
|
rm -f build/build.options.json
|
||||||
|
arduino-builder \
|
||||||
|
-build-path $(abspath build/) \
|
||||||
|
-build-cache $(abspath build/cache/) \
|
||||||
|
-fqbn arduino:avr:leonardo \
|
||||||
|
-hardware /usr/share/arduino/hardware/ \
|
||||||
|
-tools /usr/share/arduino/tools/ \
|
||||||
|
-prefs="build.extra_flags=-DUSB_VID=$(VID) -DUSB_PID=$(PID) '-DUSB_PRODUCT=\"Mockband $*\"' -DUSB_MANUFACTURER=\"woozle.org\" -DCDC_DISABLED $(FLAGS)" \
|
||||||
|
-compile $<
|
||||||
|
mv build/MockBand.ino.hex $@
|
||||||
|
|
||||||
|
|
||||||
|
flash-%: build/MockBand.%.hex
|
||||||
|
echo -n "Waiting for $(DEVICE)..."; while [ ! -e $(DEVICE) ]; do echo -n .; sleep 1; done
|
||||||
|
avrdude -v -patmega32u4 -cavr109 -P$(DEVICE) -b57600 -D -Uflash:w:$<:i
|
||||||
|
|
||||||
|
dist: build/MockBand.zip
|
||||||
|
|
||||||
|
build/MockBand.zip: firmwares
|
||||||
|
rm -f $@
|
||||||
|
zip -r $@ README.md build/*.hex docs/
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build
|
||||||
|
|
59
MockBand.ino
59
MockBand.ino
|
@ -2,11 +2,11 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <PluggableUSB.h>
|
#include <PluggableUSB.h>
|
||||||
|
|
||||||
//#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
|
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
|
||||||
#include "instrument.hh"
|
#include "instrument.hh"
|
||||||
#include "standard.hh" // Standard pins
|
#include "piezos.hh"
|
||||||
|
|
||||||
// If defined, we will check the wammy bar input
|
// If defined, we will check the wammy bar input
|
||||||
//#define WAMMY
|
//#define WAMMY
|
||||||
|
@ -41,23 +41,17 @@
|
||||||
InstrumentButtonState buttonState = {0};
|
InstrumentButtonState buttonState = {0};
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(STRUM_DOWN, INPUT_PULLUP);
|
pinMode(BUTTON_GREEN, INPUT);
|
||||||
pinMode(STRUM_UP, INPUT_PULLUP);
|
pinMode(BUTTON_RED, INPUT);
|
||||||
pinMode(TILT_SWITCH, INPUT_PULLUP);
|
pinMode(BUTTON_YELLOW, INPUT);
|
||||||
pinMode(BUTTON_GREEN, INPUT_PULLUP);
|
pinMode(BUTTON_BLUE, INPUT);
|
||||||
pinMode(BUTTON_RED, INPUT_PULLUP);
|
|
||||||
pinMode(BUTTON_YELLOW, INPUT_PULLUP);
|
|
||||||
pinMode(BUTTON_BLUE, INPUT_PULLUP);
|
|
||||||
pinMode(BUTTON_ORANGE, INPUT_PULLUP);
|
pinMode(BUTTON_ORANGE, INPUT_PULLUP);
|
||||||
pinMode(SOLO_GREEN, INPUT_PULLUP);
|
pinMode(SOLO_GREEN, INPUT);
|
||||||
pinMode(SOLO_RED, INPUT_PULLUP);
|
pinMode(SOLO_RED, INPUT);
|
||||||
pinMode(SOLO_YELLOW, INPUT_PULLUP);
|
pinMode(SOLO_YELLOW, INPUT);
|
||||||
pinMode(SOLO_BLUE, INPUT_PULLUP);
|
pinMode(SOLO_BLUE, INPUT);
|
||||||
pinMode(SOLO_ORANGE, INPUT_PULLUP);
|
|
||||||
pinMode(BUTTON_PLUS, INPUT_PULLUP);
|
pinMode(BUTTON_PLUS, INPUT_PULLUP);
|
||||||
pinMode(BUTTON_MINUS, INPUT_PULLUP);
|
pinMode(BUTTON_MINUS, INPUT_PULLUP);
|
||||||
pinMode(ANALOG_WAMMY, INPUT);
|
|
||||||
pinMode(ANALOG_DPAD, INPUT);
|
|
||||||
|
|
||||||
// Initialize HID
|
// Initialize HID
|
||||||
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
|
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
|
||||||
|
@ -86,10 +80,13 @@ uint8_t pins[] = {
|
||||||
};
|
};
|
||||||
#define npins (sizeof(pins) / sizeof(*pins))
|
#define npins (sizeof(pins) / sizeof(*pins))
|
||||||
|
|
||||||
|
#define NOISE_THRESHOLD 40 // Minimum analog value to treat as a hit
|
||||||
|
|
||||||
// The 3.3v Pro Micro is on the slow side.
|
// The 3.3v Pro Micro is on the slow side.
|
||||||
// Our strategy is to poll button state as quickly as possible,
|
// Our strategy is to poll button state as quickly as possible,
|
||||||
// and hope we don't miss anything while we're doing USB stuff.
|
// and hope we don't miss anything while we're doing USB stuff.
|
||||||
void loop() {
|
void loop() {
|
||||||
|
uint16_t inputs[16] = {0};
|
||||||
uint16_t buttons = 0;
|
uint16_t buttons = 0;
|
||||||
uint16_t samples = 0;
|
uint16_t samples = 0;
|
||||||
unsigned long next = 0;
|
unsigned long next = 0;
|
||||||
|
@ -99,13 +96,20 @@ void loop() {
|
||||||
uint16_t edge = 0;
|
uint16_t edge = 0;
|
||||||
|
|
||||||
samples++;
|
samples++;
|
||||||
|
inputs[0] = analogRead(INPUT_BLUE);
|
||||||
|
inputs[1] = analogRead(INPUT_GREEN);
|
||||||
|
inputs[2] = analogRead(INPUT_RED);
|
||||||
|
inputs[3] = analogRead(INPUT_YELLOW);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < npins; i++) {
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
if (silence[i]) {
|
if (silence[i]) {
|
||||||
silence[i]--;
|
silence[i]--;
|
||||||
} else if (bitRead(buttons, i) != !digitalRead(pins[i])) {
|
} else {
|
||||||
edge |= bit(i);
|
bool trigger = inputs[i] > NOISE_THRESHOLD;
|
||||||
silence[i] = SILENCE_SAMPLES;
|
if (trigger != bitRead(buttons, i)) {
|
||||||
|
edge |= bit(i);
|
||||||
|
silence[i] = SILENCE_SAMPLES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buttons ^= edge;
|
buttons ^= edge;
|
||||||
|
@ -142,15 +146,18 @@ void loop() {
|
||||||
}
|
}
|
||||||
#else // DRUMS
|
#else // DRUMS
|
||||||
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
|
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
|
||||||
bitWrite(buttonState.buttons, 10, buttons & (0b01111 << 0)); // Drum pad modifier
|
bitWrite(buttonState.buttons, 10, (buttons >> 0) & 0b01111); // Drum pad modifier
|
||||||
bitWrite(buttonState.buttons, 11, buttons & (0b01011 << 10)); // Cymbals modifier
|
bitWrite(buttonState.buttons, 11, (buttons >> 10) & 0b01011); // Cymbals modifier
|
||||||
buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
|
buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
|
||||||
|
|
||||||
// rbdrum2midi wants these set
|
// rbdrum2midi wants these set
|
||||||
buttonState.velocity[0] = bitRead(buttonState.buttons, 3)?127:0; // Y
|
buttonState.velocity[0] = inputs[3]/4; // Y
|
||||||
buttonState.velocity[1] = bitRead(buttonState.buttons, 2)?127:0; // R
|
buttonState.velocity[1] = inputs[2]/4; // R
|
||||||
buttonState.velocity[2] = bitRead(buttonState.buttons, 1)?127:0; // G
|
buttonState.velocity[2] = inputs[1]/2; // G
|
||||||
buttonState.velocity[3] = bitRead(buttonState.buttons, 0)?127:0; // B
|
buttonState.velocity[3] = inputs[0]/4; // B
|
||||||
|
|
||||||
|
// Say the D-pad is centered
|
||||||
|
buttonState.hatAndConstant = 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DPAD
|
#ifdef DPAD
|
||||||
|
|
|
@ -70,13 +70,19 @@ Here's what each bit means:
|
||||||
hatAndConstant
|
hatAndConstant
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Here's what the values mean:
|
The HAT switch reports its position like a clock.
|
||||||
|
|
||||||
* 2: right
|
7 0 1
|
||||||
* 6: left
|
|
||||||
* 0: up
|
6 8 2
|
||||||
* 4: down
|
|
||||||
* 8: nothing
|
5 4 3
|
||||||
|
|
||||||
|
0 is up,
|
||||||
|
2 is right,
|
||||||
|
4 is down,
|
||||||
|
6 is left,
|
||||||
|
and 8 is centered.
|
||||||
|
|
||||||
|
|
||||||
velocity
|
velocity
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Standard setup for a Pro Micro
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't forget to do this (guitar pid=0x0004, drum pid=0x0005):
|
||||||
|
|
||||||
|
< micro.build.vid=0x2341
|
||||||
|
< micro.build.pid=0x8037
|
||||||
|
--
|
||||||
|
> micro.build.vid=0x1bad
|
||||||
|
> micro.build.pid=0x0004
|
||||||
|
|
||||||
|
< micro.build.extra_flags={build.usb_flags}
|
||||||
|
---
|
||||||
|
> micro.build.extra_flags={build.usb_flags} -DCDC_DISABLED
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const int BUTTON_GREEN = 18; // A0
|
||||||
|
const int BUTTON_RED = 19; // A1
|
||||||
|
const int BUTTON_YELLOW = 20; // A2
|
||||||
|
const int BUTTON_BLUE = 21; // A3
|
||||||
|
const int BUTTON_ORANGE = 15;
|
||||||
|
|
||||||
|
const int SOLO_GREEN = 9;
|
||||||
|
const int SOLO_RED = 8;
|
||||||
|
const int SOLO_YELLOW = 6;
|
||||||
|
const int SOLO_BLUE = 4;
|
||||||
|
const int SOLO_ORANGE = 14;
|
||||||
|
|
||||||
|
const int BUTTON_PLUS = 1;
|
||||||
|
const int BUTTON_MINUS = 0;
|
Loading…
Reference in New Issue