Skip to content

Commit

Permalink
Finalize for v1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
thorrak committed Feb 12, 2021
2 parents 5fcb188 + 52fafc3 commit 9208067
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 42 deletions.
Binary file modified bin/d32_pro_tft_firmware.bin
Binary file not shown.
Binary file modified bin/lcd_ssd1306_firmware.bin
Binary file not shown.
Binary file modified bin/tft_espi_firmware.bin
Binary file not shown.
4 changes: 3 additions & 1 deletion docs/source/changelog.rst
Expand Up @@ -2,7 +2,7 @@ Changelog
#########


v1.0.0 - Feb 11, 2021 - UI Overhaul, Scanner Overhaul, and loads more
v1.0.0 - Feb 12, 2021 - UI Overhaul, Scanner Overhaul, and loads more
---------------------------------------------------------------------

This is a significant release, and is the result of a large number of changes over the past few weeks. Of note - this
Expand All @@ -22,6 +22,8 @@ the primary authors of this update - @lbussy and @pletch.
- Added uptime/last crash statistics to "About" page
- Added "Factory Reset" option which removes WiFi configuration and push target settings
- Changed: Multiple endpoints for settings updates
- Fixed bug where configuration AP could drown out other devices on nearby channels
- Added note to TFT at first boot about screen rotation being configurable



Expand Down
12 changes: 6 additions & 6 deletions platformio.ini
Expand Up @@ -47,15 +47,15 @@ build_flags = ; Do not use spaces around the "=" here,
-D CONFIG_SW_COEXIST_PREFERENCE_BALANCED=1
; Debug logging
-D PRINT_GRAV_UPDATES=0 ; Turn on and off gravity printing to serial log
-D CORE_DEBUG_LEVEL=2
-D ARDUINO_LOG_LEVEL=4 ; Set Serial log level (0 = disable)
; -D DISABLE_LOGGING ; This will remove log lib from sketch
-D CORE_DEBUG_LEVEL=0 ; Set core Arduino log level (5 = high)
-D ARDUINO_LOG_LEVEL=0 ; Set Serial log level (6 = high)
-D DISABLE_LOGGING ; This will remove log lib from sketch
; Project conditional compile/options:
-D BAUD=${common.monitor_speed} ; Serial monitor baud setting
-D FILESYSTEM=SPIFFS ; Define filesystem in use
-D DISABLE_OTA_UPDATES=1
-D DOTELNET=0 ; Allow Telnet serial logging
-D TELNETPORT=23
;-D DOTELNET=0 ; Allow Telnet serial logging
;-D TELNETPORT=23
-D WEBPORT=80
; -D FSEDIT=0 ; Use a filesystem editor
extra_scripts = tools/get_port.py ; Pick up port information based on OS
Expand All @@ -65,7 +65,7 @@ lib_deps =
https://github.com/lbussy/esptelnet.git
https://github.com/thorrak/AsyncTCP.git#queued_push ; Originally ul-gh's queued_push branch
https://github.com/thorrak/ESPAsyncWebServer.git#dev ; Originally ul-gh's dev branch
https://github.com/h2zero/NimBLE-Arduino.git ; TODO - At some point we need to lock the version of this down
h2zero/NimBLE-Arduino @ 1.2.0 ; https://github.com/h2zero/NimBLE-Arduino.git
256dpi/MQTT @ 2.4.8
https://github.com/tzapu/WiFiManager.git
https://github.com/lbussy/LCBUrl.git#devel
Expand Down
32 changes: 26 additions & 6 deletions src/bridge_lcd.cpp
Expand Up @@ -175,6 +175,15 @@ void bridge_lcd::display_wifi_connect_screen(const char *ap_name, const char *ap
print_line("this AP via WiFi:", "", 2);
print_line("Name:", ap_name, 3);
print_line("Pass: ", ap_pass, 4);

#ifdef LCD_TFT
tft->setFreeFont(&FreeSans9pt7b);
print_line("NOTE - If this appears upside-down,", "", 8);
print_line("this can be corrected via a setting in the", "", 9);
print_line("settings portal after connecting to WiFi", "", 10);
// print_line("", "", 11);
#endif

display();
}

Expand Down Expand Up @@ -240,7 +249,11 @@ void bridge_lcd::print_line(const char *left_text, const char *right_text, uint8
#endif
}

