Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Kai Nakamura
Copyright (c) 2024 EAMIR

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@
# Squidbox

Squidbox is a low-cost Bluetooth MIDI controller. It provides an intuitive and interactive way to learn about scales and chords while having fun making music. It runs on an ESP32 and features a 2-axis joystick, a small OLED screen, a knob, and multiple buttons.
The EAMIR Squidbox is a low-cost Bluetooth MIDI controller. It provides an intuitive and interactive way to learn about scales and chords while having fun making music. It runs on an ESP32 and features a 2-axis joystick, a small OLED screen, a knob, and multiple buttons.

## Python + PlatformIO setup (macOS)

In Terminal on MacOS:
- Verify Python 3 is available by running: `python3 --version`
- If not installed, install from `https://www.python.org/downloads/` (or through Homebrew: `brew install python`)
- Install PlatformIO via pip (preferred): `python3 -m pip install --user platformio` (or `pip3 install --user platformio`) (or through Homebrew: `brew install platformio`)
- Confirm install: `python3 -m platformio --version`
- If `platformio`/`pio` is not found, add your Python user bin to PATH:
- Find the user base: `python3 -m site --user-base` (expect something like `/Users/<you>/Library/Python/3.xx`)
- Add run: `echo 'export PATH="/Users/<you>/Library/Python/3.xx/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`

In VSCode:
- Restart VSCode
- Open the Terminal and test by running: `platformio --version` (or `pio --version`),`which platformio` (or `which pio`)
- If it still cannot find `pio`, set the same PATH in VS Code settings (`terminal.integrated.env.osx`) or select the `python3` interpreter in the Command Palette by Opening VS Code settings (Command Palette → “Preferences: Open User Settings (JSON)”). Add or update this: "terminal.integrated.env.osx": {
"PATH": "/Users/<you>/Library/Python/3.xx/bin:${env:PATH}"
}
(replace with your actual user bin path from python3 -m site --user-base):


## Flashing Quickstart (PlatformIO CLI)

Assumes you have the board connected (USB) and PlatformIO CLI installed (`pip install platformio` and make sure `pio` is on your PATH).

Replace `/dev/cu.usbserial-XXXX` with your serial port (check with `pio device list`).

Copying and entering this two-line command below should get the firmware built and pushed to the Squidbox:

# Build + upload main firmware
pio run -e adafruit_feather_esp32_v2 -t upload --upload-port /dev/cu.usbserial-59690893931

# Upload the LittleFS data (presets in data/config.json)
pio run -e adafruit_feather_esp32_v2 -t uploadfs --upload-port /dev/cu.usbserial-59690893931


Here are the general commands we use:

- Build + upload Squidbox firmware (Feather ESP32 V2 target):
`pio run -e adafruit_feather_esp32_v2 -t upload --upload-port /dev/cu.usbserial-XXXX`
- Upload LittleFS data (presets in `data/`):
`pio run -e adafruit_feather_esp32_v2 -t uploadfs --upload-port /dev/cu.usbserial-XXXX`
- Serial monitor at project baud:
`pio device monitor -b 115200 --port /dev/cu.usbserial-XXXX --echo`
- If you are using the DevKit simulation target instead:
`pio run -e esp32dev -t buildfs -t upload --upload-port /dev/cu.usbserial-XXXX`

If upload hangs on “Connecting…”, hold BOOT during that phase and release after the dots start. Press EN/reset to reboot after flashing.


## Related

- The Squidbox Configuration Editor is available at https://eamirorg.github.io/Squidbox-web-editor/

- The Squidbox Configuration Editor source is available at https://github.com/EAMIRorg/Squidbox-web-editor



## Contributing

Expand Down
21 changes: 18 additions & 3 deletions scripts/merge_firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,23 @@ def merge_bin(source, target, env):
# Add a post action that runs esptoolpy to merge available flash images
env.AddPostAction(APP_BIN, merge_bin)

# Also ensure the merged binary exists before upload even if the program binary
# wasn't rebuilt in this invocation (e.g., when only uploading an unchanged build).
env.AddPreAction("upload", merge_bin)

# Patch the upload command to flash the merged binary at address 0x0
env.Replace(
UPLOADERFLAGS=[] + ["0x0", MERGED_BIN],
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS',
# Keep PlatformIO's default uploader flags (chip/port/baud/reset/write_flash options),
# but replace the individual address/file pairs with our single merged image.
original_upload_flags = list(env.get("UPLOADERFLAGS", []))
first_addr_idx = next(
(i for i, flag in enumerate(original_upload_flags) if str(flag).startswith("0x")),
None,
)

if first_addr_idx is None:
# Unexpected shape; fall back to appending.
new_upload_flags = original_upload_flags + ["0x0", MERGED_BIN]
else:
new_upload_flags = original_upload_flags[:first_addr_idx] + ["0x0", MERGED_BIN]

env.Replace(UPLOADERFLAGS=new_upload_flags, UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS')
7 changes: 6 additions & 1 deletion src/components/joystick/Joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ float Joystick::getX() {

float Joystick::getY() {
// Convert the raw Y value to a value in the range -1 to 1 and return it.
// Invert on hardware so pushing the stick up yields positive (UP) values.
#ifdef SIMULATION
return convertRawValue(getRawY(), Y_CENTER, Y_MIN, Y_MAX);
#else
return -convertRawValue(getRawY(), Y_CENTER, Y_MIN, Y_MAX);
#endif
}

bool Joystick::isPressed() {
Expand Down Expand Up @@ -142,4 +147,4 @@ bool Joystick::wasDownJustInputted() {
wasDown = downInputted;
// Return whether the joystick was just moved down.
return downJustInputted;
}
}