simplify display time task:
- drawTime onEnable - disable drawColon onDisable - don't display time at startup, by default temperature is displayed now
This commit is contained in:
parent
bdefbf23bc
commit
2bb9de1f61
@ -12,16 +12,20 @@
|
|||||||
#define BRIGHTNESS_STEP 1
|
#define BRIGHTNESS_STEP 1
|
||||||
#define BRIGHTNESS_NIGHT BRIGHTNESS_MIN
|
#define BRIGHTNESS_NIGHT BRIGHTNESS_MIN
|
||||||
#define BRIGHTNESS_DAY 11
|
#define BRIGHTNESS_DAY 11
|
||||||
#define DISPLAY_TIME 2000
|
#define SECONDS(value) value*1000
|
||||||
#define DISPLAY_TEMP_TIME 5000
|
|
||||||
|
|
||||||
namespace Display {
|
namespace Display {
|
||||||
|
|
||||||
void display();
|
void displayTime();
|
||||||
Task tDisplay(500, TASK_FOREVER, display, &ts, true);
|
void drawTime();
|
||||||
|
void drawColon(bool);
|
||||||
|
Task tDisplayTime(500, TASK_FOREVER, displayTime, &ts, false, []() {
|
||||||
|
drawTime();
|
||||||
|
return true;
|
||||||
|
}, []() {
|
||||||
|
drawColon(false);
|
||||||
|
});
|
||||||
|
|
||||||
int currentHour = -1;
|
|
||||||
int currentMin = -1;
|
|
||||||
bool hourFormat24 = false;
|
bool hourFormat24 = false;
|
||||||
void (*hourFormatChangedCallback)();
|
void (*hourFormatChangedCallback)();
|
||||||
void onHourFormatChanged(void (*f)()) {
|
void onHourFormatChanged(void (*f)()) {
|
||||||
@ -71,6 +75,7 @@ namespace Display {
|
|||||||
|
|
||||||
void drawColon(bool colonOn) {
|
void drawColon(bool colonOn) {
|
||||||
if (colonOn) {
|
if (colonOn) {
|
||||||
|
static int currentHour = -1;
|
||||||
if (currentHour != hour()) {
|
if (currentHour != hour()) {
|
||||||
currentHour = hour();
|
currentHour = hour();
|
||||||
if (currentHour == 8) {
|
if (currentHour == 8) {
|
||||||
@ -81,6 +86,7 @@ namespace Display {
|
|||||||
Brightness::set(BRIGHTNESS_NIGHT);
|
Brightness::set(BRIGHTNESS_NIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static int currentMin = -1;
|
||||||
if (currentMin != minute()) {
|
if (currentMin != minute()) {
|
||||||
currentMin = minute();
|
currentMin = minute();
|
||||||
drawTime();
|
drawTime();
|
||||||
@ -89,8 +95,8 @@ namespace Display {
|
|||||||
clockDisplay.drawColon(colonOn);
|
clockDisplay.drawColon(colonOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void display() {
|
void displayTime() {
|
||||||
static bool colonOn = false;
|
static bool colonOn = true;
|
||||||
|
|
||||||
drawColon(colonOn);
|
drawColon(colonOn);
|
||||||
clockDisplay.writeDisplay();
|
clockDisplay.writeDisplay();
|
||||||
@ -99,30 +105,24 @@ namespace Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void displayTemp(float value) {
|
void displayTemp(float value) {
|
||||||
tDisplay.disable();
|
tDisplayTime.disable();
|
||||||
drawColon(false);
|
|
||||||
clockDisplay.printFloat(value, 1);
|
clockDisplay.printFloat(value, 1);
|
||||||
clockDisplay.writeDisplay();
|
clockDisplay.writeDisplay();
|
||||||
drawTime();
|
tDisplayTime.enableDelayed(SECONDS(10));
|
||||||
tDisplay.enableDelayed(DISPLAY_TEMP_TIME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayValue(uint8_t value) {
|
void displayValue(uint8_t value) {
|
||||||
tDisplay.disable();
|
tDisplayTime.disable();
|
||||||
drawColon(false);
|
|
||||||
clockDisplay.print(value, HEX);
|
clockDisplay.print(value, HEX);
|
||||||
clockDisplay.writeDisplay();
|
clockDisplay.writeDisplay();
|
||||||
drawTime();
|
tDisplayTime.enableDelayed(SECONDS(2));
|
||||||
tDisplay.enableDelayed(DISPLAY_TIME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayText(const char c[]) {
|
void displayText(const char c[]) {
|
||||||
tDisplay.disable();
|
tDisplayTime.disable();
|
||||||
drawColon(false);
|
|
||||||
clockDisplay.println(c);
|
clockDisplay.println(c);
|
||||||
clockDisplay.writeDisplay();
|
clockDisplay.writeDisplay();
|
||||||
drawTime();
|
tDisplayTime.enableDelayed(SECONDS(2));
|
||||||
tDisplay.enableDelayed(DISPLAY_TIME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeHourFormat24(bool format24) {
|
void changeHourFormat24(bool format24) {
|
||||||
@ -134,7 +134,5 @@ namespace Display {
|
|||||||
void setup() {
|
void setup() {
|
||||||
clockDisplay.begin(DISPLAY_ADDRESS);
|
clockDisplay.begin(DISPLAY_ADDRESS);
|
||||||
clockDisplay.setBrightness(Brightness::current);
|
clockDisplay.setBrightness(Brightness::current);
|
||||||
drawTime();
|
|
||||||
display();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user