Still trying, but I can't quite seem to crack it...
This loop;
// Turn on all displays, one digit at a time
for (int k = 0; k < 9; k++) { //this controls digit position
for (int i = 0; i < 8; i++) { //this controls segment number
displayBuffer[i] |= 1 << k; //this puts an (OR) command...so will keep segments on
Serial.print ("DB");
Serial.print ("\t");
Serial.println(displayBuffer[i]);
delay(dTime);
}
show();
}
followed by this write procedure;
void show() {
Wire.beginTransmission(addr);
//Serial.print ("addr: ");
//Serial.print ("\t");
//Serial.print (addr);
Wire.write(0x00); // start at address 0x0
for (int i = 0; i < 8; i++) {
Wire.write(displayBuffer[i] & 0xFF); //& is the "AND" operator and it's working on display buffer and "0xFF" which is 11111111
Serial.print ("Write i=; ");
Serial.print (i);
Serial.print ("\t");
Serial.print (displayBuffer[i] & 0xff);
Serial.print ("\t");
Wire.write(displayBuffer[i] >> 8); // >>8 shifts the value of displayBuffer 8 places right...is this effectively clearing the value?
Serial.print (">>8 write; ");
Serial.print ("\t");
Serial.print(displayBuffer[i] >> 8);
Serial.print ("\t");
Serial.println (displayBuffer[i] >> 8);
}
Wire.endTransmission();
}
Works...it turns on all segments in each digit of the display, and lights them up one at a time left to right. SO I thought..."Aha! I have the positions and segments down pat, all I need to do is replace the data in the buffer currently filled by
displayBuffer[i] |= 1 << k;
Which if I understand correctly is an "OR" command between the current contents of the buffer and the value of "1<<k", which is the value "00000001", shifted one place left for each increment in "k", "k" relating to the number of digits in the display.
So...I thought if I replace "1<<k" with something that reads from the appropriate position in the SevenSegment ASCII array - for example;
SevenSegmentASCII(k+17)
then that position in the array should equate to the number for "k" (in the array, digits start at element 16 with zero) - so the plan is to get the display to read "123456789" reading left to right.
However the following loop;
for (int k = 0; k < 9; k++) { //this controls digit position
for (int i = 0; i < 8; i++) { //this controls segment number
displayBuffer[i] = SevenSegmentASCII[k + 17] & 1 << i; //Can't seem to get this "bit" right haha
Serial.print("Alpha:");
Serial.print(k);
Serial.print("\t");
Serial.print(SevenSegmentASCII[k + 17]);
Serial.print("\t");
Serial.println (displayBuffer[i]);
delay(dTime);
}
show();
}
clear();
Followed by the same write procedure results in all the right segments being lit up - but spread across the display, so the first segment of "1". appears on the leftmost digit...but the second segment is illuminated on the digit one to the right.
What am I doing wrong???