mirror of
https://github.com/zzzzDev4/IAS-Better-Tea.git
synced 2025-04-21 07:31:20 +02:00
added time formatting
This commit is contained in:
parent
fed38c1486
commit
421d00b3fb
5 changed files with 51 additions and 13 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "SmartDisplay.hpp"
|
#include "SmartDisplay.hpp"
|
||||||
|
#include "SmartTime.hpp"
|
||||||
|
|
||||||
SmartDisplay::SmartDisplay(Adafruit_SSD1306 *display)
|
SmartDisplay::SmartDisplay(Adafruit_SSD1306 *display)
|
||||||
{
|
{
|
||||||
|
@ -12,11 +13,15 @@ void SmartDisplay::printTeaConfigScreen(TeaData tea)
|
||||||
|
|
||||||
m_display->println(tea.m_teaName);
|
m_display->println(tea.m_teaName);
|
||||||
m_display->print(tea.m_waterTemp);
|
m_display->print(tea.m_waterTemp);
|
||||||
|
m_display->drawCircle(m_display->getCursorX() + 4, m_display->getCursorY(), 1, WHITE);
|
||||||
m_display->println(" C");
|
m_display->println(" C");
|
||||||
|
|
||||||
m_display->setTextSize(2);
|
m_display->setTextSize(2);
|
||||||
m_display->print(tea.m_steepingSeconds);
|
String steepingTime = SmartTime::formatSeconds(tea.m_steepingSeconds);
|
||||||
m_display->print(" ");
|
m_display->print(steepingTime);
|
||||||
|
m_display->setTextSize(1);
|
||||||
|
m_display->setCursor(m_display->getCursorX(), m_display->getCursorY() + 7);
|
||||||
|
m_display->println(" min");
|
||||||
|
|
||||||
m_display->display();
|
m_display->display();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +34,11 @@ void SmartDisplay::printTeaSteepingProgressScreen(TeaData tea, int remainingSeco
|
||||||
m_display->println(" (Steeping)");
|
m_display->println(" (Steeping)");
|
||||||
|
|
||||||
m_display->setTextSize(2);
|
m_display->setTextSize(2);
|
||||||
m_display->println(remainingSeconds);
|
String remainingTime = SmartTime::formatSeconds(remainingSeconds);
|
||||||
|
m_display->print(remainingTime);
|
||||||
|
m_display->setTextSize(1);
|
||||||
|
m_display->setCursor(m_display->getCursorX(), m_display->getCursorY() + 7);
|
||||||
|
m_display->println(" min");
|
||||||
|
|
||||||
m_display->display();
|
m_display->display();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +51,7 @@ void SmartDisplay::printWaitForRFIDScreen()
|
||||||
m_display->display();
|
m_display->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmartDisplay::printRequestFeedbackScreen(TeaData teaData)
|
void SmartDisplay::printRequestFeedbackScreen(TeaData tea)
|
||||||
{
|
{
|
||||||
resetDisplay();
|
resetDisplay();
|
||||||
|
|
||||||
|
@ -53,15 +62,17 @@ void SmartDisplay::printRequestFeedbackScreen(TeaData teaData)
|
||||||
m_display->display();
|
m_display->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmartDisplay::printAddNewTeaConfigScreen(TeaData teaData)
|
void SmartDisplay::printAddNewTeaConfigScreen(TeaData tea)
|
||||||
{
|
{
|
||||||
resetDisplay();
|
resetDisplay();
|
||||||
|
|
||||||
m_display->println("Add initial config for new tea");
|
m_display->println("Add initial config for new tea");
|
||||||
m_display->println();
|
m_display->println();
|
||||||
m_display->print("Steeping time:");
|
m_display->print("Steeping time:");
|
||||||
m_display->print(teaData.m_steepingSeconds);
|
String steepingTime = SmartTime::formatSeconds(tea.m_steepingSeconds);
|
||||||
m_display->println("s");
|
m_display->print(steepingTime);
|
||||||
|
m_display->setTextSize(1);
|
||||||
|
m_display->println(" min");
|
||||||
|
|
||||||
m_display->display();
|
m_display->display();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ public:
|
||||||
public:
|
public:
|
||||||
// lifecycle screens
|
// lifecycle screens
|
||||||
void printWaitForRFIDScreen();
|
void printWaitForRFIDScreen();
|
||||||
void printTeaConfigScreen(TeaData teaData);
|
void printTeaConfigScreen(TeaData tea);
|
||||||
void printTeaSteepingProgressScreen(TeaData teaData, int remainingSeconds);
|
void printTeaSteepingProgressScreen(TeaData tea, int remainingSeconds);
|
||||||
void printRequestFeedbackScreen(TeaData teaData);
|
void printRequestFeedbackScreen(TeaData tea);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// special screens
|
// special screens
|
||||||
void printAddNewTeaConfigScreen(TeaData teaData);
|
void printAddNewTeaConfigScreen(TeaData tea);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// helper methods
|
// helper methods
|
||||||
|
|
14
src/SmartTime.cpp
Normal file
14
src/SmartTime.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include "SmartTime.hpp"
|
||||||
|
|
||||||
|
String SmartTime::formatSeconds(int seconds)
|
||||||
|
{
|
||||||
|
int m = seconds / 60;
|
||||||
|
int s = seconds % 60;
|
||||||
|
String str = "";
|
||||||
|
str += m;
|
||||||
|
str += ":";
|
||||||
|
if (s < 10)
|
||||||
|
str += "0";
|
||||||
|
str += s;
|
||||||
|
return str;
|
||||||
|
}
|
7
src/SmartTime.hpp
Normal file
7
src/SmartTime.hpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
class SmartTime {
|
||||||
|
public:
|
||||||
|
static String formatSeconds(int seconds);
|
||||||
|
};
|
10
src/main.cpp
10
src/main.cpp
|
@ -242,18 +242,24 @@ void loop()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBtnPressed()) {
|
||||||
|
// keep steeping time for next brew
|
||||||
|
smartDisplay.printMsg("Feedback accepted (perfect)");
|
||||||
|
delay(1000);
|
||||||
|
state = State::WAIT_FOR_RFID_SCAN;
|
||||||
|
}
|
||||||
if (buttonLeft.isJustPressed())
|
if (buttonLeft.isJustPressed())
|
||||||
{
|
{
|
||||||
// decrease steeping time for next brew
|
// decrease steeping time for next brew
|
||||||
smartDisplay.printMsg("Feedback accepted (-)");
|
smartDisplay.printMsg("Feedback accepted (-)");
|
||||||
delay(3000);
|
delay(1000);
|
||||||
state = State::WAIT_FOR_RFID_SCAN;
|
state = State::WAIT_FOR_RFID_SCAN;
|
||||||
}
|
}
|
||||||
if (buttonRight.isJustPressed())
|
if (buttonRight.isJustPressed())
|
||||||
{
|
{
|
||||||
// increase steeping time for next brew
|
// increase steeping time for next brew
|
||||||
smartDisplay.printMsg("Feedback accepted (+)");
|
smartDisplay.printMsg("Feedback accepted (+)");
|
||||||
delay(3000);
|
delay(1000);
|
||||||
state = State::WAIT_FOR_RFID_SCAN;
|
state = State::WAIT_FOR_RFID_SCAN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue