initial commit

This commit is contained in:
lsdlsd88
2024-04-25 17:22:13 +02:00
parent 683b846d60
commit b5204b2a68
2737 changed files with 1534650 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
/*******************************************************************************
* FastLED GFX Example
* This is a simple GFX example for FastLED
*
* Dependent libraries:
* FastLED: https://github.com/FastLED/FastLED.git
******************************************************************************/
#include <Arduino_GFX_Library.h>
// all settings in header file
#include "FastLED_GFX.h"
Arduino_GFX *gfx = new FastLED_GFX();
int16_t x;
uint16_t w, tw;
void setup(void)
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX FastLED example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(BLACK);
x = 0;
gfx->setCursor(x, 0);
gfx->setTextColor(RED);
gfx->println("Hello World!");
int16_t x1, y1;
uint16_t h;
gfx->getTextBounds("Hello World!", 0, 0, &x1, &y1, &w, &h);
tw = w;
w = gfx->width();
delay(1000); // 1 seconds
}
void loop()
{
x--;
if (x < (-tw))
{
x = w - 1;
}
gfx->setCursor(x, 0);
gfx->setTextColor(random(0xffff), BLACK);
gfx->println("Hello World!");
delay(100); // 0.1 second
}

View File

@@ -0,0 +1,57 @@
#ifndef _FASTLED_GFX_H_
#define _FASTLED_GFX_H_
#include <FastLED.h>
#include <Arduino_GFX.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define NEOPIXEL_PIN 1
#define NEOPIXEL_WIDTH 30
#define NEOPIXEL_HEIGHT 8
#define NUMPIXELS (NEOPIXEL_WIDTH * NEOPIXEL_HEIGHT)
#define NEOPIXEL_BRIGHTNESS 3 // 1-255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUMPIXELS];
class FastLED_GFX : public Arduino_GFX
{
public:
FastLED_GFX() : Arduino_GFX(NEOPIXEL_WIDTH, NEOPIXEL_HEIGHT)
{
wrap = false;
}
bool begin(int32_t speed = GFX_NOT_DEFINED) override
{
FastLED.addLeds<LED_TYPE, NEOPIXEL_PIN, COLOR_ORDER>(leds, NUMPIXELS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(NEOPIXEL_BRIGHTNESS);
return true;
}
void writePixelPreclipped(int16_t x, int16_t y, uint16_t color) override
{
// select you matrix mode
int32_t i = (x * NEOPIXEL_HEIGHT) + y; // vertical strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? y : (NEOPIXEL_HEIGHT - y - 1)); // vertical zigzag strip start from left top
// int32_t i = (x * NEOPIXEL_HEIGHT) + (NEOPIXEL_HEIGHT - y - 1); // vertical strip start from left bottom
// int32_t i = (x * NEOPIXEL_HEIGHT) + ((x % 2) ? (NEOPIXEL_HEIGHT - y - 1) : y); // vertical zigzag strip start from left bottom
// int32_t i = x + (y * NEOPIXEL_WIDTH); // horizontal strip start from left top
// int32_t i = ((y % 2) ? x : (NEOPIXEL_WIDTH - x - 1)) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from left top
// int32_t i = (NEOPIXEL_WIDTH - x - 1) + (y * NEOPIXEL_WIDTH); // horizontal strip start from right top
// int32_t i = ((y % 2) ? (NEOPIXEL_WIDTH - x - 1) : x) + (y * NEOPIXEL_WIDTH); // horizontal zigzag strip start from right top
leds[i] = RGB16TO24(color);
}
void endWrite(void) override
{
FastLED.show();
}
};
#endif // _FASTLED_GFX_H_