ATtiny45 + 0.96′ I2C 128X64 OLED (Arduino)

Дисплей 0.96′ I2C 128X64 OLED на контроллере SSD1306 имеет разрешение 128х64 пиксел и подключается к микроконтроллеру по интерфейсу I2C.

Параметры дисплея SSD1306:

  • Технология дисплея: OLED
  • Разрешение дисплея: 128 на 64 точки
  • Диагональ дисплея: 0,96 дюйма
  • Угол обзора: 160°
  • Напряжение питания: 2.8 В ~ 5.5 В
  • Мощность: 0,08 Вт
  • Габариты: 27.3 мм х 27.8 мм х 3.7 мм

Микроконтроллер ATtiny45 имеет всего 4 кБ памяти для программ, что не дает возможность использовать стандартные библиотеки, ниже показан тестовый скетч который занимает всего 1,2 кБ памяти. Данный скетч позволяет выводить различные символы стандартной кодировки ASCII.

Дополнительно имеется возможность менять яркость свечения дисплея, режим инверсии.

#define I2C_SDA         PB3                  
#define I2C_SCL         PB4    
#define OLED_ADDR       0x78  // OLED write address       
 
#include <avr/io.h>
#include <util/delay.h>
 
// Project Files (Github):  https://github.com/wagiminator/ATtiny13-TinyOLEDdemo
// License: http://creativecommons.org/licenses/by-sa/3.0/
 
const char Message1[] PROGMEM = "RCL-RADIO.RU";
const char Message2[] PROGMEM = "OLED 0.96";
const char Message3[] PROGMEM = "SSD1306";
const char Message4[] PROGMEM = "Line ";
const char Message5[] PROGMEM = "<--------***-------->";
int n;
 
int main(void) {
  _delay_ms(200);
  OLED_init();
  OLED_brig(150);// 0...255
  OLED_inver(0); // invers
  OLED_clear(); 
 
  while(1) {                                                  
  //  OLED_clear();                       
    OLED_cursor(0, 0);                
    OLED_printP(Message1); 
    OLED_cursor(0, 1);                
    OLED_printP(Message2);  
    OLED_cursor(0, 2);                
    OLED_printP(Message3);               
    OLED_cursor(0, 3);
    OLED_printP(Message5);
    OLED_cursor(0, 4);
    OLED_printP(Message4);OLED_num(5);
    OLED_cursor(0, 5);
    OLED_printP(Message4);OLED_num(6);
    OLED_cursor(0, 6);
    OLED_printP(Message4);OLED_num(7);
    OLED_cursor(0, 7);
    OLED_printP(Message4);OLED_num(8);
 
    n++;
    if(n>50){n=0;}
    OLED_cursor(70, 7);
    OLED_num(n/10);OLED_num(n%10);
    _delay_ms(100);                      
  } 
} 
 
 
#define I2C_SDA_HIGH()  DDRB &= ~(1<<I2C_SDA)
#define I2C_SDA_LOW()   DDRB |=  (1<<I2C_SDA) 
#define I2C_SCL_HIGH()  DDRB &= ~(1<<I2C_SCL) 
#define I2C_SCL_LOW()   DDRB |=  (1<<I2C_SCL) 
#define OLED_CMD_MODE   0x00                  
#define OLED_DAT_MODE   0x40  
const uint8_t OLED_INIT_CMD[] PROGMEM = {0xA8, 0x3F, 0x8D, 0x14, 0xAF, 0xA1, 0xC8};
 
void I2C_init(void){DDRB  &= ~((1<<I2C_SDA)|(1<<I2C_SCL));PORTB &= ~((1<<I2C_SDA)|(1<<I2C_SCL));}
void I2C_write(uint8_t data) {
  for(uint8_t i = 8; i; i--){
    I2C_SDA_LOW();                       
    if (data & 0x80) I2C_SDA_HIGH();   
    I2C_SCL_HIGH();data<<=1;I2C_SCL_LOW();}
  I2C_SDA_HIGH();I2C_SCL_HIGH();asm("nop");I2C_SCL_LOW();}
