move code to get allowed weekdays code into helper class
This commit is contained in:
@@ -446,6 +446,54 @@ void NukiHelper::fobActionToString(const int fobact, char* str)
|
||||
}
|
||||
}
|
||||
|
||||
void NukiHelper::weekdaysToJsonArray(int weekdaysInt, JsonArray& weekdays)
|
||||
{
|
||||
while(weekdaysInt > 0)
|
||||
{
|
||||
if(weekdaysInt >= 64)
|
||||
{
|
||||
weekdays.add("mon");
|
||||
weekdaysInt -= 64;
|
||||
continue;
|
||||
}
|
||||
if(weekdaysInt >= 32)
|
||||
{
|
||||
weekdays.add("tue");
|
||||
weekdaysInt -= 32;
|
||||
continue;
|
||||
}
|
||||
if(weekdaysInt >= 16)
|
||||
{
|
||||
weekdays.add("wed");
|
||||
weekdaysInt -= 16;
|
||||
continue;
|
||||
}
|
||||
if(weekdaysInt >= 8)
|
||||
{
|
||||
weekdays.add("thu");
|
||||
weekdaysInt -= 8;
|
||||
continue;
|
||||
}
|
||||
if(weekdaysInt >= 4)
|
||||
{
|
||||
weekdays.add("fri");
|
||||
weekdaysInt -= 4;
|
||||
continue;
|
||||
}
|
||||
if(weekdaysInt >= 2)
|
||||
{
|
||||
weekdays.add("sat");
|
||||
weekdaysInt -= 2;
|
||||
continue;
|
||||
}
|
||||
if(weekdaysInt >= 1)
|
||||
{
|
||||
weekdays.add("sun");
|
||||
weekdaysInt -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NukiHelper::printCommandResult(Nuki::CmdResult result)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "NukiConstants.h"
|
||||
#include "NukiLock.h"
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
class NukiHelper
|
||||
{
|
||||
@@ -19,5 +20,7 @@ public:
|
||||
static void homeKitStatusToString(const int hkstatus, char* str);
|
||||
static void fobActionToString(const int fobact, char* str);
|
||||
|
||||
static void weekdaysToJsonArray(int weekdaysInt, JsonArray& weekdays);
|
||||
|
||||
static void printCommandResult(Nuki::CmdResult result);
|
||||
};
|
||||
Reference in New Issue
Block a user