Compare commits

...

3 Commits
master ... main

Author SHA1 Message Date
Peter 0d263dda8d
Mehr Delay, kein Serial 2020-01-15 21:27:30 +01:00
Peter 2ca8764788
Funktioniert jetzt auch! 2020-01-15 21:27:24 +01:00
Peter 74a8eaeac6
Zeitdifferenz via millis() statt delay() 2020-01-15 21:27:10 +01:00
1 changed files with 48 additions and 14 deletions

View File

@ -21,35 +21,69 @@ const PROGMEM uint16_t colors[NUM_COLORS] = {
};
uint16_t currColor[2];
typedef struct {
char text[17]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
byte len = 0;
unsigned char speed;
signed char pos = 0;
unsigned long millis = 0;
} runtext;
runtext text[2];
void setParams(runtext *textstruct, char* text, unsigned char speed){
strncpy(textstruct->text, text, 16);
textstruct->len=min((int)strlen(text),16);
textstruct->speed=speed;
}
bool changed=true;
void setup()
{
matrix.begin();
matrix.setTextSize(1);
Serial.begin(9600);
matrix.setTextWrap(false);
Serial.println("Setup Done");
currColor[0] = colors[random(NUM_COLORS)];
currColor[1] = colors[random(NUM_COLORS)];
setParams(&text[0], "/usr/space", 1000);
setParams(&text[1], "Wir haben offen!", 100);
}
void move(runtext *textstruct, int row){
if(millis()-(textstruct+row)->millis>=(textstruct+row)->speed){
(textstruct+row)->millis=millis();
changed=true;
(textstruct+row)->pos--;
if((textstruct+row)->pos < -(textstruct+row)->len*6){
(textstruct+row)->pos = matrix.width();
currColor[row]=colors[random(NUM_COLORS)];
}
}
}
void loop()
{
if(changed){
matrix.fillScreen(matrix.Color(0, 0, 0));
matrix.setCursor(i, 0);
matrix.setCursor(text[0].pos, 0);
matrix.setTextColor(currColor[0]);
matrix.print("/usr/space @36C3");
matrix.print(text[0].text);
matrix.setCursor(text[1].pos, 8);
matrix.setTextColor(currColor[1]);
matrix.setCursor(i*3, 8);
matrix.print("Sticker Exchange Sticker Exchange");
matrix.print(text[1].text);
portDISABLE_INTERRUPTS();
delay(1);
delay(5);
matrix.show();
delay(5);
portENABLE_INTERRUPTS();
if(--i < -16*6) {
i = matrix.width();
currColor[0] = colors[random(NUM_COLORS)];
currColor[1] = colors[random(NUM_COLORS)];
}
delay(249);
changed=false;
}
move(text,0);
move(text,1);
}