void I2C_start(uint8_t addr){I2C_SDA_LOW();I2C_SCL_LOW();I2C_write(addr);}
void I2C_stop(void){I2C_SDA_LOW();I2C_SCL_HIGH();I2C_SDA_HIGH();}
 
const uint8_t OLED_FONT[] PROGMEM = {
   0x00, 0x00, 0x00, 0x00, 0x00, // sp
   0x00, 0x00, 0x5F, 0x00, 0x00, // !
   0x00, 0x03, 0x00, 0x03, 0x00, // "
   0x14, 0x3E, 0x14, 0x3E, 0x14, // #
   0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
   0x43, 0x33, 0x08, 0x66, 0x61, // %
   0x36, 0x49, 0x55, 0x22, 0x50, // &
   0x00, 0x05, 0x03, 0x00, 0x00, // '
   0x00, 0x1C, 0x22, 0x41, 0x00, // (
   0x00, 0x41, 0x22, 0x1C, 0x00, // )
   0x14, 0x08, 0x3E, 0x08, 0x14, // *
   0x08, 0x08, 0x3E, 0x08, 0x08, // +
   0x00, 0x50, 0x30, 0x00, 0x00, // ,
   0x08, 0x08, 0x08, 0x08, 0x08, // -
   0x00, 0x60, 0x60, 0x00, 0x00, // .
   0x20, 0x10, 0x08, 0x04, 0x02, // /
   0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
   0x00, 0x04, 0x02, 0x7F, 0x00, // 1
   0x42, 0x61, 0x51, 0x49, 0x46, // 2
   0x22, 0x41, 0x49, 0x49, 0x36, // 3
   0x18, 0x14, 0x12, 0x7F, 0x10, // 4
   0x27, 0x45, 0x45, 0x45, 0x39, // 5
   0x3E, 0x49, 0x49, 0x49, 0x32, // 6
   0x01, 0x01, 0x71, 0x09, 0x07, // 7
   0x36, 0x49, 0x49, 0x49, 0x36, // 8
   0x26, 0x49, 0x49, 0x49, 0x3E, // 9
   0x00, 0x36, 0x36, 0x00, 0x00, // :
   0x00, 0x56, 0x36, 0x00, 0x00, // ;
   0x08, 0x14, 0x22, 0x41, 0x00, // <
   0x14, 0x14, 0x14, 0x14, 0x14, // =
   0x00, 0x41, 0x22, 0x14, 0x08, // >
   0x02, 0x01, 0x51, 0x09, 0x06, // ?
   0x3E, 0x41, 0x59, 0x55, 0x5E, // @
   0x7E, 0x09, 0x09, 0x09, 0x7E, // A
   0x7F, 0x49, 0x49, 0x49, 0x36, // B
   0x3E, 0x41, 0x41, 0x41, 0x22, // C
   0x7F, 0x41, 0x41, 0x41, 0x3E, // D
   0x7F, 0x49, 0x49, 0x49, 0x41, // E
   0x7F, 0x09, 0x09, 0x09, 0x01, // F
   0x3E, 0x41, 0x41, 0x49, 0x3A, // G
   0x7F, 0x08, 0x08, 0x08, 0x7F, // H
   0x00, 0x41, 0x7F, 0x41, 0x00, // I
   0x30, 0x40, 0x40, 0x40, 0x3F, // J
   0x7F, 0x08, 0x14, 0x22, 0x41, // K
   0x7F, 0x40, 0x40, 0x40, 0x40, // L
   0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
   0x7F, 0x02, 0x04, 0x08, 0x7F, // N
   0x3E, 0x41, 0x41, 0x41, 0x3E, // O
   0x7F, 0x09, 0x09, 0x09, 0x06, // P
   0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
   0x7F, 0x09, 0x09, 0x09, 0x76, // R
   0x26, 0x49, 0x49, 0x49, 0x32, // S
   0x01, 0x01, 0x7F, 0x01, 0x01, // T
   0x3F, 0x40, 0x40, 0x40, 0x3F, // U
   0x1F, 0x20, 0x40, 0x20, 0x1F, // V
   0x7F, 0x20, 0x10, 0x20, 0x7F, // W
   0x41, 0x22, 0x1C, 0x22, 0x41, // X
   0x07, 0x08, 0x70, 0x08, 0x07, // Y
   0x61, 0x51, 0x49, 0x45, 0x43, // Z
   0x00, 0x7F, 0x41, 0x00, 0x00, // [
   0x02, 0x04, 0x08, 0x10, 0x20, // "/"
   0x00, 0x00, 0x41, 0x7F, 0x00, // ]
   0x04, 0x02, 0x01, 0x02, 0x04, // ^
   0x40, 0x40, 0x40, 0x40, 0x40, // _
   0x00, 0x01, 0x02, 0x04, 0x00, // `
   0x20, 0x54, 0x54, 0x54, 0x78, // a
   0x7F, 0x44, 0x44, 0x44, 0x38, // b
   0x38, 0x44, 0x44, 0x44, 0x44, // c
   0x38, 0x44, 0x44, 0x44, 0x7F, // d
   0x38, 0x54, 0x54, 0x54, 0x18, // e
   0x04, 0x04, 0x7E, 0x05, 0x05, // f
   0x08, 0x54, 0x54, 0x54, 0x3C, // g
   0x7F, 0x08, 0x04, 0x04, 0x78, // h
   0x00, 0x44, 0x7D, 0x40, 0x00, // i
   0x20, 0x40, 0x44, 0x3D, 0x00, // j
   0x7F, 0x10, 0x28, 0x44, 0x00, // k
   0x00, 0x41, 0x7F, 0x40, 0x00, // l
   0x7C, 0x04, 0x78, 0x04, 0x78, // m
   0x7C, 0x08, 0x04, 0x04, 0x78, // n
   0x38, 0x44, 0x44, 0x44, 0x38, // o
   0x7C, 0x14, 0x14, 0x14, 0x08, // p
   0x08, 0x14, 0x14, 0x14, 0x7C, // q
   0x00, 0x7C, 0x08, 0x04, 0x04, // r
   0x48, 0x54, 0x54, 0x54, 0x20, // s
   0x04, 0x04, 0x3F, 0x44, 0x44, // t
   0x3C, 0x40, 0x40, 0x20, 0x7C, // u
   0x1C, 0x20, 0x40, 0x20, 0x1C, // v
   0x3C, 0x40, 0x30, 0x40, 0x3C, // w
   0x44, 0x28, 0x10, 0x28, 0x44, // x
   0x0C, 0x50, 0x50, 0x50, 0x3C, // y
   0x44, 0x64, 0x54, 0x4C, 0x44, // z
   0x00, 0x08, 0x36, 0x41, 0x41, // {
   0x00, 0x00, 0x7F, 0x00, 0x00, // |
   0x41, 0x41, 0x36, 0x08, 0x00, // }
   0x02, 0x01, 0x02, 0x04, 0x02, // ~
};
 
