6 Commits

Author SHA1 Message Date
8691bc05eb code comments added, rotary encoder overflow fixed 2025-05-27 16:34:14 +02:00
6ceefa6705 readme updated 2025-05-27 16:18:33 +02:00
ab0dbe98a1 readme updated 2025-05-27 16:13:36 +02:00
202b862280 readme updated 2025-05-27 16:12:45 +02:00
4b728fffd0 readme added 2025-05-27 16:11:00 +02:00
559d92e526 alpha build 2025-05-27 13:13:29 +02:00
4 changed files with 340 additions and 310 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build

15
README.md Normal file
View File

@ -0,0 +1,15 @@
# Soundcube Firmware
## Code something yourself
1. Download [Arduino IDE](https://www.arduino.cc/en/software/)
2. Install and open "Preferences"
3. Follow these [instructions](https://github.com/earlephilhower/arduino-pico?tab=readme-ov-file#installation)
- No need to change checkboxes, only paste the URL and hit OK.
4. Install **Raspberry Pi Pico** boards ([HowTo install boards](https://support.arduino.cc/hc/en-us/articles/360016119519-Add-boards-to-Arduino-IDE))
5. Install libraries ([HowTo install libraries](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-installing-a-library/)): Adafruit Neopixel, AS5600 (Rob Tillaart), TCA9555 (Rob Tillaart)
6. Choose **Generic RP2350** as board and the correct port (Mac: /dev/cu.usbmodemXXXX, PC: COMXX Serial Port)
7. Go to **Tools -> Flash Size** and choose **16MB (no FS)**
8. Make your changes in the code
9. Hit Upload Button (Arduino IDE compiles and uploads it automatically)

View File

@ -4,8 +4,8 @@
#include <PWMAudio.h>
#include <I2S.h>
#define HAPTIC 0
#define AURAL 0
#define HAPTIC 1
#define AURAL 1
#define UI_SAMPLERATE 22050
I2S i2s(INPUT_PULLUP);
@ -74,7 +74,8 @@ void setup() {
Serial.println("SUCCESS");
// Rotary Encoder
ENC.begin(4); // set direction pin.
ENC.begin(); // set direction pin.
ENC.setDirection(AS5600_COUNTERCLOCK_WISE);
pinMode(6, OUTPUT); // Vibration Motor
pinMode(7, OUTPUT); // UI Amp Enable
@ -104,6 +105,8 @@ void setup() {
// }
}
int active = 0;
int active_led_ring = 0;
uint32_t lastTime = 0;
int32_t position = 0;
@ -121,10 +124,12 @@ void loop() {
// Serial.println(ENC.getRevolutions());
// }
// LED Ring leeren
for (int i = 0; i < 48; i++) {
ui_pixels.setPixelColor(i + 3, edge_pixels.Color(0, 0, 0));
}
// flag = true when a button is pushed
if (flag) {
int val = TCA.read16();
Serial.println(val, BIN);
@ -140,6 +145,7 @@ void loop() {
if (HAPTIC) {
digitalWrite(6, HIGH);
}
// Make beep
if (AURAL) {
digitalWrite(7, HIGH);
click = true;
@ -147,19 +153,21 @@ void loop() {
click = false;
digitalWrite(7, LOW);
}
// Make vibration
if(HAPTIC){
if(!AURAL) delay(50);
digitalWrite(6, LOW);
}
// Flash led ring
for (int i = 0; i < 48; i++) {
ui_pixels.setPixelColor(i + 3, edge_pixels.Color(0, 15, 0));
}
// Switch through LED matrix
if(buttons[RIGHT]) active++;
if(buttons[LEFT]) active--;
if(active == 13) active = 0;
if(active == -1) active = 12;
}
// 11111110 11111111 button right
// EDGE LEDs
for (int i = 0; i < 8; i++) {
@ -171,16 +179,22 @@ void loop() {
ui_pixels.setPixelColor(1, edge_pixels.Color(0, 0, 15));
ui_pixels.setPixelColor(2, edge_pixels.Color(0, 0, 15));
// empty LED matrix
for (int i = 0; i < 13; i++) {
ui_pixels.setPixelColor(i + 3 + 48 + 4, edge_pixels.Color(0, 0, 0));
}
// set active LED matrix LED
ui_pixels.setPixelColor(active + 3 + 48 + 4, edge_pixels.Color(255, 255, 255));
// put your main code here, to run repeatedly:
if(position < 0) position += 4096;
active_led_ring = (position / 32) % 48;
edge_pixels.show(); // Set all pixel colors to 'off'
ui_pixels.show(); // Set all pixel colors to 'off'
// set active LED ring LED
ui_pixels.setPixelColor(active_led_ring + 3, edge_pixels.Color(255, 255, 255));
delay(1);
edge_pixels.show();
ui_pixels.show();
delay(1); // wait 1ms
}