LCD_1306_128x32 now sets com pins correctly
clean up stb compiler warning
This commit is contained in:
parent
5f8b173155
commit
ee175ec1fd
5 changed files with 20 additions and 12 deletions
|
@ -27,7 +27,7 @@ extern "C"
|
||||||
|
|
||||||
unsigned char frame[SSD1306_128x64_BYTES];
|
unsigned char frame[SSD1306_128x64_BYTES];
|
||||||
|
|
||||||
SSD1306::SSD1306(int BSCMaster, u8 address, int flip, int type)
|
SSD1306::SSD1306(int BSCMaster, u8 address, int flip, LCD_MODEL type)
|
||||||
: BSCMaster(BSCMaster)
|
: BSCMaster(BSCMaster)
|
||||||
, address(address)
|
, address(address)
|
||||||
, type(type)
|
, type(type)
|
||||||
|
@ -61,7 +61,10 @@ void SSD1306::InitHardware()
|
||||||
}
|
}
|
||||||
|
|
||||||
SendCommand(SSD1306_CMD_SET_COM_PINS); // 0xDA Layout and direction
|
SendCommand(SSD1306_CMD_SET_COM_PINS); // 0xDA Layout and direction
|
||||||
SendCommand(0x12);
|
if (type == LCD_1306_128x32)
|
||||||
|
SendCommand(0x02);
|
||||||
|
else
|
||||||
|
SendCommand(0x12);
|
||||||
|
|
||||||
SetContrast(GetContrast());
|
SetContrast(GetContrast());
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ void SSD1306::InitHardware()
|
||||||
|
|
||||||
Home();
|
Home();
|
||||||
|
|
||||||
if (type != 1106)
|
if (type != LCD_1106_128x64)
|
||||||
SendCommand(SSD1306_CMD_DEACTIVATE_SCROLL); // 0x2E
|
SendCommand(SSD1306_CMD_DEACTIVATE_SCROLL); // 0x2E
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +123,7 @@ void SSD1306::MoveCursorByte(u8 row, u8 col)
|
||||||
if (col > 127) { col = 127; }
|
if (col > 127) { col = 127; }
|
||||||
if (row > 7) { row = 7; }
|
if (row > 7) { row = 7; }
|
||||||
|
|
||||||
if (type == 1106)
|
if (type == LCD_1106_128x64)
|
||||||
col += 2; // sh1106 uses columns 2..129
|
col += 2; // sh1106 uses columns 2..129
|
||||||
|
|
||||||
SendCommand(SSD1306_CMD_SET_PAGE | row); // 0xB0 page address
|
SendCommand(SSD1306_CMD_SET_PAGE | row); // 0xB0 page address
|
||||||
|
@ -183,7 +186,7 @@ void SSD1306::SetContrast(u8 value)
|
||||||
contrast = value;
|
contrast = value;
|
||||||
SendCommand(SSD1306_CMD_SET_CONTRAST_CONTROL);
|
SendCommand(SSD1306_CMD_SET_CONTRAST_CONTROL);
|
||||||
SendCommand(value);
|
SendCommand(value);
|
||||||
if (type == 1306)
|
if (type != LCD_1106_128x64) // dont fiddle vcomdeselect on 1106 displays
|
||||||
SetVCOMDeselect( value >> 8);
|
SetVCOMDeselect( value >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class SSD1306
|
||||||
public:
|
public:
|
||||||
// 128x32 0x3C
|
// 128x32 0x3C
|
||||||
// 128x64 0x3D or 0x3C (if SA0 is grounded)
|
// 128x64 0x3D or 0x3C (if SA0 is grounded)
|
||||||
SSD1306(int BSCMaster = 1, u8 address = 0x3C, int flip = 0, int type=1306);
|
SSD1306(int BSCMaster = 1, u8 address = 0x3C, int flip = 0, LCD_MODEL type=LCD_UNKNOWN);
|
||||||
|
|
||||||
void PlotCharacter(int x, int y, char ascii, bool inverse);
|
void PlotCharacter(int x, int y, char ascii, bool inverse);
|
||||||
void PlotText(int x, int y, char* str, bool inverse);
|
void PlotText(int x, int y, char* str, bool inverse);
|
||||||
|
|
|
@ -19,12 +19,7 @@
|
||||||
#ifndef OPTIONS_H
|
#ifndef OPTIONS_H
|
||||||
#define OPTIONS_H
|
#define OPTIONS_H
|
||||||
|
|
||||||
typedef enum {
|
#include "types.h"
|
||||||
LCD_UNKNOWN,
|
|
||||||
LCD_1306_128x64,
|
|
||||||
LCD_1306_128x32,
|
|
||||||
LCD_1106_128x64,
|
|
||||||
} LCD_MODEL;
|
|
||||||
|
|
||||||
class TextParser
|
class TextParser
|
||||||
{
|
{
|
||||||
|
|
|
@ -892,12 +892,14 @@ static int stbi__mad3sizes_valid(int a, int b, int c, int add)
|
||||||
stbi__addsizes_valid(a*b*c, add);
|
stbi__addsizes_valid(a*b*c, add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef STBI_NO_LINEAR
|
||||||
// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
|
// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
|
||||||
static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
|
static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
|
||||||
{
|
{
|
||||||
return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
|
return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
|
||||||
stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);
|
stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// mallocs with size overflow checking
|
// mallocs with size overflow checking
|
||||||
static void *stbi__malloc_mad2(int a, int b, int add)
|
static void *stbi__malloc_mad2(int a, int b, int add)
|
||||||
|
@ -912,11 +914,13 @@ static void *stbi__malloc_mad3(int a, int b, int c, int add)
|
||||||
return stbi__malloc(a*b*c + add);
|
return stbi__malloc(a*b*c + add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef STBI_NO_LINEAR
|
||||||
static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
|
static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
|
||||||
{
|
{
|
||||||
if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
|
if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
|
||||||
return stbi__malloc(a*b*c*d + add);
|
return stbi__malloc(a*b*c*d + add);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// stbi__err - error
|
// stbi__err - error
|
||||||
// stbi__errpf - error returning pointer to float
|
// stbi__errpf - error returning pointer to float
|
||||||
|
|
|
@ -9,5 +9,11 @@ typedef unsigned long long u64;
|
||||||
|
|
||||||
typedef signed long long s64;
|
typedef signed long long s64;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
LCD_UNKNOWN,
|
||||||
|
LCD_1306_128x64,
|
||||||
|
LCD_1306_128x32,
|
||||||
|
LCD_1106_128x64,
|
||||||
|
} LCD_MODEL;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue