flipdot/flipcontrol_esp32/src/main.cpp

183 lines
4.0 KiB
C++
Raw Normal View History

#include <Arduino.h>
2023-01-31 21:50:25 +00:00
#include "flipdot.h"
2023-01-31 21:50:25 +00:00
Flipdot flipdot;
2023-01-31 20:28:49 +00:00
unsigned long loopmillis=0;
unsigned long last_update=0;
2023-01-24 22:46:52 +00:00
2023-02-07 16:51:02 +00:00
#define UPDATE_INTERVAL 5
void setup() {
2023-01-31 21:50:25 +00:00
flipdot.init();
Serial.begin(115200);
}
int countz=0;
2023-02-07 16:51:02 +00:00
void loop_testDots();
void loop_drawClearTest();
void loop() {
loopmillis = millis();
2023-01-31 20:28:49 +00:00
2023-02-07 17:37:23 +00:00
loop_drawClearTest();
//loop_testDots();
2023-02-07 16:51:02 +00:00
}
2023-02-07 17:37:23 +00:00
#define COLUMNS 50
#define ROWS 16
2023-02-07 16:51:02 +00:00
void loop_testDots() {
static bool init=false;
if (!init) {
flipdot.row=0;
Serial.println("Clearing Display");
2023-02-07 17:37:23 +00:00
for (int l=0;l<COLUMNS;l++) {
flipdot.selectColumnClear(l%COLUMNS);
2023-02-07 16:51:02 +00:00
flipdot.shiftData();
if (!flipdot.clearSelectedColumn()) {
Serial.println("Error clearing column!");
}else{
Serial.println("Cleared");
}
delay(50);
}
init=true;
Serial.println("Finished Clearing");
delay(1000);
}
Serial.println("Clearing");
flipdot.row=0;
flipdot.selectColumnClear(23);
flipdot.shiftData();
if (!flipdot.clearSelectedColumn()) {
Serial.println("Error clearing column!");
}
delay(50);
flipdot.row=0;
flipdot.selectColumnClear(24);
flipdot.shiftData();
if (!flipdot.clearSelectedColumn()) {
Serial.println("Error clearing column!");
}
delay(100);
Serial.println("Setting");
for (int i=23;i<25;i++) {
flipdot.selectColumnSet(i); //lower column number is on the left
flipdot.row=0;
flipdot.row+=pow(2, 4);//low significant bits are lower rows (when connector at top)
flipdot.row+=pow(2, 5);//low significant bits are lower rows (when connector at top)
flipdot.shiftData();
flipdot.setSelectedDot();
delay(50);
}
delay(100);
countz++;
countz%=14;
//init=false;
}
void loop_drawClearTest() {
static bool init=false;
if (!init) {
2023-01-31 21:50:25 +00:00
flipdot.row=0;
Serial.println("Clearing Display");
2023-02-07 17:37:23 +00:00
for (int l=0;l<COLUMNS;l++) {
flipdot.selectColumnClear(l%COLUMNS);
2023-01-31 21:50:25 +00:00
flipdot.shiftData();
2023-01-31 21:50:25 +00:00
if (!flipdot.clearSelectedColumn()) {
Serial.println("Error clearing column!");
}else{
Serial.println("Cleared");
}
2023-02-07 16:51:02 +00:00
delay(20);
}
init=true;
delay(1000);
}
if (loopmillis > last_update + UPDATE_INTERVAL)
{
Serial.print("count=");
2023-01-24 22:46:52 +00:00
Serial.print(countz);Serial.print(": ");
//setting colX to 128, 32, 8,2 (or a combination of), then appling 12V to driver and GND to Clear, clears these colums
// this applies +12v to selected columns
//setting colX to 64,16,4,1 (or a combination of), then setting row shift registers to some setting sets the selected dots
// this applies GND to selected columns
//reset pin on annax board input should be used (not pulled to gnd for a short time) after dots have been flipped (to disable potentially activated transistors)
2023-01-24 22:46:52 +00:00
2023-01-31 20:50:48 +00:00
//cycle testing set dots
2023-02-07 17:37:23 +00:00
flipdot.selectColumnSet(countz/ROWS); //lower column number is on the left
flipdot.row=pow(2, (countz)%ROWS);//low significant bits are lower rows (when connector at top)
2023-01-31 20:28:49 +00:00
2023-01-31 20:28:49 +00:00
2023-01-31 21:50:25 +00:00
/*Serial.print("Row="); Serial.print(row); Serial.print(" Col=");
2023-01-31 20:50:48 +00:00
for (uint8_t i=0;i<7;i++) {
Serial.print(","); Serial.print(col[i]);
2023-01-31 20:28:49 +00:00
}
2023-01-31 21:50:25 +00:00
Serial.println();*/
2023-01-31 20:50:48 +00:00
//reset pin on ribbon cable high (12Vpullup/open), then low (via Transistor)
2023-01-31 21:50:25 +00:00
unsigned long starttime=micros();
2023-01-31 20:50:48 +00:00
2023-01-31 21:50:25 +00:00
flipdot.shiftData();
2023-01-24 22:46:52 +00:00
2023-01-31 21:50:25 +00:00
flipdot.setSelectedDot();
2023-01-31 21:50:25 +00:00
unsigned long shiftduration=micros()-starttime;
Serial.println("");
Serial.print("Duration="); Serial.println(shiftduration);
2023-01-31 20:28:49 +00:00
2023-01-31 20:50:48 +00:00
last_update=loopmillis;
countz++;
2023-02-07 17:37:23 +00:00
if (countz>=ROWS*COLUMNS) {
2023-01-31 20:50:48 +00:00
countz=0;
init=false;
}
}
}