From ee289159b6089b46126250fbd933062913fc255c Mon Sep 17 00:00:00 2001 From: Stephen White Date: Tue, 12 Jun 2018 19:03:29 +1000 Subject: [PATCH] Added the ability to have floating point values in the options.txt file. --- src/options.cpp | 17 +++++++++++++++++ src/options.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/options.cpp b/src/options.cpp index bb980da..26c3b31 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -17,6 +17,8 @@ // along with Pi1541. If not, see . #include "options.h" +#include +#include #include #include #include @@ -158,6 +160,13 @@ Options::Options(void) if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) \ Name = nValue; \ } +#define ELSE_CHECK_FLOAT_OPTION(Name) \ + else if (strcasecmp(pOption, #Name) == 0) \ + { \ + unsigned nValue = 0; \ + if ((nValue = GetFloat(pValue)) != INVALID_VALUE) \ + Name = nValue; \ + } void Options::Process(char* buffer) { @@ -267,6 +276,14 @@ unsigned Options::GetDecimal(char* pString) return nResult; } +float Options::GetFloat(char* pString) +{ + if (pString == 0 || *pString == '\0') + return 0; + + return atof(pString); +} + const char* Options::GetRomName(int index) const { switch (index) diff --git a/src/options.h b/src/options.h index 2cd6d37..aa80a2b 100644 --- a/src/options.h +++ b/src/options.h @@ -76,6 +76,7 @@ public: const char* GetLCDName() const { return LCDName; } static unsigned GetDecimal(char* pString); + static float GetFloat(char* pString); private: unsigned int deviceID;