acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
FastLED_GFX.h (2000B)
1 #ifndef _FASTLED_GFX_H_ 2 #define _FASTLED_GFX_H_ 3 4 #include <FastLED.h> 5 #include <Arduino_GFX.h> 6 7 // Which pin on the Arduino is connected to the NeoPixels? 8 #define NEOPIXEL_PIN 1 9 10 #define NEOPIXEL_WIDTH 30 11 #define NEOPIXEL_HEIGHT 8 12 #define NUMPIXELS (NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT) 13 #define NEOPIXEL_BRIGHTNESS 3 // 1-255 14 15 #define LED_TYPE WS2811 16 #define COLOR_ORDER GRB 17 18 CRGB leds[NUMPIXELS]; 19 20 class FastLED_GFX : public Arduino_GFX 21 { 22 public: 23 FastLED_GFX() : Arduino_GFX(NEOPIXEL_WIDTH, NEOPIXEL_HEIGHT) 24 { 25 wrap = false; 26 } 27 28 bool begin(int32_t speed = GFX_NOT_DEFINED) override 29 { 30 FastLED.addLeds<LED_TYPE, NEOPIXEL_PIN, COLOR_ORDER>(leds, NUMPIXELS).setCorrection(TypicalLEDStrip); 31 FastLED.setBrightness(NEOPIXEL_BRIGHTNESS); 32 33 return true; 34 } 35 36 void writePixelPreclipped(int16_t x, int16_t y, uint16_t color) override 37 { 38 // select you matrix mode 39 int32_t i = (x * NEOPIXEL_HEIGHT) + y; // vertical strip start from left top 40 // int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? y : (NEOPIXEL_HEIGHT - y - 1)); // vertical zigzag strip start from left top 41 // int32_t i = (x * NEOPIXEL_HEIGHT) + (NEOPIXEL_HEIGHT - y - 1); // vertical strip start from left bottom 42 // int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? (NEOPIXEL_HEIGHT - y - 1) : y); // vertical zigzag strip start from left bottom 43 // int32_t i = x + (y * NEOPIXEL_WIDTH); // horizontal strip start from left top 44 // int32_t i = ((y % 2) ? x : (NEOPIXEL_WIDTH - x - 1)) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from left top 45 // int32_t i = (NEOPIXEL_WIDTH - x - 1) + (y * NEOPIXEL_WIDTH); // horizontal strip start from right top 46 // int32_t i = ((y % 2) ? (NEOPIXEL_WIDTH - x - 1) : x) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from right top 47 48 leds[i] = RGB16TO24(color); 49 } 50 51 void endWrite(void) override 52 { 53 FastLED.show(); 54 } 55 }; 56 57 #endif // _FASTLED_GFX_H_