Attiny85 code plus library files


/*  Happy birthday
 *   
 */
#define F_CPU 8000000UL
#include "SSD1306_minimal.h"
#include <avr/pgmspace.h>
#include <avr/sleep.h>

SSD1306_Mini oled;


// 51 x 64
const unsigned char world [] PROGMEM = { 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x60,0x60,0xE0,0xC0,0xF0,0xF0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0x7C,0x7E,0xFE,
0x1F,0x0F,0x07,0x07,0x37,0x3F,0x3F,0x3F,0x3E,0x3E,0x3C,0x3E,0x3F,0x3B,0x31,0x73,0xE3,0xC7,0x8E,0x1C,0x3C,0x78,0xF0,0xC0,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0x3C,0xFF,0x87,0x83,0x03,0x03,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0xF0,0xF8,0x78,0x30,0x70,0xFC,0xFC,0xFC,0xFD,0xFF,0xFF,0xFE,
0xFC,0xF0,0xC1,0x07,0x3F,0xFC,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x01,0x7E,0xFF,0xFF,0xFF,0xFF,0xFC,0xE0,0xC0,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xF3,0xF3,0xE7,
0xE7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x07,0x3F,0xFC,0xFF,0xFF,0xFF,0x3F,0x1F,
0x0F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x7F,0x7F,0x3F,0x0F,0xC7,0xF7,0x7F,0x1F,0x01,0xC0,0xFC,0x7F,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,
0x0F,0x1C,0x38,0x70,0x60,0xE0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0xBF,0x9F,0x9F,
0xCF,0xC7,0xE3,0x70,0x38,0x1C,0x8E,0x87,0xC3,0xF1,0x78,0x3C,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x07,0x06,0x0E,0x6C,0x7C,0x3F,0x3F,0x31,0x33,0x33,0x73,0x77,0x67,0x67,0xE7,0xE7,0x67,0x67,0x73,0x73,
0x33,0x31,0x39,0x19,0x18,0x1C,0x0C,0x0E,0x07,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x3F,0x3F,0x38,
0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
;


// 64 x 24
const unsigned char happy_birthday [] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x18,0x18,0x18,0xFF,0xFF,0xFF,0x00,0xC8,0xEC,0xEC,0xAC,
0xFC,0xFC,0xF8,0x00,0xFC,0xFC,0xFC,0x8C,0xFC,0xFC,0xF8,0x00,0xFC,0xFC,0xFC,0x8C,0xFC,0xFC,0xF8,0x00,0x04,0x3C,0xFC,0xF8,
0x7C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,
0xE0,0x60,0x61,0xE1,0xE1,0xC0,0x00,0xA0,0xA1,0xA1,0x01,0x80,0x80,0x81,0x81,0x00,0x81,0xE1,0xE1,0xE0,0x87,0xE7,0xE7,0xE1,
0x81,0x81,0x80,0x00,0x07,0x07,0x87,0x81,0x81,0xE1,0xE0,0xE0,0x06,0x06,0x87,0x83,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x3F,0x33,0x33,0x3F,0x3F,0x1C,0x00,0x3F,
0x3F,0x3F,0x00,0x3F,0x3F,0x3F,0x03,0x00,0x01,0x1F,0x3F,0x3F,0x31,0x3F,0x3F,0x3F,0x01,0x3F,0x3F,0x3F,0x00,0x1F,0x3F,0x3F,
0x31,0x3F,0x3F,0x3F,0x00,0x19,0x3D,0x3D,0x15,0x3F,0x3F,0x3F,0x00,0xC0,0xC7,0xFF,0x7F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00  
};

// 128 x 32
const unsigned char nice3 [] PROGMEM = { 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0xE0,0x00,0x00,0x00,0xE0,0xE0,0xE0,0x00,
0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,
0x3F,0x03,0x03,0x03,0x3F,0x3F,0x3F,0x00,0x19,0x3D,0x3D,0x15,0x3F,0x3F,0x3F,0x01,0x0F,0x3F,0x3C,0x0F,0x01,0x00,0x0E,0x1F,
0x3F,0x35,0x37,0x37,0x16,0x00,0x00,0x00,0x00,0x00,0x19,0x3D,0x3D,0x15,0x3F,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF8,0xF8,0xF8,0x18,0xF8,0xF8,0xF0,0x00,0xFA,0xFA,0xFA,0x00,0xE0,0xF0,0xF8,0x18,0xB8,0xB0,0x00,0xE0,0xF0,
0xF8,0x58,0x78,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0xF0,0xF8,0xF8,0x18,0xFE,0xFE,0xFE,0x00,0x90,0xD8,0xD8,0x58,0xF8,0xF8,
0xF0,0x08,0x78,0xF8,0xF0,0xF8,0x38,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x03,0x03,0x03,0x00,0x03,0x03,0x03,0x00,0x00,
0x01,0x03,0x03,0x03,0x01,0x00,0x00,0x01,0x03,0x03,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x03,0x03,0x03,
0x03,0x00,0x01,0x03,0x03,0x01,0x03,0x03,0x03,0x04,0x04,0x07,0x07,0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};




// 64 64
const unsigned char ink_pot [] PROGMEM = { 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,
0xF0,0xF8,0xF8,0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0x7C,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0xBF,0xBF,0xDF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0xFB,0xFB,0xFB,0xFB,
0x7B,0x1B,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xFC,0xFE,0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,
0xF8,0xFE,0x3F,0xDF,0xE7,0xFB,0xFC,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,
0x1F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0xEF,0xF7,0xF9,0xFE,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,
0x7F,0x7F,0x3F,0x3F,0x3F,0x1E,0x1E,0x0D,0x0D,0x05,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x78,0xF8,0xF8,0xF8,0xF8,
0xF8,0xF8,0xF8,0xFC,0xFE,0xFB,0xF9,0xC0,0xF8,0xF8,0x78,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xE0,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,
0xF7,0x07,0x04,0x04,0xFC,0xFC,0xFC,0xFC,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,
0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x70,0x40,0x40,0x47,0x7F,0x7F,0x7F,
0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};


