This is an add-on library for supporting the Stream Deck V2, MkII, and (probably) XL on the Teensy 4.x with the included (no need to install) USBHost_t36 core library.
There are three "hook" points you can add your own callbacks for:
- Single key press/release hook -
void attachSinglePress(void (*f)(StreamdeckController *sdc, const uint16_t keyIndex, const uint8_t newValue, const uint8_t oldValue))
- Press/release hook showing all key states at once -
void attachAnyChange(void (*f)(StreamdeckController *sdc, const uint8_t *newStates, const uint8_t *oldStates))
- Single key hold (not released) hook -
void attachSingleKeyHeld(void (*f)(StreamdeckController *sdc, const uint16_t keyIndex))
There are a handful of useful functions you can call from your script when the controller is attached/active:
void setBrightness(float percent)
- sets brightness; percent values are floats between 0 and 1void setKeyImage(const uint16_t keyIndex, const uint8_t *image, const uint16_t length)
- lets you set a jpeg-formatted image to a keyvoid setKeyBlank(const uint16_t keyIndex)
- sets a key to blackuint16_t getNumKeys()
- retrieves the number of keys/states availablevoid reset()
- issues a reset! Don't do this for now; it irrevocably resets the pipesvoid flushImageReports()
- clears the pending queue and sends an empty outbound report to reset counters on the Streamdeck [this also isn't working right, but I haven't found a need for it].void blankAllKeys();
- shortcut to set all keys to blank (black)
The .Task()
function needs to be run on every iteration of the loop to be able to catch all the input hooks.
Yes, I now have an image helper inclusion that's based on the outstanding tgx, JPEGENC, and JPEGDEC libraries. It's included and enabled by default though it can be disabled with build options in PlatformIO or by changing streamdeck_config.hpp
in Arduino libraries.
Check out the RandomBlobhaj
example for the simplest path to using the Image Helper. Basic order of operations:
- Create a new
Streamdeck::Image
object, passing it in the settings fetched from your StreamdeckController instance. - On that new image object,
.importJpeg
to import from memory, a filename, or a file handle. - Perform any transformation operations needed on that image object. Memory will be dynamically allocated and released as needed.
- Use the
.sendToKey
shortcut to send it to your StreamdeckController instance.
Et voila!
- Add support for other Stream Decks, ideally mirroring python-elgato-streamdeck's support.
- Add support or optional addon for image manipulation (scaling, flip/rotation)
- Add more examples