You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

62 lines
1.3 KiB

#include <ControlStates.h>
ControlTextState::ControlTextState(AT24C32 &_at24c32)
{
at24c32 = _at24c32;
}
void ControlTextState::leftPressed(ViewStates &viewState, ControlStates &controlState)
{
uint8_t length = at24c32.read(TEXT_SIZE_ADDRESS);
if (length > 2)
{
length--;
at24c32.write(TEXT_SIZE_ADDRESS, length);
}
};
void ControlTextState::rightPressed(ViewStates &viewState, ControlStates &controlState)
{
uint8_t length = at24c32.read(TEXT_SIZE_ADDRESS);
if (length < 0xFF)
{
length++;
at24c32.write(TEXT_SIZE_ADDRESS, length);
}
};
void ControlTextState::enterPressed(ViewStates &viewState, ControlStates &controlState)
{
controlState = ControlStates::VIEW;
};
void ControlTextState::decrementPressed(ViewStates &viewState, ControlStates &controlState)
{
uint8_t position = at24c32.read(TEXT_SIZE_ADDRESS) - 1;
uint8_t char1 = at24c32.read(TEXT_ADDRESS + position);
if (char1 > 0)
{
char1--;
}
else
{
char1 = 0xFF;
}
at24c32.write(TEXT_ADDRESS + position, char1);
};
void ControlTextState::incrementPressed(ViewStates &viewState, ControlStates &controlState)
{
uint8_t position = at24c32.read(TEXT_SIZE_ADDRESS) - 1;
uint8_t char1 = at24c32.read(TEXT_ADDRESS + position);
if (char1 < 0xFF)
{
char1++;
}
else
{
char1 = 0;
}
at24c32.write(TEXT_ADDRESS + position, char1);
};