Skip to content

Commit 753e93e

Browse files
committed
[thermomstat] define new function instead split it
1 parent e53dfd0 commit 753e93e

File tree

1 file changed

+56
-15
lines changed

1 file changed

+56
-15
lines changed

code/espurna/thermostat.cpp

+56-15
Original file line numberDiff line numberDiff line change
@@ -583,16 +583,21 @@ bool _display_need_refresh = true;
583583
bool _temp_range_need_update = true;
584584

585585
//------------------------------------------------------------------------------
586-
void drawIco(int16_t x, int16_t y, const char *ico, bool on = true) {
587586
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
588-
uint16_t color;
587+
588+
void drawIco(int16_t x, int16_t y, const char *ico, bool on = true) {
589589
display.drawBitmap(x, y, (const uint8_t*) ico, 16, 16, ((on == true) ? ST7735_WHITE : ST77XX_BLACK));
590+
_display_need_refresh = true;
591+
590592
#else
593+
594+
void drawIco(int16_t x, int16_t y, const char *ico, bool on = true) {
591595
display.drawIco16x16(x, y, ico, !on); //FIXME
592-
#endif
593596
_display_need_refresh = true;
594597
}
595598

599+
#endif
600+
596601
//------------------------------------------------------------------------------
597602
void display_wifi_status(bool on) {
598603
_display_wifi_status = on;
@@ -618,32 +623,41 @@ void display_remote_temp_status(bool on) {
618623
}
619624

620625
//------------------------------------------------------------------------------
626+
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
627+
621628
void display_temp_range() {
622629
_temp_range.need_display_update = false;
623-
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
624630
display.fillRect(68, 0, ST7735_TFTHEIGHT_160 - 60, 16, ST7735_BLACK);
625631
display.setTextColor(ST77XX_WHITE);
626632
display.setTextWrap(true);
627633
display.setCursor(90, 0 + 13);
628634
display.setFont(&Roboto_Thin9pt8b);
629635
String temp_range = String(_temp_range.min) + "\xB0- " + String(_temp_range.max) + "\xB0";
630636
display.print(temp_range);
637+
_display_need_refresh = true;
638+
}
639+
631640
#else
641+
642+
void display_temp_range() {
643+
_temp_range.need_display_update = false;
632644
display.setColor(BLACK);
633645
display.fillRect(68, 0, 60, 16);
634646
display.setColor(WHITE);
635647
display.setTextAlignment(TEXT_ALIGN_RIGHT);
636648
display.setFont(ArialMT_Plain_16);
637649
String temp_range = String(_temp_range.min) + "°- " + String(_temp_range.max) + "°";
638650
display.drawString(128 /*x*/, 0/*y*/, temp_range);
639-
#endif
640651
_display_need_refresh = true;
641652
}
642653

654+
#endif
655+
643656
//------------------------------------------------------------------------------
657+
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
658+
644659
void display_remote_temp() {
645660
_remote_temp.need_display_update = false;
646-
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
647661
display.fillRect(0, 16, ST7735_TFTHEIGHT_160, 16, ST77XX_BLACK);
648662

649663
display.setTextColor(ST77XX_WHITE);
@@ -657,8 +671,13 @@ void display_remote_temp() {
657671
display.setCursor(75, 16 + 13);
658672
String temp_range_vol = String("= ") + (_display_remote_temp_status ? String(_remote_temp.temp, 1) : String("?")) + "\xB0";
659673
display.print(temp_range_vol);
660-
//FIXME
674+
_display_need_refresh = true;
675+
}
676+
661677
#else
678+
679+
void display_remote_temp() {
680+
_remote_temp.need_display_update = false;
662681
display.setColor(BLACK);
663682
display.fillRect(0, 16, 128, 16);
664683
display.setColor(WHITE);
@@ -669,14 +688,16 @@ void display_remote_temp() {
669688

670689
String temp_range_vol = String("= ") + (_display_remote_temp_status ? String(_remote_temp.temp, 1) : String("?")) + "°";
671690
display.drawString(75, 16, temp_range_vol);
672-
#endif
673691
_display_need_refresh = true;
674692
}
693+
#endif
675694

676695
//------------------------------------------------------------------------------
677-
void display_local_temp() {
678696
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
697+
698+
void display_local_temp() {
679699
display.fillRect(0, 32, ST7735_TFTHEIGHT_160, 16, ST77XX_BLACK);
700+
680701
display.setTextColor(ST77XX_WHITE);
681702
display.setTextWrap(true);
682703
display.setFont(&Roboto_Thin9pt8b);
@@ -688,7 +709,12 @@ void display_local_temp() {
688709
display.setCursor(75, 32 + 13);
689710
String local_temp_vol = String("= ") + (getLocalTemperature() != DBL_MIN ? String(getLocalTemperature(), 1) : String("?")) + "\xB0";
690711
display.print(local_temp_vol);
712+
_display_need_refresh = true;
713+
}
714+
691715
#else
716+
717+
void display_local_temp() {
692718
display.setColor(BLACK);
693719
display.fillRect(0, 32, 128, 16);
694720
display.setColor(WHITE);
@@ -700,15 +726,16 @@ void display_local_temp() {
700726

701727
String local_temp_vol = String("= ") + (getLocalTemperature() != DBL_MIN ? String(getLocalTemperature(), 1) : String("?")) + "°";
702728
display.drawString(75, 32, local_temp_vol);
703-
#endif
704-
705729
_display_need_refresh = true;
706730
}
731+
#endif
707732

708733
//------------------------------------------------------------------------------
709-
void display_local_humidity() {
710734
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
735+
736+
void display_local_humidity() {
711737
display.fillRect(0, 48, ST7735_TFTHEIGHT_160, 16, ST77XX_BLACK);
738+
712739
display.setTextColor(ST77XX_WHITE);
713740
display.setTextWrap(true);
714741

@@ -719,7 +746,12 @@ void display_local_humidity() {
719746
display.setCursor(75, 48 + 13);
720747
String local_hum_vol = String("= ") + (getLocalHumidity() != DBL_MIN ? String(getLocalHumidity(), 0) : String("?")) + "%";
721748
display.print(local_hum_vol);
749+
_display_need_refresh = true;
750+
}
751+
722752
#else
753+
754+
void display_local_humidity() {
723755
display.setColor(BLACK);
724756
display.fillRect(0, 48, 128, 16);
725757
display.setColor(WHITE);
@@ -731,9 +763,9 @@ void display_local_humidity() {
731763

732764
String local_hum_vol = String("= ") + (getLocalHumidity() != DBL_MIN ? String(getLocalHumidity(), 0) : String("?")) + "%";
733765
display.drawString(75, 48, local_hum_vol);
734-
#endif
735766
_display_need_refresh = true;
736767
}
768+
#endif
737769

738770
//------------------------------------------------------------------------------
739771
void displayOn() {
@@ -754,21 +786,30 @@ void displayOn() {
754786
//------------------------------------------------------------------------------
755787
// Setup
756788
//------------------------------------------------------------------------------
757-
void displaySetup() {
758789
#if THERMOSTAT_DISPLAY_ST7735_SUPPORT
790+
791+
void displaySetup() {
759792
display.initR(INITR_BLACKTAB); // Initialize ST7735R screen
760793
display.setRotation(1);
761794
display.fillScreen(ST77XX_BLACK);
762795
display.cp437(true);
796+
797+
displayOn();
798+
799+
espurnaRegisterLoop(displayLoop);
800+
}
801+
763802
#else
803+
804+
void displaySetup() {
764805
display.init();
765806
display.flipScreenVertically();
766-
#endif
767807

768808
displayOn();
769809

770810
espurnaRegisterLoop(displayLoop);
771811
}
812+
#endif
772813

773814
//------------------------------------------------------------------------------
774815
void displayLoop() {

0 commit comments

Comments
 (0)