Quick fix initial

This commit is contained in:
lilian 2016-12-07 08:34:02 +01:00
parent ac429f9148
commit 683419bc4a

View file

@ -75,6 +75,10 @@
#define SH1106_CHARGE_PUMP_DIS (0x8A) #define SH1106_CHARGE_PUMP_DIS (0x8A)
#define SH1106_CHARGE_PUMP_VALUE (0x30) #define SH1106_CHARGE_PUMP_VALUE (0x30)
#define SH1106_SET_PAGE_ADDRESS (0xB0)
#define SH1106_SET_LOW_COL_ADDR (0x00)
#define SH1106_SET_HIGH_COL_ADDR (0x10)
#ifdef SSD1306_DEBUG #ifdef SSD1306_DEBUG
#define debug(fmt, ...) printf("%s: " fmt "\n", "SSD1306", ## __VA_ARGS__) #define debug(fmt, ...) printf("%s: " fmt "\n", "SSD1306", ## __VA_ARGS__)
#else #else
@ -148,7 +152,6 @@ int ssd1306_init(const ssd1306_t *dev)
uint8_t pin_cfg; uint8_t pin_cfg;
switch (dev->height) { switch (dev->height) {
case 16: case 16:
break;
case 32: case 32:
pin_cfg = 0x02; pin_cfg = 0x02;
break; break;
@ -234,11 +237,11 @@ static int sh1106_go_coordinate(const ssd1306_t *dev, uint8_t x, uint8_t y) {
if (x >= dev->width || y >= dev->height) return -EINVAL; if (x >= dev->width || y >= dev->height) return -EINVAL;
int err = 0; int err = 0;
x+=2 ; //offset : panel is 128 ; RAM is 132 for sh1106 x+=2 ; //offset : panel is 128 ; RAM is 132 for sh1106
if ((err = ssd1306_command(dev, 0xB0 + y))) // Set row if ((err = ssd1306_command(dev, SH1106_SET_PAGE_ADDRESS + y))) // Set row
return err; return err;
if ((err = ssd1306_command(dev, x & 0xf))) // Set lower column address if ((err = ssd1306_command(dev, SH1106_SET_LOW_COL_ADDR | (x & 0xf)))) // Set lower column address
return err; return err;
return ssd1306_command(dev, 0x10 | (x >> 4)); //Set higher column address return ssd1306_command(dev, SH1106_SET_HIGH_COL_ADDR | (x >> 4)); //Set higher column address
} }
int ssd1306_load_frame_buffer(const ssd1306_t *dev, uint8_t buf[]) int ssd1306_load_frame_buffer(const ssd1306_t *dev, uint8_t buf[])
@ -247,7 +250,8 @@ int ssd1306_load_frame_buffer(const ssd1306_t *dev, uint8_t buf[])
uint8_t j; uint8_t j;
size_t len = dev->width * dev->height / 8; size_t len = dev->width * dev->height / 8;
if(dev->screen == SSD1306_SCREEN) { if(dev->screen == SSD1306_SCREEN)
{
ssd1306_set_column_addr(dev, 0, dev->width - 1); ssd1306_set_column_addr(dev, 0, dev->width - 1);
ssd1306_set_page_addr(dev, 0, dev->height / 8 - 1); ssd1306_set_page_addr(dev, 0, dev->height / 8 - 1);
} }