//could use 1/8th the memory if these were kept in groups of 8 bits as a byte in an array
//12 columns and 8 rows
//but you'd need to figure out how to modify the byte in the right column when you want to make a change
//check these out
//https://web.archive.org/web/20170627135321/https://www.avrfreaks.net/comment/26024
//edit macros to accept one position number, use it to pick byte in array and bit in the byte
#define BIT(x) (0x01 << (x % 8))
//#define BIT(x) (0x01 << (x))
#define nRow 4
#define nCol 12
byte myArray[nRow] = {
B11111111,
B01010101,
B00000101,
B00001010
};
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void loop() {
// put your main code here, to run repeatedly:
byte data;
for (int nr =0; nr < nRow; nr++) {
// for (int nc =0; nc < nCol; nc++) {
data = myArray[nr];
for (int i = 0; i < 8; i++)
{
// consider leftmost bit
// set line high if bit is 1, low if bit is 0
if (data & 0x80)
Serial.print("X");
//output_high(SD_DI);
else
//output_low(SD_DI);
Serial.print(" ");
// pulse the clock state to indicate that bit value should be read
// output_low(SD_CLK);
//delay();
//output_high(SD_CLK);
// shift byte left so next bit will be leftmost
data <<= 1;
}
// }
Serial.println("");
}
Serial.println("");
Serial.println("");
myArray[2] ^= B00010000; //xor alternates the 4th item of the 2nd row
myArray[3] ^= B01010010; //xor alternates all but the 4th item of the 3nd row
myArray[1] = 0xff - myArray[1];
delay(1000); // this speeds up the simulation
//Serial.println(sizeof(myArray));
delay(1000);
}