mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-19 12:43:28 +02:00
bfb9cb6732
* push final files
* Update max7219digit.cpp
reenter small bug fix on uint8 declaration
* small debug
* set max offset to 100
* remove unwanted file
* Update font file to make travis happy
* travis update
* further progress in keeping Yarvis happy
* travis font
* travis will never be satisfied but one step ahead
* YARVIS TAKE 10000000
* never ending yarvis
* Almost there with Yarvis
* removed double declaration YARVIS
* added namespace to font file (TRAVIS)
* almost there last changes for YARVIS
* further travis updates
* removed files for travis
* fix display.py length of line travis remark
* further update on display.py
* file delete travis requirement
* final entry for travis?
* Some further debug on max offset
* Travis updates
* scroll_left_new
* 90degreesrotate
* added option to config rotate90
* four orientations for the chips
* new setup for scroll
* replaced small bug missing {}
* debug changed int8 to int16 on scroll function
* removed small merge failure
* travis updates round 1
* travis updates round 2
* travis details round 3
* added options to set scroll parameters in yaml conf
* removed ttf and png to satisfy travis
* travis update
* travis updates
* travis
* further updates after input from @glmnet
* remove deleted comments
* Added ENUM TYPE to config file
* change in test file
* removed test files
* updates for pull request
* Typing error removed
* travis update
* PR updates travis
* Update test3.yaml
* Update test3.yaml
* update device schema as per #988
* Delete partitions.csv
* repair on image display and invert routine
* further update and a bit of cleanup
* added writing 0 in draw pixel
* small deletion error
* travis updates
* Update max7219digit.cpp
adding intensity value to dynamically set value
* Update max7219digit.h
adding option for intensity
* remove some files from tests
64 lines
2.5 KiB
Python
64 lines
2.5 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import display, spi
|
|
from esphome.const import CONF_ID, CONF_INTENSITY, CONF_LAMBDA, CONF_NUM_CHIPS
|
|
|
|
DEPENDENCIES = ['spi']
|
|
|
|
CONF_ROTATE_CHIP = 'rotate_chip'
|
|
CONF_SCROLL_SPEED = 'scroll_speed'
|
|
CONF_SCROLL_DWELL = 'scroll_dwell'
|
|
CONF_SCROLL_DELAY = 'scroll_delay'
|
|
CONF_SCROLL_ENABLE = 'scroll_enable'
|
|
CONF_SCROLL_MODE = 'scroll_mode'
|
|
|
|
SCROLL_MODES = {
|
|
'CONTINUOUS': 0,
|
|
'STOP': 1,
|
|
}
|
|
|
|
CHIP_MODES = {
|
|
'0': 0,
|
|
'90': 1,
|
|
'180': 2,
|
|
'270': 3,
|
|
}
|
|
|
|
max7219_ns = cg.esphome_ns.namespace('max7219digit')
|
|
MAX7219Component = max7219_ns.class_('MAX7219Component', cg.PollingComponent, spi.SPIDevice,
|
|
display.DisplayBuffer)
|
|
MAX7219ComponentRef = MAX7219Component.operator('ref')
|
|
|
|
CONFIG_SCHEMA = display.BASIC_DISPLAY_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_id(MAX7219Component),
|
|
cv.Optional(CONF_NUM_CHIPS, default=4): cv.int_range(min=1, max=255),
|
|
cv.Optional(CONF_INTENSITY, default=15): cv.int_range(min=0, max=15),
|
|
cv.Optional(CONF_ROTATE_CHIP, default='0'): cv.enum(CHIP_MODES, upper=True),
|
|
cv.Optional(CONF_SCROLL_MODE, default='CONTINUOUS'): cv.enum(SCROLL_MODES, upper=True),
|
|
cv.Optional(CONF_SCROLL_ENABLE, default=True): cv.boolean,
|
|
cv.Optional(CONF_SCROLL_SPEED, default='250ms'): cv.positive_time_period_milliseconds,
|
|
cv.Optional(CONF_SCROLL_DELAY, default='1000ms'): cv.positive_time_period_milliseconds,
|
|
cv.Optional(CONF_SCROLL_DWELL, default='1000ms'): cv.positive_time_period_milliseconds,
|
|
}).extend(cv.polling_component_schema('500ms')).extend(spi.spi_device_schema(CS_PIN_required=True))
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
yield cg.register_component(var, config)
|
|
yield spi.register_spi_device(var, config)
|
|
yield display.register_display(var, config)
|
|
|
|
cg.add(var.set_num_chips(config[CONF_NUM_CHIPS]))
|
|
cg.add(var.set_intensity(config[CONF_INTENSITY]))
|
|
cg.add(var.set_chip_orientation(config[CONF_ROTATE_CHIP]))
|
|
cg.add(var.set_scroll_speed(config[CONF_SCROLL_SPEED]))
|
|
cg.add(var.set_scroll_dwell(config[CONF_SCROLL_DWELL]))
|
|
cg.add(var.set_scroll_delay(config[CONF_SCROLL_DELAY]))
|
|
cg.add(var.set_scroll(config[CONF_SCROLL_ENABLE]))
|
|
cg.add(var.set_scroll_mode(config[CONF_SCROLL_MODE]))
|
|
|
|
if CONF_LAMBDA in config:
|
|
lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(MAX7219ComponentRef, 'it')],
|
|
return_type=cg.void)
|
|
cg.add(var.set_writer(lambda_))
|