Skip to content

Commit d1c09dc

Browse files
committed
2 parents d70fa56 + b94d8a9 commit d1c09dc

File tree

79 files changed

+3649
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3649
-23
lines changed

Adafruit_I2S_BFF/CircuitPython/WAV/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
audio = audiobusio.I2SOut(board.A2, board.A1, board.A0)
1313

14-
with open("chikken.wav", "rb") as wave_file:
14+
with open("booploop.wav", "rb") as wave_file:
1515
wav = audiocore.WaveFile(wave_file)
1616

1717
print("Playing wav file!")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"exportVersion": "1.0.0",
3+
"exportedBy": "tyeth_demo",
4+
"exportedAt": "2025-05-02T17:08:03.857Z",
5+
"exportedFromDevice": {
6+
"board": "rpi-pico-w",
7+
"firmwareVersion": "1.0.0-beta.100"
8+
},
9+
"components": [
10+
{
11+
"name": "Reed Switch",
12+
"pinName": "D13",
13+
"type": "reed_switch",
14+
"mode": "DIGITAL",
15+
"direction": "INPUT",
16+
"period": 0,
17+
"pull": "UP",
18+
"isPin": true,
19+
"visualization": {
20+
"offLabel": "Open",
21+
"offIcon": "fa6:solid:door-open",
22+
"onLabel": "Closed",
23+
"onIcon": "fa6:regular:door-closed"
24+
}
25+
}
26+
]
27+
}

Adafruit_IO_Schedule_Trigger/code.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ def on_message(client, feed_id, payload):
9898

9999
def on_relay_msg(client, topic, message):
100100
# Method called whenever user/feeds/relay has a new value
101-
if message == "morning":
102-
print("Morning - turning outlet ON")
101+
if message == "1":
102+
print("Received 1 - turning outlet ON")
103103
power_pin.value = True
104-
elif message == "night":
105-
print("Night - turning outlet OFF")
104+
elif message == "0":
105+
print("Received 0 - turning outlet OFF")
106106
power_pin.value = False
107107
else:
108108
print("Unexpected value received on relay feed.")

Factory_Tests/Adafruit_Sparkle_Motion_Stick_FactoryTest/.feather_esp32_v2.test.only

Whitespace-only changes.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// SPDX-FileCopyrightText: 2025 Limor Fried for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
#include <Arduino.h>
5+
#include "WiFi.h"
6+
#include <Adafruit_TestBed.h>
7+
#include "ESP_I2S.h"
8+
extern Adafruit_TestBed TB;
9+
10+
// I2S pin definitions
11+
const uint8_t I2S_SCK = 14; // BCLK
12+
const uint8_t I2S_WS = 12; // LRCLK
13+
const uint8_t I2S_DIN = 13; // DATA_IN
14+
I2SClass i2s;
15+
16+
// the setup routine runs once when you press reset:
17+
void setup() {
18+
Serial.begin(115200);
19+
pinMode(LED_BUILTIN, OUTPUT);
20+
digitalWrite(LED_BUILTIN, HIGH);
21+
i2s.setPins(I2S_SCK, I2S_WS, -1, I2S_DIN);
22+
if (!i2s.begin(I2S_MODE_STD, 44100, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO, I2S_STD_SLOT_LEFT)) {
23+
Serial.println("Failed to initialize I2S bus!");
24+
return;
25+
}
26+
// TestBed will handle the neopixel swirl for us
27+
TB.neopixelPin = PIN_NEOPIXEL;
28+
TB.neopixelNum = 1;
29+
TB.begin();
30+
31+
// Set WiFi to station mode and disconnect from an AP if it was previously connected
32+
WiFi.mode(WIFI_STA);
33+
WiFi.disconnect();
34+
}
35+
36+
// the loop routine runs over and over again forever:
37+
uint8_t wheelColor=0;
38+
void loop() {
39+
if (wheelColor == 0) {
40+
// Test WiFi Scan!
41+
// WiFi.scanNetworks will return the number of networks found
42+
int n = WiFi.scanNetworks();
43+
Serial.print("WiFi AP scan done...");
44+
if (n == 0) {
45+
Serial.println("no networks found");
46+
} else {
47+
Serial.print(n);
48+
Serial.println(" networks found");
49+
for (int i = 0; i < n; ++i) {
50+
// Print SSID and RSSI for each network found
51+
Serial.print(i + 1);
52+
Serial.print(": ");
53+
Serial.print(WiFi.SSID(i));
54+
Serial.print(" (");
55+
Serial.print(WiFi.RSSI(i));
56+
Serial.print(")");
57+
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
58+
delay(10);
59+
}
60+
}
61+
Serial.println("");
62+
for (int i=0; i < 5; i++) {
63+
int32_t sample = i2s.read();
64+
if (sample >= 0){
65+
Serial.print("Amplitude: ");
66+
Serial.println(sample);
67+
68+
// Delay to avoid printing too quickly
69+
delay(200);
70+
}
71+
}
72+
}
73+
74+
TB.setColor(TB.Wheel(wheelColor++)); // swirl NeoPixel
75+
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
76+
77+
delay(5);
78+
}