// 64 x 64
const unsigned char guitar [] PROGMEM = { 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x78,0xF0,0xF2,0x7E,0x3E,0x9E,0xCF,0xE7,0x7F,0x3F,0x9E,0xFC,0xF8,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFE,0xFE,0x7F,0x33,
0x39,0x1C,0x3E,0x3F,0x17,0x07,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xFC,0xFE,0x3E,0x0E,0x07,0x07,0x07,0x07,0x07,0x07,0x0F,0x0E,0x9E,0xFE,0xFC,0xF8,0xF8,
0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0x70,0x78,0x78,0x78,0x78,0x38,0x3C,0x3C,0x3E,0x1F,0x1F,0x0F,0x03,
0x80,0x80,0xC0,0xC0,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x0F,0x3F,0xFF,0xFC,0xF0,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0xFC,0xFF,0x1F,0x0F,0x07,0x03,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x3F,0x07,0x03,0x01,0x00,0x00,0x80,0x80,0x80,0xC0,0xC0,0xF0,0xFF,0xFF,0x3F,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x7F,0xFF,0xFF,0xF0,0x80,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x1F,0x3F,0x7E,
0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0xF0,0xFC,0xFE,0x3F,0x0F,0x07,
0x07,0x07,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0x07,0x1F,0x3F,0x7E,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x0F,0x06,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xFF,0xFF,0x3F,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x03,0x07,0x07,0x0F,0x1F,0x1E,0x3C,0x3C,0x78,0x78,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0x78,0x7C,0x3E,0x1F,0x0F,
0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};


// 41 x 64
const unsigned char drunk [] PROGMEM = { 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x20,0x00,0x80,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x08,0x82,0xC0,0xE0,0xE0,0xE1,0xE0,0xE0,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0xC0,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x0F,0x1F,0xBF,0xBF,0xBF,0xBF,0x1F,0x1F,0x07,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x30,0x30,0x30,0x3F,0x0C,0x0F,0x1F,0x1C,0x1C,0x3C,0x3C,0x3C,0x3C,
0x3C,0x1E,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x1E,0x3E,0x3C,0x7C,0xF8,0xF8,0xF0,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xF0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x1F,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,
0xF8,0xFC,0xFC,0x7E,0x3F,0x3F,0x1F,0x0F,0x0F,0xE7,0xFF,0xFF,0xFF,0xFF,0x3F,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xFF,0xFF,0xFF,0x3F,0x0F,0x01,0x00,0x00,0x00,0x00,
0x00,0xF7,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x1C,0x0E,0x0F,0x03,0x07,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xF1,0xFF,0x7F,0x1F,0x3F,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};



// 64 x 64
const unsigned char cake2 [] PROGMEM = { 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x3F,0x1F,0x07,0x01,0xC3,0x07,0x0F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0xC0,0xBE,0xFF,
0xBF,0x8E,0xE0,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x0F,0x07,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x01,0x01,0x00,0xE0,0xF9,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,
0x3F,0x3F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
0x1C,0x1C,0x1C,0x1C,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x3F,0x3F,
0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xF0,0xE0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0xC0,0xC0,0xC0,0xE0,0xF0,0x7C,0x3C,0x7C,0xF0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,0xF0,
0x7C,0x3C,0x7C,0xF0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,0xE0,0xF0,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xC7,0x87,0x87,0x87,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x87,0x87,0x87,0xC7,0xF7};

// 65 x 64
const unsigned char wine [] PROGMEM = { 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xE0,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xF0,0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xC0,0xC0,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0xE0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x03,0xEB,0xEB,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xF0,0xE0,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0xBF,0xC0,0xEB,0xEB,
0xC0,0xBF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xF8,0xE0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0xF0,0x07,0x07,0x07,
0x07,0x07,0x07,0x07,0x0F,0x0F,0x1F,0x3F,0x7F,0x7F,0xFF,0xFF,0xFF,0xF0,0x0F,0xFF,0x1F,0x1F,0x1F,0x1F,0x00,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0xF3,0xF4,0xE8,0xD0,0xD0,0xA0,0x20,0x20,0x20,0x20,
0xA0,0xD0,0xD0,0xE8,0x14,0xFB,0x04,0x0B,0x19,0x18,0x38,0xF8,0xF8,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x1F,0x7F,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xE0,
0xE0,0xE0,0xE0,0xE0,0xE1,0xE3,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,
0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x0F,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,
0xDF,0xCF,0xCF,0xCF,0xCF,0xC7,0xC3,0xC0,0xC0,0xC3,0xC7,0xCF,0xCF,0xCF,0xC8,0xD7,0xF7,0xF7,0xF7,0xF7,0xF7,0xF7,0xF7,0xF8,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x3F,0x1F,0x0F,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x07,0x07,0x0F,0x0F,0x0F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x0F,0x0F,0x0F,0x07,0x07,0x03,0x03,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};


// 73 x 64
const unsigned char health [] PROGMEM = { 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xF8,0xF8,0xF8,0xF0,0xF0,0xE0,0xE0,0xC0,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xF8,0xF8,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,0xF8,0xF8,0xF0,0xF0,0xE0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xF8,0xE0,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xE0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x30,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x0F,0x87,0x1F,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x07,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x1F,0x1F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,
0x9F,0x9F,0x9F,0x9F,0x9F,0xC7,0xF3,0xC3,0x8F,0x9F,0x9F,0x9F,0x80,0xFC,0xFF,0x00,0xFF,0x1F,0x9F,0x9F,0x87,0xE0,0xFE,0xFF,
0x00,0x0F,0x7F,0x1F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x1F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,
0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x01,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFC,0xFE,0xFF,0xFF,0xFF,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x1F,0x1F,0x0F,0x07,0x03,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};


const unsigned char *imgptr[] = {cake2, ink_pot, guitar, health, world, wine, drunk};

const unsigned char width[] = {64, 64, 64, 73, 51, 65, 41};

 

void setup(){
  oled.init(0x3c);  
  oled.clear();
  oled.drawImage(happy_birthday, 30, 3, 64, 3 ); 
  delay(3000);
  for (int i=0; i < 6 ; i++) {
    oled.clear();
    oled.drawImage(imgptr[i], 30 , 0, width[i], 8 ); 
    delay(3000);
  }
  oled.clear();
  show_drunk();
  show_snow();
  oled.drawImage(nice3, 0, 2, 128,4 ); 
  MCUCR |= (1<<SE) |(2<<SM0);
  sleep_mode();
}    

