wordclock/libraries/States/ControlDateState.cpp

77 lines
1.7 KiB
C++
Raw Permalink Normal View History

2019-02-13 19:27:22 +01:00
#include <ControlStates.h>
ControlDateState::ControlDateState(DS3231 &_ds3231)
{
ds3231 = _ds3231;
}
void ControlDateState::leftPressed(ViewStates &viewState, ControlStates &controlState)
{
switch (controlState)
{
case ControlStates::DATE_YEAR:
controlState = ControlStates::DATE_MONTH;
break;
case ControlStates::DATE_MONTH:
controlState = ControlStates::DATE_DATE;
break;
case ControlStates::DATE_DATE:
controlState = ControlStates::DATE_YEAR;
break;
}
};
void ControlDateState::rightPressed(ViewStates &viewState, ControlStates &controlState)
{
switch (controlState)
{
case ControlStates::DATE_DATE:
controlState = ControlStates::DATE_MONTH;
break;
case ControlStates::DATE_MONTH:
controlState = ControlStates::DATE_YEAR;
break;
case ControlStates::DATE_YEAR:
controlState = ControlStates::DATE_DATE;
break;
}
};
void ControlDateState::enterPressed(ViewStates &viewState, ControlStates &controlState)
{
controlState = ControlStates::VIEW;
};
void ControlDateState::decrementPressed(ViewStates &viewState, ControlStates &controlState)
{
switch (controlState)
{
case ControlStates::DATE_DATE:
ds3231.decrementDate();
break;
case ControlStates::DATE_MONTH:
ds3231.decrementMonth();
break;
case ControlStates::DATE_YEAR:
ds3231.decrementYear();
break;
}
};
void ControlDateState::incrementPressed(ViewStates &viewState, ControlStates &controlState)
{
switch (controlState)
{
case ControlStates::DATE_DATE:
ds3231.incrementDate();
break;
case ControlStates::DATE_MONTH:
ds3231.incrementMonth();
break;
case ControlStates::DATE_YEAR:
ds3231.incrementYear();
break;
}
};