1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 07:03:55 +00:00

Cleanup dashboard JS (#491)

* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
This commit is contained in:
Otto Winter
2019-04-22 21:56:30 +02:00
committed by GitHub
parent 6682c43dfa
commit 8e75980ebd
359 changed files with 4395 additions and 4223 deletions

View File

@@ -1,6 +1,6 @@
from esphome import pins
import esphome.config_validation as cv
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.const import CONF_ENABLE_TIME, CONF_ID, CONF_KEEP_ON_TIME, CONF_PIN
power_supply_ns = cg.esphome_ns.namespace('power_supply')
@@ -8,7 +8,7 @@ PowerSupply = power_supply_ns.class_('PowerSupply', cg.Component)
MULTI_CONF = True
CONFIG_SCHEMA = cv.Schema({
cv.Required(CONF_ID): cv.declare_variable_id(PowerSupply),
cv.Required(CONF_ID): cv.declare_id(PowerSupply),
cv.Required(CONF_PIN): pins.gpio_output_pin_schema,
cv.Optional(CONF_ENABLE_TIME, default='20ms'): cv.positive_time_period_milliseconds,
cv.Optional(CONF_KEEP_ON_TIME, default='10s'): cv.positive_time_period_milliseconds,
@@ -16,9 +16,12 @@ CONFIG_SCHEMA = cv.Schema({
def to_code(config):
pin = yield cg.gpio_pin_expression(config[CONF_PIN])
var = cg.new_Pvariable(config[CONF_ID], pin, config[CONF_ENABLE_TIME],
config[CONF_KEEP_ON_TIME])
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
pin = yield cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin))
cg.add(var.set_enable_time(config[CONF_ENABLE_TIME]))
cg.add(var.set_keep_on_time(config[CONF_KEEP_ON_TIME]))
cg.add_define('USE_POWER_SUPPLY')

View File

@@ -22,9 +22,6 @@ void PowerSupply::dump_config() {
float PowerSupply::get_setup_priority() const { return setup_priority::IO; }
PowerSupply::PowerSupply(GPIOPin *pin, uint32_t enable_time, uint32_t keep_on_time)
: pin_(pin), enable_time_(enable_time), keep_on_time_(keep_on_time) {}
bool PowerSupply::is_enabled() const { return this->enabled_; }
void PowerSupply::request_high_power() {

View File

@@ -8,7 +8,9 @@ namespace power_supply {
class PowerSupply : public Component {
public:
explicit PowerSupply(GPIOPin *pin, uint32_t enable_time, uint32_t keep_on_time);
void set_pin(GPIOPin *pin) { pin_ = pin; }
void set_enable_time(uint32_t enable_time) { enable_time_ = enable_time; }
void set_keep_on_time(uint32_t keep_on_time) { keep_on_time_ = keep_on_time; }
/// Is this power supply currently on?
bool is_enabled() const;