So, ich bin jetzt schonmal einen Schritt weiter. Habe folgende Basis gefunden und möchte darauf aufbauen:
https://forum.arduino.cc/index.php?topic=411117.0
Das Problem an dieser Umsetzung ist, dass eine 20x15 = 300LED Matrix verwendet wird. Mein Gedanke: 300 > 255 also kann ich keine uint8_t Variablen verwenden. Muss also alles ummodeln. Das an sich bekomme ich locker hin, vorausgesetzt ich verstehe das gesamte Script. Das ist leider noch nicht der Fall 
Für Testzwecke habe ich mir eine 3x3 Matrix aufgebaut. Diese funktioniert Hardware-seitig ohne Probleme. Auch das setzen einzelner Pixel und ganzer Zeilen / Spalten habe ich verstanden. Dies allerdings nur mit einer festen Schleife, nicht via lesen aus der font Datei.
Genau da hapert es zur Zeit.
Ich habe mir mal eine eigene pattern.h zu Testzwecken angelegt.
/* pattern.h
*
* uTFT Font library
* http://www.henningkarlsen.com/electronics/r_fonts.php
*
*/
#ifndef __FONT_H
#define __FONT_H
const unsigned char pattern[12] =
{
0x00,0x00,0x00, // <Space>
0x07,0x05,0x07, // circle
0x05,0x05,0x05, // outer lines
0x04,0x02,0x01, // diagonal line
};
#endif
Das Problem ist gerade, dass ich es nicht schaffe, die hex code in bits umzuwandeln um ihn dann bitweise auslesen.
also:
0x05 = 0101
um anschließend in einer Schleife die bits durchzugehen. Wenn bit gesetzt, dann LED AN, wenn nicht gesetzt LED AUS.
Habe mir schon Bitweise Operatoren angeschaut, verstehe aber leider nichts. Brauche also Hilfe bei dieser IF-Abfrage.
patternRowValue = 0x05;
for(uint8_t y = 0; y < 3; y++){
if( "bit an der Stelle y von patternRowValue == 1"){
leds[y] = ON;
}
else{
leds[y] = OFF;
}
}
die if Abfrage bekomm ich einfach nicht auf die Kette.
Zum Abschluss jetzt das vollständige Script inklusive der Stelle, da der ich zur Zeit hänge.
/********** basic includes and defines for LED Strip *********/
#include <FastLED.h>
#define LED_PIN 3
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define BRIGHTNESS 64
/********** Defines for the Matrix *************/
const uint8_t xMatrix = 3;
const uint8_t yMatrix = 3;
#define NUM_LEDS (xMatrix * yMatrix)
const bool kMatrixSerpentineLayout = true;
/********** Set 'kMatrixSerpentineLayout' to true if your pixels are ******/
// laid out back-and-forth, like this:
//
// 0 > 1 > 2 > 3 > 4
// |
// |
// 9 < 8 < 7 < 6 < 5
// |
// |
// 10 > 11 > 12 > 13 > 14
// |
// |
// 19 < 18 < 17 < 16 < 15
//
//
// Helper functions for an two-dimensional XY matrix of pixels.
// Simple 2-D demo code is included as well.
//
// XY(x,y) takes x and y coordinates and returns an LED index number,
// for use like this: leds[ XY(x,y) ] == CRGB::Red;
// No error checking is performed on the ranges of x and y.
//
// XYsafe(x,y) takes x and y coordinates and returns an LED index number,
// for use like this: leds[ XY(x,y) ] == CRGB::Red;
// Error checking IS performed on the ranges of x and y, and an
// index of "-1" is returned. Special instructions below
// explain how to use this without having to do your own error
// checking every time you use this function.
// This is a slightly more advanced technique, and
// it REQUIRES SPECIAL ADDITIONAL setup, described below.
uint16_t XY( uint8_t x, uint8_t y)
// method to get actual led number out
{
uint16_t i;
if( kMatrixSerpentineLayout == false) {
i = (y * xMatrix) + x;
}
if( kMatrixSerpentineLayout == true) {
if( y & 0x01) {
// Odd rows run backwards
uint8_t reverseX = (xMatrix - 1) - x;
i = (y * xMatrix) + reverseX;
} else {
// Even rows run forwards
i = (y * xMatrix) + x;
}
}
return i;
}
CRGB leds_plus_safety_pixel[ NUM_LEDS + 1];
CRGB* leds( leds_plus_safety_pixel + 1);
uint16_t XYsafe( uint8_t x, uint8_t y)
// method to get SAFE LED number; prevents overflow
{
if( x >= xMatrix) return -1;
if( y >= yMatrix) return -1;
return XY(x,y);
}
/********** methods for generell LED operations ************/
//
// initPixels sets up the Strip with chipset, output pin, color order and brightness
//
// clearTablePixels gives all LED state Black == off
//
// showPixels same as FastLED.show(); actually send the set states to the strip
//
// setPixelRGB sets n'th LED to set hex code color
//
// setPixelHSV sets n'th LED to set hue degree (0-255)
//
// setMatrixPixel sets x,y coordinate of matrix to hue color; full saturation brightness
void initPixels()
// initialize Strip; setup brightness
{
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
FastLED.setBrightness( BRIGHTNESS );
}
void clearTablePixels()
// run through all LED and give them state BLACK
{
for(uint8_t i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Black;
}
}
void showPixels()
{
FastLED.show();
}
void setPixelRGB(int n, int color)
// set n'th LED to hex color
{
leds[n] = CRGB(color);
}
void setPixelHSV(int n, uint8_t hue)
// set n'th LED to hue degree; 1byte
{
leds[n] = CHSV(hue);
}
void setMatrixPixel(uint8_t x, uint8_t y, uint8_t color)
// sets x,y coordinate of matrix to hue color; full brightness/saturation
{
leds[ XYsafe(x,y) ] = CHSV(Hue, 255, 255);
}
/********** pattern helper methods ***********/
#include "pattern.h"
uint8_t charBuffer[3][3];
void printPattern(uint8_t patternNumber, uint8_t hue)
// llops over x coloums and y rows and sets matrix pixel to states red from pattern.h
{
clearTablePixels();
// clear all pixels
uint8_t patternIndex = patternNumber*3;
// get first row number (hex value) of selected pattern
// for example: patternNumber = 2 -> actual pattern starts in pattern array (pattern.h)
// at index 6 -> patternIndex = 6
patternRowValue = pattern[patternIndex];
// get the hex value of the row of the patternIndex
/********** AB HIER HABE ICH DAS BESCHRIEBENE PROBLEM *******/
setMatrixPixel(xPos, yPos, hue);
}
/********** SETUP **************/
void setup(){
initPixels();
clearTablePixels();
showPixels();
delay(2000);
// delay for 2 sec for optical reasons, can be removed later on
}
/********** Main loop **********/
void loop(){
printPattern(2, 96);
// print pattern with index 2 --> vertical outer lines
// hue color 96 == green
delay(100);
// update every 100
}
Und nochmal das FastLED wiki falls dazu Fragen sind: