Skip to content

Commit af89125

Browse files
committed
refactor: Misc
1 parent 7697387 commit af89125

File tree

6 files changed

+31
-18
lines changed

6 files changed

+31
-18
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,17 @@ You can either use the aforementioned setupMode at runtime or edit the `config.c
7272

7373
 
7474

75+
## FAQ
76+
7577
**What needs to be configured?**
7678
- You always need to have at least one wifi network configured.
7779
- Depending on which pages you use you need to have the API keys they require configured (see [Pages](https://github.com/3urobeat/nodemcu-clock/#pages) for more information)
7880

7981
Everything else can be left at default.
8082

8183
**How do I get the API keys?**
82-
TBA
84+
TBA
85+
86+
**The clock won't connect to my iPhone hotpot!**
87+
Open the settings app and leave the "Personal Hotspot" page open while the clock attempts to connect to available WiFi networks.
88+
This ensures that the WiFi network is visible.

platformio.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ extra_flags =
3636
# Do not modify these settings
3737
# ------------------------------------------------------------------------------
3838
# Settings for all platforms
39-
monitor_filters =
39+
monitor_filters =
4040
default
4141
;time ;; Must be disabled for exception decoder to work
4242
build_flags =
4343
-I config ;; Includes config directory which is outside the default pio dirs
4444
${common.extra_flags} ;; Includes extra_flags var from above
45-
lib_deps =
45+
lib_deps =
4646
paulstoffregen/Time@^1.6.1
4747
arduino-libraries/NTPClient@^3.1.0
4848
ottowinter/ESPAsyncWebServer-esphome@^3.0.0
@@ -57,12 +57,12 @@ framework = arduino
5757
upload_speed = ${common.upload_speed}
5858
upload_port = ${common.upload_port}
5959
monitor_port = ${common.upload_port}
60-
monitor_filters =
60+
monitor_filters =
6161
${common.monitor_filters}
6262
esp8266_exception_decoder
6363
build_type = ${common.build_type}
6464
build_flags = ${common.build_flags}
65-
lib_deps =
65+
lib_deps =
6666
${common.lib_deps}
6767
vshymanskyy/Preferences@^2.0.0 ;; The ESP32 has a native prefs lib, the 8266 doesn't
6868

@@ -76,9 +76,9 @@ framework = arduino
7676
upload_speed = ${common.upload_speed}
7777
upload_port = ${common.upload_port}
7878
monitor_port = ${common.upload_port}
79-
monitor_filters =
79+
monitor_filters =
8080
${common.monitor_filters}
8181
esp32_exception_decoder
8282
build_type = ${common.build_type}
8383
build_flags = ${common.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
84-
lib_deps = ${common.lib_deps}
84+
lib_deps = ${common.lib_deps}

src/helpers/httpGetJson.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* Created Date: 2021-08-30 22:37:00
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2023-12-27 13:48:09
7+
* Last Modified: 2024-05-11 11:23:26
88
* Modified By: 3urobeat
99
*
10-
* Copyright (c) 2021 - 2023 3urobeat <https://github.com/3urobeat>
10+
* Copyright (c) 2021 - 2024 3urobeat <https://github.com/3urobeat>
1111
*
1212
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
1313
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
@@ -34,7 +34,9 @@ int16_t httpGetJson(const char *host, const char *path, uint16_t port, JsonHandl
3434
#ifdef CLOCK_DEBUG
3535
Serial.print("httpGetJson(): Sending GET request to: ");
3636
Serial.print(host);
37-
Serial.println(path);
37+
Serial.print(path);
38+
Serial.print(":");
39+
Serial.println(port);
3840

3941
debug(F("httpGetJson(): Creating new lib objects..."));
4042
#endif
@@ -112,7 +114,7 @@ int16_t httpGetJson(const char *host, const char *path, uint16_t port, JsonHandl
112114
wifiSecureClient->setInsecure();
113115

114116
if (wifiSecureClient->connect(host, port)) { // Only proceed if connection succeeded
115-
wifiSecureClient->print(request); // Send our GET req data over
117+
wifiSecureClient->print(request); // Send our GET req data over
116118

117119
// Get HTTP Code
118120
strncpy(buf, wifiSecureClient->readStringUntil('\r').c_str() + 9, 3); // Substring HTTP Code from "HTTP/1.1 200 OK" to "200"

src/helpers/initWifi.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2021-08-30 15:42:00
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2024-05-11 11:03:41
7+
* Last Modified: 2024-05-11 11:13:26
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2021 - 2024 3urobeat <https://github.com/3urobeat>
@@ -56,7 +56,6 @@ void initWifi(uint8_t row)
5656
#endif
5757

5858
if (strlen(thisSSID) > 0 && strcmp(thisSSID, Config::wifiSSID[j]) == 0) { // Checking if thisSSID is >0 seems to make this check a bit more reliable, not exactly sure why though
59-
6059
WiFiLib.begin(Config::wifiSSID[j], Config::wifiPW[j]);
6160

6261
found = true; // Stop parent loop

src/pages/pagesJsonParser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2023-01-12 12:40:54
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2024-05-10 11:14:45
7+
* Last Modified: 2024-05-11 11:05:39
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2023 - 2024 3urobeat <https://github.com/3urobeat>
@@ -77,9 +77,9 @@ class NewsJsonHandler final : public JsonHandler
7777
uint8_t _pubAtCacheSize;
7878
char *_titleCache;
7979
uint16_t _titleCacheSize;
80-
uint8_t _cacheSize; // Thats the amount of different articles in cache
80+
uint8_t _cacheSize; // Thats the amount of different articles in cache
8181

82-
uint8_t _currentIndex = 0; // Stores index of article we are at right now
82+
uint8_t _currentIndex = 0; // Stores index of article we are at right now
8383

8484
public:
8585
// Constructor that takes pointers to char arrays where the result should go to
@@ -109,7 +109,7 @@ class NewsJsonHandler final : public JsonHandler
109109

110110
if (_currentIndex >= _cacheSize) return; // This should never happen when the URL has the right amount of pages set but let's make sure
111111

112-
// Quick pointer arithmetic to make passing 2D arrays easier. We just pass pointer to element 0 of array to function and offset correctly inside function wiht passed sizes to reach desired element
112+
// Quick pointer arithmetic to make passing 2D arrays easier. We just pass pointer to element 0 of array to function and offset correctly inside function with passed sizes to reach desired element
113113
if (strcmp(key, "name") == 0) {
114114
strncpy(_sourceCache + (_sourceCacheSize * _currentIndex), value.getString(), _sourceCacheSize - 1);
115115

src/pages/spotify.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2023-01-17 10:39:35
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2024-05-10 11:15:07
7+
* Last Modified: 2024-05-11 11:33:13
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2023 - 2024 3urobeat <https://github.com/3urobeat>
@@ -129,7 +129,9 @@ namespace spotifyPage
129129

130130
// Don't clear/write anything if user just paused playback
131131
if (!spotifyData.currentlyPlaying) return; // Next update() iteration will immediately run and skip page
132+
132133
displayCurrentData();
134+
133135
lcd.clearLine(1);
134136
lcd.clearLine(2);
135137
lcd.clearLine(3);
@@ -147,13 +149,16 @@ namespace spotifyPage
147149
lcd.setCursor(0, 2);
148150
lcd.movingPrint(spotifyData.title, &spotifyTitleOffset, Config::maxcol);
149151

152+
150153
// Calculate progress with current timestamp and last update timestamp
151154
char buf[4] = "";
152155
uint32_t currentProgress = (millis() - spotifyLastPlaybackUpdate) + spotifyData.progressTimestamp - 1000; // Subtract last API update timestamp from now, add the difference to progressTimestamp and subtract some tolerance
153156

154157
// Set max if song ended and we need to wait for the next data refresh
155158
if (currentProgress > spotifyData.songLength) currentProgress = spotifyData.songLength;
156159

160+
161+
// Construct page content and update screen
157162
char progressStr[12] = "";
158163
char *p = progressStr;
159164

@@ -171,6 +176,7 @@ namespace spotifyPage
171176
lcd.setCursor(spaceLeft, 3);
172177
lcd.print(progressStr);
173178

179+
174180
// Display progress bar based on currentProgress
175181
uint8_t amountOfHashtags = (spaceLeft - 1) * ((float) currentProgress / (float) spotifyData.songLength); // Calculate amount of hashtags by calculating percentage and stuff lol
176182

0 commit comments

Comments
 (0)