LCD_1306_128x32 now sets com pins correctly

clean up stb compiler warning
This commit is contained in:
penfold42 2018-07-26 11:34:59 +10:00
parent 5f8b173155
commit ee175ec1fd
5 changed files with 20 additions and 12 deletions

View file

@ -27,7 +27,7 @@ extern "C"
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)
, address(address)
, type(type)
@ -61,7 +61,10 @@ void SSD1306::InitHardware()
}
SendCommand(SSD1306_CMD_SET_COM_PINS); // 0xDA Layout and direction
SendCommand(0x12);
if (type == LCD_1306_128x32)
SendCommand(0x02);
else
SendCommand(0x12);
SetContrast(GetContrast());
@ -86,7 +89,7 @@ void SSD1306::InitHardware()
Home();
if (type != 1106)
if (type != LCD_1106_128x64)
SendCommand(SSD1306_CMD_DEACTIVATE_SCROLL); // 0x2E
}
@ -120,7 +123,7 @@ void SSD1306::MoveCursorByte(u8 row, u8 col)
if (col > 127) { col = 127; }
if (row > 7) { row = 7; }
if (type == 1106)
if (type == LCD_1106_128x64)
col += 2; // sh1106 uses columns 2..129
SendCommand(SSD1306_CMD_SET_PAGE | row); // 0xB0 page address
@ -183,7 +186,7 @@ void SSD1306::SetContrast(u8 value)
contrast = value;
SendCommand(SSD1306_CMD_SET_CONTRAST_CONTROL);
SendCommand(value);
if (type == 1306)
if (type != LCD_1106_128x64) // dont fiddle vcomdeselect on 1106 displays
SetVCOMDeselect( value >> 8);
}

View file

@ -76,7 +76,7 @@ class SSD1306
public:
// 128x32 0x3C
// 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 PlotText(int x, int y, char* str, bool inverse);

View file

@ -19,12 +19,7 @@
#ifndef OPTIONS_H
#define OPTIONS_H
typedef enum {
LCD_UNKNOWN,
LCD_1306_128x64,
LCD_1306_128x32,
LCD_1106_128x64,
} LCD_MODEL;
#include "types.h"
class TextParser
{

View file

@ -892,12 +892,14 @@ static int stbi__mad3sizes_valid(int a, int b, int c, int 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
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) &&
stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);
}
#endif
// mallocs with size overflow checking
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);
}
#ifndef STBI_NO_LINEAR
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;
return stbi__malloc(a*b*c*d + add);
}
#endif
// stbi__err - error
// stbi__errpf - error returning pointer to float

View file

@ -9,5 +9,11 @@ typedef unsigned long long u64;
typedef signed long long s64;
typedef enum {
LCD_UNKNOWN,
LCD_1306_128x64,
LCD_1306_128x32,
LCD_1106_128x64,
} LCD_MODEL;
#endif