From 627d3deed7c3c419c3a9f4360d2f90b542938ac6 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Sun, 22 Apr 2018 10:39:07 +0200 Subject: [PATCH] Fixed compiler warnings --- gulpfile.js | 2 +- src/assets/version.h | 2 +- src/config.cpp | 46 ++++++++++++++++++++++++++++++++++ src/config.h | 39 +++++++++++++--------------- src/settings/steps.h | 4 +-- src/settings/triggers/time.cpp | 7 ++++-- 6 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 src/config.cpp diff --git a/gulpfile.js b/gulpfile.js index c7b95c0..69d2266 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -207,7 +207,7 @@ gulp.task('embedVersion', function(cb) headerFile += "const uint8_t VersionMajor = " + version.Major + ";\r\n"; headerFile += "const uint8_t VersionMinor = " + version.Minor + ";\r\n"; headerFile += "const uint8_t VersionPatch = " + version.Patch + ";\r\n"; - headerFile += "const uint8_t VersionMetadata = " + version.BuildMetaData + ";\r\n"; + headerFile += "const uint8_t VersionMetadata = " + (version.BuildMetaData ? version.BuildMetaData : '0') + ";\r\n"; headerFile += "const char VersionBranch[] = \"" + version.BranchName + "\";\r\n"; diff --git a/src/assets/version.h b/src/assets/version.h index f8f8ae5..563e4f5 100644 --- a/src/assets/version.h +++ b/src/assets/version.h @@ -4,7 +4,7 @@ const uint8_t VersionMajor = 2; const uint8_t VersionMinor = 1; const uint8_t VersionPatch = 0; -const uint8_t VersionMetadata = ; +const uint8_t VersionMetadata = 0; const char VersionBranch[] = "develop"; const char VersionSemVer[] = "2.1.0-unstable.3"; const char VersionFullSemVer[] = "2.1.0-unstable.3"; diff --git a/src/config.cpp b/src/config.cpp new file mode 100644 index 0000000..3e289ac --- /dev/null +++ b/src/config.cpp @@ -0,0 +1,46 @@ +/* + * Stairs + * Copyright 2017 (c) Mark van Renswoude + * + * https://git.x2software.net/pub/Stairs +*/ +#include "./config.h" + +#ifdef SerialDebug +const uint32_t SerialDebugBaudrate = 115200; +const uint32_t SerialDebugStartupDelay = 2000; +#endif + + +const char* ConnectionSettingsFile = "/connection.json"; +const char* SystemSettingsFile = "/system.json"; +const char* StepsSettingsFile = "/steps.json"; +const char* TimeTriggerSettingsFile = "/timetriggers.json"; +const char* MotionTriggerSettingsFile = "/motiontriggers.json"; + + +const char* DefaultAPSSIDPrefix = "Stairs-"; + +const char* DefaultNTPServer = "pool.ntp.org"; + +// Timeout when in AP + station mode (otherwise trying to connect +// to the STA will block the AP) +const uint32_t StationModeTimeout = 30000; + +const uint16_t APButtonHoldTime = 2000; + + +// Only used if the timezone has not been succesfully retrieved yet, otherwise +// the configurable NTP interval is used +const uint32_t TimezoneRetryInterval = 60000; + + +#ifdef MapsAPIViaProxyScript +const char* TimezoneProxyScriptHost = "api.x2software.net"; +const char* TimezoneProxyScriptPath = "/timezone.php"; +#endif + + +const uint8_t InitialisationBrightness = 40; +const uint8_t InitialisationFadeTime = 250; +const uint8_t InitialisationBlinkCount = 2; diff --git a/src/config.h b/src/config.h index ab9d6c9..010da09 100644 --- a/src/config.h +++ b/src/config.h @@ -20,32 +20,27 @@ #ifdef SerialDebug -static const uint32_t SerialDebugBaudrate = 115200; -static const uint32_t SerialDebugStartupDelay = 2000; +extern const uint32_t SerialDebugBaudrate; +extern const uint32_t SerialDebugStartupDelay; #endif -static const char* ConnectionSettingsFile = "/connection.json"; -static const char* SystemSettingsFile = "/system.json"; -static const char* StepsSettingsFile = "/steps.json"; -static const char* TimeTriggerSettingsFile = "/timetriggers.json"; -static const char* MotionTriggerSettingsFile = "/motiontriggers.json"; +extern const char* ConnectionSettingsFile; +extern const char* SystemSettingsFile; +extern const char* StepsSettingsFile; +extern const char* TimeTriggerSettingsFile; +extern const char* MotionTriggerSettingsFile; -static const char* DefaultAPSSIDPrefix = "Stairs-"; +extern const char* DefaultAPSSIDPrefix; -static const char* DefaultNTPServer = "pool.ntp.org"; +extern const char* DefaultNTPServer; -// Timeout when in AP + station mode (otherwise trying to connect -// to the STA will block the AP) -static const uint32_t StationModeTimeout = 30000; - -static const uint16_t APButtonHoldTime = 2000; +extern const uint32_t StationModeTimeout; +extern const uint16_t APButtonHoldTime; -// Only used if the timezone has not been succesfully retrieved yet, otherwise -// the configurable NTP interval is used -static const uint32_t TimezoneRetryInterval = 60000; +extern const uint32_t TimezoneRetryInterval; // SSL takes quite a bit of memory (and I haven't been optimizing much), @@ -66,13 +61,13 @@ static const uint32_t TimezoneRetryInterval = 60000; #define MapsAPIViaProxyScript #ifdef MapsAPIViaProxyScript -static const char* TimezoneProxyScriptHost = "api.x2software.net"; -static const char* TimezoneProxyScriptPath = "/timezone.php"; +extern const char* TimezoneProxyScriptHost; +extern const char* TimezoneProxyScriptPath; #endif -static const uint8_t InitialisationBrightness = 40; -static const uint8_t InitialisationFadeTime = 250; -static const uint8_t InitialisationBlinkCount = 2; +extern const uint8_t InitialisationBrightness; +extern const uint8_t InitialisationFadeTime; +extern const uint8_t InitialisationBlinkCount; #endif \ No newline at end of file diff --git a/src/settings/steps.h b/src/settings/steps.h index 6d16b54..f05df9e 100644 --- a/src/settings/steps.h +++ b/src/settings/steps.h @@ -48,10 +48,10 @@ class StepsSettings : public AbstractJsonSettings void useCurve(bool value) { mUseCurve = value; } uint16_t rangeStart(uint8_t step) { return step < MaxStepCount ? mRange[step].start : 0; } - uint16_t rangeStart(uint8_t step, uint16_t value) { if (step < MaxStepCount) mRange[step].start = value; } + void rangeStart(uint8_t step, uint16_t value) { if (step < MaxStepCount) mRange[step].start = value; } uint16_t rangeEnd(uint8_t step) { return step < MaxStepCount ? mRange[step].end : 0; } - uint16_t rangeEnd(uint8_t step, uint16_t value) { if (step < MaxStepCount) mRange[step].end = value; } + void rangeEnd(uint8_t step, uint16_t value) { if (step < MaxStepCount) mRange[step].end = value; } }; #endif \ No newline at end of file diff --git a/src/settings/triggers/time.cpp b/src/settings/triggers/time.cpp index fce1b15..5737465 100644 --- a/src/settings/triggers/time.cpp +++ b/src/settings/triggers/time.cpp @@ -39,9 +39,8 @@ DayOfWeek toDayOfWeek(timeDayOfWeek_t timeDay) case dowThursday: return Thursday; case dowFriday: return Friday; case dowSaturday: return Saturday; + default: return Monday; } - - return Monday; } @@ -163,6 +162,10 @@ TimeTrigger* TimeTriggerSettings::getActiveTrigger(tmElements_t &time) case RelativeToSunset: triggerTime += sunsetMinutes; break; + + case FixedTime: + // No changes (but eliminates warning) + break; } // Check if the current time is after the time set in the trigger, and