#include <TinyWireM.h>
#include<util/delay.h>
#define F_CPU 8000000U
#define SSD1306_ADDR 0x3C // I2C address of SSD1306
#define OLED_WIDTH 128 // OLED display width
#define OLED_HEIGHT 32 // OLED display height
void i2cSendCommand(uint8_t command) {
TinyWireM.beginTransmission(SSD1306_ADDR);
TinyWireM.send(0x00);
TinyWireM.send(command);
TinyWireM.endTransmission();
}
void i2cSendData(uint8_t data) {
TinyWireM.beginTransmission(SSD1306_ADDR);
TinyWireM.send(0x40);
TinyWireM.send(data);
TinyWireM.endTransmission();
}
void setcursor(uint8_t row, uint8_t col) {
}
void setup() {
TinyWireM.begin(); // Initialize I2C communication
// Turn on the OLED display
i2cSendCommand(0xAE);
i2cSendCommand(0xAF);
// Set display to horizontal addressing mode
i2cSendCommand(0xA1);
i2cSendCommand(0x20);
i2cSendCommand(0x00);
// Set column start and end address to 0 and 127 respectively
i2cSendCommand(0x21);
i2cSendCommand(0);
i2cSendCommand(OLED_WIDTH - 1);
// Set page start and end address to 0 and 3 respectively
i2cSendCommand(0x22);
i2cSendCommand(0);
i2cSendCommand((OLED_HEIGHT / 4) - 1);
// Set cursor position to pixel (30, 63)
i2cSendCommand(0x21);
i2cSendCommand(120);
i2cSendCommand(127);
i2cSendCommand(0x22);
i2cSendCommand(7);
i2cSendCommand(7);
// Send "pulse" and data 60
i2cSendData('p');
// i2cSendData('u');
//i2cSendData('l');
//i2cSendData('s');
//i2cSendData('e');
//i2cSendData(':');
// i2cSendData(' ');
// i2cSendData(60);
}
void loop() {
// Nothing to do here
}