working clearing individual columns, problem with setting individual dots
This commit is contained in:
parent
0438b4094a
commit
f916bafb84
|
@ -37,9 +37,12 @@ void selectColumnClear(uint8_t selcolumn);
|
||||||
void selectColumnSet(uint8_t selcolumn);
|
void selectColumnSet(uint8_t selcolumn);
|
||||||
void selectColumn(uint8_t selcolumn, bool clear);
|
void selectColumn(uint8_t selcolumn, bool clear);
|
||||||
|
|
||||||
|
bool HBridgeOK();
|
||||||
|
void shiftData();
|
||||||
|
|
||||||
unsigned long loopmillis=0;
|
unsigned long loopmillis=0;
|
||||||
unsigned long last_update=0;
|
unsigned long last_update=0;
|
||||||
#define UPDATE_INTERVAL 3000
|
#define UPDATE_INTERVAL 500
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -83,7 +86,26 @@ void loop() {
|
||||||
digitalWrite(PIN_OE, LOW); //Active Low
|
digitalWrite(PIN_OE, LOW); //Active Low
|
||||||
|
|
||||||
|
|
||||||
|
static bool init=false;
|
||||||
|
if (!init) {
|
||||||
|
delay(2000);
|
||||||
|
Serial.println("Clearing Display");
|
||||||
|
for (int l=0;l<25;l++) {
|
||||||
|
selectColumnClear(l%25);
|
||||||
|
|
||||||
|
shiftData();
|
||||||
|
|
||||||
|
if (!clearSelectedColumn()) {
|
||||||
|
Serial.println("Error clearing column!");
|
||||||
|
}else{
|
||||||
|
Serial.println("Cleared");
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
|
init=true;
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (loopmillis > last_update + UPDATE_INTERVAL)
|
if (loopmillis > last_update + UPDATE_INTERVAL)
|
||||||
|
@ -126,11 +148,11 @@ void loop() {
|
||||||
//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)
|
//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)
|
||||||
|
|
||||||
|
|
||||||
selectColumnClear(countz%25);
|
//selectColumnClear(countz%25);
|
||||||
|
|
||||||
//selectColumnSet(countz%25);
|
selectColumnSet((12+(countz/25))%25); //lower column number is on the left
|
||||||
|
|
||||||
//row=pow(2, countz/25);
|
row=pow(2, countz%16); //low significant bits are lower rows (when connector at top)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,28 +165,18 @@ void loop() {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
//reset pin on ribbon cable high (12Vpullup/open), then low (via Transistor)
|
//reset pin on ribbon cable high (12Vpullup/open), then low (via Transistor)
|
||||||
|
|
||||||
//Select Columns via Shift registers
|
shiftData();
|
||||||
for (uint8_t i=0;i<7;i++) {
|
|
||||||
shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, col[6-i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//select Rows via shift registers on own controller board
|
|
||||||
shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, row%256);
|
|
||||||
shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, row/256); //LSBFIRST= LSB is QH, bit 8 is QA.
|
|
||||||
digitalWrite(PIN_LATCH, HIGH);
|
|
||||||
delayMicroseconds(100);
|
|
||||||
digitalWrite(PIN_LATCH, LOW);
|
|
||||||
|
|
||||||
|
|
||||||
//setSelectedDot();
|
setSelectedDot();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!clearSelectedColumn()) {
|
/*if (!clearSelectedColumn()) {
|
||||||
Serial.println("Error clearing column!");
|
Serial.println("Error clearing column!");
|
||||||
}else{
|
}else{
|
||||||
Serial.println("Cleared");
|
Serial.println("Cleared");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +226,17 @@ void selectColumn(uint8_t selcolumn, bool clear) {
|
||||||
col[i]=0;
|
col[i]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
col[sc_byte]=pow(2, (sc_bit*2+clear));
|
col[sc_byte]=pow(2, (sc_bit*2+clear)); // possible numbers for clear=false: 1,4,16,64
|
||||||
|
/*
|
||||||
|
if (!clear) { //when setting a dot set all other columns to 12v (to avoid ghost flipping)
|
||||||
|
for (uint8_t i=0;i<7;i++) {
|
||||||
|
col[i]+=2+8+32+128; //set to +12v
|
||||||
|
}
|
||||||
|
col[sc_byte]-=pow(2, (sc_bit*2+1)); //avoid short circuit on H-bridge
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool clearSelectedColumn() {
|
bool clearSelectedColumn() {
|
||||||
|
@ -235,7 +257,7 @@ bool clearSelectedColumn() {
|
||||||
|
|
||||||
digitalWrite(PIN_DRIVE, HIGH);
|
digitalWrite(PIN_DRIVE, HIGH);
|
||||||
digitalWrite(PIN_CLEAR, HIGH);
|
digitalWrite(PIN_CLEAR, HIGH);
|
||||||
delay(200);
|
delay(50);
|
||||||
digitalWrite(PIN_CLEAR, LOW);
|
digitalWrite(PIN_CLEAR, LOW);
|
||||||
digitalWrite(PIN_DRIVE, LOW);
|
digitalWrite(PIN_DRIVE, LOW);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -243,7 +265,7 @@ bool clearSelectedColumn() {
|
||||||
|
|
||||||
bool setSelectedDot() {
|
bool setSelectedDot() {
|
||||||
|
|
||||||
for (uint8_t cc=0;cc<7;cc++) {
|
/*for (uint8_t cc=0;cc<7;cc++) {
|
||||||
//Serial.print("checking cc="); Serial.println(cc);
|
//Serial.print("checking cc="); Serial.println(cc);
|
||||||
for (uint8_t i=1;i<8;i+=2) {
|
for (uint8_t i=1;i<8;i+=2) {
|
||||||
if (CHECK_BIT(col[cc],i)) {
|
if (CHECK_BIT(col[cc],i)) {
|
||||||
|
@ -252,10 +274,42 @@ bool setSelectedDot() {
|
||||||
return 0; //a column is set to ground (should not be set for clear column)
|
return 0; //a column is set to ground (should not be set for clear column)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (!HBridgeOK) {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
digitalWrite(PIN_DRIVE, HIGH);
|
digitalWrite(PIN_DRIVE, HIGH);
|
||||||
delay(200);
|
delay(10);
|
||||||
digitalWrite(PIN_DRIVE, LOW);
|
digitalWrite(PIN_DRIVE, LOW);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HBridgeOK() {
|
||||||
|
for (uint8_t cc=0;cc<7;cc++) {
|
||||||
|
//Serial.print("checking cc="); Serial.println(cc);
|
||||||
|
for (uint8_t i=0;i<8;i+=2) {
|
||||||
|
if (CHECK_BIT(col[cc],i) && CHECK_BIT(col[cc],i+1)) {
|
||||||
|
Serial.print("Short circuit on bit ");
|
||||||
|
Serial.print(i); Serial.print(" col="); Serial.println(cc);
|
||||||
|
return 0; //a column is set to ground (should not be set for clear column)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void shiftData() { //send out all data to shift registers
|
||||||
|
//Select Columns via Shift registers
|
||||||
|
for (uint8_t i=0;i<7;i++) {
|
||||||
|
shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, col[6-i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//select Rows via shift registers on own controller board
|
||||||
|
shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, row%256);
|
||||||
|
shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, row/256); //LSBFIRST= LSB is QH, bit 8 is QA.
|
||||||
|
digitalWrite(PIN_LATCH, HIGH);
|
||||||
|
delayMicroseconds(100);
|
||||||
|
digitalWrite(PIN_LATCH, LOW);
|
||||||
}
|
}
|
Loading…
Reference in New Issue