This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # adafruit_dashboard.py | |
| import board, neopixel, os, ssl, socketpool, wifi | |
| import adafruit_minimqtt.adafruit_minimqtt as MQTT | |
| # set up the NeoPixel strand | |
| strand = neopixel.NeoPixel(board.GPIO15, 256, brightness=0.2) | |
| RED = (255, 0, 0); BLACK = (0, 0, 0); BLUE = (0, 0, 255); GREEN = (0, 255, 0) | |
| strand.fill(BLACK) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # dashboard_color.py | |
| # The connection function will read the feed's last value & sync | |
| # the build according to that value. | |
| import board, neopixel, os, ssl, socketpool, wifi | |
| import adafruit_minimqtt.adafruit_minimqtt as MQTT | |
| # set up the NeoPixel strand | |
| strand = neopixel.NeoPixel(board.GPIO15, 256, brightness=0.2) | |
| RED = (255, 0, 0); BLACK = (0, 0, 0); BLUE = (0, 0, 255); GREEN = (0, 255, 0) | |
| strand.fill(BLACK) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ntp_clock.py | |
| import board, time, os, wifi, socketpool, rtc | |
| import adafruit_ntp | |
| UTC_OFFSET_HOURS = int(os.getenv("UTC_OFFSET_HOURS", "-5")) # -5 = Boston in winter | |
| RESYNC_HOUR = 3 # once a day, at 3 AM, ask again so the clock doesn't drift | |
| # settings.toml connects to Wi-Fi at boot; this only runs if that didn't happen | |
| if not wifi.radio.connected: | |
| wifi.radio.connect(os.getenv("CIRCUITPY_WIFI_SSID"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import SwiftData | |
| struct ListView: View { | |
| @Query private var guests: [Guest] // every saved Guest (or the preview sample data in the canvas) | |
| @State private var sheetIsPresented = false | |
| @Environment(\.modelContext) private var modelContext // the "desk" where we add and delete | |
| var body: some View { | |
| NavigationStack { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Sample data for the Preview canvas only. It lives in memory, never on the device. | |
| // You'll need to change values for the Class and class properties, and the data you pass in. | |
| extension Guest { | |
| @MainActor | |
| static var preview: ModelContainer { | |
| do { | |
| let container = try ModelContainer(for: Guest.self, configurations: ModelConfiguration(isStoredInMemoryOnly: true)) | |
| container.mainContext.insert(Guest(name: "Snoop", item: "Brownies")) | |
| container.mainContext.insert(Guest(name: "Travis Kelce", item: "Ribs")) | |
| container.mainContext.insert(Guest(name: "Taylor Swift", item: "Cheese Steaks")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // DetailView.swift | |
| // FriendsGiving | |
| // | |
| // Created by John Gallaugher on 11/9/26. | |
| // | |
| import SwiftUI | |
| import SwiftData |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # touch_piano_esp32.py | |
| import board, busio, time, audiobusio, synthio | |
| import adafruit_mpr121 | |
| # I2S DAC wiring: WSEL -> GPIO16, DIN -> GPIO17, BCK -> GPIO18 | |
| audio = audiobusio.I2SOut(bit_clock=board.GPIO18, word_select=board.GPIO16, data=board.GPIO17) | |
| synth = synthio.Synthesizer(sample_rate=22050) | |
| audio.play(synth) # silent until a note is pressed | |
| # Middle octave: pad 0 = C4 (middle C), pad 1 = C#4 ... pad 11 = B4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # tone_test_esp32.py | |
| import board, time, audiobusio, synthio | |
| # I2S DAC wiring: WSEL -> GPIO16, DIN -> GPIO17, BCK -> GPIO18 | |
| audio = audiobusio.I2SOut(bit_clock=board.GPIO18, word_select=board.GPIO16, data=board.GPIO17) | |
| synth = synthio.Synthesizer(sample_rate=22050) | |
| audio.play(synth) # the synth is now "playing" but silent until a note is pressed | |
| # The middle octave: C4 (middle C) up to B4. One frequency (Hz) per key, in order | |
| note_names = ["C4", "C#4", "D4", "D#4", "E4", "F4", "F#4", "G4", "G#4", "A4", "A#4", "B4"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # funky_fingers_esp32.py | |
| import board, busio, time, audiobusio | |
| import adafruit_mpr121 | |
| from audiocore import WaveFile | |
| # I2S DAC wiring: WSEL -> GPIO16, DIN -> GPIO17, BCK -> GPIO18 | |
| audio = audiobusio.I2SOut(bit_clock=board.GPIO18, word_select=board.GPIO16, data=board.GPIO17) | |
| path = "funky/" | |
| loops = ["full_drum_loop_128bpm.wav", "big_boom_loop_1_c_128bpm.wav", | |
| "drum_buildup_12_128bpm.wav", "drum_loop_3_128bpm.wav", |
NewerOlder