/*
* Copyright (C) 2022, Andrei Egorov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wire.h>
#define ssd1306_addr 0x3C
static const uint8_t PROGMEM init_bytes[]={0x00,0xAE,0xD5,0x80,0xA8,0x3F,0xD3,0x00,0x40,0x8D,0x14,0x20,0x00,0xA1,0xC8,
0xDA,0x12,0xD9,0xF1,0xDB,0x40,0xA4,0xA6,0xAF};
static const uint8_t PROGMEM arduino[] = {
0x00, 0x7c, 0x12, 0x12, 0x12, 0x7c, 0x00, 0x7e, 0x12, 0x12, 0x12, 0x6c, 0x00, 0x7e, 0x42, 0x42,
0x42, 0x3c, 0x00, 0x3e, 0x40, 0x40, 0x40, 0x3e, 0x00, 0x7a, 0x00, 0x7e, 0x08, 0x10, 0x20, 0x7e,
0x00, 0x3c, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x40, 0x00, 0x7e, 0x12, 0x12, 0x12, 0x6c, 0x00, 0x3e,
0x40, 0x40, 0x40, 0x3e, 0x00
};
void setup() {
Wire.begin();
Wire.setClock(800000);
Wire.beginTransmission(ssd1306_addr);
for (uint8_t i=0; i<sizeof(init_bytes); i++) {
Wire.write(pgm_read_byte(init_bytes+i));
}
Wire.endTransmission();
}
void loop() {
uint8_t p=0;
Wire.beginTransmission(ssd1306_addr);
Wire.write(0x40);
for (uint8_t i=0;i<28;i++) Wire.write(pgm_read_byte(arduino+p++));
Wire.endTransmission();
Wire.beginTransmission(ssd1306_addr);
Wire.write(0x40);
for (uint8_t i=0;i<25;i++) Wire.write(pgm_read_byte(arduino+p++));
Wire.endTransmission();
for (uint8_t i=0;i<128*8/16-3;i++) {
Wire.beginTransmission(ssd1306_addr);
Wire.write(0x40);
Wire.write(0x33);
Wire.write(0x33);
Wire.write(0xCC);
Wire.write(0xCC);
Wire.write(0x33);
Wire.write(0x33);
Wire.write(0xCC);
Wire.write(0xCC);
Wire.write(0x33);
Wire.write(0x33);
Wire.write(0xCC);
Wire.write(0xCC);
if (i<(128*8/16-4)) {
Wire.write(0x33);
Wire.write(0x33);
Wire.write(0xCC);
Wire.write(0xCC);
}
Wire.endTransmission();
}
}