1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

Add SSD1305 support to SSD1306 integration along with few new options (#1902)

* Add serveral options for SSD1306 integration
* Add SSD1305 support
  (SSD1305 is similar to SSD1306, it seems SSD1305 has
  brightness and color register but does not have charge pump)
* Add some description when manipulating registers
* Add flip, offset and invert option to get more compatibility
  with various display modules
* Fix typo `setup_ssd1036' -> `setup_ssd1306'

* Add SSD1306 brightness validation tip

* Add more description, limit offset range

* Changes according to linter

* Fix test

* Raise error instead of using warning

* Fix wrong logic

* Remove logger

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>

* Remove logging import

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
ZJY
2021-09-22 19:47:41 +08:00
committed by GitHub
parent 8bebf138ee
commit 66761ff340
8 changed files with 159 additions and 27 deletions

View File

@@ -1,6 +1,7 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import ssd1306_base, i2c
from esphome.components.ssd1306_base import _validate
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_PAGES
AUTO_LOAD = ["ssd1306_base"]
@@ -18,10 +19,11 @@ CONFIG_SCHEMA = cv.All(
.extend(cv.COMPONENT_SCHEMA)
.extend(i2c.i2c_device_schema(0x3C)),
cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA),
_validate,
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await ssd1306_base.setup_ssd1036(var, config)
await ssd1306_base.setup_ssd1306(var, config)
await i2c.register_i2c_device(var, config)

View File

@@ -25,6 +25,11 @@ void I2CSSD1306::dump_config() {
ESP_LOGCONFIG(TAG, " Model: %s", this->model_str_());
LOG_PIN(" Reset Pin: ", this->reset_pin_);
ESP_LOGCONFIG(TAG, " External VCC: %s", YESNO(this->external_vcc_));
ESP_LOGCONFIG(TAG, " Flip X: %s", YESNO(this->flip_x_));
ESP_LOGCONFIG(TAG, " Flip Y: %s", YESNO(this->flip_y_));
ESP_LOGCONFIG(TAG, " Offset X: %d", this->offset_x_);
ESP_LOGCONFIG(TAG, " Offset Y: %d", this->offset_y_);
ESP_LOGCONFIG(TAG, " Inverted Color: %s", YESNO(this->invert_));
LOG_UPDATE_INTERVAL(this);
if (this->error_code_ == COMMUNICATION_FAILED) {