119 lines
1.8 KiB
C++
119 lines
1.8 KiB
C++
#include "screen/menu.h"
|
|
#include "config.h"
|
|
#include "buzzer.h"
|
|
#include "display.h"
|
|
|
|
#include "menu/time.h"
|
|
|
|
|
|
MenuScreen::MenuScreen(ScreenManager* screenManager) : BaseScreen(screenManager)
|
|
{
|
|
mCount = 3;
|
|
mItems = new MenuItem*[mCount];
|
|
|
|
mItems[0] = new TimeMenuItem();
|
|
mItems[1] = new TimeMenuItem();
|
|
mItems[2] = new TimeMenuItem();
|
|
}
|
|
|
|
|
|
MenuScreen::~MenuScreen()
|
|
{
|
|
for (uint8_t i = 0; i < mCount; i++)
|
|
delete mItems[i];
|
|
|
|
delete[] mItems;
|
|
}
|
|
|
|
|
|
void MenuScreen::onShow()
|
|
{
|
|
printFullUpdate();
|
|
}
|
|
|
|
|
|
void MenuScreen::onHide()
|
|
{
|
|
}
|
|
|
|
|
|
void MenuScreen::printFullUpdate()
|
|
{
|
|
printTitle();
|
|
printScrollIndicators();
|
|
printValue();
|
|
}
|
|
|
|
|
|
void MenuScreen::printTitle()
|
|
{
|
|
LCDPrintLineCentered(getDisplay(), 0, mItems[mSelected]->getTitle(), 1);
|
|
}
|
|
|
|
|
|
void MenuScreen::printScrollIndicators()
|
|
{
|
|
LiquidCrystal* display = getDisplay();
|
|
|
|
display->setCursor(0, 0);
|
|
if (mSelected > 0)
|
|
display->write(mEditing ? LCDCharArrowLeftHollow : LCDCharArrowLeft);
|
|
else
|
|
display->write(' ');
|
|
|
|
display->setCursor(LCDWidth - 1, 0);
|
|
if (mSelected < mCount - 1)
|
|
display->write(mEditing ? LCDCharArrowRightHollow : LCDCharArrowRight);
|
|
else
|
|
display->write(' ');
|
|
}
|
|
|
|
|
|
void MenuScreen::printValue()
|
|
{
|
|
LiquidCrystal* display = getDisplay();
|
|
|
|
display->setCursor(0, 1);
|
|
for (uint8_t x = 0; x < LCDWidth; x++)
|
|
display->write(' ');
|
|
}
|
|
|
|
|
|
|
|
void MenuScreen::onButton()
|
|
{
|
|
}
|
|
|
|
|
|
void MenuScreen::onEncoder(long lastPosition, long newPosition)
|
|
{
|
|
if (!mEditing)
|
|
{
|
|
if (newPosition > lastPosition)
|
|
{
|
|
if (mSelected < mCount - 1)
|
|
{
|
|
Buzzer::select();
|
|
mSelected++;
|
|
|
|
printFullUpdate();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (mSelected > 0)
|
|
{
|
|
Buzzer::select();
|
|
mSelected--;
|
|
|
|
printFullUpdate();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void MenuScreen::onTick()
|
|
{
|
|
}
|