Skip to content

Commit

Permalink
Add color text for each tilt (#26)
Browse files Browse the repository at this point in the history
* add env for ttgo t-display

* add lcd code for tft_espi

* fixed typo in debugging print

* fixed width for t-display

* add usb ports

* show three tilts on a page

* remove debugging prints

* add method that returns color code

* use color for tilt and display temp on ttgo t-displat

* fix startup display
  • Loading branch information
duncan-brown committed Jun 7, 2020
1 parent 03dbf74 commit 9dc2997
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/bridge_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,16 @@ void bridge_lcd::print_tilt_to_line(tiltHydrometer* tilt, uint8_t line) {
sprintf(gravity, "%.3f", double_t(tilt->gravity)/1000);
sprintf(temp, "%d F", tilt->temp);

#ifdef LCD_TFT_ESPI
tft->setTextColor(tilt->text_color());
#endif

print_line(tilt->color_name().c_str(), temp, gravity, line);

#ifdef LCD_TFT_ESPI
tft->setTextColor(TFT_WHITE);
#endif

}


Expand Down Expand Up @@ -323,7 +332,11 @@ void bridge_lcd::display() {


void bridge_lcd::print_line(const String& left_text, const String& right_text, uint8_t line) {
#ifdef LCD_TFT_ESPI
print_line("", left_text, right_text, line);
#else
print_line(left_text, "", right_text, line);
#endif
}


Expand Down Expand Up @@ -369,13 +382,13 @@ void bridge_lcd::print_line(const String& left_text, const String& middle_text,
#endif

#ifdef LCD_TFT_ESPI
// middle_text is ignored for non-TFT displays
// ignore left text as we color the text by the tilt
int16_t starting_pixel_row = 0;

starting_pixel_row = (TFT_ESPI_LINE_CLEARANCE + TFT_ESPI_FONT_SIZE) * (line-1) + TFT_ESPI_LINE_CLEARANCE;

// TFT_eSPI::drawString(const char *string, int32_t poX, int32_t poY, uint8_t font_number)
tft->drawString(left_text, 0, starting_pixel_row, TFT_ESPI_FONT_NUMBER);
tft->drawString(middle_text, 0, starting_pixel_row, TFT_ESPI_FONT_NUMBER);
tft->drawString(right_text, tft->width()/2, starting_pixel_row, TFT_ESPI_FONT_NUMBER);
#endif

Expand Down
24 changes: 24 additions & 0 deletions src/tilt/tiltHydrometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,30 @@ std::string tiltHydrometer::color_name() {
}
}

uint32_t tiltHydrometer::text_color() {

switch(m_color) {
case TILT_COLOR_RED:
return 0xF800;
case TILT_COLOR_GREEN:
return 0x07E0;
case TILT_COLOR_BLACK:
return 0xFFFF;
case TILT_COLOR_PURPLE:
return 0x780F;
case TILT_COLOR_ORANGE:
return 0xFDA0;
case TILT_COLOR_BLUE:
return 0x001F;
case TILT_COLOR_YELLOW:
return 0xFFE0;
case TILT_COLOR_PINK:
return 0xFE19;
default:
return 0xFFFF;
}
}


std::string tiltHydrometer::gsheets_beer_name() {
switch(m_color) {
Expand Down
1 change: 1 addition & 0 deletions src/tilt/tiltHydrometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class tiltHydrometer {

bool set_values(uint32_t i_temp, uint32_t i_grav);
std::string color_name();
uint32_t text_color();
std::string converted_gravity();
std::string gsheets_beer_name();
nlohmann::json to_json();
Expand Down

0 comments on commit 9dc2997

Please sign in to comment.