Skip to content

Commit

Permalink
Merge remote-tracking branch 'tbnobody/OpenDTU/master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Nov 17, 2023
2 parents 0085970 + 859b902 commit dd8446d
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 191 deletions.
1 change: 0 additions & 1 deletion include/SunPosition.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class SunPositionClass {
bool getDoRecalc();

SunSet _sun;
bool _isDayPeriod = true;
bool _isSunsetAvailable = true;
uint32_t _sunriseMinutes = 0;
uint32_t _sunsetMinutes = 0;
Expand Down
13 changes: 8 additions & 5 deletions src/SunPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ void SunPositionClass::loop()

bool SunPositionClass::isDayPeriod()
{
return _isDayPeriod;
if (!_isValidInfo) {
return true;
}

struct tm timeinfo;
getLocalTime(&timeinfo, 5);
uint32_t minutesPastMidnight = timeinfo.tm_hour * 60 + timeinfo.tm_min;
return (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes);
}

bool SunPositionClass::isSunsetAvailable()
Expand Down Expand Up @@ -73,7 +80,6 @@ void SunPositionClass::updateSunData()
setDoRecalc(false);

if (!gotLocalTime) {
_isDayPeriod = true;
_sunriseMinutes = 0;
_sunsetMinutes = 0;
_isValidInfo = false;
Expand Down Expand Up @@ -108,7 +114,6 @@ void SunPositionClass::updateSunData()
// If no sunset/sunrise exists (e.g. astronomical calculation in summer)
// assume it's day period
if (std::isnan(sunriseRaw) || std::isnan(sunsetRaw)) {
_isDayPeriod = true;
_isSunsetAvailable = false;
_sunriseMinutes = 0;
_sunsetMinutes = 0;
Expand All @@ -118,9 +123,7 @@ void SunPositionClass::updateSunData()

_sunriseMinutes = static_cast<int>(sunriseRaw);
_sunsetMinutes = static_cast<int>(sunsetRaw);
uint32_t minutesPastMidnight = timeinfo.tm_hour * 60 + timeinfo.tm_min;

_isDayPeriod = (minutesPastMidnight >= _sunriseMinutes) && (minutesPastMidnight < _sunsetMinutes);
_isSunsetAvailable = true;
_isValidInfo = true;
}
Expand Down
7 changes: 4 additions & 3 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "opendtu",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
Expand All @@ -18,7 +19,7 @@
"sortablejs": "^1.15.0",
"spark-md5": "^3.0.2",
"vue": "^3.3.8",
"vue-i18n": "^9.6.5",
"vue-i18n": "^9.7.0",
"vue-router": "^4.2.5"
},
"devDependencies": {
Expand All @@ -29,7 +30,7 @@
"@types/node": "^20.9.0",
"@types/sortablejs": "^1.15.5",
"@types/spark-md5": "^3.0.4",
"@vitejs/plugin-vue": "^4.4.1",
"@vitejs/plugin-vue": "^4.5.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.4.0",
"eslint": "^8.53.0",
Expand All @@ -38,7 +39,7 @@
"sass": "^1.69.5",
"terser": "^5.24.0",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vite": "^5.0.0",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-css-injected-by-js": "^3.3.0",
"vue-tsc": "^1.8.22"
Expand Down
2 changes: 1 addition & 1 deletion webapp/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import viteCompression from 'vite-plugin-compression';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'

const path = require('path')
import path from 'path'

// example 'vite.user.ts': export const proxy_target = '192.168.16.107'
let proxy_target;
Expand Down
430 changes: 249 additions & 181 deletions webapp/yarn.lock

Large diffs are not rendered by default.

Binary file modified webapp_dist/index.html.gz
Binary file not shown.
Binary file modified webapp_dist/js/app.js.gz
Binary file not shown.

0 comments on commit dd8446d

Please sign in to comment.