Deluge Firmware 1.3.0
Build date: 2025.04.11
Loading...
Searching...
No Matches
PIC Class Reference

The static class for interacting with the PIC peripheral. More...

#include <pic.h>

Public Types

enum class  Response : uint8_t {
  NONE = 0 , UNKNOWN_BOOT_RESPONSE = 129 , RESET_SETTINGS = 175 , FIRMWARE_VERSION_NEXT = 245 ,
  UNKNOWN_OLED_RELATED_COMMAND = 246 , SET_DC_HIGH = 251 , NEXT_PAD_OFF = 252 , UNKNOWN_BREAK = 253 ,
  NO_PRESSES_HAPPENING = 254
}
 The response received from the PIC.
 

Static Public Member Functions

static void setupForPads ()
 Change the UART baud rate to the output speed safe for rapid pad updates.
 
static void setColourForTwoColumns (size_t idx, const std::array< RGB, kDisplayHeight *2 > &colours)
 Set the Colour for two columns of leds.
 
static void setDebounce (uint8_t time_ms)
 Set the PIC's debounce time in milliseconds. This prevents extra keypresses from happening when the switch is not fully closed.
 
static void setGoldKnobIndicator (bool which, const std::array< uint8_t, kNumGoldKnobIndicatorLEDs > &indicator)
 This sets the indicator for the gold knobs,.
 
static void setLEDOff (size_t idx)
 
static void setLEDOn (size_t idx)
 
static void resendButtonStates ()
 Request that the PIC resend all button states.
 
static void setMinInterruptInterval (uint8_t time_ms)
 
static void setFlashLength (uint8_t time_ms)
 
static void setUARTSpeed ()
 
static void flashMainPad (size_t idx)
 
static void flashMainPadWithColourIdx (size_t idx, int32_t colour_idx)
 Flash a pad using the PIC's built-in timer and colour system.
 
static void update7SEG (const std::array< uint8_t, kNumericDisplayLength > &display)
 
static void enableOLED ()
 
static void selectOLED ()
 
static void deselectOLED ()
 
static void setDCLow ()
 
static void setDCHigh ()
 
static void requestFirmwareVersion ()
 
static void sendColour (const RGB &colour)
 
static void setRefreshTime (uint8_t time_ms)
 
static void setDimmerInterval (uint8_t interval)
 
static void sendScrollRow (size_t idx, RGB colour)
 This is used to make smooth scrolling on the horizontal axis, by filling up an 8-pixel framebuffer on the PIC that it can then provide an animation to smear across the axis to give a sensation of motion See (scrolling between clip pages)
 
static void setupHorizontalScroll (uint8_t bitflags)
 
static void doVerticalScroll (bool direction, const std::array< RGB, kDisplayWidth+kSideBarWidth > &colours)
 
static void doneSendingRows ()
 
static void flush ()
 Flush the UART buffer if it's not already being done.
 
static void waitForFlush ()
 Wait for the last flush() operation to complete (blocking)
 
static Response read ()
 Read a single response from the PIC.
 
static Response read (uint32_t timeout)
 Fetch a response from the PIC (blocking)
 
static int32_t read (uint32_t timeout, std::function< int32_t(Response)> handler)
 Fetch a response from the PIC, using a callback handler.
 

Static Public Attributes

static constexpr Response kPadAndButtonMessagesEnd {180}
 

Private Types

