pixbuf.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef APP_MODULES_PIXBUF_H_
  2. #define APP_MODULES_PIXBUF_H_
  3. typedef struct pixbuf {
  4. const size_t npix;
  5. const size_t nchan;
  6. /* Flexible Array Member; true size is npix * pixbuf_channels_for(type) */
  7. uint8_t values[];
  8. } pixbuf;
  9. enum pixbuf_fade {
  10. PIXBUF_FADE_IN,
  11. PIXBUF_FADE_OUT
  12. };
  13. enum pixbuf_shift {
  14. PIXBUF_SHIFT_LOGICAL,
  15. PIXBUF_SHIFT_CIRCULAR
  16. };
  17. pixbuf *pixbuf_from_lua_arg(lua_State *, int);
  18. const size_t pixbuf_size(pixbuf *);
  19. // Exported for backwards compat with ws2812 module
  20. int pixbuf_new_lua(lua_State *);
  21. /*
  22. * WS2812_EFFECTS does pixbuf manipulation directly in C, which isn't the
  23. * intended use case, but for backwards compat, we export just what it needs.
  24. * Move this struct to pixbuf.c and mark these exports static instead once
  25. * WS2812_EFFECTS is no more.
  26. */
  27. struct pixbuf_shift_params {
  28. enum pixbuf_shift type;
  29. // 0 <= offset <= buffer length
  30. size_t offset;
  31. // 0 <= window + offset <= buffer length
  32. size_t window;
  33. // 0 <= shift <= window_size
  34. size_t shift;
  35. bool shiftLeft;
  36. };
  37. void pixbuf_shift(pixbuf *, struct pixbuf_shift_params *);
  38. void pixbuf_prepare_shift(pixbuf *, struct pixbuf_shift_params *,
  39. int val, enum pixbuf_shift, int start, int end);
  40. const size_t pixbuf_channels(pixbuf *);
  41. /* end WS2812_EFFECTS exports */
  42. #endif