mirror of
https://github.com/esphome/esphome.git
synced 2024-12-20 16:18:49 +01:00
7c7032c59e
* Implement custom sensor platform
* Update
* Ethernet
* Lint
* Fix
* Login page
* Rename cookie secret
* Update manifest
* Update cookie check logic
* Favicon
* Fix
* Favicon manifest
* Fix
* Fix
* Fix
* Use hostname
* Message
* Temporary commit for screenshot
* Automatic board selection
* Undo temporary commit
* Update esphomeyaml-edge
* In-dashboard editing and hosting files locally
* Update esphomeyaml-edge
* Better ANSI color escaping
* Message
* Lint
* Download Efficiency
* Fix gitlab
* Fix
* Rename extra_libraries to libraries
* Add example
* Update README.md
* Update README.md
* Update README.md
* HassIO -> Hass.io
* Updates
* Add update available notice
* Update
* Fix substitutions
* Better error message
* Re-do dashboard ANSI colors
* Only include FastLED if user says so
* Autoscroll logs
* Remove old checks
* Use safer RedirectText
* Improvements
* Fix
* Use enviornment variable
* Use http://hassio/host/info
* Fix conditions
* Update platformio versions
* Revert "Use enviornment variable"
This reverts commit 7f038eb5d2
.
* Fix
* README update
* Temp
* Better invalid config messages
* Platformio debug
* Improve error messages
* Debug
* Remove debug
* Multi Conf
* Update
* Better paths
* Remove unused
* Fixes
* Lint
* lib_ignore
* Try fix platformio colors
* Fix dashboard scrolling
* Revert
* Lint
* Revert
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
# coding=utf-8
|
|
import voluptuous as vol
|
|
|
|
import esphomeyaml.config_validation as cv
|
|
from esphomeyaml.const import CONF_LAMBDA, CONF_ROTATION, CONF_UPDATE_INTERVAL
|
|
from esphomeyaml.core import CORE
|
|
from esphomeyaml.cpp_generator import add
|
|
from esphomeyaml.cpp_types import esphomelib_ns
|
|
|
|
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
|
|
|
})
|
|
|
|
display_ns = esphomelib_ns.namespace('display')
|
|
DisplayBuffer = display_ns.class_('DisplayBuffer')
|
|
DisplayBufferRef = DisplayBuffer.operator('ref')
|
|
|
|
DISPLAY_ROTATIONS = {
|
|
0: display_ns.DISPLAY_ROTATION_0_DEGREES,
|
|
90: display_ns.DISPLAY_ROTATION_90_DEGREES,
|
|
180: display_ns.DISPLAY_ROTATION_180_DEGREES,
|
|
270: display_ns.DISPLAY_ROTATION_270_DEGREES,
|
|
}
|
|
|
|
|
|
def validate_rotation(value):
|
|
value = cv.string(value)
|
|
if value.endswith(u"°"):
|
|
value = value[:-1]
|
|
try:
|
|
value = int(value)
|
|
except ValueError:
|
|
raise vol.Invalid(u"Expected integer for rotation")
|
|
return cv.one_of(*DISPLAY_ROTATIONS)(value)
|
|
|
|
|
|
BASIC_DISPLAY_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
|
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
|
})
|
|
|
|
FULL_DISPLAY_PLATFORM_SCHEMA = BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
|
|
vol.Optional(CONF_ROTATION): validate_rotation,
|
|
})
|
|
|
|
|
|
def setup_display_core_(display_var, config):
|
|
if CONF_UPDATE_INTERVAL in config:
|
|
add(display_var.set_update_interval(config[CONF_UPDATE_INTERVAL]))
|
|
if CONF_ROTATION in config:
|
|
add(display_var.set_rotation(DISPLAY_ROTATIONS[config[CONF_ROTATION]]))
|
|
|
|
|
|
def setup_display(display_var, config):
|
|
CORE.add_job(setup_display_core_, display_var, config)
|
|
|
|
|
|
BUILD_FLAGS = '-DUSE_DISPLAY'
|