I've started a new thread topic because the other one was getting too
long and deeply nested for my liking. This display code should do what
you requested in MID: <uqnbn7$3q8ii$
1...@dont-email.me>
The text for the actual temperature is always shown unless the target
bar is showing. When the bar for actual temperature is showing, the
last (current) block should flash if heating. Let me know if you'd
like a new gif image.
lambda: |-
auto swc = id(lhsw_cond).state;
auto hvc = id(hvac).state;
auto tgt = id(target).state;
auto act = id(actual).state;
auto colr = id(color_white);
auto box_x = 1;
auto box_y = 1;
auto box_h = 40;
auto box_w = it.get_width() - (box_x * 2);
auto temp_lo = 20;
auto temp_hi = 25;
auto bar_inc = int(box_w / (1 + temp_hi - temp_lo));
auto gap = 4;
auto bar_h = box_h - gap * 2;
auto stat = false;
auto heat = false;
auto show_temp = true;
if (swc != "unavailable") {
if (hvc == "idle") {
colr = id(color_green);
stat = true;
}
else if (hvc == "heating") {
colr = id(color_red);
stat = true;
heat = true;
}
}
it.rectangle(0, 0, it.get_width(), it.get_height(), id(color_gray));
//it.rectangle(box_x, box_y, box_w, box_h, id(color_gray));
for (auto last_x = 0; auto x = box_x + gap, i = temp_lo; i <= temp_hi; i++) {
if (i > int(act)) {
if (heat) {
it.filled_rectangle(last_x, box_y + gap, bar_inc - gap, bar_h, id(color_black));
it.image(last_x, box_y + gap, id(anim_blk), COLOR_ON, COLOR_OFF);
}
break;
}
it.filled_rectangle(x, box_y + gap, bar_inc - gap, bar_h, colr);
last_x = x;
x += bar_inc;
}
box_y += box_h + 10;
box_h = 80;
bar_h = box_h - gap * 2;
if (stat) {
//it.rectangle(box_x, box_y, box_w, box_h, id(color_gray));
for (auto x = box_x + gap, i = temp_lo; i <= temp_hi; i++) {
if (i > int(tgt)) break;
it.filled_rectangle(x, box_y + gap, bar_inc - gap, bar_h, colr);
x += bar_inc;
show_temp = false;
}
}
if (show_temp) {
it.printf(it.get_width()/2, box_y - 35, id(font_90), id(colr),
TextAlign::CENTER_HORIZONTAL, "%.1f°c", act);
}