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 MapKit | |
| import FirebaseFirestore | |
| struct AllTeamsMapView: View { | |
| @FirestoreQuery(collectionPath: "teams") var teams: [Team] | |
| @State private var cameraPosition: MapCameraPosition = .automatic | |
| var body: some View { |
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 FirebaseFirestore | |
| @Observable | |
| class PlaceViewModel { | |
| static func savePlace(place: Place) async -> String? { | |
| let db = Firestore.firestore() | |
| if let id = place.id { // if true, the place exists | |
| do { |
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
| # This .gitignore tells Git which files and folders to ignore. | |
| # Ignored files are: | |
| # - not tracked in your local .git history | |
| # - not committed | |
| # - not pushed to GitHub | |
| # API KEYS & SECRETS | |
| # Any files with sensitive info (API keys, tokens, passwords) go here. | |
| # Example: if your keys are in "Secrets.swift", add that line below. | |
| # IMPORTANT: Keep backups of your secrets in a safe place! |
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
| # Uses adafruit_mpr121, an Adalogger Cowbell, PCM5102 DAC, & PAM8302 AMP | |
| import board, busio, sdcardio, storage, os, time, digitalio, adafruit_mpr121 | |
| import audiomixer, audiocore, audiobusio # use this instead of audiopwmio | |
| from audiocore import WaveFile | |
| touch_pad = adafruit_mpr121.MPR121(board.STEMMA_I2C()) | |
| # Create an I2S audio output w/our pins | |
| audio = audiobusio.I2SOut( | |
| bit_clock=board.GP10, |
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
| // Improved Matrix Mapper Code | |
| function (pixelCount) { | |
| width = 16 // width of LED panel | |
| angle = 90 // rotation in degrees: 0, 90, 180, 270 | |
| flip = true // does the rendering need to be flipped? | |
| height = width/pixelCount | |
| map = [] | |
| for (i = 0; i < pixelCount; i++) { |
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
| var holdMs = 120 // milliseconds each LED stays on (lower = faster) | |
| var currentPixel = 0 // index of the currently lit pixel | |
| var accumulatedMs = 0 // accumulated elapsed time (in milliseconds) | |
| // A beforeRender fuction runs before each frame or refresh of all LEDs | |
| export function beforeRender(delta) { // delta = ms since last frame (refresh of all LEDs) | |
| accumulatedMs += delta // add this frame's time to the accumulator | |
| // If we've held long enough, advance to the next pixel. | |
| // NOTE: This advances at most one pixel per frame. |
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
| ```# text-and-displayio.py | |
| import board, busio, time, displayio, pwmio, terminalio, fourwire | |
| from adafruit_display_text.label import Label | |
| from adafruit_display_text.bitmap_label import Label as BitmapLabel | |
| from adafruit_bitmap_font import bitmap_font | |
| import adafruit_ili9341 | |
| # --- Display Setup --- | |
| displayio.release_displays() |
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
| # roy-g-biv-pico-flash-with-each-color-off.py | |
| import board, time, neopixel | |
| # define colors: | |
| RED = (255, 0, 0) | |
| ORANGE = (255, 40, 0) | |
| YELLOW = (255, 150, 0) | |
| GREEN = (0, 255, 0) | |
| BLUE = (0, 0, 255) | |
| INDIGO = (75, 0, 130) # no official INDIGO from CircuitPython |
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
| func playSound(soundName: String) { | |
| guard let soundFile = NSDataAsset(name: soundName) else { | |
| print("😡 ERROR: Could not read file named \(soundName).") | |
| return | |
| } | |
| do { | |
| audioPlayer = try AVAudioPlayer(data: soundFile.data) | |
| audioPlayer.play() | |
| } catch { | |
| print("😡 ERROR: \(error.localizedDescription) when trying to create audioPlayer.") |
NewerOlder