99 lines
2.0 KiB
C++
99 lines
2.0 KiB
C++
#include <Arduino.h>
|
|
|
|
|
|
|
|
#include "flipdot.h"
|
|
#include "image.h"
|
|
|
|
|
|
|
|
|
|
Image flip;
|
|
|
|
unsigned long loopmillis=0;
|
|
unsigned long last_update=0;
|
|
|
|
|
|
|
|
void setup() {
|
|
flip.init();
|
|
|
|
Serial.begin(115200);
|
|
flip.setBuffer_solid(0);
|
|
|
|
}
|
|
|
|
|
|
void loop() {
|
|
loopmillis = millis();
|
|
|
|
static unsigned long last_change=0;
|
|
static bool color=0;
|
|
|
|
static uint8_t image=0;
|
|
if (loopmillis-last_change >= 1000*10)
|
|
{
|
|
/*
|
|
Serial.print("Change to Solid color ="); Serial.println(color);
|
|
|
|
flip.setBuffer_solid(color);
|
|
color=1-color;
|
|
|
|
*/
|
|
|
|
|
|
switch (image){
|
|
case 0:
|
|
flip.setBuffer_Image1();
|
|
break;
|
|
case 1:
|
|
flip.setBuffer_Image2();
|
|
break;
|
|
case 2:
|
|
flip.setBuffer_Image3();
|
|
break;
|
|
case 3:
|
|
flip.setBuffer_Image4();
|
|
break;
|
|
|
|
}
|
|
|
|
image++;
|
|
image%=4;
|
|
|
|
|
|
|
|
/*
|
|
uint8_t _randomvalue=random(128);
|
|
Serial.print("set buffer random. ");
|
|
Serial.println(_randomvalue);
|
|
flip.setBuffer_random(_randomvalue);
|
|
*/
|
|
/*
|
|
for (uint8_t _x=0;_x<COLUMNS;_x++) {
|
|
uint8_t _y=(sin( loopmillis/100000.0 + _x/5.0 )/2+0.5)*15+0.5;
|
|
uint16_t _row=pow(2, _y);
|
|
flip.setBufferColumn(_x,_row);
|
|
}
|
|
*/
|
|
|
|
|
|
|
|
last_change=loopmillis;
|
|
}
|
|
|
|
|
|
//UpdateReturn result=flip.updateByColumn(true,true,true); //0=not finished, 1=finished
|
|
UpdateReturn result=flip.updateByColumn(true,false,false); //0=not finished, 1=finished
|
|
if (result == finished) //just finished
|
|
{
|
|
unsigned long duration=millis()-last_change;
|
|
Serial.print("Last Change took "); Serial.print(duration); Serial.println(" ms");
|
|
Serial.print("Update max took "); Serial.print(flip.updateDuration); Serial.println(" ms");
|
|
flip.updateDuration=0; //reset
|
|
|
|
//flip.shuffleOrder(1);
|
|
}
|
|
|
|
}
|