92 lines
2.2 KiB
C++
92 lines
2.2 KiB
C++
#include <ControlStates.h>
|
|
|
|
ControlViewState::ControlViewState(AT24C32 &_at24c32)
|
|
{
|
|
at24c32 = _at24c32;
|
|
}
|
|
|
|
void ControlViewState::leftPressed(ViewStates &viewState, ControlStates &controlState)
|
|
{
|
|
switch (viewState)
|
|
{
|
|
case ViewStates::TIME:
|
|
viewState = ViewStates::LED_DEMO;
|
|
break;
|
|
case ViewStates::TEMPERATURE:
|
|
viewState = ViewStates::TIME;
|
|
break;
|
|
case ViewStates::SECONDS:
|
|
viewState = ViewStates::TEMPERATURE;
|
|
break;
|
|
case ViewStates::DATE:
|
|
viewState = ViewStates::SECONDS;
|
|
break;
|
|
case ViewStates::TEXT:
|
|
viewState = ViewStates::DATE;
|
|
break;
|
|
case ViewStates::LED_DEMO:
|
|
viewState = ViewStates::TEXT;
|
|
break;
|
|
}
|
|
};
|
|
|
|
void ControlViewState::rightPressed(ViewStates &viewState, ControlStates &controlState)
|
|
{
|
|
switch (viewState)
|
|
{
|
|
case ViewStates::TIME:
|
|
viewState = ViewStates::TEMPERATURE;
|
|
break;
|
|
case ViewStates::TEMPERATURE:
|
|
viewState = ViewStates::SECONDS;
|
|
break;
|
|
case ViewStates::SECONDS:
|
|
viewState = ViewStates::DATE;
|
|
break;
|
|
case ViewStates::DATE:
|
|
viewState = ViewStates::TEXT;
|
|
break;
|
|
case ViewStates::TEXT:
|
|
viewState = ViewStates::LED_DEMO;
|
|
break;
|
|
case ViewStates::LED_DEMO:
|
|
viewState = ViewStates::TIME;
|
|
break;
|
|
}
|
|
};
|
|
|
|
void ControlViewState::enterPressed(ViewStates &viewState, ControlStates &controlState)
|
|
{
|
|
switch (viewState)
|
|
{
|
|
case ViewStates::TIME:
|
|
controlState = ControlStates::TIME_HOURS;
|
|
break;
|
|
case ViewStates::SECONDS:
|
|
controlState = ControlStates::TIME_SECONDS;
|
|
break;
|
|
case ViewStates::DATE:
|
|
controlState = ControlStates::DATE_DATE;
|
|
break;
|
|
case ViewStates::TEXT:
|
|
controlState = ControlStates::TEXT;
|
|
break;
|
|
case ViewStates::LED_DEMO:
|
|
controlState = ControlStates::COLOR_R;
|
|
break;
|
|
}
|
|
};
|
|
|
|
void ControlViewState::decrementPressed(ViewStates &viewState, ControlStates &controlState)
|
|
{
|
|
uint8_t value = at24c32.read(BRIGHTNESS_ADDRESS);
|
|
value = (value - 5) % 256;
|
|
at24c32.write(BRIGHTNESS_ADDRESS, value);
|
|
};
|
|
|
|
void ControlViewState::incrementPressed(ViewStates &viewState, ControlStates &controlState)
|
|
{
|
|
uint8_t value = at24c32.read(BRIGHTNESS_ADDRESS);
|
|
value = (value + 5) % 256;
|
|
at24c32.write(BRIGHTNESS_ADDRESS, value);
|
|
}; |