void OLED_init(void) {
  I2C_init();                             
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  for (uint8_t i = 0; i < 7; i++) I2C_write(pgm_read_byte(&OLED_INIT_CMD[i])); 
  I2C_stop();                            
}
 
void OLED_printC(char ch) {
  uint16_t offset = ch - 32;             
  offset += offset << 2;                
  I2C_write(0x00);        
  for(uint8_t i=5; i; i--) I2C_write(pgm_read_byte(&OLED_FONT[offset++])); 
}
 
void OLED_printP(const char* p) {
  I2C_start(OLED_ADDR);                  
  I2C_write(OLED_DAT_MODE);               
  char ch = pgm_read_byte(p);             
  while (ch != 0){OLED_printC(ch);ch = pgm_read_byte(++p);}
  I2C_stop();       
}
 
void OLED_num(byte num){
  I2C_start(OLED_ADDR);                 
  I2C_write(OLED_DAT_MODE);    
  OLED_printC(num+48); 
  I2C_stop();    
  }
 
void OLED_cursor(uint8_t xpos, uint8_t ypos) {
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(xpos & 0x0F);                 
  I2C_write(0x10 | (xpos >> 4));     
  I2C_write(0xB0 | (ypos & 0x07));    
  I2C_stop();                           
}
 
void OLED_brig(byte br){
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(0x81);                 
  I2C_write(br);        
  I2C_stop();
  }
 
