1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include <stdio.h>
- #include "TempEditorActivity.h"
- #include "Helpers.h"
- #include "defines.h"
- #include "globals.h"
-
- TempEditorActivity::TempEditorActivity(
- IActivity* mParentActivity
- , IActivity* mPreviousActivity
- , IActivity* mNextActivity
- , const char* line1
- , temp_t* value
- )
- : BaseActivity(mParentActivity, nullptr, mPreviousActivity, mNextActivity)
- , m_line1(line1)
- , m_value(value)
- , m_tmpValue(*value)
- , m_isEditMode(false)
- {
- }
-
- void TempEditorActivity::begin()
- {
- m_tmpValue = *m_value;
- BaseActivity::begin();
- }
-
- void TempEditorActivity::getLcdText(char** lines)
- {
- Helpers::center(lines[0], m_line1, 16, ' ');
-
- char temp[7];
- Helpers::tempToStr(temp, m_tmpValue, 5);
- snprintf(lines[1], 17, "%c %s C %c", m_isEditMode ? '>' : ' ', temp, *m_value != m_tmpValue ? '*' : ' ');
- }
-
- void TempEditorActivity::onButtonReleased(BaseActivity::Button button)
- {
- if (m_isEditMode)
- {
- if (button == Cancel)
- {
- m_tmpValue = *m_value;
- m_isEditMode = false;
- g_hibernateService.setPaused(false);
- }
- else if (button == Ok)
- {
- *m_value = m_tmpValue;
- g_storage.save();
- m_isEditMode = false;
- g_hibernateService.setPaused(false);
- }
- else if (button == Minus)
- {
- m_tmpValue -= TEMP_INTERVAL;
- }
- else if (button == Plus)
- {
- m_tmpValue += TEMP_INTERVAL;
- }
- m_lcdUpdateNeeded = true;
- }
- else
- {
- if (button == Ok)
- {
- m_isEditMode = true;
- m_lcdUpdateNeeded = true;
- g_hibernateService.setPaused(true);
- }
- else
- {
- BaseActivity::onButtonReleased(button);
- }
- }
- }
|