@ -29,6 +29,7 @@ All text above, and the splash screen below must be included in any redistributi
# include "ssd1306_i2c.h"
# include "ssd1306_i2c.h"
# include "oled_fonts.h"
# include "oled_fonts.h"
# include "lcd_oled.h"
# define true 1
# define true 1
# define false 0
# define false 0
@ -37,11 +38,11 @@ All text above, and the splash screen below must be included in any redistributi
# define pgm_read_byte(addr) (*(const uint8_t *)(addr))
# define pgm_read_byte(addr) (*(const uint8_t *)(addr))
int 16 _t cursor_y = 0 ;
int 8 _t cursor_y = 0 ;
int 16 _t cursor_x = 0 ;
int 8 _t cursor_x = 0 ;
// the memory buffer for the LCD. Displays Adafruit logo
// the memory buffer for the LCD. Displays Adafruit logo
uint 16 _t buffer [ SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8 ] = {
uint 8 _t buffer [ SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8 ] = {
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
@ -66,7 +67,6 @@ uint16_t buffer[SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8] = {
0x00 , 0x80 , 0x80 , 0x80 ,
0x00 , 0x80 , 0x80 , 0x80 ,
0x80 , 0x80 , 0x00 , 0x80 , 0x80 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0x80 , 0x80 ,
0x80 , 0x80 , 0x00 , 0x80 , 0x80 , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0x80 , 0x80 ,
0x80 , 0x80 , 0x00 , 0xFF ,
0x80 , 0x80 , 0x00 , 0xFF ,
# if (SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH > 96*16)
0xFF , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0x80 , 0x80 , 0x80 , 0x00 , 0x00 ,
0xFF , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 , 0x80 , 0x80 , 0x80 , 0x80 , 0x00 , 0x00 ,
0x80 , 0x80 , 0x00 , 0x00 ,
0x80 , 0x80 , 0x00 , 0x00 ,
0x80 , 0xFF , 0xFF , 0x80 , 0x80 , 0x00 , 0x80 , 0x80 , 0x00 , 0x80 , 0x80 , 0x80 ,
0x80 , 0xFF , 0xFF , 0x80 , 0x80 , 0x00 , 0x80 , 0x80 , 0x00 , 0x80 , 0x80 , 0x80 ,
@ -107,7 +107,6 @@ uint16_t buffer[SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8] = {
0x00 , 0x00 , 0x00 , 0x03 ,
0x00 , 0x00 , 0x00 , 0x03 ,
0x03 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x03 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 ,
# if (SSD1306_LCDHEIGHT == 64)
0x00 , 0x00 , 0x00 , 0x80 , 0xC0 , 0xE0 , 0xF0 , 0xF9 , 0xFF , 0xFF , 0xFF , 0xFF ,
0x00 , 0x00 , 0x00 , 0x80 , 0xC0 , 0xE0 , 0xF0 , 0xF9 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0x3F , 0x1F , 0x0F ,
0xFF , 0x3F , 0x1F , 0x0F ,
0x87 , 0xC7 , 0xF7 , 0xFF , 0xFF , 0x1F , 0x1F , 0x3D , 0xFC , 0xF8 , 0xF8 , 0xF8 ,
0x87 , 0xC7 , 0xF7 , 0xFF , 0xFF , 0x1F , 0x1F , 0x3D , 0xFC , 0xF8 , 0xF8 , 0xF8 ,
@ -172,12 +171,11 @@ uint16_t buffer[SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8] = {
0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00
0x00 , 0x00 , 0x00 , 0x00
# endif
# endif
} ;
} ;
int 16 _t _vccstate ;
int 8 _t _vccstate ;
int16_t i2cd ;
int16_t i2cd ;
i2c_t i2c_device ;
# define ssd1306_swap(a, b) { int16_t t = a; a = b; b = t; }
# define ssd1306_swap(a, b) { int16_t t = a; a = b; b = t; }
@ -217,88 +215,160 @@ void ssd1306_drawPixel(int16_t x, int16_t y, uint16_t color)
}
}
}
}
//Section : 10.1.12 Set Display ON/OFF (AEh/AFh) | Page 37
void ssd1306_i2c_set_display_off ( i2c_t * i2c_dev )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_DISPLAYOFF ) ;
}
//Section : 10.1.12 Set Display ON/OFF (AEh/AFh) | Page 37
void ssd1306_i2c_set_display_on ( i2c_t * i2c_dev )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_DISPLAYON ) ;
}
// TODO: Find a ferq Calculator
// Section : 10.1.16 Set Display Clock Divide Ratio/ Oscillator Frequency (D5h) | Page : 40
void ssd1306_i2c_set_display_clkDiv_oscFreq ( i2c_t * i2c_dev , uint8_t clockDivider , uint8_t oscillatorFreq )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_SETDISPLAYCLOCKDIV ) ; // 0xD5
ssd1306_i2c_command ( i2c_dev , 0x80 ) ; // the suggested ratio 0x80
}
// Section : 10.1.11 Set Multiplex Ratio (A8h) | Page : 37
void ssd1306_i2c_set_multiplex_ratio ( i2c_t * i2c_dev , uint8_t ratio )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_SETMULTIPLEX ) ; // 0xA8
ssd1306_i2c_command ( i2c_dev , ratio ) ;
}
// Section : 10.1.15 Set Display Offset (D3h) | Page : 37
void ssd1306_i2c_set_display_offset ( i2c_t * i2c_dev , uint8_t offset )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_SETDISPLAYOFFSET ) ; // 0xD3
ssd1306_i2c_command ( i2c_dev , offset ) ;
}
// Section : 10.1.13 Set Page Start Address for Page Addressing Mode (B0h~B7h) | Page : 37
void ssd1306_i2c_set_display_start_line ( i2c_t * i2c_dev , uint8_t start )
{
if ( start < = 7 )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_SETSTARTLINE | start ) ;
}
}
// TODO : Some things are not clear What does 0x10 do ?
// Section : 2.1 Command Table for Charge Bump Setting | Page : 60
void ssd1306_i2c_set_chage_pump ( i2c_t * i2c_dev , uint8_t voltageSource )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_CHARGEPUMP ) ; // 0x8D
if ( voltageSource = = SSD1306_EXTERNALVCC ) {
ssd1306_i2c_command ( i2c_dev , 0x10 ) ;
} else {
ssd1306_i2c_command ( i2c_dev , SSD1306_ENABLE_CHAGE_PUMP ) ;
}
}
// Section :10.1.3 Set Memory Addressing Mode (20h) | Page : 34
void ssd1306_i2c_set_memory_addressing_mode ( i2c_t * i2c_dev , uint8_t mode )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_MEMORYMODE ) ;
ssd1306_i2c_command ( i2c_dev , mode ) ;
}
// TODO : Not very clear what this functionality does :S
// Section : 10.1.8 Set Segment Re-map (A0h/A1h)
void ssd1306_i2c_set_segment_remap ( i2c_t * i2c_dev , uint8_t enable )
{
if ( enable )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_SEGREMAP | 0x1 ) ;
}
else
{
ssd1306_i2c_command ( i2c_dev , SSD1306_SEGREMAP | 0x0 ) ;
}
}
// Section : 10.1.14 Set COM Output Scan Direction (C0h/C8h) | Page 37
void ssd1306_i2c_set_com_scan_direction ( i2c_t * i2c_dev , uint8_t incremental )
{
if ( incremental )
{
ssd1306_i2c_command ( i2c_dev , SSD1306_COMSCANINC ) ;
}
else
{
ssd1306_i2c_command ( i2c_dev , SSD1306_COMSCANDEC ) ;
}
}
// Init SSD1306
// Init SSD1306
void ssd1306_begin ( i2c_t * i2c_dev , uint16_t vccstate , uint16_t i2caddr )
void ssd1306_begin ( i2c_t * i2c_dev , uint16_t vccstate , uint16_t i2caddr )
{
{
// I2C Init
// I2C Init
_vccstate = vccstate ;
_vccstate = vccstate ;
ssd1306_i2c_set_display_off ( i2c_dev ) ;
// Init sequence
ssd1306_i2c_set_display_clkDiv_oscFreq ( i2c_dev , 0x00 , 0x00 ) ;
ssd1306_command ( i2c_dev , SSD1306_DISPLAYOFF ) ; // 0xAE
ssd1306_i2c_set_multiplex_ratio ( i2c_dev , HEIGHT - 1 ) ; // Pages start at 0 and ends at 63
ssd1306_command ( i2c_dev , SSD1306_SETDISPLAYCLOCKDIV ) ; // 0xD5
ssd1306_i2c_set_display_offset ( i2c_dev , 0x00 ) ; // No Offset
ssd1306_command ( i2c_dev , 0x80 ) ; // the suggested ratio 0x80
ssd1306_i2c_set_display_start_line ( i2c_dev , 0 ) ; // Start line 0
ssd1306_i2c_set_chage_pump ( i2c_dev , vccstate ) ;
ssd1306_command ( i2c_dev , SSD1306_SETMULTIPLEX ) ; // 0xA8
ssd1306_i2c_set_memory_addressing_mode ( i2c_dev , SSD1306_MEMORY_MODE_HORIZONTAL ) ;
ssd1306_command ( i2c_dev , SSD1306_LCDHEIGHT - 1 ) ;
ssd1306_i2c_set_segment_remap ( i2c_dev , 1 ) ;
ssd1306_i2c_set_com_scan_direction ( i2c_dev , 0 ) ; //Decremental TODO : Make a define for it
ssd1306_command ( i2c_dev , SSD1306_SETDISPLAYOFFSET ) ; // 0xD3
ssd1306_command ( i2c_dev , 0x0 ) ; // no offset
ssd1306_command ( i2c_dev , SSD1306_SETSTARTLINE | 0x0 ) ; // line #0
ssd1306_command ( i2c_dev , SSD1306_CHARGEPUMP ) ; // 0x8D
if ( vccstate = = SSD1306_EXTERNALVCC ) {
ssd1306_command ( i2c_dev , 0x10 ) ;
} else {
ssd1306_command ( i2c_dev , 0x14 ) ;
}
ssd1306_command ( i2c_dev , SSD1306_MEMORYMODE ) ; // 0x20
ssd1306_command ( i2c_dev , 0x00 ) ; // 0x0 act like ks0108
ssd1306_command ( i2c_dev , SSD1306_SEGREMAP | 0x1 ) ;
ssd1306_command ( i2c_dev , SSD1306_COMSCANDEC ) ;
# if defined SSD1306_128_32
# if defined SSD1306_128_32
ssd1306_command ( i2c_dev , SSD1306_SETCOMPINS ) ; // 0xDA
ssd1306_i2c_command ( i2c_dev , SSD1306_SETCOMPINS ) ; // 0xDA
ssd1306_command ( i2c_dev , 0x02 ) ;
ssd1306_i2c_command ( i2c_dev , 0x02 ) ;
ssd1306_command ( i2c_dev , SSD1306_SETCONTRAST ) ; // 0x81
ssd1306_i2c_command ( i2c_dev , SSD1306_SETCONTRAST ) ; // 0x81
ssd1306_command ( i2c_dev , 0x8F ) ;
ssd1306_i2c_command ( i2c_dev , 0x8F ) ;
# elif defined SSD1306_128_64
# elif defined SSD1306_128_64
ssd1306_command ( i2c_dev , SSD1306_SETCOMPINS ) ; // 0xDA
ssd1306_i2c_command ( i2c_dev , SSD1306_SETCOMPINS ) ; // 0xDA
ssd1306_command ( i2c_dev , 0x12 ) ;
ssd1306_i2c_command ( i2c_dev , 0x12 ) ;
ssd1306_command ( i2c_dev , SSD1306_SETCONTRAST ) ; // 0x81
ssd1306_i2c_command ( i2c_dev , SSD1306_SETCONTRAST ) ; // 0x81
if ( vccstate = = SSD1306_EXTERNALVCC ) {
if ( vccstate = = SSD1306_EXTERNALVCC ) {
ssd1306_command ( i2c_dev , 0x9F ) ;
ssd1306_i2c_command ( i2c_dev , 0x9F ) ;
} else {
} else {
ssd1306_command ( i2c_dev , 0xCF ) ;
ssd1306_ i2c_ command( i2c_dev , 0xCF ) ;
}
}
# elif defined SSD1306_96_16
# elif defined SSD1306_96_16
ssd1306_command ( i2c_dev , SSD1306_SETCOMPINS ) ; // 0xDA
ssd1306_ i2c_ command( i2c_dev , SSD1306_SETCOMPINS ) ; // 0xDA
ssd1306_command ( i2c_dev , 0x2 ) ; // ada x12
ssd1306_ i2c_ command( i2c_dev , 0x2 ) ; // ada x12
ssd1306_command ( i2c_dev , SSD1306_SETCONTRAST ) ; // 0x81
ssd1306_ i2c_ command( i2c_dev , SSD1306_SETCONTRAST ) ; // 0x81
if ( vccstate = = SSD1306_EXTERNALVCC ) {
if ( vccstate = = SSD1306_EXTERNALVCC ) {
ssd1306_command ( i2c_dev , 0x10 ) ;
ssd1306_ i2c_ command( i2c_dev , 0x10 ) ;
} else {
} else {
ssd1306_command ( i2c_dev , 0xAF ) ;
ssd1306_ i2c_ command( i2c_dev , 0xAF ) ;
}
}
# endif
# endif
ssd1306_command ( i2c_dev , SSD1306_SETPRECHARGE ) ; // 0xd9
ssd1306_ i2c_ command( i2c_dev , SSD1306_SETPRECHARGE ) ; // 0xd9
if ( vccstate = = SSD1306_EXTERNALVCC ) {
if ( vccstate = = SSD1306_EXTERNALVCC ) {
ssd1306_command ( i2c_dev , 0x22 ) ;
ssd1306_ i2c_ command( i2c_dev , 0x22 ) ;
} else {
} else {
ssd1306_command ( i2c_dev , 0xF1 ) ;
ssd1306_ i2c_ command( i2c_dev , 0xF1 ) ;
}
}
ssd1306_command ( i2c_dev , SSD1306_SETVCOMDETECT ) ; // 0xDB
ssd1306_ i2c_ command( i2c_dev , SSD1306_SETVCOMDETECT ) ; // 0xDB
ssd1306_command ( i2c_dev , 0x40 ) ;
ssd1306_ i2c_ command( i2c_dev , 0x40 ) ;
ssd1306_command ( i2c_dev , SSD1306_DISPLAYALLON_RESUME ) ; // 0xA4
ssd1306_ i2c_ command( i2c_dev , SSD1306_DISPLAYALLON_RESUME ) ; // 0xA4
ssd1306_command ( i2c_dev , SSD1306_NORMALDISPLAY ) ; // 0xA6
ssd1306_ i2c_ command( i2c_dev , SSD1306_NORMALDISPLAY ) ; // 0xA6
ssd1306_command ( i2c_dev , SSD1306_DEACTIVATE_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_DEACTIVATE_SCROLL ) ;
ssd1306_command ( i2c_dev , SSD1306_DISPLAYON ) ; // --turn on oled panel
ssd1306_ i2c_set_display_on( i2c_dev ) ;
}
}
void ssd1306_invertDisplay ( i2c_t * i2c_dev , uint16_t i )
void ssd1306_invertDisplay ( i2c_t * i2c_dev , uint16_t i )
{
{
if ( i ) {
if ( i ) {
ssd1306_command ( i2c_dev , SSD1306_INVERTDISPLAY ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_INVERTDISPLAY ) ;
} else {
} else {
ssd1306_command ( i2c_dev , SSD1306_NORMALDISPLAY ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_NORMALDISPLAY ) ;
}
}
}
}
void ssd1306_command ( i2c_t * i2c_dev , uint16_t c )
void ssd1306_ i2c_ command( i2c_t * i2c_dev , uint16_t c )
{
{
// I2C
// I2C
uint16_t control = 0x00 ; // Co = 0, D/C = 0
uint16_t control = 0x00 ; // Co = 0, D/C = 0
@ -309,21 +379,21 @@ void ssd1306_command(i2c_t *i2c_dev,uint16_t c)
void ssd1306_display ( i2c_t * i2c_dev )
void ssd1306_display ( i2c_t * i2c_dev )
{
{
ssd1306_ command( i2c_dev , SSD1306_COLUMNADDR ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_COLUMNADDR ) ;
ssd1306_ command( i2c_dev , 0 ) ; // Column start address (0 = reset)
ssd1306_ i2c_ command( i2c_dev , 0 ) ; // Column start address (0 = reset)
ssd1306_ command( i2c_dev , SSD1306_LCDWIDTH - 1 ) ; // Column end address (127
ssd1306_ i2c_ command( i2c_dev , SSD1306_LCDWIDTH - 1 ) ; // Column end address (127
// = reset)
// = reset)
ssd1306_ command( i2c_dev , SSD1306_PAGEADDR ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_PAGEADDR ) ;
ssd1306_ command( i2c_dev , 0 ) ; // Page start address (0 = reset)
ssd1306_ i2c_ command( i2c_dev , 0 ) ; // Page start address (0 = reset)
# if SSD1306_LCDHEIGHT == 64
# if SSD1306_LCDHEIGHT == 64
ssd1306_ command( i2c_dev , 7 ) ; // Page end address
ssd1306_ i2c_ command( i2c_dev , 7 ) ; // Page end address
# endif
# endif
# if SSD1306_LCDHEIGHT == 32
# if SSD1306_LCDHEIGHT == 32
ssd1306_ command( i2c_dev , 3 ) ; // Page end address
ssd1306_ i2c_ command( i2c_dev , 3 ) ; // Page end address
# endif
# endif
# if SSD1306_LCDHEIGHT == 16
# if SSD1306_LCDHEIGHT == 16
ssd1306_ command( i2c_dev , 1 ) ; // Page end address
ssd1306_ i2c_ command( i2c_dev , 1 ) ; // Page end address
# endif
# endif
uint8_t i2cDataLenght = 1 ; // Co = 0, D/C = 0
uint8_t i2cDataLenght = 1 ; // Co = 0, D/C = 0
@ -345,14 +415,14 @@ void ssd1306_display(i2c_t *i2c_dev)
// ssd1306_scrollright(0x00, 0x0F)
// ssd1306_scrollright(0x00, 0x0F)
void ssd1306_startscrollright ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
void ssd1306_startscrollright ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
{
{
ssd1306_ command( i2c_dev , SSD1306_RIGHT_HORIZONTAL_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_RIGHT_HORIZONTAL_SCROLL ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , start ) ;
ssd1306_ i2c_ command( i2c_dev , start ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , stop ) ;
ssd1306_ i2c_ command( i2c_dev , stop ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , 0 XFF ) ;
ssd1306_ i2c_ command( i2c_dev , 0 XFF ) ;
ssd1306_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
}
}
// startscrollleft
// startscrollleft
@ -361,14 +431,14 @@ void ssd1306_startscrollright(i2c_t *i2c_dev, uint16_t start, uint16_t stop)
// ssd1306_scrollright(0x00, 0x0F)
// ssd1306_scrollright(0x00, 0x0F)
void ssd1306_startscrollleft ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
void ssd1306_startscrollleft ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
{
{
ssd1306_ command( i2c_dev , SSD1306_LEFT_HORIZONTAL_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_LEFT_HORIZONTAL_SCROLL ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , start ) ;
ssd1306_ i2c_ command( i2c_dev , start ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , stop ) ;
ssd1306_ i2c_ command( i2c_dev , stop ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , 0 XFF ) ;
ssd1306_ i2c_ command( i2c_dev , 0 XFF ) ;
ssd1306_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
}
}
// startscrolldiagright
// startscrolldiagright
@ -377,16 +447,16 @@ void ssd1306_startscrollleft(i2c_t *i2c_dev,uint16_t start, uint16_t stop)
// ssd1306_scrollright(0x00, 0x0F)
// ssd1306_scrollright(0x00, 0x0F)
void ssd1306_startscrolldiagright ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
void ssd1306_startscrolldiagright ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
{
{
ssd1306_ command( i2c_dev , SSD1306_SET_VERTICAL_SCROLL_AREA ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_SET_VERTICAL_SCROLL_AREA ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , SSD1306_LCDHEIGHT ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_LCDHEIGHT ) ;
ssd1306_ command( i2c_dev , SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , start ) ;
ssd1306_ i2c_ command( i2c_dev , start ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , stop ) ;
ssd1306_ i2c_ command( i2c_dev , stop ) ;
ssd1306_ command( i2c_dev , 0 X01 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X01 ) ;
ssd1306_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
}
}
// startscrolldiagleft
// startscrolldiagleft
@ -395,21 +465,21 @@ void ssd1306_startscrolldiagright(i2c_t *i2c_dev, uint16_t start, uint16_t stop)
// ssd1306_scrollright(0x00, 0x0F)
// ssd1306_scrollright(0x00, 0x0F)
void ssd1306_startscrolldiagleft ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
void ssd1306_startscrolldiagleft ( i2c_t * i2c_dev , uint16_t start , uint16_t stop )
{
{
ssd1306_ command( i2c_dev , SSD1306_SET_VERTICAL_SCROLL_AREA ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_SET_VERTICAL_SCROLL_AREA ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , SSD1306_LCDHEIGHT ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_LCDHEIGHT ) ;
ssd1306_ command( i2c_dev , SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , start ) ;
ssd1306_ i2c_ command( i2c_dev , start ) ;
ssd1306_ command( i2c_dev , 0 X00 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X00 ) ;
ssd1306_ command( i2c_dev , stop ) ;
ssd1306_ i2c_ command( i2c_dev , stop ) ;
ssd1306_ command( i2c_dev , 0 X01 ) ;
ssd1306_ i2c_ command( i2c_dev , 0 X01 ) ;
ssd1306_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_ACTIVATE_SCROLL ) ;
}
}
void ssd1306_stopscroll ( i2c_t * i2c_dev )
void ssd1306_stopscroll ( i2c_t * i2c_dev )
{
{
ssd1306_ command( i2c_dev , SSD1306_DEACTIVATE_SCROLL ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_DEACTIVATE_SCROLL ) ;
}
}
// Dim the display
// Dim the display
@ -430,12 +500,12 @@ void ssd1306_dim(i2c_t *i2c_dev, uint16_t dim)
}
}
// the range of contrast to too small to be really useful
// the range of contrast to too small to be really useful
// it is useful to dim the display
// it is useful to dim the display
ssd1306_ command( i2c_dev , SSD1306_SETCONTRAST ) ;
ssd1306_ i2c_ command( i2c_dev , SSD1306_SETCONTRAST ) ;
ssd1306_ command( i2c_dev , contrast ) ;
ssd1306_ i2c_ command( i2c_dev , contrast ) ;
}
}
// clear everything
// clear everything
void ssd1306_clearDisplay ( void )
void ssd1306_clearDisplay ( )
{
{
memset ( buffer , 0 ,
memset ( buffer , 0 ,
( SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8 ) * sizeof ( int ) ) ;
( SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8 ) * sizeof ( int ) ) ;