void OLED_inver(bool inv){
  int inv_data;
  if(inv==0) inv_data=0xA6; else inv_data=0xA7;
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(inv_data);                        
  I2C_stop();
  }  
 
void OLED_clear(void) {
  for (uint8_t i = 0; i < 8; i++){
    OLED_cursor(0, i);
    I2C_start(OLED_ADDR);                  
    I2C_write(OLED_DAT_MODE);              
    for(uint8_t i=128; i; i--) I2C_write(0x00);
    I2C_stop();                            
  }
  }

Скетч использует 1216 байт (29%) памяти устройства. Всего доступно 4096 байт.
Глобальные переменные используют 2 байт (0%) динамической памяти, оставляя 254 байт для локальных переменных. Максимум: 256 байт.


 0.91′ SSD1306 128×32 OLED I2C

#include <avr/io.h>
#include <util/delay.h>
 
// Project Files (Github):  https://github.com/wagiminator/ATtiny13-TinyOLEDdemo
// License: http://creativecommons.org/licenses/by-sa/3.0/
 
#define I2C_SDA         PB3                   
#define I2C_SCL         PB4                  
 
#define I2C_SDA_HIGH()  DDRB &= ~(1<<I2C_SDA) 
#define I2C_SDA_LOW()   DDRB |=  (1<<I2C_SDA) 
#define I2C_SCL_HIGH()  DDRB &= ~(1<<I2C_SCL) 
#define I2C_SCL_LOW()   DDRB |=  (1<<I2C_SCL) 
 
const char Message1[] PROGMEM = "RCL-RADIO.RU";
const char Message2[] PROGMEM = "OLED 0.91 / 128x32";
const char Message3[] PROGMEM = "SSD1306";
const char Message4[] PROGMEM = "Line 4";
int n;
 
int main(void) {
  OLED_init();
  OLED_brig(150);// 0...255
  OLED_inver(0); // invers                           
  OLED_clear(); 
 
  while(1) { 
OLED_cursor(0, 0);                
    OLED_printP(Message1); 
    OLED_cursor(0, 1);                
    OLED_printP(Message2);  
    OLED_cursor(0, 2);                
    OLED_printP(Message3);               
    OLED_cursor(0, 3);
    OLED_printP(Message4);                   
        n++;
    if(n>50){n=0;}
    OLED_cursor(70, 3);
    OLED_num(n/10);OLED_num(n%10);
    _delay_ms(100);                      
}}
 
///// I2C ///////////////////////////////////////////////////////
void I2C_init(void) {DDRB  &= ~((1<<I2C_SDA)|(1<<I2C_SCL)); PORTB &= ~((1<<I2C_SDA)|(1<<I2C_SCL));}
void I2C_write(uint8_t data) {
  for(uint8_t i = 8; i; i--) {I2C_SDA_LOW();                        
    if (data & 0x80) I2C_SDA_HIGH();I2C_SCL_HIGH();data<<=1;I2C_SCL_LOW();}
  I2C_SDA_HIGH();I2C_SCL_HIGH();asm("nop");I2C_SCL_LOW();                         
}
void I2C_start(uint8_t addr) {I2C_SDA_LOW();I2C_SCL_LOW();I2C_write(addr);}
void I2C_stop(void) {I2C_SDA_LOW();I2C_SCL_HIGH();I2C_SDA_HIGH();}
 
///// OLED ///////////////////////////////////
#define OLED_ADDR       0x78                  
#define OLED_CMD_MODE   0x00                  
#define OLED_DAT_MODE   0x40                  
#define OLED_INIT_LEN   12                 
 
