Skip to content

Commit

Permalink
Fixes a lot of compile errors when using Arduino > 1.8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
CelliesProjects committed Sep 28, 2018
1 parent ff90efb commit 12f4253
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 66 deletions.
2 changes: 2 additions & 0 deletions aquacontrol32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ enum lightStatus_t
LIGHTS_OFF, LIGHTS_ON, LIGHTS_AUTO
};

const char *lightStatusToString( const lightStatus_t status );

const char *lightStatusToString( const lightStatus_t status )
{
switch ( status )
Expand Down
132 changes: 66 additions & 66 deletions dimmertask.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,69 @@
bool defaultTimersLoaded()
{
//find 'default.aqu' on selected storage and if present load the timerdata from this file
//return true on success
//return false on error

if ( !SPIFFS.exists( defaultTimerFile ) )
{
ESP_LOGI( TAG, "No default timer file found. [%s]", defaultTimerFile );
return false;
}

File f = SPIFFS.open( defaultTimerFile, "r" );

if ( !f.available() )
{
ESP_LOGI( TAG, "Error opening default timer file. [%s]", defaultTimerFile );
return false;
}
String lineBuf;
byte currentTimer = 0;
byte thisChannel;
while ( f.position() < f.size() )
{
lineBuf = f.readStringUntil( '\n' );
if ( lineBuf.indexOf( "[" ) > -1 )
{
String thisChannelStr;
thisChannelStr = lineBuf.substring( lineBuf.indexOf("[") + 1, lineBuf.indexOf("]") );
thisChannel = thisChannelStr.toInt();
currentTimer = 0;
}
else
{
String thisPercentage;
String thisTime;
thisTime = lineBuf.substring( 0, lineBuf.indexOf(",") );
thisPercentage = lineBuf.substring( lineBuf.indexOf(",") + 1 );
channel[thisChannel].timer[currentTimer].time = thisTime.toInt();
channel[thisChannel].timer[currentTimer].percentage = thisPercentage.toInt();
currentTimer++;
channel[thisChannel].numberOfTimers = currentTimer;
}
}
f.close();
//add the 24:00 timers ( copy of timer percentage no: 0 )
for ( thisChannel = 0; thisChannel < NUMBER_OF_CHANNELS; thisChannel++ )
{
channel[thisChannel].timer[channel[thisChannel].numberOfTimers].time = 86400;
channel[thisChannel].timer[channel[thisChannel].numberOfTimers].percentage = channel[thisChannel].timer[0].percentage;
}
return true;
}

void setEmptyTimers()
{
for ( byte channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++)
{
channel[channelNumber].timer[0].time = 0;
channel[channelNumber].timer[0].percentage = 0;
channel[channelNumber].timer[1].time = 86400;
channel[channelNumber].timer[1].percentage = 0;
channel[channelNumber].numberOfTimers = 1;
}
}

void IRAM_ATTR dimmerTask ( void * pvParameters )
{
const TickType_t dimmerTaskdelayTime = 1000 / UPDATE_FREQ_LEDS / portTICK_PERIOD_MS;
Expand Down Expand Up @@ -148,69 +214,3 @@ static inline __attribute__((always_inline)) void lightsAuto()
lightStatus = LIGHTS_AUTO;
vTaskResume( xDimmerTaskHandle );
}

bool defaultTimersLoaded()
{
//find 'default.aqu' on selected storage and if present load the timerdata from this file
//return true on success
//return false on error

if ( !SPIFFS.exists( defaultTimerFile ) )
{
ESP_LOGI( TAG, "No default timer file found. [%s]", defaultTimerFile );
return false;
}

File f = SPIFFS.open( defaultTimerFile, "r" );

if ( !f.available() )
{
ESP_LOGI( TAG, "Error opening default timer file. [%s]", defaultTimerFile );
return false;
}
String lineBuf;
byte currentTimer = 0;
byte thisChannel;
while ( f.position() < f.size() )
{
lineBuf = f.readStringUntil( '\n' );
if ( lineBuf.indexOf( "[" ) > -1 )
{
String thisChannelStr;
thisChannelStr = lineBuf.substring( lineBuf.indexOf("[") + 1, lineBuf.indexOf("]") );
thisChannel = thisChannelStr.toInt();
currentTimer = 0;
}
else
{
String thisPercentage;
String thisTime;
thisTime = lineBuf.substring( 0, lineBuf.indexOf(",") );
thisPercentage = lineBuf.substring( lineBuf.indexOf(",") + 1 );
channel[thisChannel].timer[currentTimer].time = thisTime.toInt();
channel[thisChannel].timer[currentTimer].percentage = thisPercentage.toInt();
currentTimer++;
channel[thisChannel].numberOfTimers = currentTimer;
}
}
f.close();
//add the 24:00 timers ( copy of timer percentage no: 0 )
for ( thisChannel = 0; thisChannel < NUMBER_OF_CHANNELS; thisChannel++ )
{
channel[thisChannel].timer[channel[thisChannel].numberOfTimers].time = 86400;
channel[thisChannel].timer[channel[thisChannel].numberOfTimers].percentage = channel[thisChannel].timer[0].percentage;
}
return true;
}

void setEmptyTimers()
{
for ( byte channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++)
{
channel[channelNumber].timer[0].time = 0;
channel[channelNumber].timer[0].percentage = 0;
channel[channelNumber].timer[1].time = 86400;
channel[channelNumber].timer[1].percentage = 0;
channel[channelNumber].numberOfTimers = 1;
}
}

0 comments on commit 12f4253

Please sign in to comment.