#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SPI.h>
#include <Wire.h>
int x[2] = {2, 65};
int y[2] = {12, 12};
unsigned char i;
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void draw() {
display.drawLine(0, 0, 127, 0, WHITE); // Top
display.drawLine(0, 0, 0, 63, WHITE); // Left
display.drawLine(127, 0, 127, 63, WHITE); // Right
display.drawLine(0, 63, 127, 63, WHITE); // Bottom
display.drawLine(63, 0, 63, 63, WHITE); // Middle Vertical
display.drawLine(0, 10, 127, 10, WHITE); // Header separator
// Headers
display.setCursor(2, 2);
display.print("us.char");
display.setCursor(65, 2);
display.print("char");
}
void loop() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
// Drawing the frame and text
draw();
// Displaying characters from 0 to 127
for (i = 0; i <= 127; i++) {
display.setCursor(x[0], y[0]);
display.print(i);
display.setCursor(x[1], y[1]);
display.print((char)i);
y[0] += 10;
y[1] += 10;
// Check if the first box is full
if (x[0] >= 42 && y[0] >= 62) {
// If the first box is full, clear and show the second box
display.display();
delay(2000);
display.clearDisplay();
draw();
x[0] = 2;
y[0] = 12;
x[1] = 65;
y[1] = 12;
}
// Move to the next column if the current column is full
if (y[0] >= 62 || y[1] >= 62) {
y[0] = 12;
y[1] = 12;
x[0] += 20;
x[1] += 20;
}
}
x[0] = 2;
y[0] = 12;
x[1] = 65;
y[1] = 12;
display.display(); // Show all remaining characters
delay(2000); // Optional: Delay to see the result before clearing
}