const uint8_t OLED_INIT_CMD[] PROGMEM = {0xA8,0x1F,0x22,0x00,0x03,0x20,0x00,0xDA,0x02,0x8D,0x14,0xAF,0xA1,0xC8};
const uint8_t OLED_FONT[] PROGMEM = {
   0x00, 0x00, 0x00, 0x00, 0x00, // sp
   0x00, 0x00, 0x5F, 0x00, 0x00, // !
   0x00, 0x03, 0x00, 0x03, 0x00, // "
   0x14, 0x3E, 0x14, 0x3E, 0x14, // #
   0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
   0x43, 0x33, 0x08, 0x66, 0x61, // %
   0x36, 0x49, 0x55, 0x22, 0x50, // &
   0x00, 0x05, 0x03, 0x00, 0x00, // '
   0x00, 0x1C, 0x22, 0x41, 0x00, // (
   0x00, 0x41, 0x22, 0x1C, 0x00, // )
   0x14, 0x08, 0x3E, 0x08, 0x14, // *
   0x08, 0x08, 0x3E, 0x08, 0x08, // +
   0x00, 0x50, 0x30, 0x00, 0x00, // ,
   0x08, 0x08, 0x08, 0x08, 0x08, // -
   0x00, 0x60, 0x60, 0x00, 0x00, // .
   0x20, 0x10, 0x08, 0x04, 0x02, // /
   0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
   0x00, 0x04, 0x02, 0x7F, 0x00, // 1
   0x42, 0x61, 0x51, 0x49, 0x46, // 2
   0x22, 0x41, 0x49, 0x49, 0x36, // 3
   0x18, 0x14, 0x12, 0x7F, 0x10, // 4
   0x27, 0x45, 0x45, 0x45, 0x39, // 5
   0x3E, 0x49, 0x49, 0x49, 0x32, // 6
   0x01, 0x01, 0x71, 0x09, 0x07, // 7
   0x36, 0x49, 0x49, 0x49, 0x36, // 8
   0x26, 0x49, 0x49, 0x49, 0x3E, // 9
   0x00, 0x36, 0x36, 0x00, 0x00, // :
   0x00, 0x56, 0x36, 0x00, 0x00, // ;
   0x08, 0x14, 0x22, 0x41, 0x00, // <
   0x14, 0x14, 0x14, 0x14, 0x14, // =
   0x00, 0x41, 0x22, 0x14, 0x08, // >
   0x02, 0x01, 0x51, 0x09, 0x06, // ?
   0x3E, 0x41, 0x59, 0x55, 0x5E, // @
   0x7E, 0x09, 0x09, 0x09, 0x7E, // A
   0x7F, 0x49, 0x49, 0x49, 0x36, // B
   0x3E, 0x41, 0x41, 0x41, 0x22, // C
   0x7F, 0x41, 0x41, 0x41, 0x3E, // D
   0x7F, 0x49, 0x49, 0x49, 0x41, // E
   0x7F, 0x09, 0x09, 0x09, 0x01, // F
   0x3E, 0x41, 0x41, 0x49, 0x3A, // G
   0x7F, 0x08, 0x08, 0x08, 0x7F, // H
   0x00, 0x41, 0x7F, 0x41, 0x00, // I
   0x30, 0x40, 0x40, 0x40, 0x3F, // J
   0x7F, 0x08, 0x14, 0x22, 0x41, // K
   0x7F, 0x40, 0x40, 0x40, 0x40, // L
   0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
   0x7F, 0x02, 0x04, 0x08, 0x7F, // N
   0x3E, 0x41, 0x41, 0x41, 0x3E, // O
   0x7F, 0x09, 0x09, 0x09, 0x06, // P
   0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
   0x7F, 0x09, 0x09, 0x09, 0x76, // R
   0x26, 0x49, 0x49, 0x49, 0x32, // S
   0x01, 0x01, 0x7F, 0x01, 0x01, // T
   0x3F, 0x40, 0x40, 0x40, 0x3F, // U
   0x1F, 0x20, 0x40, 0x20, 0x1F, // V
   0x7F, 0x20, 0x10, 0x20, 0x7F, // W
   0x41, 0x22, 0x1C, 0x22, 0x41, // X
   0x07, 0x08, 0x70, 0x08, 0x07, // Y
   0x61, 0x51, 0x49, 0x45, 0x43, // Z
   0x00, 0x7F, 0x41, 0x00, 0x00, // [
   0x02, 0x04, 0x08, 0x10, 0x20, // "/"
   0x00, 0x00, 0x41, 0x7F, 0x00, // ]
   0x04, 0x02, 0x01, 0x02, 0x04, // ^
   0x40, 0x40, 0x40, 0x40, 0x40, // _
   0x00, 0x01, 0x02, 0x04, 0x00, // `
   0x20, 0x54, 0x54, 0x54, 0x78, // a
   0x7F, 0x44, 0x44, 0x44, 0x38, // b
   0x38, 0x44, 0x44, 0x44, 0x44, // c
   0x38, 0x44, 0x44, 0x44, 0x7F, // d
   0x38, 0x54, 0x54, 0x54, 0x18, // e
   0x04, 0x04, 0x7E, 0x05, 0x05, // f
   0x08, 0x54, 0x54, 0x54, 0x3C, // g
   0x7F, 0x08, 0x04, 0x04, 0x78, // h
   0x00, 0x44, 0x7D, 0x40, 0x00, // i
   0x20, 0x40, 0x44, 0x3D, 0x00, // j
   0x7F, 0x10, 0x28, 0x44, 0x00, // k
   0x00, 0x41, 0x7F, 0x40, 0x00, // l
   0x7C, 0x04, 0x78, 0x04, 0x78, // m
   0x7C, 0x08, 0x04, 0x04, 0x78, // n
   0x38, 0x44, 0x44, 0x44, 0x38, // o
   0x7C, 0x14, 0x14, 0x14, 0x08, // p
   0x08, 0x14, 0x14, 0x14, 0x7C, // q
   0x00, 0x7C, 0x08, 0x04, 0x04, // r
   0x48, 0x54, 0x54, 0x54, 0x20, // s
   0x04, 0x04, 0x3F, 0x44, 0x44, // t
   0x3C, 0x40, 0x40, 0x20, 0x7C, // u
   0x1C, 0x20, 0x40, 0x20, 0x1C, // v
   0x3C, 0x40, 0x30, 0x40, 0x3C, // w
   0x44, 0x28, 0x10, 0x28, 0x44, // x
   0x0C, 0x50, 0x50, 0x50, 0x3C, // y
   0x44, 0x64, 0x54, 0x4C, 0x44, // z
   0x00, 0x08, 0x36, 0x41, 0x41, // {
   0x00, 0x00, 0x7F, 0x00, 0x00, // |
   0x41, 0x41, 0x36, 0x08, 0x00, // }
   0x02, 0x01, 0x02, 0x04, 0x02, // ~
};
 
