mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-20 21:13:28 +02:00
7ff3f752e2
* Initial Commit - ST7735 * Updated for CI checks * Updated for travis build * Travis fixes * Travis line too long * Travis fixes * Fixed up travis format issues * Travis Fixes * Initial Commit - ST7735 * Updated for CI checks * Updated for travis build * Travis fixes * Travis line too long * Travis fixes * Fixed up travis format issues * Travis Fixes * Update to new color API and added test * Check fixes * Fixed sid length in test * Cleaned up whitespaces * kbx81 recommended fixes * test fix * Fixes of fixes * Fixed test1.yaml * Fixed test1.yaml * Changed digital pin #s to gpio * Updated to match kbx's color names * Typo for ST7735_INITR_MINI_160X80 * Updated 8bit color space code Added to_rgb_332 to color.h fixed typo * Added in to_rgb_332,to_bgr_332, rgb_332to_rgb_556 and a more generic scale * Fixed MADCTL * Fixp MADCTL * Implemented usrbgr option updated color to support 332 bgr conversion typo fix * Updated to_bgr_332 * Fix up for clang * FIx up init code. type in buffer caused overrun * fixup protected names * typos * Matched use_bgr to its conf * color.h red fix in bgr_233to_rgb_565 * Fix ST7735_INITR_MINI_160X80 * Renamed bgr_233to_bgr_565 to match its function Color space leak in bgr_233to_bgr_565. cleaned up init code for displays. * Fix * clang fix * Started Color Conversion * Added various bit color functions add triadto * lint changes * Various fixes * Various formatting fixes. Wish my checks worked! * Updated color api to support different formats removed to_rgb_565 * lint clang fixes * Test1 fix * test1.yaml fix * fixed 565 in ILI9341Display * Added CodeOwners * Updated CODEOWNERS * changed to to332 and to565 * Waiting for color.h changes * Stage changes * Removed all changes except this driver * Moved color functions into driver * lint changes * Lint and removed unrelated display driver changes * Lint changes * Initial Commit - ST7735 * Updated for CI checks * Updated for travis build * Travis fixes * Travis line too long * Travis fixes * Fixed up travis format issues * Travis Fixes * Initial Commit - ST7735 * Updated for CI checks * Updated for travis build * Travis fixes * Travis line too long * Travis fixes * Fixed up travis format issues * Travis Fixes * Update to new color API and added test * Check fixes * Fixed sid length in test * Cleaned up whitespaces * kbx81 recommended fixes * test fix * Fixes of fixes * Fixed test1.yaml * Fixed test1.yaml * Changed digital pin #s to gpio * Updated to match kbx's color names * Typo for ST7735_INITR_MINI_160X80 * Updated 8bit color space code Added to_rgb_332 to color.h fixed typo * Added in to_rgb_332,to_bgr_332, rgb_332to_rgb_556 and a more generic scale * Fixed MADCTL * Fixp MADCTL * Implemented usrbgr option updated color to support 332 bgr conversion typo fix * Updated to_bgr_332 * Fix up for clang * FIx up init code. type in buffer caused overrun * fixup protected names * typos * Matched use_bgr to its conf * color.h red fix in bgr_233to_rgb_565 * Fix ST7735_INITR_MINI_160X80 * Renamed bgr_233to_bgr_565 to match its function Color space leak in bgr_233to_bgr_565. cleaned up init code for displays. * Fix * clang fix * Started Color Conversion * Added various bit color functions add triadto * lint changes * Various fixes * Various formatting fixes. Wish my checks worked! * Updated color api to support different formats removed to_rgb_565 * lint clang fixes * Test1 fix * test1.yaml fix * fixed 565 in ILI9341Display * Added CodeOwners * Updated CODEOWNERS * changed to to332 and to565 * Waiting for color.h changes * Stage changes * Removed all changes except this driver * Moved color functions into driver * lint changes * Lint and removed unrelated display driver changes * Lint changes * Updated with latest color api * pulled from origin * Updated for color.h changes * pulled test1 from dev * Added test
76 lines
2.9 KiB
Python
76 lines
2.9 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome import pins
|
|
from esphome.components import spi
|
|
from esphome.components import display
|
|
from esphome.core import coroutine
|
|
from esphome.const import CONF_DC_PIN, CONF_ID, CONF_LAMBDA, CONF_MODEL, CONF_RESET_PIN, CONF_PAGES
|
|
from . import st7735_ns
|
|
|
|
CODEOWNERS = ['@SenexCrenshaw']
|
|
|
|
DEPENDENCIES = ['spi']
|
|
|
|
CONF_DEVICEWIDTH = 'devicewidth'
|
|
CONF_DEVICEHEIGHT = 'deviceheight'
|
|
CONF_ROWSTART = 'rowstart'
|
|
CONF_COLSTART = 'colstart'
|
|
CONF_EIGHTBITCOLOR = 'eightbitcolor'
|
|
CONF_USEBGR = 'usebgr'
|
|
|
|
SPIST7735 = st7735_ns.class_('ST7735', cg.PollingComponent, display.DisplayBuffer, spi.SPIDevice)
|
|
ST7735Model = st7735_ns.enum('ST7735Model')
|
|
|
|
MODELS = {
|
|
'INITR_GREENTAB': ST7735Model.ST7735_INITR_GREENTAB,
|
|
'INITR_REDTAB': ST7735Model.ST7735_INITR_REDTAB,
|
|
'INITR_BLACKTAB': ST7735Model.ST7735_INITR_BLACKTAB,
|
|
'INITR_MINI160X80': ST7735Model.ST7735_INITR_MINI_160X80,
|
|
'INITR_18BLACKTAB': ST7735Model.ST7735_INITR_18BLACKTAB,
|
|
'INITR_18REDTAB': ST7735Model.ST7735_INITR_18REDTAB
|
|
}
|
|
ST7735_MODEL = cv.enum(MODELS, upper=True, space="_")
|
|
|
|
|
|
ST7735_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend({
|
|
cv.Required(CONF_MODEL): ST7735_MODEL,
|
|
cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema
|
|
}).extend(cv.polling_component_schema('1s'))
|
|
|
|
CONFIG_SCHEMA = cv.All(ST7735_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_id(SPIST7735),
|
|
cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema,
|
|
cv.Required(CONF_DEVICEWIDTH): cv.int_,
|
|
cv.Required(CONF_DEVICEHEIGHT): cv.int_,
|
|
cv.Required(CONF_COLSTART): cv.int_,
|
|
cv.Required(CONF_ROWSTART): cv.int_,
|
|
cv.Optional(CONF_EIGHTBITCOLOR, default=False): cv.boolean,
|
|
cv.Optional(CONF_USEBGR, default=False): cv.boolean,
|
|
}).extend(cv.COMPONENT_SCHEMA).extend(spi.spi_device_schema()),
|
|
cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA))
|
|
|
|
|
|
@coroutine
|
|
def setup_st7735(var, config):
|
|
yield cg.register_component(var, config)
|
|
yield display.register_display(var, config)
|
|
|
|
if CONF_RESET_PIN in config:
|
|
reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN])
|
|
cg.add(var.set_reset_pin(reset))
|
|
if CONF_LAMBDA in config:
|
|
lambda_ = yield cg.process_lambda(
|
|
config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')], return_type=cg.void)
|
|
cg.add(var.set_writer(lambda_))
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID], config[CONF_MODEL], config[CONF_DEVICEWIDTH],
|
|
config[CONF_DEVICEHEIGHT], config[CONF_COLSTART], config[CONF_ROWSTART],
|
|
config[CONF_EIGHTBITCOLOR], config[CONF_USEBGR])
|
|
yield setup_st7735(var, config)
|
|
yield spi.register_spi_device(var, config)
|
|
|
|
dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN])
|
|
cg.add(var.set_dc_pin(dc))
|