2023-01-22 21:47:03 +00:00
# include <Arduino.h>
2023-01-31 21:50:25 +00:00
# include "flipdot.h"
2023-01-22 21:47:03 +00:00
2023-01-31 21:50:25 +00:00
Flipdot flipdot ;
2023-01-22 21:47:03 +00:00
2023-01-31 20:28:49 +00:00
2023-01-22 21:47:03 +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
2023-01-22 21:47:03 +00:00
void setup ( ) {
2023-01-31 21:50:25 +00:00
flipdot . init ( ) ;
2023-01-22 21:47:03 +00:00
Serial . begin ( 115200 ) ;
}
int countz = 0 ;
2023-02-07 16:51:02 +00:00
void loop_testDots ( ) ;
void loop_drawClearTest ( ) ;
2023-01-22 21:47:03 +00:00
void loop ( ) {
loopmillis = millis ( ) ;
2023-01-31 20:28:49 +00:00
2023-02-07 16:51:02 +00:00
//loop_drawClearTest();
loop_testDots ( ) ;
2023-01-22 21:47:03 +00:00
2023-02-07 16:51:02 +00:00
}
void loop_testDots ( ) {
static bool init = false ;
if ( ! init ) {
flipdot . row = 0 ;
Serial . println ( " Clearing Display " ) ;
for ( int l = 0 ; l < 25 ; l + + ) {
flipdot . selectColumnClear ( l % 25 ) ;
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 ( ) {
2023-01-24 23:18:15 +00:00
static bool init = false ;
if ( ! init ) {
2023-01-31 21:50:25 +00:00
flipdot . row = 0 ;
2023-01-24 23:18:15 +00:00
Serial . println ( " Clearing Display " ) ;
for ( int l = 0 ; l < 25 ; l + + ) {
2023-01-31 21:50:25 +00:00
flipdot . selectColumnClear ( l % 25 ) ;
2023-01-24 23:18:15 +00:00
2023-01-31 21:50:25 +00:00
flipdot . shiftData ( ) ;
2023-01-24 23:18:15 +00:00
2023-01-31 21:50:25 +00:00
if ( ! flipdot . clearSelectedColumn ( ) ) {
2023-01-24 23:18:15 +00:00
Serial . println ( " Error clearing column! " ) ;
} else {
Serial . println ( " Cleared " ) ;
}
2023-02-07 16:51:02 +00:00
delay ( 20 ) ;
2023-01-24 23:18:15 +00:00
}
init = true ;
delay ( 1000 ) ;
}
2023-01-22 21:47:03 +00:00
if ( loopmillis > last_update + UPDATE_INTERVAL )
{
Serial . print ( " count= " ) ;
2023-01-24 22:46:52 +00:00
Serial . print ( countz ) ; Serial . print ( " : " ) ;
2023-01-22 21:47:03 +00:00
//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-01-31 21:50:25 +00:00
flipdot . selectColumnSet ( countz / 16 ) ; //lower column number is on the left
flipdot . row = pow ( 2 , ( countz ) % 16 ) ; //low significant bits are lower rows (when connector at top)
2023-01-31 20:28:49 +00:00
2023-01-22 21:47:03 +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 ( ) ;
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
2023-01-22 21:47:03 +00:00
last_update = loopmillis ;
countz + + ;
2023-01-31 20:50:48 +00:00
if ( countz > = 16 * 25 ) {
countz = 0 ;
init = false ;
}
2023-01-22 21:47:03 +00:00
}
}