SSD1306_base: Add support for 64x32 size and fix flip functions (#2682)

* Add support for SSD1306 OLED display 0.42inch 64x32 and fix a typo in __init__.py preventing flip functions to operate as intended

* convert tab to spaces

* fix typo on filename for __init__.py
This commit is contained in:
ychieux 2021-11-09 20:47:19 +03:00 committed by GitHub
parent a509f6ccd2
commit f72389147d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -26,6 +26,7 @@ MODELS = {
"SSD1306_128X64": SSD1306Model.SSD1306_MODEL_128_64, "SSD1306_128X64": SSD1306Model.SSD1306_MODEL_128_64,
"SSD1306_96X16": SSD1306Model.SSD1306_MODEL_96_16, "SSD1306_96X16": SSD1306Model.SSD1306_MODEL_96_16,
"SSD1306_64X48": SSD1306Model.SSD1306_MODEL_64_48, "SSD1306_64X48": SSD1306Model.SSD1306_MODEL_64_48,
"SSD1306_64X32": SSD1306Model.SSD1306_MODEL_64_32,
"SH1106_128X32": SSD1306Model.SH1106_MODEL_128_32, "SH1106_128X32": SSD1306Model.SH1106_MODEL_128_32,
"SH1106_128X64": SSD1306Model.SH1106_MODEL_128_64, "SH1106_128X64": SSD1306Model.SH1106_MODEL_128_64,
"SH1106_96X16": SSD1306Model.SH1106_MODEL_96_16, "SH1106_96X16": SSD1306Model.SH1106_MODEL_96_16,
@ -84,7 +85,7 @@ async def setup_ssd1306(var, config):
if CONF_FLIP_X in config: if CONF_FLIP_X in config:
cg.add(var.init_flip_x(config[CONF_FLIP_X])) cg.add(var.init_flip_x(config[CONF_FLIP_X]))
if CONF_FLIP_Y in config: if CONF_FLIP_Y in config:
cg.add(var.init_flip_y(config[CONF_FLIP_X])) cg.add(var.init_flip_y(config[CONF_FLIP_Y]))
if CONF_OFFSET_X in config: if CONF_OFFSET_X in config:
cg.add(var.init_offset_x(config[CONF_OFFSET_X])) cg.add(var.init_offset_x(config[CONF_OFFSET_X]))
if CONF_OFFSET_Y in config: if CONF_OFFSET_Y in config:

View file

@ -94,6 +94,7 @@ void SSD1306::setup() {
case SSD1306_MODEL_128_64: case SSD1306_MODEL_128_64:
case SH1106_MODEL_128_64: case SH1106_MODEL_128_64:
case SSD1306_MODEL_64_48: case SSD1306_MODEL_64_48:
case SSD1306_MODEL_64_32:
case SH1106_MODEL_64_48: case SH1106_MODEL_64_48:
case SSD1305_MODEL_128_32: case SSD1305_MODEL_128_32:
case SSD1305_MODEL_128_64: case SSD1305_MODEL_128_64:
@ -141,6 +142,7 @@ void SSD1306::display() {
this->command(SSD1306_COMMAND_COLUMN_ADDRESS); this->command(SSD1306_COMMAND_COLUMN_ADDRESS);
switch (this->model_) { switch (this->model_) {
case SSD1306_MODEL_64_48: case SSD1306_MODEL_64_48:
case SSD1306_MODEL_64_32:
this->command(0x20 + this->offset_x_); this->command(0x20 + this->offset_x_);
this->command(0x20 + this->offset_x_ + this->get_width_internal() - 1); this->command(0x20 + this->offset_x_ + this->get_width_internal() - 1);
break; break;
@ -197,6 +199,7 @@ void SSD1306::turn_off() {
int SSD1306::get_height_internal() { int SSD1306::get_height_internal() {
switch (this->model_) { switch (this->model_) {
case SSD1306_MODEL_128_32: case SSD1306_MODEL_128_32:
case SSD1306_MODEL_64_32:
case SH1106_MODEL_128_32: case SH1106_MODEL_128_32:
case SSD1305_MODEL_128_32: case SSD1305_MODEL_128_32:
return 32; return 32;
@ -227,6 +230,7 @@ int SSD1306::get_width_internal() {
case SH1106_MODEL_96_16: case SH1106_MODEL_96_16:
return 96; return 96;
case SSD1306_MODEL_64_48: case SSD1306_MODEL_64_48:
case SSD1306_MODEL_64_32:
case SH1106_MODEL_64_48: case SH1106_MODEL_64_48:
return 64; return 64;
default: default:
@ -271,6 +275,8 @@ const char *SSD1306::model_str_() {
return "SSD1306 128x32"; return "SSD1306 128x32";
case SSD1306_MODEL_128_64: case SSD1306_MODEL_128_64:
return "SSD1306 128x64"; return "SSD1306 128x64";
case SSD1306_MODEL_64_32:
return "SSD1306 64x32";
case SSD1306_MODEL_96_16: case SSD1306_MODEL_96_16:
return "SSD1306 96x16"; return "SSD1306 96x16";
case SSD1306_MODEL_64_48: case SSD1306_MODEL_64_48:

View file

@ -12,6 +12,7 @@ enum SSD1306Model {
SSD1306_MODEL_128_64, SSD1306_MODEL_128_64,
SSD1306_MODEL_96_16, SSD1306_MODEL_96_16,
SSD1306_MODEL_64_48, SSD1306_MODEL_64_48,
SSD1306_MODEL_64_32,
SH1106_MODEL_128_32, SH1106_MODEL_128_32,
SH1106_MODEL_128_64, SH1106_MODEL_128_64,
SH1106_MODEL_96_16, SH1106_MODEL_96_16,