"bluescreen on Boot"

develop
LuBeDa 3 years ago
parent 79587a7c64
commit d01c63f96f

@ -115,12 +115,12 @@ namespace esphome
for (JsonVariant v : array) for (JsonVariant v : array)
{ {
uint16_t buf = v.as<int>(); uint16_t buf = v.as<int>();
unsigned char b = (((buf)&0x001F) << 3); unsigned char b = (((buf)&0x001F) << 3);
unsigned char g = (((buf)&0x07E0) >> 3); // Fixed: shift >> 5 and << 2 unsigned char g = (((buf)&0x07E0) >> 3); // Fixed: shift >> 5 and << 2
unsigned char r = (((buf)&0xF800) >> 8); // shift >> 11 and << 3 unsigned char r = (((buf)&0xF800) >> 8); // shift >> 11 and << 3
Color c = Color(r, g, b); Color c = Color(r, g, b);
this->bitmap[i++] = c; this->bitmap[i++] = c;
} }
@ -269,14 +269,14 @@ namespace esphome
if (this->clock->now().is_valid()) if (this->clock->now().is_valid())
{ {
ESP_LOGD(TAG, "time sync => start running"); ESP_LOGD(TAG, "time sync => start running");
this->bitmap_screen("[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,63519,63519,63519,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,0,0,0,0,2016,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,63488,0,63488,0,0,0,63519,0,0,0,0,2016,2016,0,0,0,65514,0,65514,0,0,0,31,0,0,0,64512,0,0,64512,0,63488,63488,0,63488,63488,0,0,63519,63519,63519,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,31,31,31,0,0,0,64512,64512,0,0,63488,63488,63488,63488,63488,0,0,63519,0,0,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,31,0,0,0,0,64512,64512,0,0,0,63488,63488,63488,0,0,0,63519,63519,63519,63519,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,0,31,31,0,64512,0,0,64512,0,0,0,63488,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]",1,10); this->bitmap_screen("[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,63519,63519,63519,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,0,0,0,0,2016,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,63488,0,63488,0,0,0,63519,0,0,0,0,2016,2016,0,0,0,65514,0,65514,0,0,0,31,0,0,0,64512,0,0,64512,0,63488,63488,0,63488,63488,0,0,63519,63519,63519,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,31,31,31,0,0,0,64512,64512,0,0,63488,63488,63488,63488,63488,0,0,63519,0,0,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,31,0,0,0,0,64512,64512,0,0,0,63488,63488,63488,0,0,0,63519,63519,63519,63519,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,0,31,31,0,64512,0,0,64512,0,0,0,63488,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]", 1, 10);
this->clock_screen(14 * 24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); this->clock_screen(14 * 24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE);
this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); this->date_screen(14 * 24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE);
this->is_running = true; this->is_running = true;
} }
} }
} }
void EHMTX::force_screen(std::string icon_name, int mode) void EHMTX::force_screen(std::string icon_name, int mode)
{ {
for (uint8_t i = 0; i < MAXQUEUE; i++) for (uint8_t i = 0; i < MAXQUEUE; i++)
@ -348,53 +348,59 @@ namespace esphome
void EHMTX::remove_expired_queue_element() void EHMTX::remove_expired_queue_element()
{ {
time_t ts = this->clock->now().timestamp; if (this->clock->now().is_valid())
std::string infotext;
for (size_t i = 0; i < MAXQUEUE; i++)
{ {
if ((this->queue[i]->endtime > 0) && (this->queue[i]->endtime < ts)) std::string infotext;
time_t ts = this->clock->now().timestamp;
for (size_t i = 0; i < MAXQUEUE; i++)
{ {
this->queue[i]->endtime = 0; if ((this->queue[i]->endtime > 0) && (this->queue[i]->endtime < ts))
if (this->queue[i]->mode != MODE_EMPTY)
{ {
ESP_LOGD(TAG, "remove expired queue element: slot %d: mode: %d icon_name: %s text: %s", i, this->queue[i]->mode, this->queue[i]->icon_name.c_str(), this->queue[i]->text.c_str()); this->queue[i]->endtime = 0;
for (auto *t : on_expired_screen_triggers_) if (this->queue[i]->mode != MODE_EMPTY)
{ {
infotext = ""; ESP_LOGD(TAG, "remove expired queue element: slot %d: mode: %d icon_name: %s text: %s", i, this->queue[i]->mode, this->queue[i]->icon_name.c_str(), this->queue[i]->text.c_str());
switch (this->queue[i]->mode) for (auto *t : on_expired_screen_triggers_)
{ {
case MODE_EMPTY: infotext = "";
break; switch (this->queue[i]->mode)
case MODE_BLANK: {
break; case MODE_EMPTY:
case MODE_CLOCK: break;
infotext = "clock"; case MODE_BLANK:
break; break;
case MODE_DATE: case MODE_CLOCK:
infotext = "clock"; infotext = "clock";
break; break;
case MODE_FULL_SCREEN: case MODE_DATE:
infotext = "full screen " + this->queue[i]->icon_name; infotext = "clock";
break; break;
case MODE_ICON_SCREEN: case MODE_FULL_SCREEN:
case MODE_RAINBOW_ICON: infotext = "full screen " + this->queue[i]->icon_name;
infotext = this->queue[i]->icon_name.c_str(); break;
break; case MODE_ICON_SCREEN:
case MODE_RAINBOW_TEXT: case MODE_RAINBOW_ICON:
case MODE_TEXT_SCREEN: infotext = this->queue[i]->icon_name.c_str();
infotext = "TEXT"; break;
break; case MODE_RAINBOW_TEXT:
default: case MODE_TEXT_SCREEN:
break; infotext = "TEXT";
break;
case MODE_BITMAP_SCREEN:
infotext = "BITMAP";
break;
default:
break;
}
t->process(this->queue[i]->icon_name, infotext);
} }
t->process(this->queue[i]->icon_name, infotext);
} }
this->queue[i]->mode = MODE_EMPTY;
} }
this->queue[i]->mode = MODE_EMPTY;
} }
} }
} }
void EHMTX::tick() void EHMTX::tick()
{ {
this->hue_++; this->hue_++;
@ -406,10 +412,10 @@ namespace esphome
esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue); 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)); 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 && this->clock->now().is_valid())
if (this->is_running)
{ {
time_t ts = this->clock->now().timestamp;
if (millis() - this->last_scroll_time >= this->scroll_interval) if (millis() - this->last_scroll_time >= this->scroll_interval)
{ {
this->scroll_step++; this->scroll_step++;
@ -940,10 +946,6 @@ namespace esphome
{ {
ESP_LOGCONFIG(TAG, "weekstart: sunday"); ESP_LOGCONFIG(TAG, "weekstart: sunday");
} }
if (this->clock->now().is_valid())
{
this->is_running = true;
}
} }
void EHMTX::add_icon(EHMTX_Icon *icon) void EHMTX::add_icon(EHMTX_Icon *icon)

@ -37,7 +37,7 @@ namespace esphome
class EHMTX : public PollingComponent, public api::CustomAPIDevice { class EHMTX : public PollingComponent, public api::CustomAPIDevice {
protected: protected:
float get_setup_priority() const override { return esphome::setup_priority::BEFORE_CONNECTION; } float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; }
uint8_t brightness_; uint8_t brightness_;
uint32_t boot_anim=0; uint32_t boot_anim=0;
uint8_t screen_pointer; uint8_t screen_pointer;

Loading…
Cancel
Save