Fruit_Jam/Larsio_Paint_Music/code.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# SPDX-FileCopyrightText: 2025 John Park and Claude AI for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Larsio Paint Music
6+
Fruit Jam w mouse, HDMI, audio out
7+
or Metro RP2350 with EYESPI DVI breakout and TLV320DAC3100 breakout on STEMMA_I2C,
8+
pin D7 reset, 9/10/11 = BCLC/WSEL/DIN
9+
"""
10+
# pylint: disable=invalid-name,too-few-public-methods,broad-except,redefined-outer-name
11+
12+
# Main application file for Larsio Paint Music
13+
14+
import time
15+
import gc
16+
from sound_manager import SoundManager
17+
from note_manager import NoteManager
18+
from ui_manager import UIManager
19+
20+
# Configuration
21+
AUDIO_OUTPUT = "i2s" # Options: "pwm" or "i2s"
22+
23+
class MusicStaffApp:
24+
"""Main application class that ties everything together"""
25+
26+
def __init__(self, audio_output="pwm"):
27+
# Initialize the sound manager with selected audio output
28+
# Calculate tempo parameters
29+
BPM = 120 # Beats per minute
30+
SECONDS_PER_BEAT = 60 / BPM
31+
SECONDS_PER_EIGHTH = SECONDS_PER_BEAT / 2
32+
33+
# Initialize components in a specific order
34+
# First, force garbage collection to free memory
35+
gc.collect()
36+
37+
# Initialize the sound manager
38+
print("Initializing sound manager...")
39+
self.sound_manager = SoundManager(
40+
audio_output=audio_output,
41+
seconds_per_eighth=SECONDS_PER_EIGHTH
42+
)
43+
44+
# Give hardware time to stabilize
45+
time.sleep(0.5)
46+
gc.collect()
47+
48+
# Initialize the note manager
49+
print("Initializing note manager...")
50+
self.note_manager = NoteManager(
51+
start_margin=25, # START_MARGIN
52+
staff_y_start=int(240 * 0.1), # STAFF_Y_START
53+
line_spacing=int((240 - int(240 * 0.1) - int(240 * 0.2)) * 0.95) // 8 # LINE_SPACING
54+
)
55+
56+
gc.collect()
57+
58+
# Initialize the UI manager
59+
print("Initializing UI manager...")
60+
self.ui_manager = UIManager(self.sound_manager, self.note_manager)
61+
62+
def run(self):
63+
"""Set up and run the application"""
64+
# Setup the display and UI
65+
print("Setting up display...")
66+
self.ui_manager.setup_display()
67+
68+
# Give hardware time to stabilize
69+
time.sleep(0.5)
70+
gc.collect()
71+
72+
# Try to find the mouse with multiple attempts
73+
MAX_ATTEMPTS = 5
74+
RETRY_DELAY = 1 # seconds
75+
76+
mouse_found = False
77+
for attempt in range(MAX_ATTEMPTS):
78+
print(f"Mouse detection attempt {attempt+1}/{MAX_ATTEMPTS}")
79+
if self.ui_manager.find_mouse():
80+
mouse_found = True
81+
print("Mouse found successfully!")
82+
break
83+
84+
print(f"Mouse detection attempt {attempt+1} failed, retrying...")
85+
time.sleep(RETRY_DELAY)
86+
87+
if not mouse_found:
88+
print("WARNING: Mouse not found after multiple attempts.")
89+
print("The application will run, but mouse control may be limited.")
90+
91+
# Enter the main loop
92+
self.ui_manager.main_loop()
93+
94+
95+
# Create and run the application
96+
if __name__ == "__main__":
97+
# Start with garbage collection
98+
gc.collect()
99+
print("Starting Music Staff Application...")
100+
101+
try:
102+
app = MusicStaffApp(audio_output=AUDIO_OUTPUT)
103+
app.run()
104+
except Exception as e: # pylint: disable=broad-except
105+
print(f"Error with I2S audio: {e}")
106+
107+
# Force garbage collection
108+
gc.collect()
109+
time.sleep(1)
110+
111+
# Fallback to PWM
112+
try:
113+
app = MusicStaffApp(audio_output="pwm")
114+
app.run()
115+
except Exception as e2: # pylint: disable=broad-except
116+
print(f"Fatal error: {e2}")

0 commit comments

Comments
 (0)