void show_drunk() {
   for (int i=0; i < 80 ; i+=2) {  // 28 px 
        oled.startScreen();
        oled.drawImage(imgptr[6], i , 0, 41, 8 );     
        delay(15);
   }
  delay(1000);
}

// 16x16
const unsigned char snow [] PROGMEM = {
0x30,0x70,0xF0,0xF0,0x60,0x60,0xB8,0x9E,0xFF,0x7F,0x78,0xE0,0xE0,0xC0,0xC0,0xC0,
0x80,0x60,0x78,0x7D,0x3F,0x3B,0x1D,0x1F,0x3D,0x7B,0xFF,0xF3,0x01,0x01,0x00,0x00 };

const byte rndX [] {10,22,33,47,64,84,93,110 };  
const byte rndY [] {1, 3, 0, 1, 4, 0, 2,  1 };

void show_snow() {
  for (int k = 0; k < 4; k++) {
    for (int j = 0; j < 8; j++) {
      oled.clear();   // includes startScreen(); 
    for(int i = 0; i < 8; i++) {
      oled.drawImage(snow, rndX[i]+rndY[j] , rndY[i] + j, 16, 2 );  
    }
    delay(100);
    } 
  }
}
 
void loop(){ 
}
  

/* file=SSD1306_minimal.cpp SSD1306_minimal.h - SSD1306 OLED Driver Library 2015 Copyright (c) CoPiino Electronics All right reserved. Original Author: GOF Electronics Co. Ltd. Modified by: CoPiino Electronics ( http://copiino.cc ) CoPiino Electronics invests time and resources providing this open source code, please support CoPiino Electronics and open-source hardware by purchasing products from CoPiino Electronics! What is it? This library is derived from GOFi2cOLED library, only for SSD1306 in I2C Mode. As the original library only supports Frame Buffered mode which requires to have at least 1024bytes of free RAM for a 128x64px display it is too big for smaller devices. So this a SSD1306 library that works great with ATTiny85 devices :) It is a free software; you can redistribute it and/or modify it under the terms of BSD license, check license.txt for more information. All text above must be included in any redistribution. */ #include "SSD1306_minimal.h" // a 5x7 font table const unsigned char BasicFont[] PROGMEM = { /* 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x21, 0x54, 0x54, 0x78, 0x41, 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0xF0, 0x29, 0x24, 0x29, 0xF0, 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x32, 0x48, 0x48, 0x48, 0x32, 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x39, 0x44, 0x44, 0x44, 0x39, 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0xAA, 0x00, 0x55, 0x00, 0xAA, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0x7C, 0x2A, 0x2A, 0x3E, 0x14, 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, */ }; unsigned char SSD1306_Mini::getFlash( const unsigned char * mem, unsigned int idx ){ unsigned char data= pgm_read_byte( &(mem[idx]) ); return data; } void SSD1306_Mini::sendCommand(unsigned char command) { Wire.begin(); //initialize I2C Wire.beginTransmission(SlaveAddress); // begin I2C communication Wire.send(GOFi2cOLED_Command_Mode); // Set OLED Command mode Wire.send(command); Wire.endTransmission(); // End I2C communication } void SSD1306_Mini::sendData(unsigned char Data) { Wire.begin(); //initialize I2C Wire.beginTransmission(SlaveAddress); // begin I2C transmission Wire.send(GOFi2cOLED_Data_Mode); // data mode Wire.send(Data); Wire.endTransmission(); // stop I2C transmission } void SSD1306_Mini::init(uint8_t address) { Wire.begin(); delay(5); //wait for OLED hardware init // constructor(128, 64); //SlaveAddress = address; sendCommand(GOFi2cOLED_Display_Off_Cmd); /*display off*/ sendCommand(Set_Multiplex_Ratio_Cmd); /*multiplex ratio*/ sendCommand(0x3F); /*duty = 1/64*/ sendCommand(Set_Display_Offset_Cmd); /*set display offset*/ sendCommand(0x00); sendCommand(Set_Memory_Addressing_Mode_Cmd); //set addressing mode sendCommand(HORIZONTAL_MODE); //set horizontal addressing mode sendCommand(0xB0); //set page address sendCommand(0x00); //set column lower address sendCommand(0x10); //set column higher address sendCommand(0x40); /*set display starconstructort line*/ sendCommand(Set_Contrast_Cmd); /*contract control*/ sendCommand(0xcf); /*128*/ sendCommand(Segment_Remap_Cmd); /*set segment remap*/ sendCommand(COM_Output_Remap_Scan_Cmd); /*Com scan direction*/ sendCommand(GOFi2cOLED_Normal_Display_Cmd); /*normal / reverse*/ sendCommand(Set_Display_Clock_Divide_Ratio_Cmd); /*set osc division*/ sendCommand(0x80); sendCommand(Set_Precharge_Period_Cmd); /*set pre-charge period*/ sendCommand(0xf1); sendCommand(Set_COM_Pins_Hardware_Config_Cmd); /*set COM pins*/ sendCommand(0x12); sendCommand(Set_VCOMH_Deselect_Level_Cmd); /*set vcomh*/ sendCommand(0x30); sendCommand(Deactivate_Scroll_Cmd); sendCommand(Charge_Pump_Setting_Cmd); /*set charge pump enable*/ sendCommand(Charge_Pump_Enable_Cmd); sendCommand(GOFi2cOLED_Display_On_Cmd); /*display ON*/ } void SSD1306_Mini::clipArea(unsigned char col, unsigned char row, unsigned char w, unsigned char h){ TinyWireM.begin(); //initialize I2C TinyWireM.beginTransmission(SlaveAddress); // begin I2C transmission TinyWireM.send(GOFi2cOLED_Command_Mode); // data mode TinyWireM.send(Set_Column_Address_Cmd); TinyWireM.send(0); TinyWireM.send(col); TinyWireM.send(col+w-1); TinyWireM.endTransmission(); // stop I2C transmission TinyWireM.begin(); //initialize I2C TinyWireM.beginTransmission(SlaveAddress); // begin I2C transmission TinyWireM.send(GOFi2cOLED_Command_Mode); // data mode TinyWireM.send(Set_Page_Address_Cmd); TinyWireM.send(0); TinyWireM.send(row); TinyWireM.send(row+h-1); TinyWireM.endTransmission(); // stop I2C transmission } void SSD1306_Mini::cursorTo(unsigned char col, unsigned char row){ clipArea(col, row, 128-col, 8-row); /* TinyWireM.begin(); //initialize I2C TinyWireM.beginTransmission(SlaveAddress); // begin I2C transmission TinyWireM.send(GOFi2cOLED_Command_Mode); // data mode TinyWireM.send(Set_Column_Address_Cmd); TinyWireM.send(0); TinyWireM.send(col); TinyWireM.send(127); TinyWireM.endTransmission(); // stop I2C transmission TinyWireM.begin(); //initialize I2C TinyWireM.beginTransmission(SlaveAddress); // begin I2C transmission TinyWireM.send(GOFi2cOLED_Command_Mode); // data mode TinyWireM.send(Set_Page_Address_Cmd); TinyWireM.send(0); TinyWireM.send(row); TinyWireM.send(7); TinyWireM.endTransmission(); // stop I2C transmission */ } /* void SSD1306_Mini::cursorToX( unsigned char row, unsigned char col ){ sendCommand(0x00 | (0x0F & col) ); // low col = 0 sendCommand(0x10 | (0x0F & (col>>4)) ); // hi col = 0 // sendCommand(0x40 | (0x0F & row) ); // line #0 sendCommand(0xb0 | (0x03 & row) ); // hi col = 0 } */ void SSD1306_Mini::startScreen(){ sendCommand(0x00 | 0x0); // low col = 0 sendCommand(0x10 | 0x0); // hi col = 0 sendCommand(0x40 | 0x0); // line #0 } void SSD1306_Mini::clear() { sendCommand(0x00 | 0x0); // low col = 0 sendCommand(0x10 | 0x0); // hi col = 0 sendCommand(0x40 | 0x0); // line #0 clipArea(0,0,128,8); for (uint16_t i=0; i<=((128*64/8)/16); i++) { // send a bunch of data in one xmission Wire.beginTransmission(SlaveAddress); Wire.send(GOFi2cOLED_Data_Mode); // data mode for (uint8_t k=0;k<16;k++){ Wire.send( 0 ); } Wire.endTransmission(); } } void SSD1306_Mini::displayX(int off) { sendCommand(0x00 | 0x0); // low col = 0 sendCommand(0x10 | 0x0); // hi col = 0 sendCommand(0x40 | 0x0); // line #0 for (uint16_t i=0; i<=((128*64/8)/16); i++) { // send a bunch of data in one xmission Wire.beginTransmission(SlaveAddress); Wire.send(GOFi2cOLED_Data_Mode); // data mode for (uint8_t k=0;k<16;k++){ Wire.send( i*16 + k + off); } Wire.endTransmission(); } } void SSD1306_Mini::printChar( char ch ){ char data[5]; unsigned char i= ch; data[0]= getFlash(BasicFont, i*5 ); data[1]= getFlash(BasicFont, i*5 + 1); data[2]= getFlash(BasicFont, i*5 + 2); data[3]= getFlash(BasicFont, i*5 + 3); data[4]= getFlash(BasicFont, i*5 + 4); Wire.beginTransmission(SlaveAddress); Wire.send(GOFi2cOLED_Data_Mode); // data mode Wire.send( 0x00 ); Wire.send( data[0] ); Wire.send( data[1] ); Wire.send( data[2] ); Wire.send( data[3] ); Wire.send( data[4] ); Wire.send( 0x00 ); Wire.endTransmission(); } void SSD1306_Mini::printString( char * pText ){ unsigned char i; unsigned char len = strlen( pText ); for (i=0;i<len;i++){ printChar( pText[i] ); } } void SSD1306_Mini::drawImage( const unsigned char * img, unsigned char col, unsigned char row, unsigned char w, unsigned char h ){ unsigned int i,k,data; clipArea( col, row, w, h); for (i=0;i< (w*h);i++){ data= getFlash( img, i); Wire.beginTransmission(SlaveAddress); Wire.send(GOFi2cOLED_Data_Mode); // data mode Wire.send( data ); Wire.endTransmission(); } }
/* SSD1306_minimal.h - SSD1306 OLED Driver Library 2015 Copyright (c) CoPiino Electronics All right reserved. Original Author: GOF Electronics Co. Ltd. Modified by: CoPiino Electronics ( http://copiino.cc ) CoPiino Electronics invests time and resources providing this open source code, please support CoPiino Electronics and open-source hardware by purchasing products from CoPiino Electronics! What is it? This library is derived from GOFi2cOLED library, only for SSD1306 in I2C Mode. As the original library only supports Frame Buffered mode which requires to have at least 1024bytes of free RAM for a 128x64px display it is too big for smaller devices. So this a SSD1306 library that works great with ATTiny85 devices :) It is a free software; you can redistribute it and/or modify it under the terms of BSD license, check license.txt for more information. All text above must be included in any redistribution. */ #ifndef __SSD1306_MINIMAL_H__ #define __SSD1306_MINIMAL_H__ #include // config #define SlaveAddress 0x3c // setup used wire lib #include "TinyWireM.h" #define Wire TinyWireM // defines taken from GOFi2cOLED #define GOFi2cOLED_Command_Mode 0x80 #define GOFi2cOLED_Data_Mode 0x40 //Fundamental Command (more than one bytes command pleaserefer to SSD1306 datasheet for details) #define Set_Contrast_Cmd 0x81 //Double byte command to select 1 out of 256 contrast //steps.Default(RESET = 0x7F) #define Entire_Display_On_Resume_Cmd 0xA4 //Resume to RAM content display(RESET), Output follows RAM //content #define Entire_Display_On_Cmd 0xA5 //Entire display ON, Output ignores RAM content #define GOFi2cOLED_Normal_Display_Cmd 0xA6 //Normal display (RESET) #define GOFi2cOLED_Inverse_Display_Cmd 0xA7 //Inverse display #define GOFi2cOLED_Display_Off_Cmd 0xAE //sleep mode(RESET) #define GOFi2cOLED_Display_On_Cmd 0xAF //normal mode //Scrolling Command (more than one bytes command pleaserefer to SSD1306 datasheet for details) #define Right_Horizontal_Scroll_Cmd 0x26 #define Left_Horizontal_Scroll_Cmd 0x27 #define Vertical_Right_Horizontal_Scroll_Cmd 0x29 #define Vertical_Left_Horizontal_Scroll_Cmd 0x2A #define Activate_Scroll_Cmd 0x2F #define Deactivate_Scroll_Cmd 0x2E #define Set_Vertical_Scroll_Area_Cmd 0xA3 //Addressing Setting Command (more than one bytes command pleaserefer to SSD1306 datasheet for details) #define Set_Memory_Addressing_Mode_Cmd 0x20 #define HORIZONTAL_MODE 0x00 #define VERTICAL_MODE 0x01 #define PAGE_MODE 0x02 //Default(reset) #define Set_Column_Address_Cmd 0x21 //Setup column start and end address. This command is only for //horizontal or vertical addressing mode. #define Set_Page_Address_Cmd 0x22 //Setup page start and end address. This command is only for //horizontal or vertical addressing mode. //Hardware Configuration (Panel resolution & layout related) Command (more than one bytes command please refer to //SSD1306 datasheet for details) #define Segment_Remap_Cmd 0xA1 //column address 127 is mapped to SEG0 #define Segment_Normal_map_Cmd 0xA0 //Default. column address 0 is mapped to SEG0(RESET) #define Set_Multiplex_Ratio_Cmd 0xA8 //Set MUX ratio to N+1 MUX #define COM_Output_Normal_Scan_Cmd 0xC0 //Normal mode (RESET). Scan from COM0 to COM[N �C1] #define COM_Output_Remap_Scan_Cmd 0xC8 //Remapped mode. Scan from COM[N-1] to COM0 #define Set_Display_Offset_Cmd 0xD3 //Set vertical shift by COM from 0d~63d. The value is reset to //00h after RESET. #define Set_COM_Pins_Hardware_Config_Cmd 0xDA //Timing & Driving Scheme Setting Command (more than one bytes command pleaserefer to SSD1some more than one bytes //command please 306 datasheet for details) #define Set_Display_Clock_Divide_Ratio_Cmd 0xD5 #define Set_Precharge_Period_Cmd 0xD9 #define Set_VCOMH_Deselect_Level_Cmd 0xDB #define No_Operation_Cmd 0xE3 #define Charge_Pump_Setting_Cmd 0x8D #define Charge_Pump_Enable_Cmd 0x14 #define Charge_Pump_Disable_Cmd 0x10 //default #define Scroll_Left 0x00 #define Scroll_Right 0x01 #define Scroll_2Frames 0x7 #define Scroll_3Frames 0x4 #define Scroll_4Frames 0x5 #define Scroll_5Frames 0x0 #define Scroll_25Frames 0x6 #define Scroll_64Frames 0x1 #define Scroll_128Frames 0x2 #define Scroll_256Frames 0x3 #define Dummy_Byte_0x00 0x00 #define Dummy_Byte_0xFF 0xFF // class SSD1306_Mini { public: // call this function once in "void setup()" to initiallize the display void init(uint8_t address); // reset clipArea to maximum and clear the display void clear(); // move cursor to upper left corner in current clipArea void startScreen(); // set the clipArea, by default (0,0,128,8) void clipArea(unsigned char col, unsigned char row, unsigned char w, unsigned char h); // move the cursor to a location (similar to clipArea) void cursorTo( unsigned char row, unsigned char col ); // print a single character void printChar( char ch ); // print a string to the screen void printString( char * pText ); // draw an image with defined x,y position and width,height definition void drawImage( const unsigned char * img, unsigned char col, unsigned char row, unsigned char w, unsigned char h ); // void displayX(int off); // private: void sendCommand(unsigned char command); void sendData(unsigned char Data); unsigned char getFlash( const unsigned char * mem, unsigned int idx ); }; #endif
/* file=TinyWireM.cpp TinyWireM.cpp - a wrapper class for TWI/I2C Master library for the ATtiny on Arduino 1/21/2011 BroHogan - brohoganx10 at gmail dot com **** See TinyWireM.h for Credits and Usage information **** This library 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 2.1 of the License, or 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. */ extern "C" { //#include "USI_TWI_Master.h" //#include "USI_TWI_Master.h" //#include "USI_TWI_Master\USI_TWI_Master.h" //#include "USI_TWI_Master/USI_TWI_Master.h" } #include "USI_TWI_Master.h" #include "TinyWireM.h" // Initialize Class Variables ////////////////////////////////////////////////// uint8_t USI_TWI::USI_Buf[USI_BUF_SIZE]; // holds I2C send and receive data uint8_t USI_TWI::USI_BufIdx = 0; // current number of bytes in the send buff uint8_t USI_TWI::USI_LastRead = 0; // number of bytes read so far uint8_t USI_TWI::USI_BytesAvail = 0; // number of bytes requested but not read // Constructors //////////////////////////////////////////////////////////////// USI_TWI::USI_TWI(){ } // Public Methods ////////////////////////////////////////////////////////////// void USI_TWI::begin(){ // initialize I2C lib USI_TWI_Master_Initialise(); } void USI_TWI::beginTransmission(uint8_t slaveAddr){ // setup address & write bit USI_BufIdx = 0; USI_Buf[USI_BufIdx] = (slaveAddr<= USI_BUF_SIZE) return; // dont blow out the buffer USI_BufIdx++; // inc for next byte in buffer USI_Buf[USI_BufIdx] = data; } uint8_t USI_TWI::endTransmission(){ // actually sends the buffer bool xferOK = false; uint8_t errorCode = 0; xferOK = USI_TWI_Start_Read_Write(USI_Buf,USI_BufIdx+1); // core func that does the work USI_BufIdx = 0; if (xferOK) return 0; else { // there was an error errorCode = USI_TWI_Get_State_Info(); // this function returns the error number return errorCode; } } uint8_t USI_TWI::requestFrom(uint8_t slaveAddr, uint8_t numBytes){ // setup for receiving from slave bool xferOK = false; uint8_t errorCode = 0; USI_LastRead = 0; USI_BytesAvail = numBytes; // save this off in a global numBytes++; // add extra byte to transmit header USI_Buf[0] = (slaveAddr< /* file=TineWireM.h TinyWireM.h - a wrapper(+) class for TWI/I2C Master library for the ATtiny on Arduino 1/21/2011 BroHogan - brohoganx10 at gmail dot com Thanks to 'jkl' for the gcc version of Atmel's USI_TWI_Master code http://www.cs.cmu.edu/~dst/ARTSI/Create/PC%20Comm/ I added Atmel's original Device dependant defines section back into USI_TWI_Master.h NOTE! - It's very important to use pullups on the SDA & SCL lines! More so than with the Wire lib. USAGE is modeled after the standard Wire library . . . Put in setup(): TinyWireM.begin(){ // initialize I2C lib To Send: TinyWireM.beginTransmission(uint8_t slaveAddr){ // setup slave's address (7 bit address - same as Wire) TinyWireM.send(uint8_t data){ // buffer up bytes to send - can be called multiple times someByte = TinyWireM.endTransmission(){ // actually send the bytes in the buffer // returns (optional) 0 = sucess or see USI_TWI_Master.h for error codes To Receive: someByte = TinyWireM.requestFrom(uint8_t slaveAddr, uint8_t numBytes){ // reads 'numBytes' from slave's address // (usage optional) returns 0= success or see USI_TWI_Master.h for error codes someByte = TinyWireM.receive(){ // returns the next byte in the received buffer - called multiple times someByte = TinyWireM.available(){ // returns the number of unread bytes in the received buffer TODO: (by others!) - merge this class with TinyWireS for master & slave support in one library This library 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 2.1 of the License, or 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. */ #ifndef TinyWireM_h #define TinyWireM_h #include <inttypes.h> #define USI_SEND 0 // indicates sending to TWI #define USI_RCVE 1 // indicates receiving from TWI #define USI_BUF_SIZE 20 // bytes in message buffer class USI_TWI { private: static uint8_t USI_Buf[]; // holds I2C send and receive data static uint8_t USI_BufIdx; // current number of bytes in the send buff static uint8_t USI_LastRead; // number of bytes read so far static uint8_t USI_BytesAvail; // number of bytes requested but not read public: USI_TWI(); void begin(); void beginTransmission(uint8_t); void send(uint8_t); uint8_t endTransmission(); uint8_t requestFrom(uint8_t, uint8_t); uint8_t receive(); uint8_t available(); }; extern USI_TWI TinyWireM; #endif
/***************************************************************************** * * * File USI_TWI_Master.c compiled with gcc * Date Friday, 10/31/08 Boo! * Updated by jkl * * AppNote : AVR310 - Using the USI module as a TWI Master * * Extensively modified to provide complete I2C driver. * *Notes: * - T4_TWI and T2_TWI delays are modified to work with 1MHz default clock * and now use hard code values. They would need to change * for other clock rates. Refer to the Apps Note. * * 12/17/08 Added USI_TWI_Start_Memory_Read Routine -jkl * Note msg buffer will have slave adrs ( with write bit set) and memory adrs; * length should be these two bytes plus the number of bytes to read. ****************************************************************************/ #include <avr/interrupt.h> #define F_CPU 1000000UL // Sets up the default speed for delay.h //#define F_CPU 8000000UL // Sets up the default speed for delay.h #include <util/delay.h> #include <avr/io.h> #include "USI_TWI_Master.h" unsigned char USI_TWI_Start_Transceiver_With_Data( unsigned char * , unsigned char ); unsigned char USI_TWI_Master_Transfer( unsigned char ); unsigned char USI_TWI_Master_Stop( void ); unsigned char USI_TWI_Master_Start( void ); union USI_TWI_state { unsigned char errorState; // Can reuse the TWI_state for error states since it will not be needed if there is //an error. struct { unsigned char addressMode : 1; unsigned char masterWriteDataMode : 1; unsigned char memReadMode : 1; unsigned char unused : 5; }; } USI_TWI_state; /*--------------------------------------------------------------- USI TWI single master initialization function ---------------------------------------------------------------*/ void USI_TWI_Master_Initialise( void ) { PORT_USI |= (1<<PIN_USI_SDA); // Enable pullup on SDA, to set high as released state. PORT_USI |= (1<<PIN_USI_SCL); // Enable pullup on SCL, to set high as released state. DDR_USI |= (1<<PIN_USI_SCL); // Enable SCL as output. DDR_USI |= (1<<PIN_USI_SDA); // Enable SDA as output. USIDR = 0xFF; // Preload dataregister with "released level" data. USICR = (0<<USISIE)|(0<<USIOIE)| // Disable Interrupts. (1<<USIWM1)|(0<<USIWM0)| // Set USI in Two-wire mode. (1<<USICS1)|(0<<USICS0)|(1<<USICLK)| // Software stobe as counter clock source (0<<USITC); USISR = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)| // Clear flags, (0x0<<USICNT0); // and reset counter. } /*--------------------------------------------------------------- Use this function to get hold of the error message from the last transmission ---------------------------------------------------------------*/ unsigned char USI_TWI_Get_State_Info( void ) { return ( USI_TWI_state.errorState ); // Return error state. } /*--------------------------------------------------------------- USI Random (memory) Read function. This function sets up for call to USI_TWI_Start_Transceiver_With_Data which does the work. Doesn't matter if read/write bit is set or cleared, it'll be set correctly in this function. The msgSize is passed to USI_TWI_Start_Transceiver_With_Data. Success or error code is returned. Error codes are defined in USI_TWI_Master.h ---------------------------------------------------------------*/ unsigned char USI_TWI_Start_Random_Read( unsigned char *msg, unsigned char msgSize) { *(msg) &= ~(TRUE<<TWI_READ_BIT); // clear the read bit if it's set USI_TWI_state.errorState = 0; USI_TWI_state.memReadMode = TRUE; return (USI_TWI_Start_Transceiver_With_Data( msg, msgSize)); } /*--------------------------------------------------------------- USI Normal Read / Write Function Transmit and receive function. LSB of first byte in buffer indicates if a read or write cycles is performed. If set a read operation is performed. Function generates (Repeated) Start Condition, sends address and R/W, Reads/Writes Data, and verifies/sends ACK. Success or error code is returned. Error codes are defined in USI_TWI_Master.h ---------------------------------------------------------------*/ unsigned char USI_TWI_Start_Read_Write( unsigned char *msg, unsigned char msgSize) { USI_TWI_state.errorState = 0; // Clears all mode bits also return (USI_TWI_Start_Transceiver_With_Data( msg, msgSize)); } /*--------------------------------------------------------------- USI Transmit and receive function. LSB of first byte in buffer indicates if a read or write cycles is performed. If set a read operation is performed. Function generates (Repeated) Start Condition, sends address and R/W, Reads/Writes Data, and verifies/sends ACK. This function also handles Random Read function if the memReadMode bit is set. In that case, the function will: The address in memory will be the second byte and is written *without* sending a STOP. Then the Read bit is set (lsb of first byte), the byte count is adjusted (if needed), and the function function starts over by sending the slave address again and reading the data. Success or error code is returned. Error codes are defined in USI_TWI_Master.h ---------------------------------------------------------------*/ unsigned char USI_TWI_Start_Transceiver_With_Data( unsigned char *msg, unsigned char msgSize) { unsigned char const tempUSISR_8bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)| // Prepare register value to: //Clear flags, and (0x0<<USICNT0); // set USI to shift 8 bits i.e. //count 16 clock edges. unsigned char const tempUSISR_1bit = (1<<USISIF)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)| // Prepare register value to: //Clear flags, and (0xE<<USICNT0); // set USI to shift 1 bit i.e. count 2 clock edges. unsigned char *savedMsg; unsigned char savedMsgSize; //This clear must be done before calling this function so that memReadMode can be specified. // USI_TWI_state.errorState = 0; // Clears all mode bits also USI_TWI_state.addressMode = TRUE; // Always true for first byte #ifdef PARAM_VERIFICATION if(msg > (unsigned char*)RAMEND) // Test if address is outside SRAM space { USI_TWI_state.errorState = USI_TWI_DATA_OUT_OF_BOUND; return (FALSE); } if(msgSize <= 1) // Test if the transmission buffer is empty { USI_TWI_state.errorState = USI_TWI_NO_DATA; return (FALSE); } #endif #ifdef NOISE_TESTING // Test if any unexpected conditions have arrived prior to this //execution. if( USISR & (1<<USISIF) ) { USI_TWI_state.errorState = USI_TWI_UE_START_CON; return (FALSE); } if( USISR & (1<<USIPF) ) { USI_TWI_state.errorState = USI_TWI_UE_STOP_CON; return (FALSE); } if( USISR & (1<<USIDC) ) { USI_TWI_state.errorState = USI_TWI_UE_DATA_COL; return (FALSE); } #endif if ( !(*msg & (1<<TWI_READ_BIT)) ) // The LSB in the address byte determines if is a masterRead or //masterWrite operation. { USI_TWI_state.masterWriteDataMode = TRUE; } // if (USI_TWI_state.memReadMode) // { savedMsg = msg; savedMsgSize = msgSize; // } if ( !USI_TWI_Master_Start( )) { return (FALSE); // Send a START condition on the TWI bus. } /*Write address and Read/Write data */ do { /* If masterWrite cycle (or inital address tranmission)*/ if (USI_TWI_state.addressMode || USI_TWI_state.masterWriteDataMode) { /* Write a byte */ PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW. USIDR = *(msg++); // Setup data. USI_TWI_Master_Transfer( tempUSISR_8bit ); // Send 8 bits on bus. /* Clock and verify (N)ACK from slave */ DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input. if( USI_TWI_Master_Transfer( tempUSISR_1bit ) & (1<<TWI_NACK_BIT) ) { if ( USI_TWI_state.addressMode ) USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_ADDRESS; else USI_TWI_state.errorState = USI_TWI_NO_ACK_ON_DATA; return (FALSE); } if ((!USI_TWI_state.addressMode) && USI_TWI_state.memReadMode)// means memory start address has been written { msg = savedMsg; // start at slave address again *(msg) |= (TRUE<<TWI_READ_BIT); // set the Read Bit on Slave address USI_TWI_state.errorState = 0; USI_TWI_state.addressMode = TRUE; // Now set up for the Read cycle msgSize = savedMsgSize; // Set byte count correctly // NOte that the length should be Slave adrs byte + # bytes to read + 1 (gets decremented below) if ( !USI_TWI_Master_Start( )) { USI_TWI_state.errorState = USI_TWI_BAD_MEM_READ; return (FALSE); // Send a START condition on the TWI bus. } } else { USI_TWI_state.addressMode = FALSE; // Only perform address transmission once. } } /* Else masterRead cycle*/ else { /* Read a data byte */ DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input. *(msg++) = USI_TWI_Master_Transfer( tempUSISR_8bit ); /* Prepare to generate ACK (or NACK in case of End Of Transmission) */ if( msgSize == 1) // If transmission of last byte was performed. { USIDR = 0xFF; // Load NACK to confirm End Of Transmission. } else { USIDR = 0x00; // Load ACK. Set data register bit 7 (output for SDA) low. } USI_TWI_Master_Transfer( tempUSISR_1bit ); // Generate ACK/NACK. } }while( --msgSize) ; // Until all data sent/received. if (!USI_TWI_Master_Stop()) { return (FALSE); // Send a STOP condition on the TWI bus. } /* Transmission successfully completed*/ return (TRUE); } /*--------------------------------------------------------------- Core function for shifting data in and out from the USI. Data to be sent has to be placed into the USIDR prior to calling this function. Data read, will be return'ed from the function. ---------------------------------------------------------------*/ unsigned char USI_TWI_Master_Transfer( unsigned char temp ) { USISR = temp; // Set USISR according to temp. // Prepare clocking. temp = (0<<USISIE)|(0<<USIOIE)| // Interrupts disabled (1<<USIWM1)|(0<<USIWM0)| // Set USI in Two-wire mode. (1<<USICS1)|(0<<USICS0)|(1<<USICLK)| // Software clock strobe as source. (1<<USITC); // Toggle Clock Port. do { _delay_us(T2_TWI); USICR = temp; // Generate positve SCL edge. while( !(PIN_USI & (1<<PIN_USI_SCL)) );// Wait for SCL to go high. _delay_us(T4_TWI); USICR = temp; // Generate negative SCL edge. }while( !(USISR & (1<<USIOIF)) ); // Check for transfer complete. _delay_us(T2_TWI); temp = USIDR; // Read out data. USIDR = 0xFF; // Release SDA. DDR_USI |= (1<<PIN_USI_SDA); // Enable SDA as output. return temp; // Return the data from the USIDR } /*--------------------------------------------------------------- Function for generating a TWI Start Condition. ---------------------------------------------------------------*/ unsigned char USI_TWI_Master_Start( void ) { /* Release SCL to ensure that (repeated) Start can be performed */ PORT_USI |= (1<<PIN_USI_SCL); // Release SCL. while( !(PORT_USI & (1<<PIN_USI_SCL)) ); // Verify that SCL becomes high. _delay_us(T2_TWI); /* Generate Start Condition */ PORT_USI &= ~(1<<PIN_USI_SDA); // Force SDA LOW. _delay_us(T4_TWI); PORT_USI &= ~(1<<PIN_USI_SCL); // Pull SCL LOW. PORT_USI |= (1<<PIN_USI_SDA); // Release SDA. #ifdef SIGNAL_VERIFY if( !(USISR & (1<<USISIF)) ) { USI_TWI_state.errorState = USI_TWI_MISSING_START_CON; return (FALSE); } #endif return (TRUE); } /*--------------------------------------------------------------- Function for generating a TWI Stop Condition. Used to release the TWI bus. ---------------------------------------------------------------*/ unsigned char USI_TWI_Master_Stop( void ) { PORT_USI &= ~(1<<PIN_USI_SDA); // Pull SDA low. PORT_USI |= (1<<PIN_USI_SCL); // Release SCL. while( !(PIN_USI & (1<<PIN_USI_SCL)) ); // Wait for SCL to go high. _delay_us(T4_TWI); PORT_USI |= (1<<PIN_USI_SDA); // Release SDA. _delay_us(T2_TWI); #ifdef SIGNAL_VERIFY if( !(USISR & (1<<USIPF)) ) { USI_TWI_state.errorState = USI_TWI_MISSING_STOP_CON; return (FALSE); } #endif return (TRUE); }
/***************************************************************************** * * * File USI_TWI_Master.h compiled with gcc * Date Friday, 10/31/08 Boo! * Updated by jkl * * * Supported devices : All device with USI module can be used. * The example is written for the ATtiny2313 * * AppNote : AVR310 - Using the USI module as a TWI Master * * This is modified to just do I2C communication on ATtiny2313 running at * 1MHz. Fast mode is probably possible, but would need a faster clock * and has not been tested. * * 12/15/08 Added declaration of USI_TWI_Start_Memory_Read -jkl ****************************************************************************/ //********** Defines **********// // Defines controlling timing limits - SCL <= 100KHz. #define SYS_CLK 1000.0 // [kHz] Default for ATtiny2313 //#define SYS_CLK 8000.0 // For use with _delay_us() #define T2_TWI 5 // >4,7us #define T4_TWI 4 // >4,0us // Defines error code generating //#define PARAM_VERIFICATION //#define NOISE_TESTING #define SIGNAL_VERIFY // This should probably be on always. /**************************************************************************** Bit and byte definitions ****************************************************************************/ #define TWI_READ_BIT 0 // Bit position for R/W bit in "address byte". #define TWI_ADR_BITS 1 // Bit position for LSB of the slave address bits in the init byte. #define TWI_NACK_BIT 0 // Bit position for (N)ACK bit. // Note these have been renumbered from the Atmel Apps Note. Most likely errors are now // lowest numbers so they're easily recognized as LED flashes. #define USI_TWI_NO_DATA 0x08 // Transmission buffer is empty #define USI_TWI_DATA_OUT_OF_BOUND 0x09 // Transmission buffer is outside SRAM space #define USI_TWI_UE_START_CON 0x07 // Unexpected Start Condition #define USI_TWI_UE_STOP_CON 0x06 // Unexpected Stop Condition #define USI_TWI_UE_DATA_COL 0x05 // Unexpected Data Collision (arbitration) #define USI_TWI_NO_ACK_ON_DATA 0x02 // The slave did not acknowledge all data #define USI_TWI_NO_ACK_ON_ADDRESS 0x01 // The slave did not acknowledge the address #define USI_TWI_MISSING_START_CON 0x03 // Generated Start Condition not detected on bus #define USI_TWI_MISSING_STOP_CON 0x04 // Generated Stop Condition not detected on bus #define USI_TWI_BAD_MEM_READ 0x0A // Error during external memory read // Device dependant defines ADDED BACK IN FROM ORIGINAL ATMEL .H #if defined(__AVR_AT90Mega169__) | defined(__AVR_ATmega169__) | \ defined(__AVR_AT90Mega165__) | defined(__AVR_ATmega165__) | \ defined(__AVR_ATmega325__) | defined(__AVR_ATmega3250__) | \ defined(__AVR_ATmega645__) | defined(__AVR_ATmega6450__) | \ defined(__AVR_ATmega329__) | defined(__AVR_ATmega3290__) | \ defined(__AVR_ATmega649__) | defined(__AVR_ATmega6490__) #define DDR_USI DDRE #define PORT_USI PORTE #define PIN_USI PINE #define PORT_USI_SDA PORTE5 #define PORT_USI_SCL PORTE4 #define PIN_USI_SDA PINE5 #define PIN_USI_SCL PINE4 #endif #if defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | \ defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__) #define DDR_USI DDRB #define PORT_USI PORTB #define PIN_USI PINB #define PORT_USI_SDA PORTB0 #define PORT_USI_SCL PORTB2 #define PIN_USI_SDA PINB0 #define PIN_USI_SCL PINB2 #endif #if defined(__AVR_AT90Tiny2313__) | defined(__AVR_ATtiny2313__) #define DDR_USI DDRB #define PORT_USI PORTB #define PIN_USI PINB #define PORT_USI_SDA PORTB5 #define PORT_USI_SCL PORTB7 #define PIN_USI_SDA PINB5 #define PIN_USI_SCL PINB7 #endif /* From the original .h // Device dependant defines - These for ATtiny2313. // CHANGED FOR ATtiny85 #define DDR_USI DDRB #define PORT_USI PORTB #define PIN_USI PINB #define PORT_USI_SDA PORTB0 // was PORTB5 - N/U #define PORT_USI_SCL PORTB2 // was PORTB7 - N/U #define PIN_USI_SDA PINB0 // was PINB5 #define PIN_USI_SCL PINB2 // was PINB7 */ // General defines #define TRUE 1 #define FALSE 0 //********** Prototypes **********// void USI_TWI_Master_Initialise( void ); unsigned char USI_TWI_Start_Random_Read( unsigned char * , unsigned char ); unsigned char USI_TWI_Start_Read_Write( unsigned char * , unsigned char ); unsigned char USI_TWI_Get_State_Info( void );