void OLED_init(void) {
  I2C_init();                             
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  for (uint8_t i = 0; i < OLED_INIT_LEN; i++) I2C_write(pgm_read_byte(&OLED_INIT_CMD[i])); 
  I2C_stop();                            
}
 
void OLED_printC(char ch) {
  uint16_t offset = ch - 32;             
  offset += offset << 2;                
  I2C_write(0x00);        
  for(uint8_t i=5; i; i--) I2C_write(pgm_read_byte(&OLED_FONT[offset++])); 
}
 
void OLED_printP(const char* p) {
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_DAT_MODE);               
  char ch = pgm_read_byte(p);            
  while (ch != 0){OLED_printC(ch);ch = pgm_read_byte(++p);}
  I2C_stop();                   
}
 
void OLED_cursor(uint8_t xpos, uint8_t ypos) {
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(xpos & 0x0F);                 
  I2C_write(0x10 | (xpos >> 4));     
  I2C_write(0xB0 | (ypos & 0x07));    
  I2C_stop();                           
}
 
void OLED_clear(void) {
  OLED_cursor(0, 0);                      
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_DAT_MODE);              
  for(uint16_t i=512; i; i--) I2C_write(0x00); 
  I2C_stop();  
}
 
void OLED_num(byte num){
  I2C_start(OLED_ADDR);                 
  I2C_write(OLED_DAT_MODE);    
  OLED_printC(num+48); 
  I2C_stop();    
  }
 
void OLED_brig(byte br){
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(0x81);                 
  I2C_write(br);        
  I2C_stop();
  }
 
void OLED_inver(bool inv){
  int inv_data;
  if(inv==0) inv_data=0xA6; else inv_data=0xA7;
  I2C_start(OLED_ADDR);                   
  I2C_write(OLED_CMD_MODE);               
  I2C_write(inv_data);                        
  I2C_stop();
  } 

Форум — http://forum.rcl-radio.ru/viewtopic.php?id=518

Добавить комментарий

Войти с помощью: