Also es leuchtet weiterhin die ganze 1 Reihe/Spalte blau,
wenn ich das USB-Kabel raus ziehe und wieder reinstecke leuchtet dann nur die erste LED der Reihe/Spalte,
und manchmal auch die ersten zwei, oder random irgendwelche.
Folgender Code wird benutzt:
#define NUM_TLCS 3 // Hier Anzahl der verwendeten TLC5940 hinschreiben
#define NUM_ROWS 8 // Anzahl der ROWS der Matrix
#define NUM_COLUMNS 8 // An zahl der Columns der Matrix
#include "Tlc5940Mux.h"
volatile uint8_t isShifting;
uint8_t shiftRow;
// SHIFT_DATA_PIN (PC0 is analog 0) = '595 SER pin (Pin 14)
#define SHIFT_DATA_PORT PORTC
#define SHIFT_DATA_PIN PC0
#define SHIFT_DATA_DDR DDRC
// SHIFT_CLK_PIN (PC1 is analog 1) = '595 SRCLK (Pin 11)
#define SHIFT_CLK_PORT PORTC
#define SHIFT_CLK_PIN PC1
#define SHIFT_CLK_DDR DDRC
// '595 RCLK is hooked to tlc XLAT pin (Arduino digital Pin 9, 74HC595 Pin 12)
uint16_t Led_Red;
uint16_t Led_Green;
uint16_t Led_Blue;
static inline void
shift8_595_row(uint8_t row)
{
// the output of the '595 for the selected row should be low, all others
// high
//uint8_t output = ~(1 << row);
uint8_t output = (1 << row); // Eventuell beides mal probieren
for (uint8_t bit = 0x80; bit; bit >>= 1) {
if (bit & output) {
SHIFT_DATA_PORT |= _BV(SHIFT_DATA_PIN);
} else {
SHIFT_DATA_PORT &= ~_BV(SHIFT_DATA_PIN);
}
// pulse the '595 sclk
SHIFT_CLK_PORT |= _BV(SHIFT_CLK_PIN);
SHIFT_CLK_PORT &= ~_BV(SHIFT_CLK_PIN);
}
}
ISR(TIMER1_OVF_vect)
{
if (!isShifting) {
disable_XLAT_pulses();
isShifting = 1;
sei();
TlcMux_shiftRow(shiftRow);
shift8_595_row(shiftRow);
shiftRow++;
if (shiftRow == NUM_ROWS) {
shiftRow = 0;
}
enable_XLAT_pulses();
isShifting = 0;
}
}
void setup()
{
SHIFT_DATA_DDR |= _BV(SHIFT_DATA_PIN);
SHIFT_CLK_DDR |= _BV(SHIFT_CLK_PIN);
TlcMux_init();
}
void loop()
{
Matrix_Pixel(0, 0, 0, 0, 255);
//RandomColors(NUM_ROWS, NUM_COLUMNS, 150, 250);
delay(250);
}
void RandomColors(uint8_t NumRow, uint8_t NumColumn, int Again, int Speed)
{
byte Nr;
uint8_t Row;
uint8_t Column;
for (Nr = 0; Nr < Again; Nr += 1)
{
for (Row = 0; Row < NumRow ; Row += 1)
{
for (Column = 0; Column < NumColumn; Column += 1)
{
if (Nr < (Again - 1))
{
Matrix_Pixel(Row, Column, random(255), random(255), random(255));
}
else
{
Matrix_Pixel(Row, Column, 0, 0, 0);
}
}
}
delay(Speed);
}
}
void Matrix_Pixel(uint8_t Row, uint8_t Column, byte Red, byte Green, byte Blue)
{
Led_Red = map(Red, 0, 255, 0, 4095);
Led_Green = map(Green, 0, 255, 0, 4095);
Led_Blue = map(Blue, 0, 255, 0, 4095);
TlcMux_set(Row, Column, Led_Green);
TlcMux_set(Row, Column + 16, Led_Red / 1.8);
TlcMux_set(Row, Column + 32, Led_Blue);
}