From 7f32dec9f3485fda7edad444bf733738f3c2f4ba Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 4 Jan 2024 23:07:43 -0700 Subject: [PATCH 1/3] Smarter build `arduino-builder` lets you override stuff from `boards.txt`. That's nice, because the way I was doing it before was bananas. --- .gitea/build.sh | 32 ++++++++++++++++---------------- .gitea/workflows/build.yaml | 2 +- MockBand.ino | 4 +--- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.gitea/build.sh b/.gitea/build.sh index 681def0..b5a4e8d 100755 --- a/.gitea/build.sh +++ b/.gitea/build.sh @@ -11,36 +11,36 @@ cd $(dirname $0)/.. mkdir -p out/ -while read vid pid variant; do +while read variant vid pid flags; do log log Building $vid $pid $product log - ## This is bananas. + # 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/ - cp -rL /usr/share/arduino /usr/share/arduino-builder build/ || true # there's a cyclic symlink that causes failure - - sed -i " - /leonardo.build.vid/ s/=.*/=$vid/ - /leonardo.build.pid/ s/=.*/=$pid/ - /leonardo.build.usb_product/ s/=.*/=\"Mockband $variant\"/ - " build/arduino/hardware/arduino/avr/boards.txt - grep 'leonardo.build' build/arduino/hardware/arduino/avr/boards.txt arduino-builder \ - -fqbn arduino:avr:leonardo \ -build-path $(pwd)/build/ \ -build-cache $(pwd)/build/cache/ \ - -hardware build/arduino/hardware \ - -tools build/arduino/tools \ + -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 - find out build/cache done << EOD -0x1bad 0x0004 guitar -0x1bad 0x3110 drums +guitar 0x1bad 0x0004 +guitar-wammy 0x1bad 0x0004 -DWAMMY +drums 0x1bad 0x3110 EOD ls -l out/ diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 5dd1192..7774179 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -8,7 +8,7 @@ jobs: PACKAGE_API_TOKEN: ${PACKAGE_API_TOKEN} steps: - name: check out repository - run: git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . + run: git clone -b $GITHUB_REF_NAME $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . - name: build run: .gitea/build.sh - name: publish diff --git a/MockBand.ino b/MockBand.ino index 9860fef..31f1b28 100644 --- a/MockBand.ino +++ b/MockBand.ino @@ -96,9 +96,6 @@ void loop() { uint16_t silence[npins] = {0}; while (1) { -#ifdef WAMMY - unsigned long now = millis(); -#endif uint16_t edge = 0; samples++; @@ -115,6 +112,7 @@ void loop() { // We've sampled everything. Is it time to do calculations and USB? #ifdef WAMMY + unsigned long now = millis(); if (!edge && (next > now)) { continue; } From 3c80053cb7759fdd6970a95cc06f15348cbce4bd Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 4 Jan 2024 23:19:10 -0700 Subject: [PATCH 2/3] Build log formatting --- .gitea/build.sh | 2 +- .gitea/publish.sh | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.gitea/build.sh b/.gitea/build.sh index b5a4e8d..35786a8 100755 --- a/.gitea/build.sh +++ b/.gitea/build.sh @@ -13,7 +13,7 @@ mkdir -p out/ while read variant vid pid flags; do log - log Building $vid $pid $product + log "Building $variant ($vid:$pid)" log # We can overload build.extra_flags from boards.txt, diff --git a/.gitea/publish.sh b/.gitea/publish.sh index 65a7556..efcbbc3 100755 --- a/.gitea/publish.sh +++ b/.gitea/publish.sh @@ -7,19 +7,16 @@ VERSION=$GITHUB_REF_NAME BASE=$GITHUB_SERVER_URL/api/packages/$GITHUB_ACTOR/generic/$PACKAGE/$VERSION -echo "=== Delete existing version: $VERSION" -curl \ - --include \ - --user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \ - --request DELETE \ - $BASE - for path in "$@"; do fn=$(basename "$path") echo "=== Upload $VERSION/$fn" + curl \ + --user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \ + --request DELETE \ + $BASE/$fn + curl \ --fail \ - --include \ --user "$GITHUB_ACTOR:$PACKAGE_API_TOKEN" \ --upload-file "$path" \ $BASE/$fn From 703b070844a766208ae22667c7042741ea6e05c2 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 5 Jan 2024 18:16:29 -0700 Subject: [PATCH 3/3] Remove dpad kludge for drums - it messes up CH --- MockBand.ino | 9 --------- 1 file changed, 9 deletions(-) diff --git a/MockBand.ino b/MockBand.ino index 31f1b28..8373f36 100644 --- a/MockBand.ino +++ b/MockBand.ino @@ -151,15 +151,6 @@ void loop() { buttonState.velocity[1] = bitRead(buttonState.buttons, 2)?127:0; // R buttonState.velocity[2] = bitRead(buttonState.buttons, 1)?127:0; // G buttonState.velocity[3] = bitRead(buttonState.buttons, 0)?127:0; // B - - // Use the cymbals for up and down, since I don't have a D-pad - if bitRead(buttons, 13) { - buttonState.hatAndConstant = 0; // up - } else if bitRead(buttons, 10) { - buttonState.hatAndConstant = 4; // down - } else { - buttonState.hatAndConstant = 8; // nothing - } #endif #ifdef DPAD