Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
617fa3fbd2 | |||
ad65d4e233 | |||
6fc1b2ad80 |
@ -10,14 +10,14 @@
|
||||
|
||||
[env:attiny85]
|
||||
platform = atmelavr
|
||||
board = pro16MHzatmega328
|
||||
board = pro8MHzatmega328
|
||||
framework = arduino
|
||||
|
||||
;upload_protocol = stk500v1
|
||||
;upload_flags = -P$UPLOAD_PORT -b$UPLOAD_SPEED
|
||||
;upload_speed = 19200
|
||||
upload_protocol = stk500v1
|
||||
upload_flags = -P$UPLOAD_PORT -b$UPLOAD_SPEED -e
|
||||
upload_speed = 19200
|
||||
|
||||
board_f_cpu = 16000000L
|
||||
board_f_cpu = 8000000L
|
||||
|
||||
lib_deps =
|
||||
Bounce2
|
||||
|
@ -8,7 +8,7 @@ void LCDPrintLine(LiquidCrystal* display, uint8_t y, const char* value, uint8_t
|
||||
|
||||
uint8_t width = LCDWidth - (2 * margin);
|
||||
|
||||
if (value != NULL)
|
||||
if (value != nullptr)
|
||||
{
|
||||
uint8_t length = strlen(value);
|
||||
|
||||
@ -47,7 +47,7 @@ void LCDPrintLineCentered(LiquidCrystal* display, uint8_t y, const char* value,
|
||||
|
||||
uint8_t width = LCDWidth - (2 * margin);
|
||||
|
||||
if (value != NULL)
|
||||
if (value != nullptr)
|
||||
{
|
||||
uint8_t length = strlen(value);
|
||||
|
||||
@ -119,7 +119,6 @@ const char* FormatPercentage(uint8_t percentage)
|
||||
{
|
||||
char* value = new char[6];
|
||||
|
||||
|
||||
itoa(percentage, value, 10);
|
||||
|
||||
uint8_t length = strlen(value);
|
||||
|
27
src/menu/reset.cpp
Normal file
27
src/menu/reset.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "reset.h"
|
||||
#include "state.h"
|
||||
#include "display.h"
|
||||
#include "Config.h"
|
||||
#include "screen/reset.h"
|
||||
|
||||
const char* ResetMenuItem::getTitle()
|
||||
{
|
||||
return UniqueString("Reset");
|
||||
}
|
||||
|
||||
|
||||
const char* ResetMenuItem::getValue()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void ResetMenuItem::execute(ScreenManager* screenManager, uint32_t currentTime)
|
||||
{
|
||||
SetExposureTime(DefaultExposureTime);
|
||||
SetExposureIntensity(DefaultExposureIntensity);
|
||||
SetBuzzer(BuzzerSetting::CompletedButtonStartup);
|
||||
SaveSettings();
|
||||
|
||||
screenManager->show<ResetScreen>();
|
||||
}
|
19
src/menu/reset.h
Normal file
19
src/menu/reset.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef __resetmenuitem
|
||||
#define __resetmenuitem
|
||||
|
||||
#include "screen/menu.h"
|
||||
|
||||
class ResetMenuItem : public MenuItem
|
||||
{
|
||||
public:
|
||||
ResetMenuItem() : MenuItem() { }
|
||||
|
||||
const char* getTitle();
|
||||
const char* getValue();
|
||||
|
||||
bool editable() { return false; }
|
||||
|
||||
void execute(ScreenManager* screenManager, uint32_t currentTime);
|
||||
};
|
||||
|
||||
#endif
|
@ -28,7 +28,7 @@ const char* SoundMenuItem::getValue()
|
||||
return UniqueString("None");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ class ScreenManager
|
||||
LiquidCrystal* mDisplay;
|
||||
uint32_t* mCurrentTime;
|
||||
|
||||
BaseScreen* mCurrent = NULL;
|
||||
BaseScreen* mCurrent = nullptr;
|
||||
|
||||
public:
|
||||
ScreenManager(LiquidCrystal* display, uint32_t* currentTime)
|
||||
@ -69,7 +69,7 @@ class ScreenManager
|
||||
|
||||
template<class T> void show()
|
||||
{
|
||||
if (mCurrent != NULL)
|
||||
if (mCurrent != nullptr)
|
||||
{
|
||||
mCurrent->onHide();
|
||||
delete mCurrent;
|
||||
|
@ -14,7 +14,9 @@ inline uint32_t intDivCeil(uint32_t x, uint32_t y)
|
||||
|
||||
void CountdownScreen::printRemainingTime()
|
||||
{
|
||||
LCDPrintLineCentered(getDisplay(), 1, FormatTime(mLastDisplayed));
|
||||
const char* time = FormatTime(mLastDisplayed);
|
||||
LCDPrintLineCentered(getDisplay(), 1, time);
|
||||
delete[] time;
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,17 +8,19 @@
|
||||
#include "menu/time.h"
|
||||
#include "menu/intensity.h"
|
||||
#include "menu/sound.h"
|
||||
#include "menu/reset.h"
|
||||
|
||||
|
||||
MenuScreen::MenuScreen(ScreenManager* screenManager) : BaseScreen(screenManager)
|
||||
{
|
||||
mCount = 4;
|
||||
mCount = 5;
|
||||
mItems = new MenuItem*[mCount];
|
||||
|
||||
mItems[0] = new StartMenuItem();
|
||||
mItems[1] = new TimeMenuItem();
|
||||
mItems[2] = new IntensityMenuItem();
|
||||
mItems[3] = new SoundMenuItem();
|
||||
mItems[4] = new ResetMenuItem();
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +57,7 @@ void MenuScreen::printTitle()
|
||||
const char* title = mItems[mSelected]->getTitle();
|
||||
LCDPrintLineCentered(getDisplay(), 0, title, 1);
|
||||
|
||||
if (title != NULL)
|
||||
if (title != nullptr)
|
||||
delete[] title;
|
||||
}
|
||||
|
||||
@ -84,7 +86,7 @@ void MenuScreen::printValue()
|
||||
|
||||
const char* value = mItems[mSelected]->getValue();
|
||||
|
||||
if (mEditing && value != NULL)
|
||||
if (mEditing && value != nullptr)
|
||||
{
|
||||
uint8_t valueLength = strlen(value);
|
||||
char* editingValue = new char[valueLength + 5];
|
||||
@ -115,7 +117,7 @@ void MenuScreen::printValue()
|
||||
else
|
||||
LCDPrintLineCentered(display, 1, value);
|
||||
|
||||
if (value != NULL)
|
||||
if (value != nullptr)
|
||||
delete[] value;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ class MenuItem
|
||||
virtual ~MenuItem() { }
|
||||
|
||||
virtual const char* getTitle() = 0;
|
||||
virtual const char* getValue() { return NULL; }
|
||||
virtual const char* getValue() { return nullptr; }
|
||||
|
||||
virtual bool editable() { return false; }
|
||||
|
||||
|
37
src/screen/reset.cpp
Normal file
37
src/screen/reset.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "reset.h"
|
||||
#include "screen/menu.h"
|
||||
#include "display.h"
|
||||
#include "state.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
void ResetScreen::onShow()
|
||||
{
|
||||
LCDPrintLineCentered(getDisplay(), 0, "Settings reset!");
|
||||
LCDPrintLineCentered(getDisplay(), 1, nullptr);
|
||||
|
||||
mStart = getCurrentTime();
|
||||
}
|
||||
|
||||
|
||||
void ResetScreen::onHide()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ResetScreen::onButton()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ResetScreen::onEncoder(int32_t lastPosition, int32_t newPosition)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ResetScreen::onTick()
|
||||
{
|
||||
if (getCurrentTime() - mStart >= 2000)
|
||||
getScreenManager()->show<MenuScreen>();
|
||||
}
|
||||
|
26
src/screen/reset.h
Normal file
26
src/screen/reset.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef __reset
|
||||
#define __reset
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
/*
|
||||
* Reset screen
|
||||
* Shows that you just lost all data. And the game.
|
||||
*/
|
||||
class ResetScreen : public BaseScreen
|
||||
{
|
||||
private:
|
||||
uint32_t mStart;
|
||||
|
||||
public:
|
||||
ResetScreen(ScreenManager* screenManager) : BaseScreen(screenManager) { }
|
||||
|
||||
void onShow();
|
||||
void onHide();
|
||||
|
||||
void onButton();
|
||||
void onEncoder(int32_t lastPosition, int32_t newPosition);
|
||||
void onTick();
|
||||
};
|
||||
|
||||
#endif
|
@ -96,10 +96,10 @@ void ResetExposureTimer()
|
||||
}
|
||||
|
||||
|
||||
uint16_t GetExposureTimeRemaining(uint32_t currentTime)
|
||||
uint32_t GetExposureTimeRemaining(uint32_t currentTime)
|
||||
{
|
||||
uint32_t elapsed = (currentTime - ExposureTimerStart);
|
||||
uint32_t exposureTimeMs = ExposureTime * 1000;
|
||||
uint32_t exposureTimeMs = static_cast<uint32_t>(ExposureTime) * 1000;
|
||||
|
||||
return elapsed <= exposureTimeMs ? exposureTimeMs - elapsed : 0;
|
||||
}
|
@ -29,6 +29,6 @@ void SaveSettings();
|
||||
|
||||
void StartExposureTimer(uint32_t currentTime);
|
||||
void ResetExposureTimer();
|
||||
uint16_t GetExposureTimeRemaining(uint32_t currentTime);
|
||||
uint32_t GetExposureTimeRemaining(uint32_t currentTime);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user