Files
esphome-dev/esphome/components/sx1509/output/sx1509_float_output.cpp
T
Michiel van Turnhout 5f2808ec2f support for the sx1509 i2c device (#651)
* added ANALOG_OUTPUT as first functionality

* added gpio

* seperated the code for different functions

* fixed code

* Revert "fixed code"

This reverts commit 0c6eacb225522f7d738fa371d0db976a97f2f3e8.

* add timings for breathe and blink

* made the sx1509_float_output am output component

* add keypad

* implementation for sx1509 keypad

* keypad code cleanup and first device tests

* debounce

* keypad working now.

* update for timings.
does not compile yet

* added all options for breathe and blink
fixed var namings

* blink and breath still not ok

* fixed ms for timings

* sync with repo

* fixed issue with gpio pin output

* code cleanup

* lint

* more lint

* remove log from header

* Update esphome/components/sx1509/__init__.py

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* review

* feedback

* fixed review issues
did some extended testing with mqtt spy

* code cleanup (comments)

* fixed row col swap for binarysensor_keypad

* flake and lint

* travis

* travis

* travis

* Update esphome/components/sx1509/sx1509.cpp

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* review

* separated platforms

* code cleanup

* travis relative paths in python

* remove blink/breathe
code cleanup

* cpp lint

* feedback

* travis

* lint line to long

* check keypad settings to be valid

* clang

* keypad config

* text

* Remove wrong .gitignore from .gitignore

* Remove .pio folder from .gitignore (merge)

* Formatting

* Formatting

* Add i2c log in dump_config

* Remove unused variables

* Disable static for header files

We don't need internal linkage

* Use consistent member default argument style

* Run clang-format


Co-authored-by: null <m.vanturnhout@exxellence.nl>
Co-authored-by: Otto Winter <otto@otto-winter.com>
2019-10-14 11:27:50 +02:00

31 lines
822 B
C++

#include "sx1509_float_output.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace sx1509 {
static const char *TAG = "sx1509_float_channel";
void SX1509FloatOutputChannel::write_state(float state) {
const uint16_t max_duty = 255;
const float duty_rounded = roundf(state * max_duty);
auto duty = static_cast<uint16_t>(duty_rounded);
this->parent_->set_pin_value(this->pin_, duty);
}
void SX1509FloatOutputChannel::setup() {
ESP_LOGD(TAG, "setup pin %d", this->pin_);
this->parent_->pin_mode(this->pin_, SX1509_ANALOG_OUTPUT);
this->turn_off();
}
void SX1509FloatOutputChannel::dump_config() {
ESP_LOGCONFIG(TAG, "SX1509 PWM:");
ESP_LOGCONFIG(TAG, " sx1509 pin: %d", this->pin_);
LOG_FLOAT_OUTPUT(this);
}
} // namespace sx1509
} // namespace esphome