slightky working

pull/16/head
LuBeDa 3 years ago
parent cb7cdd4341
commit e86227304d

@ -20,7 +20,7 @@ namespace esphome
this->alarm_color = Color(CA_RED, CA_GREEN, CA_BLUE);
this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE);
this->gauge_value = 0;
this->screen_pointer = 0;
this->screen_pointer = MAXQUEUE;
for (uint8_t i = 0; i < MAXQUEUE; i++)
{
@ -194,6 +194,7 @@ namespace esphome
register_service(&EHMTX::set_brightness, "brightness", {"value"});
ESP_LOGD(TAG, "Setup and running!");
this->is_running = true;
}
void EHMTX::show_alarm(int r, int g, int b, int size)
@ -228,9 +229,9 @@ namespace esphome
{
if (!this->is_running)
{
if (this->clock->is_valid())
if (this->clock->now().is_valid())
{
ESP_LOGD(TAG, "time sync => starting");
ESP_LOGD(TAG, "time sync => start running");
this->is_running = true;
}
}
@ -364,36 +365,39 @@ namespace esphome
esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue);
this->rainbow_color = Color(uint8_t(255 * red), uint8_t(255 * green), uint8_t(255 * blue));
time_t ts = this->clock->now().timestamp;
if (this->is_running)
{
if (ts > this->next_action_time)
{
this->scroll_step++;
this->remove_expired_queue_element();
this->screen_pointer = this->find_last_clock();
if (this->screen_pointer == MAXQUEUE)
{
this->screen_pointer = find_oldest_queue_element();
}
switch (this->queue[this->screen_pointer]->mode)
{
case MODE_ICON_SCREEN:
case MODE_RAINBOW_ICON:
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) {
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8)
{
this->scroll_step = 0;
}
break;
case MODE_RAINBOW_TEXT:
case MODE_TEXT_SCREEN:
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) {
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31)
{
this->scroll_step = 0;
}
break;
}
ESP_LOGD(TAG, "tick action Pointer: %d",this->screen_pointer);
time_t ts = this->clock->now().timestamp;
if (this->is_running)
{
if (ts > this->next_action_time)
{
this->remove_expired_queue_element();
this->screen_pointer = this->find_last_clock();
if (this->screen_pointer == MAXQUEUE)
{
this->screen_pointer = find_oldest_queue_element();
}
if (this->screen_pointer != MAXQUEUE)
{
this->queue[this->screen_pointer]->shiftx_ = 0;
@ -431,6 +435,7 @@ namespace esphome
}
else
{
ESP_LOGD(TAG, "tick rectangle %d", this->is_running);
uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32;
this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40));
this->boot_anim++;
@ -689,7 +694,11 @@ namespace esphome
ESP_LOGD(TAG, "clock_screen_color lifetime: %d screen_time: %d red: %d green: %d blue: %d", lifetime, screen_time, r, g, b);
screen->mode = MODE_CLOCK;
screen->default_font = default_font;
screen->screen_time_ = (this->clock_interval > screen_time )?screen_time:this->clock_interval-1;
if (this->clock_interval ==0 || (this->clock_interval > screen_time )) {
screen->screen_time_ = screen_time;
} else {
screen->screen_time_ = this->clock_interval-2;
}
screen->endtime = this->clock->now().timestamp + lifetime * 60;
screen->status();
}
@ -885,6 +894,10 @@ namespace esphome
{
ESP_LOGCONFIG(TAG, "show date");
}
if (this->rtl)
{
ESP_LOGCONFIG(TAG, "RTL activated");
}
if (this->week_starts_monday)
{
ESP_LOGCONFIG(TAG, "weekstart: monday");
@ -893,6 +906,7 @@ namespace esphome
{
ESP_LOGCONFIG(TAG, "weekstart: sunday");
}
this->is_running = true;
}
void EHMTX::add_icon(EHMTX_Icon *icon)

@ -20,7 +20,7 @@ const uint8_t MAXICONS = 90;
const uint8_t TEXTSCROLLSTART = 8;
const uint8_t TEXTSTARTOFFSET = (32 - 8);
const uint16_t POLLINGINTERVAL = 800;
const uint16_t POLLINGINTERVAL = 1000;
static const char *const EHMTX_VERSION = "Version: 2023.5.0 beta";
static const char *const TAG = "EHMTXv2";
enum show_mode : uint8_t { MODE_EMPTY = 0,MODE_BLANK = 1, MODE_CLOCK = 2, MODE_DATE = 3, MODE_FULL_SCREEN = 4, MODE_ICON_SCREEN = 5, MODE_TEXT_SCREEN = 6 , MODE_RAINBOW_ICON = 7,MODE_RAINBOW_TEXT = 8, MODE_RAINBOW_CLOCK = 9,MODE_RAINBOW_DATE=10 };
@ -37,7 +37,7 @@ namespace esphome
class EHMTX : public PollingComponent, public api::CustomAPIDevice {
protected:
float get_setup_priority() const override { return esphome::setup_priority::PROCESSOR; }
float get_setup_priority() const override { return esphome::setup_priority::BEFORE_CONNECTION; }
uint8_t brightness_;
uint32_t boot_anim=0;
uint8_t screen_pointer;
@ -57,7 +57,7 @@ namespace esphome
EHMTX();
Color text_color, alarm_color, gauge_color,indicator_color,clock_color;
Color today_color,weekday_color,rainbow_color;
int hue_;
uint16_t hue_=0;
void dump_config();
std::string time_fmt;
std::string date_fmt;

@ -172,7 +172,7 @@ namespace esphome
break;
case MODE_RAINBOW_CLOCK:
case MODE_CLOCK:
if (this->config_->clock->now().timestamp > 6000) // valid time
if (this->config_->clock->now().is_valid()) // valid time
{
color_ = (this->mode == MODE_RAINBOW_CLOCK) ? this->config_->rainbow_color : this->config_->clock_color;
time_t ts = this->config_->clock->now().timestamp;
@ -194,7 +194,7 @@ namespace esphome
break;
case MODE_RAINBOW_DATE:
case MODE_DATE:
if (this->config_->clock->now().timestamp > 6000) // valid time
if (this->config_->clock->now().is_valid())
{
color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->config_->clock_color;
time_t ts = this->config_->clock->now().timestamp;

Loading…
Cancel
Save