enum class  Message : uint8_t {
  NONE = 0 , SET_COLOUR_FOR_TWO_COLUMNS = 1 , SET_FLASH_COLOR = 10 , SET_DEBOUNCE_TIME = 18 ,
  SET_REFRESH_TIME = 19 , SET_GOLD_KNOB_0_INDICATORS = 20 , SET_GOLD_KNOB_1_INDICATORS = 21 , RESEND_BUTTON_STATES = 22 ,
  SET_FLASH_LENGTH = 23 , SET_PAD_FLASHING = 24 , SET_LED_OFF = 152 , SET_LED_ON = 188 ,
  UPDATE_SEVEN_SEGMENT_DISPLAY = 224 , SET_UART_SPEED = 225 , SET_SCROLL_ROW = 228 , SET_SCROLL_LEFT = 236 ,
  SET_SCROLL_RIGHT , SET_SCROLL_RIGHT_FULL , SET_SCROLL_LEFT_FULL , DONE_SENDING_ROWS = 240 ,
  SET_SCROLL_UP = 241 , SET_SCROLL_DOWN = 242 , SET_DIMMER_INTERVAL = 243 , SET_MIN_INTERRUPT_INTERVAL = 244 ,
  REQUEST_FIRMWARE_VERSION = 245 , ENABLE_OLED = 247 , SELECT_OLED = 248 , DESELECT_OLED = 249 ,
  SET_DC_LOW = 250 , SET_DC_HIGH = 251
}
 

Static Private Member Functions

template<typename... Bytes>
static void send (Message msg, Bytes... bytes)
 Send a message and a variable number of following bytes.
 
template<typename T, size_t size>
static void send (Message msg, const std::array< T, size > &bytes)
 Send a message followed by all the objects in the provided array.
 
static void send (Message msg)
 Send a single message.
 
static void send (const RGB &colour)
 Send a single colour.
 
static void send (uint8_t msg)
 Send a byte. This was originally bufferPICUart()
 

Static Private Attributes

static constexpr uint32_t kUartFullSpeedPadsHz = 200000
 

Detailed Description

The static class for interacting with the PIC peripheral.

Member Function Documentation

◆ flashMainPadWithColourIdx()

static void PIC::flashMainPadWithColourIdx ( size_t idx,
int32_t colour_idx )
inlinestatic

Flash a pad using the PIC's built-in timer and colour system.

Parameters
idxThe pad to flash
colour_idxThe colour "index" of colours the PIC knows

◆ read() [1/2]

static Response PIC::read ( )
inlinestatic

Read a single response from the PIC.

Returns
Response The PIC response message (Response::NONE if no byte immediately available)

◆ read() [2/2]

static int32_t PIC::read ( uint32_t timeout,
std::function< int32_t(Response)> handler )
inlinestatic

Fetch a response from the PIC, using a callback handler.

Parameters
handlerThe response handler function. If the return value is nonzero, the read attempt will immediately halt;
timeoutThe timeout to run for. Can be cancelled by the callback returning a nonzero value.

◆ sendScrollRow()

static void PIC::sendScrollRow ( size_t idx,
RGB colour )
inlinestatic

This is used to make smooth scrolling on the horizontal axis, by filling up an 8-pixel framebuffer on the PIC that it can then provide an animation to smear across the axis to give a sensation of motion See (scrolling between clip pages)

Parameters
idxthe row to set

◆ setColourForTwoColumns()

static void PIC::setColourForTwoColumns ( size_t idx,
const std::array< RGB, kDisplayHeight *2 > & colours )
inlinestatic

Set the Colour for two columns of leds.

This allows updating the Deluge main pads in groups of columns, as though the pair were a continuous strip of 16 (rather than 8) LEDs

Parameters
idxThe column-pair idx (so half the number of squares from the left)
coloursThe colours to set the pads to

◆ setDebounce()

static void PIC::setDebounce ( uint8_t time_ms)
inlinestatic

Set the PIC's debounce time in milliseconds. This prevents extra keypresses from happening when the switch is not fully closed.

See also
https://learn.adafruit.com/make-it-switch/debouncing
Parameters
time_msThe number of milliseconds to use debounce using

◆ setGoldKnobIndicator()

static void PIC::setGoldKnobIndicator ( bool which,
const std::array< uint8_t, kNumGoldKnobIndicatorLEDs > & indicator )
inlinestatic

This sets the indicator for the gold knobs,.

Parameters
whichThe knob to set
indicatorAn array of brightness values for each LED

The documentation for this class was generated from the following file: