Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23f1798d20 | ||
|
|
6f3c126805 | ||
|
|
a9ae70cff1 | ||
|
|
d7a8c50c98 | ||
|
|
9e56318498 | ||
|
|
2570f2d6f2 |
0
esphome/components/binary_sensor_map/__init__.py
Normal file
0
esphome/components/binary_sensor_map/__init__.py
Normal file
60
esphome/components/binary_sensor_map/binary_sensor_map.cpp
Normal file
60
esphome/components/binary_sensor_map/binary_sensor_map.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "binary_sensor_map.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace binary_sensor_map {
|
||||
|
||||
static const char *TAG = "binary_sensor_map";
|
||||
|
||||
void BinarySensorMap::dump_config() { LOG_SENSOR(" ", "binary_sensor_map", this); }
|
||||
|
||||
void BinarySensorMap::loop() {
|
||||
switch (this->sensor_type_) {
|
||||
case BINARY_SENSOR_MAP_TYPE_GROUP:
|
||||
this->process_group_();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BinarySensorMap::process_group_() {
|
||||
float total_current_value = 0.0;
|
||||
uint8_t num_active_sensors = 0;
|
||||
uint64_t mask = 0x00;
|
||||
// check all binary_sensors for its state. when active add its value to total_current_value.
|
||||
// create a bitmask for the binary_sensor status on all channels
|
||||
for (size_t i = 0; i < this->channels_.size(); i++) {
|
||||
auto bs = this->channels_[i];
|
||||
if (bs.binary_sensor->state) {
|
||||
num_active_sensors++;
|
||||
total_current_value += bs.sensor_value;
|
||||
mask |= 1 << i;
|
||||
}
|
||||
}
|
||||
// check if the sensor map was touched
|
||||
if (mask != 0ULL) {
|
||||
// did the bit_mask change or is it a new sensor touch
|
||||
if (this->last_mask_ != mask) {
|
||||
float publish_value = total_current_value / num_active_sensors;
|
||||
ESP_LOGD(TAG, "'%s' - Publishing %.2f", this->name_.c_str(), publish_value);
|
||||
this->publish_state(publish_value);
|
||||
}
|
||||
} else if (this->last_mask_ != 0ULL) {
|
||||
// is this a new sensor release
|
||||
ESP_LOGD(TAG, "'%s' - No binary sensor active, publishing NAN", this->name_.c_str());
|
||||
this->publish_state(NAN);
|
||||
}
|
||||
this->last_mask_ = mask;
|
||||
}
|
||||
|
||||
void BinarySensorMap::add_channel(binary_sensor::BinarySensor *sensor, float value) {
|
||||
BinarySensorMapChannel sensor_channel{
|
||||
.binary_sensor = sensor,
|
||||
.sensor_value = value,
|
||||
};
|
||||
this->channels_.push_back(sensor_channel);
|
||||
}
|
||||
|
||||
void BinarySensorMap::set_sensor_type(BinarySensorMapType sensor_type) { this->sensor_type_ = sensor_type; }
|
||||
|
||||
} // namespace binary_sensor_map
|
||||
} // namespace esphome
|
||||
58
esphome/components/binary_sensor_map/binary_sensor_map.h
Normal file
58
esphome/components/binary_sensor_map/binary_sensor_map.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace binary_sensor_map {
|
||||
|
||||
enum BinarySensorMapType {
|
||||
BINARY_SENSOR_MAP_TYPE_GROUP,
|
||||
};
|
||||
|
||||
struct BinarySensorMapChannel {
|
||||
binary_sensor::BinarySensor *binary_sensor;
|
||||
float sensor_value;
|
||||
};
|
||||
|
||||
/** Class to group binary_sensors to one Sensor.
|
||||
*
|
||||
* Each binary sensor represents a float value in the group.
|
||||
*/
|
||||
class BinarySensorMap : public sensor::Sensor, public Component {
|
||||
public:
|
||||
void dump_config() override;
|
||||
/**
|
||||
* The loop checks all binary_sensor states
|
||||
* When the binary_sensor reports a true value for its state, then the float value it represents is added to the
|
||||
* total_current_value
|
||||
*
|
||||
* Only when the total_current_value changed and at least one sensor reports an active state we publish the sensors
|
||||
* average value. When the value changed and no sensors ar active we publish NAN.
|
||||
* */
|
||||
void loop() override;
|
||||
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||
/** Add binary_sensors to the group.
|
||||
* Each binary_sensor represents a float value when its state is true
|
||||
*
|
||||
* @param *sensor The binary sensor.
|
||||
* @param value The value this binary_sensor represents
|
||||
*/
|
||||
void add_channel(binary_sensor::BinarySensor *sensor, float value);
|
||||
void set_sensor_type(BinarySensorMapType sensor_type);
|
||||
|
||||
protected:
|
||||
std::vector<BinarySensorMapChannel> channels_{};
|
||||
BinarySensorMapType sensor_type_{BINARY_SENSOR_MAP_TYPE_GROUP};
|
||||
// this gives max 64 channels per binary_sensor_map
|
||||
uint64_t last_mask_{0x00};
|
||||
/**
|
||||
* methods to process the types of binary_sensor_maps
|
||||
* GROUP: process_group_() just map to a value
|
||||
* */
|
||||
void process_group_();
|
||||
};
|
||||
|
||||
} // namespace binary_sensor_map
|
||||
} // namespace esphome
|
||||
42
esphome/components/binary_sensor_map/sensor.py
Normal file
42
esphome/components/binary_sensor_map/sensor.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
|
||||
from esphome.components import sensor, binary_sensor
|
||||
from esphome.const import CONF_ID, CONF_CHANNELS, CONF_VALUE, CONF_TYPE, UNIT_EMPTY, \
|
||||
ICON_CHECK_CIRCLE_OUTLINE, CONF_BINARY_SENSOR
|
||||
|
||||
DEPENDENCIES = ['binary_sensor']
|
||||
|
||||
binary_sensor_map_ns = cg.esphome_ns.namespace('binary_sensor_map')
|
||||
BinarySensorMap = binary_sensor_map_ns.class_('BinarySensorMap', cg.Component, sensor.Sensor)
|
||||
SensorMapType = binary_sensor_map_ns.enum('SensorMapType')
|
||||
|
||||
CONF_GROUP = 'group'
|
||||
SENSOR_MAP_TYPES = {
|
||||
CONF_GROUP: SensorMapType.BINARY_SENSOR_MAP_TYPE_GROUP,
|
||||
}
|
||||
|
||||
entry = {
|
||||
cv.Required(CONF_BINARY_SENSOR): cv.use_id(binary_sensor.BinarySensor),
|
||||
cv.Required(CONF_VALUE): cv.float_,
|
||||
}
|
||||
|
||||
CONFIG_SCHEMA = cv.typed_schema({
|
||||
CONF_GROUP: sensor.sensor_schema(UNIT_EMPTY, ICON_CHECK_CIRCLE_OUTLINE, 0).extend({
|
||||
cv.GenerateID(): cv.declare_id(BinarySensorMap),
|
||||
cv.Required(CONF_CHANNELS): cv.All(cv.ensure_list(entry), cv.Length(min=1)),
|
||||
}),
|
||||
}, lower=True)
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield sensor.register_sensor(var, config)
|
||||
|
||||
constant = SENSOR_MAP_TYPES[config[CONF_TYPE]]
|
||||
cg.add(var.set_sensor_type(constant))
|
||||
|
||||
for ch in config[CONF_CHANNELS]:
|
||||
input_var = yield cg.get_variable(ch[CONF_BINARY_SENSOR])
|
||||
cg.add(var.add_channel(input_var, ch[CONF_VALUE]))
|
||||
@@ -19,6 +19,8 @@ class CWWWLightOutput : public light::LightOutput {
|
||||
traits.set_supports_rgb(false);
|
||||
traits.set_supports_rgb_white_value(false);
|
||||
traits.set_supports_color_temperature(true);
|
||||
traits.set_min_mireds(this->cold_white_temperature_);
|
||||
traits.set_min_mireds(this->warm_white_temperature_);
|
||||
return traits;
|
||||
}
|
||||
void write_state(light::LightState *state) override {
|
||||
|
||||
@@ -3,6 +3,11 @@ import esphome.config_validation as cv
|
||||
from esphome.components import i2c
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
CONF_TOUCH_THRESHOLD = "touch_threshold"
|
||||
CONF_RELEASE_THRESHOLD = "release_threshold"
|
||||
CONF_TOUCH_DEBOUNCE = "touch_debounce"
|
||||
CONF_RELEASE_DEBOUNCE = "release_debounce"
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
AUTO_LOAD = ['binary_sensor']
|
||||
|
||||
@@ -13,10 +18,18 @@ MPR121Component = mpr121_ns.class_('MPR121Component', cg.Component, i2c.I2CDevic
|
||||
MULTI_CONF = True
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(MPR121Component),
|
||||
cv.Optional(CONF_RELEASE_DEBOUNCE, default=0): cv.int_range(min=0, max=7),
|
||||
cv.Optional(CONF_TOUCH_DEBOUNCE, default=0): cv.int_range(min=0, max=7),
|
||||
cv.Optional(CONF_TOUCH_THRESHOLD, default=0x0b): cv.int_range(min=0x05, max=0x30),
|
||||
cv.Optional(CONF_RELEASE_THRESHOLD, default=0x06): cv.int_range(min=0x05, max=0x30),
|
||||
}).extend(cv.COMPONENT_SCHEMA).extend(i2c.i2c_device_schema(0x5A))
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
cg.add(var.set_touch_debounce(config[CONF_TOUCH_DEBOUNCE]))
|
||||
cg.add(var.set_release_debounce(config[CONF_RELEASE_DEBOUNCE]))
|
||||
cg.add(var.set_touch_threshold(config[CONF_TOUCH_THRESHOLD]))
|
||||
cg.add(var.set_release_threshold(config[CONF_RELEASE_THRESHOLD]))
|
||||
yield cg.register_component(var, config)
|
||||
yield i2c.register_i2c_device(var, config)
|
||||
|
||||
@@ -2,7 +2,8 @@ import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
from esphome.const import CONF_CHANNEL, CONF_ID
|
||||
from . import mpr121_ns, MPR121Component, CONF_MPR121_ID
|
||||
from . import mpr121_ns, MPR121Component, CONF_MPR121_ID, CONF_TOUCH_THRESHOLD, \
|
||||
CONF_RELEASE_THRESHOLD
|
||||
|
||||
DEPENDENCIES = ['mpr121']
|
||||
MPR121Channel = mpr121_ns.class_('MPR121Channel', binary_sensor.BinarySensor)
|
||||
@@ -11,14 +12,20 @@ CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(MPR121Channel),
|
||||
cv.GenerateID(CONF_MPR121_ID): cv.use_id(MPR121Component),
|
||||
cv.Required(CONF_CHANNEL): cv.int_range(min=0, max=11),
|
||||
cv.Optional(CONF_TOUCH_THRESHOLD): cv.int_range(min=0x05, max=0x30),
|
||||
cv.Optional(CONF_RELEASE_THRESHOLD): cv.int_range(min=0x05, max=0x30),
|
||||
})
|
||||
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield binary_sensor.register_binary_sensor(var, config)
|
||||
|
||||
hub = yield cg.get_variable(config[CONF_MPR121_ID])
|
||||
cg.add(var.set_channel(config[CONF_CHANNEL]))
|
||||
|
||||
hub = yield cg.get_variable(config[CONF_MPR121_ID])
|
||||
if CONF_TOUCH_THRESHOLD in config:
|
||||
cg.add(var.set_touch_threshold(config[CONF_TOUCH_THRESHOLD]))
|
||||
if CONF_RELEASE_THRESHOLD in config:
|
||||
cg.add(var.set_release_threshold(config[CONF_RELEASE_THRESHOLD]))
|
||||
|
||||
cg.add(hub.register_channel(var))
|
||||
|
||||
@@ -18,9 +18,11 @@ void MPR121Component::setup() {
|
||||
}
|
||||
|
||||
// set touch sensitivity for all 12 channels
|
||||
for (uint8_t i = 0; i < 12; i++) {
|
||||
this->write_byte(MPR121_TOUCHTH_0 + 2 * i, 12);
|
||||
this->write_byte(MPR121_RELEASETH_0 + 2 * i, 6);
|
||||
for (auto *channel : this->channels_) {
|
||||
this->write_byte(MPR121_TOUCHTH_0 + 2 * channel->channel_,
|
||||
channel->touch_threshold_.value_or(this->touch_threshold_));
|
||||
this->write_byte(MPR121_RELEASETH_0 + 2 * channel->channel_,
|
||||
channel->release_threshold_.value_or(this->release_threshold_));
|
||||
}
|
||||
this->write_byte(MPR121_MHDR, 0x01);
|
||||
this->write_byte(MPR121_NHDR, 0x01);
|
||||
@@ -44,6 +46,19 @@ void MPR121Component::setup() {
|
||||
// start with first 5 bits of baseline tracking
|
||||
this->write_byte(MPR121_ECR, 0x8F);
|
||||
}
|
||||
|
||||
void MPR121Component::set_touch_debounce(uint8_t debounce) {
|
||||
uint8_t mask = debounce << 4;
|
||||
this->debounce_ &= 0x0f;
|
||||
this->debounce_ |= mask;
|
||||
}
|
||||
|
||||
void MPR121Component::set_release_debounce(uint8_t debounce) {
|
||||
uint8_t mask = debounce & 0x0f;
|
||||
this->debounce_ &= 0xf0;
|
||||
this->debounce_ |= mask;
|
||||
};
|
||||
|
||||
void MPR121Component::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MPR121:");
|
||||
LOG_I2C_DEVICE(this);
|
||||
|
||||
@@ -46,17 +46,29 @@ enum {
|
||||
};
|
||||
|
||||
class MPR121Channel : public binary_sensor::BinarySensor {
|
||||
friend class MPR121Component;
|
||||
|
||||
public:
|
||||
void set_channel(uint8_t channel) { channel_ = channel; }
|
||||
void process(uint16_t data) { this->publish_state(static_cast<bool>(data & (1 << this->channel_))); }
|
||||
void set_touch_threshold(uint8_t touch_threshold) { this->touch_threshold_ = touch_threshold; };
|
||||
void set_release_threshold(uint8_t release_threshold) { this->release_threshold_ = release_threshold; };
|
||||
|
||||
protected:
|
||||
uint8_t channel_{0};
|
||||
optional<uint8_t> touch_threshold_{};
|
||||
optional<uint8_t> release_threshold_{};
|
||||
};
|
||||
|
||||
class MPR121Component : public Component, public i2c::I2CDevice {
|
||||
public:
|
||||
void register_channel(MPR121Channel *channel) { this->channels_.push_back(channel); }
|
||||
void set_touch_debounce(uint8_t debounce);
|
||||
void set_release_debounce(uint8_t debounce);
|
||||
void set_touch_threshold(uint8_t touch_threshold) { this->touch_threshold_ = touch_threshold; };
|
||||
void set_release_threshold(uint8_t release_threshold) { this->release_threshold_ = release_threshold; };
|
||||
uint8_t get_touch_threshold() { return this->touch_threshold_; };
|
||||
uint8_t get_release_threshold() { return this->release_threshold_; };
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||
@@ -64,6 +76,9 @@ class MPR121Component : public Component, public i2c::I2CDevice {
|
||||
|
||||
protected:
|
||||
std::vector<MPR121Channel *> channels_{};
|
||||
uint8_t debounce_{0};
|
||||
uint8_t touch_threshold_{};
|
||||
uint8_t release_threshold_{};
|
||||
enum ErrorCode {
|
||||
NONE = 0,
|
||||
COMMUNICATION_FAILED,
|
||||
|
||||
@@ -22,6 +22,8 @@ class RGBWWLightOutput : public light::LightOutput {
|
||||
traits.set_supports_rgb(true);
|
||||
traits.set_supports_rgb_white_value(true);
|
||||
traits.set_supports_color_temperature(true);
|
||||
traits.set_min_mireds(this->cold_white_temperature_);
|
||||
traits.set_min_mireds(this->warm_white_temperature_);
|
||||
return traits;
|
||||
}
|
||||
void write_state(light::LightState *state) override {
|
||||
|
||||
@@ -8,29 +8,6 @@ namespace waveshare_epaper {
|
||||
|
||||
static const char *TAG = "waveshare_epaper";
|
||||
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_DRIVER_OUTPUT_CONTROL = 0x01;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_BOOSTER_SOFT_START_CONTROL = 0x0C;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_GATE_SCAN_START_POSITION = 0x0F;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_DEEP_SLEEP_MODE = 0x10;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_DATA_ENTRY_MODE_SETTING = 0x11;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_SW_RESET = 0x12;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_TEMPERATURE_SENSOR_CONTROL = 0x1A;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_MASTER_ACTIVATION = 0x20;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_DISPLAY_UPDATE_CONTROL_1 = 0x21;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_DISPLAY_UPDATE_CONTROL_2 = 0x22;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_WRITE_RAM = 0x24;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_WRITE_VCOM_REGISTER = 0x2C;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_WRITE_LUT_REGISTER = 0x32;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_DUMMY_LINE_PERIOD = 0x3A;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_GATE_TIME = 0x3B;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_BORDER_WAVEFORM_CONTROL = 0x3C;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_START_END_POSITION = 0x44;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_START_END_POSITION = 0x45;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_COUNTER = 0x4E;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_COUNTER = 0x4F;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_TERMINATE_FRAME_READ_WRITE = 0xFF;
|
||||
|
||||
// not in .text section since only 30 bytes
|
||||
static const uint8_t FULL_UPDATE_LUT[30] = {0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69,
|
||||
0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00};
|
||||
@@ -52,13 +29,7 @@ void WaveshareEPaper::setup_pins_() {
|
||||
}
|
||||
this->spi_setup();
|
||||
|
||||
// Reset
|
||||
if (this->reset_pin_ != nullptr) {
|
||||
this->reset_pin_->digital_write(false);
|
||||
delay(200);
|
||||
this->reset_pin_->digital_write(true);
|
||||
delay(200);
|
||||
}
|
||||
this->reset_();
|
||||
}
|
||||
float WaveshareEPaper::get_setup_priority() const { return setup_priority::PROCESSOR; }
|
||||
void WaveshareEPaper::command(uint8_t value) {
|
||||
@@ -121,34 +92,39 @@ void WaveshareEPaper::start_data_() {
|
||||
this->enable();
|
||||
}
|
||||
void WaveshareEPaper::end_data_() { this->disable(); }
|
||||
void WaveshareEPaper::on_safe_shutdown() { this->deep_sleep(); }
|
||||
|
||||
// ========================================================
|
||||
// Type A
|
||||
// ========================================================
|
||||
|
||||
void WaveshareEPaperTypeA::setup() {
|
||||
this->setup_pins_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_DRIVER_OUTPUT_CONTROL);
|
||||
void WaveshareEPaperTypeA::initialize() {
|
||||
// COMMAND DRIVER OUTPUT CONTROL
|
||||
this->command(0x01);
|
||||
this->data(this->get_height_internal() - 1);
|
||||
this->data((this->get_height_internal() - 1) >> 8);
|
||||
this->data(0x00); // ? GD = 0, SM = 0, TB = 0
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_BOOSTER_SOFT_START_CONTROL); // ?
|
||||
// COMMAND BOOSTER SOFT START CONTROL
|
||||
this->command(0x0C);
|
||||
this->data(0xD7);
|
||||
this->data(0xD6);
|
||||
this->data(0x9D);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_WRITE_VCOM_REGISTER); // ?
|
||||
// COMMAND WRITE VCOM REGISTER
|
||||
this->command(0x2C);
|
||||
this->data(0xA8);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_DUMMY_LINE_PERIOD); // ?
|
||||
// COMMAND SET DUMMY LINE PERIOD
|
||||
this->command(0x3A);
|
||||
this->data(0x1A);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_GATE_TIME); // 2µs per row
|
||||
this->data(0x08);
|
||||
// COMMAND SET GATE TIME
|
||||
this->command(0x3B);
|
||||
this->data(0x08); // 2µs per row
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_DATA_ENTRY_MODE_SETTING);
|
||||
// COMMAND DATA ENTRY MODE SETTING
|
||||
this->command(0x11);
|
||||
this->data(0x03); // from top left to bottom right
|
||||
}
|
||||
void WaveshareEPaperTypeA::dump_config() {
|
||||
@@ -186,18 +162,22 @@ void HOT WaveshareEPaperTypeA::display() {
|
||||
}
|
||||
|
||||
// Set x & y regions we want to write to (full)
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_START_END_POSITION);
|
||||
// COMMAND SET RAM X ADDRESS START END POSITION
|
||||
this->command(0x44);
|
||||
this->data(0x00);
|
||||
this->data((this->get_width_internal() - 1) >> 3);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_START_END_POSITION);
|
||||
// COMMAND SET RAM Y ADDRESS START END POSITION
|
||||
this->command(0x45);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(this->get_height_internal() - 1);
|
||||
this->data((this->get_height_internal() - 1) >> 8);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_COUNTER);
|
||||
// COMMAND SET RAM X ADDRESS COUNTER
|
||||
this->command(0x4E);
|
||||
this->data(0x00);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_COUNTER);
|
||||
// COMMAND SET RAM Y ADDRESS COUNTER
|
||||
this->command(0x4F);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
|
||||
@@ -206,15 +186,19 @@ void HOT WaveshareEPaperTypeA::display() {
|
||||
return;
|
||||
}
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_WRITE_RAM);
|
||||
// COMMAND WRITE RAM
|
||||
this->command(0x24);
|
||||
this->start_data_();
|
||||
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||
this->end_data_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_DISPLAY_UPDATE_CONTROL_2);
|
||||
// COMMAND DISPLAY UPDATE CONTROL 2
|
||||
this->command(0x22);
|
||||
this->data(0xC4);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_MASTER_ACTIVATION);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_TERMINATE_FRAME_READ_WRITE);
|
||||
// COMMAND MASTER ACTIVATION
|
||||
this->command(0x20);
|
||||
// COMMAND TERMINATE FRAME READ WRITE
|
||||
this->command(0xFF);
|
||||
|
||||
this->status_clear_warning();
|
||||
}
|
||||
@@ -241,7 +225,8 @@ int WaveshareEPaperTypeA::get_height_internal() {
|
||||
return 0;
|
||||
}
|
||||
void WaveshareEPaperTypeA::write_lut_(const uint8_t *lut) {
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_WRITE_LUT_REGISTER);
|
||||
// COMMAND WRITE LUT REGISTER
|
||||
this->command(0x32);
|
||||
for (uint8_t i = 0; i < 30; i++)
|
||||
this->data(lut[i]);
|
||||
}
|
||||
@@ -253,47 +238,9 @@ void WaveshareEPaperTypeA::set_full_update_every(uint32_t full_update_every) {
|
||||
// ========================================================
|
||||
// Type B
|
||||
// ========================================================
|
||||
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING = 0x00;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING = 0x01;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_OFF = 0x02;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_OFF_SEQUENCE_SETTING = 0x03;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_ON = 0x04;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_MEASURE = 0x05;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START = 0x06;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DEEP_SLEEP = 0x07;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1 = 0x10;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DATA_STOP = 0x11;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH = 0x12;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_2 = 0x13;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DATA_START_TRANSMISSION_1 = 0x14;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DATA_START_TRANSMISSION_2 = 0x15;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DISPLAY_REFRESH = 0x16;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_FOR_VCOM = 0x20;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_WHITE = 0x21;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_WHITE = 0x22;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_BLACK = 0x23;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_BLACK = 0x24;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL = 0x30;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_COMMAND = 0x40;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_CALIBRATION = 0x41;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_WRITE = 0x42;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_READ = 0x43;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_VCOM_AND_DATA_INTERVAL_SETTING = 0x50;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LOW_POWER_DETECTION = 0x51;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TCON_SETTING = 0x60;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_RESOLUTION_SETTING = 0x61;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_GET_STATUS = 0x71;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_AUTO_MEASURE_VCOM = 0x80;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_VCOM_VALUE = 0x81;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER = 0x82;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_WINDOW = 0x90;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_IN = 0x91;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_OUT = 0x92;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PROGRAM_MODE = 0xA0;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_ACTIVE_PROGRAM = 0xA1;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_READ_OTP_DATA = 0xA2;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_SAVING = 0xE3;
|
||||
// Datasheet:
|
||||
// - https://www.waveshare.com/w/upload/7/7f/4.2inch-e-paper-b-specification.pdf
|
||||
// - https://github.com/soonuse/epd-library-arduino/blob/master/4.2inch_e-paper/epd4in2/
|
||||
|
||||
static const uint8_t LUT_VCOM_DC_2_7[44] = {
|
||||
0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x32, 0x32, 0x00, 0x00, 0x02, 0x00,
|
||||
@@ -325,18 +272,17 @@ static const uint8_t LUT_BLACK_TO_BLACK_2_7[42] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
void WaveshareEPaper2P7In::setup() {
|
||||
this->setup_pins_();
|
||||
// this->buffer_.init(this->get_width_(), this->get_height_());
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING);
|
||||
void WaveshareEPaper2P7In::initialize() {
|
||||
// command power setting
|
||||
this->command(0x01);
|
||||
this->data(0x03); // VDS_EN, VDG_EN
|
||||
this->data(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
|
||||
this->data(0x2B); // VDH
|
||||
this->data(0x2B); // VDL
|
||||
this->data(0x09); // VDHR
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START);
|
||||
// command booster soft start
|
||||
this->command(0x06);
|
||||
this->data(0x07);
|
||||
this->data(0x07);
|
||||
this->data(0x17);
|
||||
@@ -364,51 +310,66 @@ void WaveshareEPaper2P7In::setup() {
|
||||
this->data(0x73);
|
||||
this->data(0x41);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DISPLAY_REFRESH);
|
||||
// command partial display refresh
|
||||
this->command(0x16);
|
||||
this->data(0x00);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_ON);
|
||||
// command power on
|
||||
this->command(0x04);
|
||||
this->wait_until_idle_();
|
||||
delay(10);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING);
|
||||
// Command panel setting
|
||||
this->command(0x00);
|
||||
this->data(0xAF); // KW-BF KWR-AF BWROTP 0f
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL);
|
||||
// command pll control
|
||||
this->command(0x30);
|
||||
this->data(0x3A); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER);
|
||||
// COMMAND VCM DC SETTING
|
||||
this->command(0x82);
|
||||
this->data(0x12);
|
||||
|
||||
delay(2);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_FOR_VCOM);
|
||||
// COMMAND LUT FOR VCOM
|
||||
this->command(0x20);
|
||||
for (uint8_t i : LUT_VCOM_DC_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_WHITE);
|
||||
|
||||
// COMMAND LUT WHITE TO WHITE
|
||||
this->command(0x21);
|
||||
for (uint8_t i : LUT_WHITE_TO_WHITE_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_WHITE);
|
||||
// COMMAND LUT BLACK TO WHITE
|
||||
this->command(0x22);
|
||||
for (uint8_t i : LUT_BLACK_TO_WHITE_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_BLACK);
|
||||
// COMMAND LUT WHITE TO BLACK
|
||||
this->command(0x23);
|
||||
for (uint8_t i : LUT_WHITE_TO_BLACK_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_BLACK);
|
||||
// COMMAND LUT BLACK TO BLACK
|
||||
this->command(0x24);
|
||||
for (uint8_t i : LUT_BLACK_TO_BLACK_2_7)
|
||||
this->data(i);
|
||||
}
|
||||
void HOT WaveshareEPaper2P7In::display() {
|
||||
// TODO check active frame buffer to only transmit once / use partial transmits
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1);
|
||||
// COMMAND DATA START TRANSMISSION 1
|
||||
this->command(0x10);
|
||||
delay(2);
|
||||
this->start_data_();
|
||||
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||
this->end_data_();
|
||||
delay(2);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_2);
|
||||
|
||||
// COMMAND DATA START TRANSMISSION 2
|
||||
this->command(0x13);
|
||||
delay(2);
|
||||
this->start_data_();
|
||||
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||
this->end_data_();
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH);
|
||||
|
||||
// COMMAND DISPLAY REFRESH
|
||||
this->command(0x12);
|
||||
}
|
||||
int WaveshareEPaper2P7In::get_width_internal() { return 176; }
|
||||
int WaveshareEPaper2P7In::get_height_internal() { return 264; }
|
||||
@@ -449,73 +410,88 @@ static const uint8_t LUT_WHITE_TO_BLACK_4_2[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
void WaveshareEPaper4P2In::setup() {
|
||||
this->setup_pins_();
|
||||
void WaveshareEPaper4P2In::initialize() {
|
||||
// https://www.waveshare.com/w/upload/7/7f/4.2inch-e-paper-b-specification.pdf - page 8
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING);
|
||||
// COMMAND POWER SETTING
|
||||
this->command(0x01);
|
||||
this->data(0x03); // VDS_EN, VDG_EN
|
||||
this->data(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
|
||||
this->data(0x2B); // VDH
|
||||
this->data(0x2B); // VDL
|
||||
this->data(0xFF); // VDHR
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START);
|
||||
this->data(0x17);
|
||||
this->data(0x17);
|
||||
this->data(0x17);
|
||||
// COMMAND BOOSTER SOFT START
|
||||
this->command(0x06);
|
||||
this->data(0x17); // PHA
|
||||
this->data(0x17); // PHB
|
||||
this->data(0x17); // PHC
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_ON);
|
||||
// COMMAND POWER ON
|
||||
this->command(0x04);
|
||||
this->wait_until_idle_();
|
||||
delay(10);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING);
|
||||
// COMMAND PANEL SETTING
|
||||
this->command(0x00);
|
||||
this->data(0xBF); // KW-BF KWR-AF BWROTP 0f
|
||||
this->data(0x0B);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL);
|
||||
// COMMAND PLL CONTROL
|
||||
this->command(0x30);
|
||||
this->data(0x3C); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
|
||||
|
||||
delay(2);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_FOR_VCOM);
|
||||
// COMMAND LUT FOR VCOM
|
||||
this->command(0x20);
|
||||
for (uint8_t i : LUT_VCOM_DC_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_WHITE);
|
||||
// COMMAND LUT WHITE TO WHITE
|
||||
this->command(0x21);
|
||||
for (uint8_t i : LUT_WHITE_TO_WHITE_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_WHITE);
|
||||
// COMMAND LUT BLACK TO WHITE
|
||||
this->command(0x22);
|
||||
for (uint8_t i : LUT_BLACK_TO_WHITE_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_BLACK);
|
||||
// COMMAND LUT WHITE TO BLACK
|
||||
this->command(0x23);
|
||||
for (uint8_t i : LUT_WHITE_TO_BLACK_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_BLACK);
|
||||
// COMMAND LUT BLACK TO BLACK
|
||||
this->command(0x24);
|
||||
for (uint8_t i : LUT_BLACK_TO_BLACK_4_2)
|
||||
this->data(i);
|
||||
}
|
||||
void HOT WaveshareEPaper4P2In::display() {
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_RESOLUTION_SETTING);
|
||||
// COMMAND RESOLUTION SETTING
|
||||
this->command(0x61);
|
||||
this->data(0x01);
|
||||
this->data(0x90);
|
||||
this->data(0x01);
|
||||
this->data(0x2C);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER);
|
||||
// COMMAND VCM DC SETTING REGISTER
|
||||
this->command(0x82);
|
||||
this->data(0x12);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCOM_AND_DATA_INTERVAL_SETTING);
|
||||
// COMMAND VCOM AND DATA INTERVAL SETTING
|
||||
this->command(0x50);
|
||||
this->data(0x97);
|
||||
|
||||
// TODO check active frame buffer to only transmit once / use partial transmits
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1);
|
||||
// COMMAND DATA START TRANSMISSION 1
|
||||
this->command(0x10);
|
||||
delay(2);
|
||||
this->start_data_();
|
||||
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||
this->end_data_();
|
||||
delay(2);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_2);
|
||||
// COMMAND DATA START TRANSMISSION 2
|
||||
this->command(0x13);
|
||||
delay(2);
|
||||
this->start_data_();
|
||||
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||
this->end_data_();
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH);
|
||||
// COMMAND DISPLAY REFRESH
|
||||
this->command(0x12);
|
||||
}
|
||||
int WaveshareEPaper4P2In::get_width_internal() { return 400; }
|
||||
int WaveshareEPaper4P2In::get_height_internal() { return 300; }
|
||||
@@ -529,52 +505,61 @@ void WaveshareEPaper4P2In::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
void WaveshareEPaper7P5In::setup() {
|
||||
this->setup_pins_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING);
|
||||
void WaveshareEPaper7P5In::initialize() {
|
||||
// COMMAND POWER SETTING
|
||||
this->command(0x01);
|
||||
this->data(0x37);
|
||||
this->data(0x00);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING);
|
||||
// COMMAND PANEL SETTING
|
||||
this->command(0x00);
|
||||
this->data(0xCF);
|
||||
this->data(0x0B);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START);
|
||||
// COMMAND BOOSTER SOFT START
|
||||
this->command(0x06);
|
||||
this->data(0xC7);
|
||||
this->data(0xCC);
|
||||
this->data(0x28);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_ON);
|
||||
// COMMAND POWER ON
|
||||
this->command(0x04);
|
||||
this->wait_until_idle_();
|
||||
delay(10);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL);
|
||||
// COMMAND PLL CONTROL
|
||||
this->command(0x30);
|
||||
this->data(0x3C);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_CALIBRATION);
|
||||
// COMMAND TEMPERATURE SENSOR CALIBRATION
|
||||
this->command(0x41);
|
||||
this->data(0x00);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCOM_AND_DATA_INTERVAL_SETTING);
|
||||
// COMMAND VCOM AND DATA INTERVAL SETTING
|
||||
this->command(0x50);
|
||||
this->data(0x77);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_TCON_SETTING);
|
||||
// COMMAND TCON SETTING
|
||||
this->command(0x60);
|
||||
this->data(0x22);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_RESOLUTION_SETTING);
|
||||
// COMMAND RESOLUTION SETTING
|
||||
this->command(0x61);
|
||||
this->data(0x02);
|
||||
this->data(0x80);
|
||||
this->data(0x01);
|
||||
this->data(0x80);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER);
|
||||
// COMMAND VCM DC SETTING REGISTER
|
||||
this->command(0x82);
|
||||
this->data(0x1E);
|
||||
|
||||
this->command(0xE5);
|
||||
this->data(0x03);
|
||||
}
|
||||
void HOT WaveshareEPaper7P5In::display() {
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1);
|
||||
// COMMAND DATA START TRANSMISSION 1
|
||||
this->command(0x10);
|
||||
|
||||
this->start_data_();
|
||||
for (size_t i = 0; i < this->get_buffer_length_(); i++) {
|
||||
@@ -601,7 +586,8 @@ void HOT WaveshareEPaper7P5In::display() {
|
||||
}
|
||||
this->end_data_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH);
|
||||
// COMMAND DISPLAY REFRESH
|
||||
this->command(0x12);
|
||||
}
|
||||
int WaveshareEPaper7P5In::get_width_internal() { return 640; }
|
||||
int WaveshareEPaper7P5In::get_height_internal() { return 384; }
|
||||
|
||||
@@ -19,11 +19,20 @@ class WaveshareEPaper : public PollingComponent, public spi::SPIDevice, public d
|
||||
void data(uint8_t value);
|
||||
|
||||
virtual void display() = 0;
|
||||
virtual void initialize() = 0;
|
||||
virtual void deep_sleep() = 0;
|
||||
|
||||
void update() override;
|
||||
|
||||
void fill(int color) override;
|
||||
|
||||
void setup() override {
|
||||
this->setup_pins_();
|
||||
this->initialize();
|
||||
}
|
||||
|
||||
void on_safe_shutdown() override;
|
||||
|
||||
protected:
|
||||
void draw_absolute_pixel_internal(int x, int y, int color) override;
|
||||
|
||||
@@ -31,6 +40,15 @@ class WaveshareEPaper : public PollingComponent, public spi::SPIDevice, public d
|
||||
|
||||
void setup_pins_();
|
||||
|
||||
void reset_() {
|
||||
if (this->reset_pin_ != nullptr) {
|
||||
this->reset_pin_->digital_write(false);
|
||||
delay(200);
|
||||
this->reset_pin_->digital_write(true);
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_buffer_length_();
|
||||
|
||||
bool is_device_high_speed() override;
|
||||
@@ -55,12 +73,18 @@ class WaveshareEPaperTypeA : public WaveshareEPaper {
|
||||
public:
|
||||
WaveshareEPaperTypeA(WaveshareEPaperTypeAModel model);
|
||||
|
||||
void setup() override;
|
||||
void initialize() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void display() override;
|
||||
|
||||
void deep_sleep() override {
|
||||
// COMMAND DEEP SLEEP MODE
|
||||
this->command(0x10);
|
||||
this->wait_until_idle_();
|
||||
}
|
||||
|
||||
void set_full_update_every(uint32_t full_update_every);
|
||||
|
||||
protected:
|
||||
@@ -83,12 +107,18 @@ enum WaveshareEPaperTypeBModel {
|
||||
|
||||
class WaveshareEPaper2P7In : public WaveshareEPaper {
|
||||
public:
|
||||
void setup() override;
|
||||
void initialize() override;
|
||||
|
||||
void display() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void deep_sleep() override {
|
||||
// COMMAND DEEP SLEEP
|
||||
this->command(0x07);
|
||||
this->data(0xA5); // check byte
|
||||
}
|
||||
|
||||
protected:
|
||||
int get_width_internal() override;
|
||||
|
||||
@@ -97,12 +127,41 @@ class WaveshareEPaper2P7In : public WaveshareEPaper {
|
||||
|
||||
class WaveshareEPaper4P2In : public WaveshareEPaper {
|
||||
public:
|
||||
void setup() override;
|
||||
void initialize() override;
|
||||
|
||||
void display() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void deep_sleep() override {
|
||||
// COMMAND VCOM AND DATA INTERVAL SETTING
|
||||
this->command(0x50);
|
||||
this->data(0x17); // border floating
|
||||
|
||||
// COMMAND VCM DC SETTING
|
||||
this->command(0x82);
|
||||
// COMMAND PANEL SETTING
|
||||
this->command(0x00);
|
||||
|
||||
delay(100);
|
||||
|
||||
// COMMAND POWER SETTING
|
||||
this->command(0x01);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
delay(100);
|
||||
|
||||
// COMMAND POWER OFF
|
||||
this->command(0x02);
|
||||
this->wait_until_idle_();
|
||||
// COMMAND DEEP SLEEP
|
||||
this->command(0x07);
|
||||
this->data(0xA5); // check byte
|
||||
}
|
||||
|
||||
protected:
|
||||
int get_width_internal() override;
|
||||
|
||||
@@ -113,12 +172,21 @@ class WaveshareEPaper4P2In : public WaveshareEPaper {
|
||||
|
||||
class WaveshareEPaper7P5In : public WaveshareEPaper {
|
||||
public:
|
||||
void setup() override;
|
||||
void initialize() override;
|
||||
|
||||
void display() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void deep_sleep() override {
|
||||
// COMMAND POWER OFF
|
||||
this->command(0x02);
|
||||
this->wait_until_idle_();
|
||||
// COMMAND DEEP SLEEP
|
||||
this->command(0x07);
|
||||
this->data(0xA5); // check byte
|
||||
}
|
||||
|
||||
protected:
|
||||
int get_width_internal() override;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
MAJOR_VERSION = 1
|
||||
MINOR_VERSION = 13
|
||||
PATCH_VERSION = '0b3'
|
||||
PATCH_VERSION = '0b4'
|
||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||
|
||||
@@ -458,6 +458,7 @@ ICON_BATTERY = 'mdi:battery'
|
||||
ICON_BRIEFCASE_DOWNLOAD = 'mdi:briefcase-download'
|
||||
ICON_BRIGHTNESS_5 = 'mdi:brightness-5'
|
||||
ICON_CHEMICAL_WEAPON = 'mdi:chemical-weapon'
|
||||
ICON_CHECK_CIRCLE_OUTLINE = 'mdi:check-circle-outline'
|
||||
ICON_EMPTY = ''
|
||||
ICON_FLASH = 'mdi:flash'
|
||||
ICON_FLOWER = 'mdi:flower'
|
||||
|
||||
@@ -406,16 +406,27 @@ const logsModal = new LogModalElem({
|
||||
});
|
||||
logsModal.setup();
|
||||
|
||||
const retryUploadButton = document.querySelector('.retry-upload');
|
||||
const editAfterUploadButton = document.querySelector('.edit-after-upload');
|
||||
const downloadAfterUploadButton = document.querySelector('.download-after-upload');
|
||||
const uploadModal = new LogModalElem({
|
||||
name: 'upload',
|
||||
onPrepare: (modalElem, config) => {
|
||||
downloadAfterUploadButton.classList.add('disabled');
|
||||
retryUploadButton.setAttribute('data-node', uploadModal.activeConfig);
|
||||
retryUploadButton.classList.add('disabled');
|
||||
editAfterUploadButton.setAttribute('data-node', uploadModal.activeConfig);
|
||||
modalElem.querySelector(".stop-logs").innerHTML = "Stop";
|
||||
},
|
||||
onProcessExit: (modalElem, code) => {
|
||||
if (code === 0) {
|
||||
M.toast({html: "Program exited successfully."});
|
||||
// if compilation succeeds but OTA fails, you can still download the binary and upload manually
|
||||
downloadAfterUploadButton.classList.remove('disabled');
|
||||
} else {
|
||||
M.toast({html: `Program failed with code ${code}`});
|
||||
downloadAfterUploadButton.classList.add('disabled');
|
||||
retryUploadButton.classList.remove('disabled');
|
||||
}
|
||||
modalElem.querySelector(".stop-logs").innerHTML = "Close";
|
||||
},
|
||||
@@ -425,6 +436,14 @@ const uploadModal = new LogModalElem({
|
||||
dismissible: false,
|
||||
});
|
||||
uploadModal.setup();
|
||||
downloadAfterUploadButton.addEventListener('click', () => {
|
||||
const link = document.createElement("a");
|
||||
link.download = name;
|
||||
link.href = `./download.bin?configuration=${encodeURIComponent(uploadModal.activeConfig)}`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
});
|
||||
|
||||
const validateModal = new LogModalElem({
|
||||
name: 'validate',
|
||||
@@ -587,6 +606,12 @@ const startAceWebsocket = () => {
|
||||
|
||||
editor.session.setAnnotations(arr);
|
||||
|
||||
if(arr.length) {
|
||||
saveUploadButton.classList.add('disabled');
|
||||
} else {
|
||||
saveUploadButton.classList.remove('disabled');
|
||||
}
|
||||
|
||||
aceValidationRunning = false;
|
||||
} else if (msg.type === "read_file") {
|
||||
sendAceStdin({
|
||||
@@ -621,7 +646,7 @@ editor.session.setOption('tabSize', 2);
|
||||
editor.session.setOption('useWorker', false);
|
||||
|
||||
const saveButton = editModalElem.querySelector(".save-button");
|
||||
const saveValidateButton = editModalElem.querySelector(".save-validate-button");
|
||||
const saveUploadButton = editModalElem.querySelector(".save-upload-button");
|
||||
const saveEditor = () => {
|
||||
fetch(`./edit?configuration=${activeEditorConfig}`, {
|
||||
credentials: "same-origin",
|
||||
@@ -673,14 +698,14 @@ setInterval(() => {
|
||||
}, 100);
|
||||
|
||||
saveButton.addEventListener('click', saveEditor);
|
||||
saveValidateButton.addEventListener('click', saveEditor);
|
||||
saveUploadButton.addEventListener('click', saveEditor);
|
||||
|
||||
document.querySelectorAll(".action-edit").forEach((btn) => {
|
||||
btn.addEventListener('click', (e) => {
|
||||
activeEditorConfig = e.target.getAttribute('data-node');
|
||||
const modalInstance = M.Modal.getInstance(editModalElem);
|
||||
const filenameField = editModalElem.querySelector('.filename');
|
||||
editModalElem.querySelector(".save-validate-button").setAttribute('data-node', activeEditorConfig);
|
||||
editModalElem.querySelector(".save-upload-button").setAttribute('data-node', activeEditorConfig);
|
||||
filenameField.innerHTML = activeEditorConfig;
|
||||
|
||||
fetch(`./edit?configuration=${activeEditorConfig}`, {credentials: "same-origin"})
|
||||
|
||||
@@ -124,8 +124,14 @@
|
||||
class="tooltipped" data-position="left" data-tooltip="Flash using esphomeflasher" rel="noreferrer">
|
||||
<i class="material-icons flash-using-esphomeflasher">help_outline</i>
|
||||
</a>
|
||||
<a class="modal-close waves-effect waves-green btn-flat action-edit edit-after-upload">Edit</a>
|
||||
<a class="modal-close waves-effect waves-green btn-flat stop-logs">Stop</a>
|
||||
<div class="btn-flat"><i class="material-icons dropdown-trigger" data-target="dropdown-upload-actions">more_vert</i></div>
|
||||
</div>
|
||||
<ul id="dropdown-upload-actions" class="select-action dropdown-content card-dropdown-action">
|
||||
<li><a class="modal-close waves-effect waves-green btn-flat disabled download-after-upload">Download Binary</a></li>
|
||||
<li><a class="waves-effect waves-green btn-flat disabled action-upload retry-upload">Retry</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="modal-compile" class="modal modal-fixed-footer">
|
||||
@@ -434,7 +440,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="waves-effect waves-green btn-flat save-button">Save</a>
|
||||
<a class="modal-close waves-effect waves-green btn-flat action-validate save-validate-button">Save & Validate</a>
|
||||
<a class="modal-close waves-effect waves-green btn-flat action-upload save-upload-button">Save & Upload</a>
|
||||
<a class="modal-close waves-effect waves-green btn-flat">Close</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -152,6 +152,16 @@ sensor:
|
||||
sensors:
|
||||
- id: custom_sensor
|
||||
name: Custom Sensor
|
||||
- platform: binary_sensor_map
|
||||
name: Binary Sensor Map
|
||||
type: group
|
||||
channels:
|
||||
- binary_sensor: bin1
|
||||
value: 10.0
|
||||
- binary_sensor: bin2
|
||||
value: 15.0
|
||||
- binary_sensor: bin3
|
||||
value: 100.0
|
||||
|
||||
time:
|
||||
- platform: homeassistant
|
||||
@@ -196,12 +206,15 @@ binary_sensor:
|
||||
- platform: mpr121
|
||||
channel: 1
|
||||
name: "touchkey1"
|
||||
id: bin1
|
||||
- platform: mpr121
|
||||
channel: 2
|
||||
name: "touchkey2"
|
||||
id: bin2
|
||||
- platform: mpr121
|
||||
channel: 3
|
||||
name: "touchkey3"
|
||||
id: bin3
|
||||
on_press:
|
||||
then:
|
||||
- switch.toggle: mpr121_toggle
|
||||
|
||||
Reference in New Issue
Block a user