create wrapper class for image functions
This commit is contained in:
parent
b8d34ebd54
commit
8b5ff04fa5
|
@ -45,18 +45,19 @@ class Flipdot
|
|||
{
|
||||
|
||||
private:
|
||||
int blafoo;
|
||||
|
||||
bool HBridgeOK();
|
||||
void resetColumns();
|
||||
void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
|
||||
|
||||
uint16_t row; //controls shift registers on own controller pcb
|
||||
|
||||
uint8_t col[COLUMNBYTES]; //column drivers and shift registers on annax pcb
|
||||
|
||||
|
||||
public:
|
||||
Flipdot();
|
||||
void init();
|
||||
|
||||
|
||||
void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
|
||||
bool clearSelectedColumn();
|
||||
bool setSelectedDot();
|
||||
|
||||
|
@ -64,15 +65,10 @@ public:
|
|||
void selectColumnSet(uint8_t selcolumn);
|
||||
void selectColumn(uint8_t selcolumn, bool clear);
|
||||
|
||||
bool HBridgeOK();
|
||||
void setRow(uint16_t _row);
|
||||
uint16_t getRow();
|
||||
|
||||
void shiftData();
|
||||
|
||||
void resetColumns();
|
||||
|
||||
|
||||
uint16_t row; //controls shift registers on own controller pcb
|
||||
|
||||
uint8_t col[COLUMNBYTES]; //column drivers and shift registers on annax pcb
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef IMAGE_H
|
||||
#define IMAGE_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "flipdot.h"
|
||||
|
||||
|
||||
#define COLUMNS 50
|
||||
#define ROWS 16
|
||||
|
||||
|
||||
#define UPDATE_INTERVAL 5
|
||||
|
||||
class Image
|
||||
{
|
||||
|
||||
private:
|
||||
Flipdot flipdot;
|
||||
|
||||
bool frontBuffer[16][16];
|
||||
|
||||
|
||||
int countz=0;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
Image();
|
||||
void init();
|
||||
|
||||
bool updateByColumn(bool direction, bool clearFirst, bool optimizeClear, bool optimizeSet);
|
||||
|
||||
uint8_t getW(); //returns Columns
|
||||
uint8_t getH(); //returns Rows
|
||||
|
||||
|
||||
void loop_testDots();
|
||||
void loop_drawClearTest();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -159,3 +159,11 @@ void Flipdot::resetColumns() {
|
|||
col[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
void Flipdot::setRow(uint16_t _row){
|
||||
row=_row;
|
||||
}
|
||||
|
||||
uint16_t Flipdot::getRow() {
|
||||
return row;
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
#include "image.h"
|
||||
|
||||
|
||||
|
||||
Image::Image()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Image::init()
|
||||
{
|
||||
flipdot.init(); //sets pin modes etc.
|
||||
}
|
||||
|
||||
uint8_t Image::getW() {
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
uint8_t Image::getH() {
|
||||
return ROWS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Image::loop_testDots() {
|
||||
|
||||
static bool init=false;
|
||||
if (!init) {
|
||||
flipdot.setRow(0);
|
||||
Serial.println("Clearing Display");
|
||||
for (int l=0;l<COLUMNS;l++) {
|
||||
flipdot.selectColumnClear(l%COLUMNS);
|
||||
|
||||
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.setRow(0);
|
||||
flipdot.selectColumnClear(23);
|
||||
flipdot.shiftData();
|
||||
if (!flipdot.clearSelectedColumn()) {
|
||||
Serial.println("Error clearing column!");
|
||||
}
|
||||
delay(50);
|
||||
|
||||
flipdot.setRow(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.setRow(0);
|
||||
flipdot.setRow(flipdot.getRow()+pow(2, 4));//low significant bits are lower rows (when connector at top)
|
||||
flipdot.setRow(flipdot.getRow()+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 Image::loop_drawClearTest() {
|
||||
|
||||
static bool init=false;
|
||||
if (!init) {
|
||||
flipdot.setRow(0);
|
||||
Serial.println("Clearing Display");
|
||||
for (int l=0;l<COLUMNS;l++) {
|
||||
flipdot.selectColumnClear(l%COLUMNS);
|
||||
|
||||
flipdot.shiftData();
|
||||
|
||||
if (!flipdot.clearSelectedColumn()) {
|
||||
Serial.println("Error clearing column!");
|
||||
}else{
|
||||
Serial.println("Cleared");
|
||||
}
|
||||
|
||||
delay(20);
|
||||
}
|
||||
init=true;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Serial.print("count=");
|
||||
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)
|
||||
|
||||
|
||||
//cycle testing set dots
|
||||
flipdot.selectColumnSet(countz/ROWS); //lower column number is on the left
|
||||
flipdot.setRow(pow(2, (countz)%ROWS));//low significant bits are lower rows (when connector at top)
|
||||
|
||||
|
||||
|
||||
|
||||
/*Serial.print("Row="); Serial.print(row); Serial.print(" Col=");
|
||||
for (uint8_t i=0;i<7;i++) {
|
||||
Serial.print(","); Serial.print(col[i]);
|
||||
}
|
||||
Serial.println();*/
|
||||
//reset pin on ribbon cable high (12Vpullup/open), then low (via Transistor)
|
||||
|
||||
unsigned long starttime=micros();
|
||||
|
||||
flipdot.shiftData();
|
||||
|
||||
|
||||
flipdot.setSelectedDot();
|
||||
|
||||
|
||||
unsigned long shiftduration=micros()-starttime;
|
||||
Serial.println("");
|
||||
Serial.print("Duration="); Serial.println(shiftduration);
|
||||
|
||||
|
||||
|
||||
countz++;
|
||||
|
||||
if (countz>=ROWS*COLUMNS) {
|
||||
countz=0;
|
||||
init=false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,182 +1,39 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
|
||||
|
||||
#include "flipdot.h"
|
||||
#include "image.h"
|
||||
|
||||
|
||||
Flipdot flipdot;
|
||||
|
||||
|
||||
Image flip;
|
||||
|
||||
unsigned long loopmillis=0;
|
||||
unsigned long last_update=0;
|
||||
|
||||
#define UPDATE_INTERVAL 5
|
||||
|
||||
|
||||
void setup() {
|
||||
flipdot.init();
|
||||
flip.init();
|
||||
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
int countz=0;
|
||||
|
||||
void loop_testDots();
|
||||
void loop_drawClearTest();
|
||||
|
||||
void loop() {
|
||||
loopmillis = millis();
|
||||
|
||||
loop_drawClearTest();
|
||||
//loop_testDots();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#define COLUMNS 50
|
||||
#define ROWS 16
|
||||
|
||||
void loop_testDots() {
|
||||
|
||||
static bool init=false;
|
||||
if (!init) {
|
||||
flipdot.row=0;
|
||||
Serial.println("Clearing Display");
|
||||
for (int l=0;l<COLUMNS;l++) {
|
||||
flipdot.selectColumnClear(l%COLUMNS);
|
||||
|
||||
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) {
|
||||
flipdot.row=0;
|
||||
Serial.println("Clearing Display");
|
||||
for (int l=0;l<COLUMNS;l++) {
|
||||
flipdot.selectColumnClear(l%COLUMNS);
|
||||
|
||||
flipdot.shiftData();
|
||||
|
||||
if (!flipdot.clearSelectedColumn()) {
|
||||
Serial.println("Error clearing column!");
|
||||
}else{
|
||||
Serial.println("Cleared");
|
||||
}
|
||||
|
||||
delay(20);
|
||||
}
|
||||
init=true;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
if (loopmillis > last_update + UPDATE_INTERVAL)
|
||||
{
|
||||
|
||||
Serial.print("count=");
|
||||
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)
|
||||
|
||||
|
||||
//cycle testing set dots
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
/*Serial.print("Row="); Serial.print(row); Serial.print(" Col=");
|
||||
for (uint8_t i=0;i<7;i++) {
|
||||
Serial.print(","); Serial.print(col[i]);
|
||||
}
|
||||
Serial.println();*/
|
||||
//reset pin on ribbon cable high (12Vpullup/open), then low (via Transistor)
|
||||
|
||||
unsigned long starttime=micros();
|
||||
|
||||
flipdot.shiftData();
|
||||
|
||||
|
||||
flipdot.setSelectedDot();
|
||||
|
||||
|
||||
unsigned long shiftduration=micros()-starttime;
|
||||
Serial.println("");
|
||||
Serial.print("Duration="); Serial.println(shiftduration);
|
||||
|
||||
|
||||
flip.loop_drawClearTest();
|
||||
//loop_testDots();
|
||||
|
||||
last_update=loopmillis;
|
||||
countz++;
|
||||
|
||||
if (countz>=ROWS*COLUMNS) {
|
||||
countz=0;
|
||||
init=false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue