Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion usermods/usermod_v2_skystrip/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The actual temperature→hue stops used by the renderer are:
| ≥104 | 0.0 | Red |


## 24 Hour Delta View (DV)
## 24-Hour Delta View (DV)

Hue represents the temperature change relative to the previous day:
blues for cooling, greens for steady conditions, and yellows through
Expand Down
14 changes: 12 additions & 2 deletions usermods/usermod_v2_skystrip/open_weather_map_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ static void normalizeLocation(char* q) {
}
}

// Treat two coordinates as equal if they differ by less than ~1 meter.
// 1e-5 degrees ≈ 1.11 meters at the equator; adequate for our purposes.
static inline bool nearlyEqualCoord(double a, double b, double eps = 1e-5) {
return fabs(a - b) <= eps;
}

static bool parseCoordToken(char* token, double& out) {
while (isspace((unsigned char)*token)) ++token;
bool neg = false;
Expand Down Expand Up @@ -221,7 +227,7 @@ bool OpenWeatherMapSource::readFromConfig(JsonObject &subtree,
// If the location changed update lat/long via parsing or lookup
if (location_ == lastLocation_) {
// if the user changed the lat and long directly clear the location
if (latitude_ != oldLatitude || longitude_ != oldLongitude)
if (!nearlyEqualCoord(latitude_, oldLatitude) || !nearlyEqualCoord(longitude_, oldLongitude))
location_ = "";
} else {
lastLocation_ = location_;
Expand All @@ -240,8 +246,12 @@ bool OpenWeatherMapSource::readFromConfig(JsonObject &subtree,
}

// if the lat/long changed we need to invalidate_history
if (latitude_ != oldLatitude || longitude_ != oldLongitude)
if (!nearlyEqualCoord(latitude_, oldLatitude) || !nearlyEqualCoord(longitude_, oldLongitude)) {
DEBUG_PRINTF("SkyStrip::OWM::readFromConfig lat/long changed"
" oldLat=%f, newLat=%f, oldLng=%f, newLng=%f\n",
oldLatitude, latitude_, oldLongitude, longitude_);
invalidate_history = true;
}

return configComplete;
}
Expand Down
13 changes: 13 additions & 0 deletions usermods/usermod_v2_skystrip/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ Enter the latitude and longitude for the desired forecast. You can:

Please see the [Interpretation FAQ](./FAQ.md) for more information on how to
interpret the forecast views.

## Hardware/Platform notes

- SkyStrip was developed/tested using the
[Athom esp32-based LED strip controller](https://www.athom.tech/blank-1/wled-esp32-rf433-music-addressable-led-strip-controller).
- I use a display consisting of 4 parallel 1-meter long
[WS2815 strips](https://www.superlightingled.com/dc12v-ws2815-upgraded-ws2812b-1m-144-leds-individually-addressable-digital-led-strip-lights-dual-signal-wires-waterproof-dream-color-programmable-5050-rgb-flexible-led-ribbon-light-p-2134:fd57dd8a8ac1ee0e78f5493a35b28792.html)
- SkyStrip makes 25 API calls to the
[OpenWeatherMap One Call API](https://openweathermap.org/api/one-call-3)
when it first starts running and one API call per hour after that.
- Based on comparisons with a baseline build SkyStrip uses:
* RAM: +2080 bytes
* Flash: +153,812 bytes
5 changes: 5 additions & 0 deletions usermods/usermod_v2_skystrip/usermod_v2_skystrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,20 @@ bool SkyStrip::readFromConfig(JsonObject& root) {
for (auto& src : sources_) {
JsonObject sub1 = top[src->configKey()];
ok &= src->readFromConfig(sub1, startup_complete, invalidate_history);
DEBUG_PRINTF("SkyStrip:readFromConfig: after source %s invalidate_history=%d\n",
src->name().c_str(), invalidate_history);
}

// read the views
for (auto& vw : views_) {
JsonObject sub2 = top[vw->configKey()];
ok &= vw->readFromConfig(sub2, startup_complete, invalidate_history);
DEBUG_PRINTF("SkyStrip:readFromConfig: after view %s invalidate_history=%d\n",
vw->name().c_str(), invalidate_history);
}

if (invalidate_history) {
DEBUG_PRINTLN(F("SkyStrip::readFromConfig invalidating history"));
time_t const now = skystrip::util::time_now_utc();
model_->invalidate_history(now);
if (startup_complete) reloadSources(now); // not safe during startup
Expand Down