Documentation Index
Fetch the complete documentation index at: https://mintlify.com/benz206/SpotifyMacroBoard/llms.txt
Use this file to discover all available pages before exploring further.
Core functions
setup()
Initializes all hardware components and establishes WiFi connection.Setup sequence
Setup sequence
- Configure all button pins as inputs with pull-up resistors
- Configure LED and I2C pins
- Initialize FastLED library with WS2812B configuration
- Set LED brightness to 230 and power limit to 5V @ 500mA
- Display white color on all LEDs during initialization
- Initialize I2C bus at 400 kHz
- Initialize OLED display at I2C address 0x3C
- Connect to WiFi network
- Set server SSL certificate for secure HTTPS connections
The setup function blocks until WiFi connection is established. LEDs pulse white during connection.
- OrangeRed LEDs: OLED display initialization failed
- Pulsing white LEDs: Attempting WiFi connection
- Solid green LEDs: Setup completed successfully
loop()
Main program loop that handles button inputs and periodic updates.Loop operations
Loop operations
- Read all button states and detect button presses
- Call corresponding function when button pressed
- Update WiFi signal strength every 10 seconds
- Fetch current playback state every 5 seconds
- Update progress bar every 1 second
- Animate LED color fading when track changes
- Button polling: Every loop iteration
- RSSI update: 10,000 ms
- Current state update: 5,000 ms
- Time update: 1,000 ms
- LED fade step: 4 ms
Button handler functions
shuffle()
Toggles shuffle mode on the connected Spotify account.volumeDecrease()
Decreases Spotify playback volume and updates the display.volumeIncrease()
Increases Spotify playback volume and updates the display.repeat()
Toggles repeat/loop mode for the current track or playlist.back()
Skips to the previous track in the playback queue.pausePlay()
Toggles between play and pause states.skip()
Skips to the next track in the playback queue.Display functions
updateScreen()
Refreshes the OLED display with WiFi signal and volume indicators.Display layout
Display layout
- Top-left (0-18px): WiFi signal strength icon
- No bars: RSSI = 0 (disconnected)
- One bar: RSSI < -70 dBm (weak)
- Two bars: RSSI >= -70 dBm (strong)
- Top-right (108-128px): Volume level icon
- Muted: volume = 0
- Low: volume 1-33
- Medium: volume 34-66
- High: volume 67-100
updateTime()
Draws the playback progress bar and time display.Total track duration in seconds
Current playback position in seconds
- Width: 100 pixels
- Height: 6 pixels
- Position: X=14, Y=56
- Filled proportionally based on current/total ratio
Network functions
updateState()
Sends playback control commands to the server API.Command type:
'p'- Play/pause'b'- Back's'- Skip'r'- Repeat/loop'v'- Volume (requires subAction)'f'- Shuffle
Volume direction:
0- Decrease1- Increase
updateCurrent()
Fetches current playback information from the server API.- Track title
- Artist name
- Album name
- Duration and progress (seconds)
- Paused state (boolean)
- Volume level (0-100)
- Album art dominant color (RGB)
- Red LEDs: Connection to server failed
- Yellow LEDs: Server response timeout (>5 seconds)
- Orange LEDs: HTTP headers not found in response
When the track title changes, the display clears and shows new track information. The LED color fades to match the album art’s dominant color.
Utility functions
fadeLED()
Animates RGB LED transition between colors.true if fade is still in progress, false when complete.
Fades from previous color to new color over 256 steps using FastLED’s blend function. Called every 4ms during active fade.
extractValue()
Parses JSON responses to extract specific field values.JSON key name to search for
Complete JSON response string
Output variable to store the extracted value
"key": pattern in JSON string and extracts the value between quotes, trimming whitespace.
Function pointer array
Button functions are mapped to an array for efficient event handling:funcs[i]() when button i is pressed.