fix row flipping

This commit is contained in:
interfisch 2023-01-31 21:28:49 +01:00
parent f916bafb84
commit 387a02b37d
1 changed files with 91 additions and 33 deletions

View File

@ -40,6 +40,8 @@ void selectColumn(uint8_t selcolumn, bool clear);
bool HBridgeOK();
void shiftData();
void resetColumns();
unsigned long loopmillis=0;
unsigned long last_update=0;
#define UPDATE_INTERVAL 500
@ -83,7 +85,7 @@ uint8_t col[7];
void loop() {
loopmillis = millis();
digitalWrite(PIN_OE, LOW); //Active Low
static bool init=false;
@ -150,13 +152,55 @@ void loop() {
//selectColumnClear(countz%25);
selectColumnSet((12+(countz/25))%25); //lower column number is on the left
row=pow(2, countz%16); //low significant bits are lower rows (when connector at top)
//cycle testing set dots
selectColumnSet(countz/16); //lower column number is on the left
row=pow(2, (countz)%16);//low significant bits are lower rows (when connector at top)
bool run_setdots=true;
/*
switch(countz) {
case 0:
selectColumnSet(5);
row=pow(2, 3); //4. zeile von unten
break;
case 1:
selectColumnSet(5);
row=pow(2, 4); //5. zeile von unten
break;
case 2:
selectColumnSet(5);
row=pow(2, 5);
break;
case 3:
selectColumnSet(5);
row=pow(2, 8);
break;
case 4:
selectColumnSet(2);
row=pow(2, 1);
break;
default:
row=0;
resetColumns();
run_setdots=false;
}
*/
if (run_setdots)
{
Serial.print("Row="); Serial.print(row); Serial.print(" Col=");
for (uint8_t i=0;i<7;i++) {
@ -177,6 +221,9 @@ void loop() {
}else{
Serial.println("Cleared");
}*/
}else{
Serial.println("END");
}
@ -203,11 +250,11 @@ void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t v
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
delayMicroseconds(100);
delayMicroseconds(1000);
digitalWrite(clockPin, HIGH);
delayMicroseconds(100);
delayMicroseconds(1000);
digitalWrite(clockPin, LOW);
delayMicroseconds(100);
delayMicroseconds(1000);
}
}
@ -222,9 +269,10 @@ void selectColumn(uint8_t selcolumn, bool clear) {
uint8_t sc_bit=3-(selcolumn%4); //each two shift registers control four columns
uint8_t sc_byte=selcolumn/4;
for (uint8_t i=0;i<7;i++) {
/*for (uint8_t i=0;i<7;i++) {
col[i]=0;
}
}*/
resetColumns();
col[sc_byte]=pow(2, (sc_bit*2+clear)); // possible numbers for clear=false: 1,4,16,64
/*
@ -280,8 +328,10 @@ bool setSelectedDot() {
return 0;
}
digitalWrite(PIN_OE, LOW); //Active Low
digitalWrite(PIN_DRIVE, HIGH);
delay(10);
digitalWrite(PIN_OE, HIGH); //Active Low
digitalWrite(PIN_DRIVE, LOW);
return 1;
}
@ -301,15 +351,23 @@ bool HBridgeOK() {
}
void shiftData() { //send out all data to shift registers
//select Rows via shift registers on own controller board
shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, row&0xff); //lower byte
shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, row>>8); //LSBFIRST= LSB is QH, bit 8 is QA. //upper byte
digitalWrite(PIN_LATCH, HIGH);
delayMicroseconds(1000);
digitalWrite(PIN_LATCH, LOW);
//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);
}
void resetColumns() {
for (uint8_t i=0;i<7;i++) {
col[i]=0;
}
}