void bridge_lcd::print_line(const char *left_text, const char *middle_text, const char *right_text, uint8_t line)
void bridge_lcd::print_line(const char *left_text, const char *middle_text, const char *right_text, uint8_t line) {
print_line(left_text, middle_text, right_text, line, false);
}

void bridge_lcd::print_line(const char *left_text, const char *middle_text, const char *right_text, uint8_t line, bool add_gutter)
{
#ifdef LCD_SSD1306
int16_t starting_pixel_row = 0;
Expand All @@ -257,15 +270,21 @@ void bridge_lcd::print_line(const char *left_text, const char *middle_text, cons
oled_display->setTextAlignment(TEXT_ALIGN_RIGHT);
oled_display->drawString(128, starting_pixel_row, right_text);
#elif defined(LCD_TFT)

int16_t starting_pixel_row = 0;
starting_pixel_row = (tft->fontHeight(GFXFF)) * (line - 1) + 2;

tft->drawString(left_text, 25, starting_pixel_row, GFXFF);
if(add_gutter) // We need space to the left to be able to display the Tilt color block
tft->drawString(left_text, 25, starting_pixel_row, GFXFF);
else
tft->drawString(left_text, 1, starting_pixel_row, GFXFF);

yield();
tft->drawString(middle_text, 134, starting_pixel_row, GFXFF);
yield();
tft->drawString(right_text, 300 - tft->textWidth(right_text, GFXFF), starting_pixel_row, GFXFF);
if(add_gutter)
tft->drawString(right_text, 300 - tft->textWidth(right_text, GFXFF), starting_pixel_row, GFXFF);
else
tft->drawString(right_text, 319 - tft->textWidth(right_text, GFXFF), starting_pixel_row, GFXFF);
#elif defined(LCD_TFT_ESPI)
// ignore left text as we color the text by the tilt
int16_t starting_pixel_row = 0;
Expand Down Expand Up @@ -364,7 +383,7 @@ void bridge_lcd::display_tilt_screen(uint8_t screen_number) {
#endif

// Display the header row
print_line("Color", "Temp", "Gravity", header_row);
print_line("Color", "Temp", "Gravity", header_row, true);

// Loop through each of the tilt colors cached by tilt_scanner, searching for active tilts
for (uint8_t i = 0; i < TILT_COLORS; i++) {
Expand Down Expand Up @@ -415,7 +434,8 @@ void bridge_lcd::print_tilt_to_line(tiltHydrometer *tilt, uint8_t line) {
tft->setTextColor(tilt->text_color());
#endif

print_line(tilt->color_name().c_str(), temp, gravity, line);
// Print line with gutter for the color block for TFT screens
print_line(tilt->color_name().c_str(), temp, gravity, line, true);

#ifdef LCD_TFT
uint16_t fHeight = tft->fontHeight(GFXFF);
Expand Down
1 change: 1 addition & 0 deletions src/bridge_lcd.h
Expand Up @@ -60,6 +60,7 @@ class bridge_lcd {

void print_line(const char *left_text, const char *right_text, uint8_t line);
void print_line(const char *left_text, const char *middle_text, const char *right_text, uint8_t line);
void print_line(const char *left_text, const char *middle_text, const char *right_text, uint8_t line, bool add_gutter);

void check_screen();
void clear();
Expand Down
57 changes: 28 additions & 29 deletions src/wifi_setup.cpp
Expand Up @@ -10,9 +10,10 @@ void saveParamsCallback() {
}

void apCallback(WiFiManager *myWiFiManager) {
// Callback to display the WiFi LCD notification
// Callback to display the WiFi LCD notification and set bandwidth
Log.verbose(F("Entered config mode: SSID: %s, IP: %s" CR), myWiFiManager->getConfigPortalSSID().c_str(), WiFi.softAPIP().toString().c_str());
lcd.display_wifi_connect_screen(myWiFiManager->getConfigPortalSSID().c_str(), WIFI_SETUP_AP_PASS);
esp_wifi_set_bandwidth(WIFI_IF_AP, WIFI_BW_HT20); // Set the bandwidth of ESP32 interface
}

void disconnectWiFi() {
Expand Down Expand Up @@ -46,29 +47,27 @@ void initWiFi() {
#if ARDUINO_LOG_LEVEL == 6
wm.setDebugOutput(true); // Use debug if we are at max log level
#else
wm.setDebugOutput(false); // In case we have a serial connection
wm.setDebugOutput(false);
#endif

// The main purpose of this is to set a boolean value which will allow us to know we
// just saved a new configuration (as opposed to rebooting normally)
wm.setSaveParamsCallback(saveParamsCallback);
wm.setAPCallback(apCallback);
wm.setConfigPortalTimeout(5 * 60); // Setting to 5 mins
wm.setSaveParamsCallback(saveParamsCallback); // Signals settings change
wm.setAPCallback(apCallback); // Set up when portal fires
wm.setConfigPortalTimeout(5 * 60); // Timeout portal in 5 mins

wm.setHostname(config.mdnsID); // Allow DHCP to get proper name
wm.setWiFiAutoReconnect(true); // Enable auto reconnect (should remove need for reconnectWiFi())
wm.setWiFiAPChannel(1); // Pick the most common channel, safe for all countries
wm.setCleanConnect(true); // Always disconnect before connecting
wm.setCountry("US"); // US country code is most restrictive, use for all countries

wm.setCleanConnect(true);
wm.setCustomHeadElement("<style type=\"text/css\">body {background-image: url(\"data:image/svg+xml;utf8,%3Csvg%20id%3D%22Layer_1%22%20data-name%3D%22Layer%201%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20231.62%20169.18%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%2281.067%22%20height%3D%2259.213%22%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill%3A%23f7f8fa%7D%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22tb_logo%22%3E%3Cg%3E%3Cpath%20class%3D%22cls-1%22%20d%3D%22M31.77%2C13.6A29.88%2C29.88%2C0%2C0%2C1%2C74%2C13.6a2.42%2C2.42%2C0%2C0%2C0%2C3.42-3.43%2C34.73%2C34.73%2C0%2C0%2C0-49.11%2C0%2C2.42%2C2.42%2C0%2C0%2C0%2C3.42%2C3.43Z%22%2F%3E%3Cpath%20class%3D%22cls-1%22%20d%3D%22M67.93%2C22.13A2.42%2C2.42%2C0%2C0%2C0%2C69.64%2C18a23.65%2C23.65%2C0%2C0%2C0-33.47%2C0%2C2.42%2C2.42%2C0%2C0%2C0%2C3.42%2C3.42%2C18.84%2C18.84%2C0%2C0%2C1%2C26.63%2C0A2.42%2C2.42%2C0%2C0%2C0%2C67.93%2C22.13Z%22%2F%3E%3Cpath%20class%3D%22cls-1%22%20d%3D%22M43.91%2C25.73a2.42%2C2.42%2C0%2C0%2C0%2C3.42%2C3.43%2C7.88%2C7.88%2C0%2C0%2C1%2C11.15%2C0%2C2.43%2C2.43%2C0%2C0%2C0%2C3.43-3.43A12.75%2C12.75%2C0%2C0%2C0%2C43.91%2C25.73Z%22%2F%3E%3C%2Fg%3E%3Cpath%20class%3D%22cls-1%22%20d%3D%22M103.39%2C61.76H91.7C80%2C61.76%2C70.34%2C57.24%2C63%2C48.32a45.48%2C45.48%2C0%2C0%2C1-7.38-12.7%2C3.85%2C3.85%2C0%2C0%2C1-5.36%2C0A45.31%2C45.31%2C0%2C0%2C1%2C43%2C48.19%2C35.71%2C35.71%2C0%2C0%2C1%2C14.12%2C61.76H2.42a2.42%2C2.42%2C0%2C0%2C0%2C0%2C4.84h101a2.42%2C2.42%2C0%2C0%2C0%2C0-4.84Zm-52.9%2C0H34.08A42.36%2C42.36%2C0%2C0%2C0%2C46.7%2C51.26%2C52%2C52%2C0%2C0%2C0%2C50.49%2C46Zm4.84%2C0V46a50.35%2C50.35%2C0%2C0%2C0%2C3.78%2C5.3%2C42.49%2C42.49%2C0%2C0%2C0%2C12.62%2C10.5Z%22%2F%3E%3Ccircle%20class%3D%22cls-1%22%20cx%3D%2252.91%22%20cy%3D%2232.86%22%20r%3D%222.81%22%2F%3E%3Cg%3E%3Cpath%20class%3D%22cls-1%22%20d%3D%22M22.39%2C77.09A2.44%2C2.44%2C0%2C0%2C1%2C20%2C74.65V64.52a2.45%2C2.45%2C0%2C0%2C1%2C4.89%2C0V74.65A2.45%2C2.45%2C0%2C0%2C1%2C22.39%2C77.09Z%22%2F%3E%3Cpath%20class%3D%22cls-1%22%20d%3D%22M83.42%2C77.09A2.45%2C2.45%2C0%2C0%2C1%2C81%2C74.65V64.52a2.45%2C2.45%2C0%2C0%2C1%2C4.89%2C0V74.65A2.45%2C2.45%2C0%2C0%2C1%2C83.42%2C77.09Z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3Cuse%20xlink%3Ahref%3D%22%23tb_logo%22%20x%3D%220%22%20y%3D%220%22%2F%3E%3Cuse%20xlink%3Ahref%3D%22%23tb_logo%22%20x%3D%22115.81%22%20y%3D%220%22%2F%3E%3Cuse%20xlink%3Ahref%3D%22%23tb_logo%22%20x%3D%22-57.905%22%20y%3D%2284.59%22%2F%3E%3Cuse%20xlink%3Ahref%3D%22%23tb_logo%22%20x%3D%2257.905%22%20y%3D%2284.59%22%2F%3E%3Cuse%20xlink%3Ahref%3D%22%23tb_logo%22%20x%3D%22173.715%22%20y%3D%2284.59%22%2F%3E%3C%2Fsvg%3E\")}</style>");

// The third parameter we're passing here (mdns_id.c_str()) is the default name that will appear on the form.
// It's nice, but it means the user gets no actual prompt for what they're entering.
char mdns_id[31];
strcpy(mdns_id, config.mdnsID);
WiFiManagerParameter custom_mdns_name("mdns", "Device (mDNS) Name", mdns_id, 20);
// config.mdnsID is the default name that will appear on the form
WiFiManagerParameter custom_mdns_name("mdns", "Device (mDNS) Name", config.mdnsID, 20);
wm.addParameter(&custom_mdns_name);

wm.setHostname(config.mdnsID);

if (!wm.autoConnect(WIFI_SETUP_AP_NAME, WIFI_SETUP_AP_PASS)) {
Log.warning(F("Failed to connect and/or hit timeout. Restarting" CR));
Log.warning(F("Failed to connect and/or hit timeout. Restarting." CR));
ESP.restart();
} else {
// We finished with portal (We were configured)
Expand All @@ -79,19 +78,19 @@ void initWiFi() {
if (shouldSaveConfig) {
// If we connected, then let's save the mDNS name
LCBUrl url;
// If the mDNS name is valid, save it.
if (url.isValidHostName(custom_mdns_name.getValue())) {
strlcpy(config.mdnsID, custom_mdns_name.getValue(), 31);
strcpy(mdns_id, config.mdnsID);

// TODO - Probably have to re-connect via WiFiManager and wm.setHostname(config.mdnsID);
} else {
// If the mDNS name is invalid, reset the WiFi configuration and restart
// the ESP8266
// TODO - add an LCD error message here maybe
disconnectWiFi();
if (strcmp(custom_mdns_name.getValue(), config.mdnsID) != 0) {
// If the mDNS name is valid, save it.
if (url.isValidHostName(custom_mdns_name.getValue())) {
strlcpy(config.mdnsID, custom_mdns_name.getValue(), 31);
saveConfig();
// Doing this to reset the DHCP name, the portal should never pop
ESP.restart();
} else {
// If the mDNS name is invalid, reset the WiFi configuration and restart
// the ESP8266
disconnectWiFi();
}
}
saveConfig();
}

if (!MDNS.begin(config.mdnsID)) {
Expand All @@ -106,7 +105,7 @@ void initWiFi() {

// Display a screen so the user can see how to access the Tiltbridge
char mdns_url[50] = "http://";
strncat(mdns_url, mdns_id, 31);
strncat(mdns_url, config.mdnsID, 31);
strcat(mdns_url, ".local/");

char ip_address_url[25] = "http://";
Expand Down

0 comments on commit 9208067

Please sign in to comment.