boas noites a todos
Estou a tentar criar um prog que me permita (para ja) usar um menu para ligar a um contador de tempo.
Eu tenho um scketsh com o menu e outro com o contador de tempo que ambos funcionam bem.
o problemas está quando os junto
ao escolher a opção do menu (5min) que é a unica que está a programada, nao acontece nada e não vejo o contador a contar
alguem pode ajudar ?
/***********************************************************
Curing/Washing Box 1.01
by Xmodpt
Last update @ 08/04/2020
****** Version Control *******
1.0 - Countdown tested and working with relay and stepper
1.01 - Added menu with 3 options
***********************************************************/
#include <Arduino.h>
/****** U8G2 LIB *********/
#include <U8g2lib.h>
/***** U8G2 settings *****/
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
/********STEPPER LIB *****************/
#include <AccelStepper.h> // stepper motor lib
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
/**** U8G2 Display settings *****/
//U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
/********* Timer Settings ******************/
// 10000ul = 10 sec
// 30250ul = 30 sec
// 60500ul = 1 min
// 302500ul = 5 min
// 605000ul = 10 min
// 907500ul = 15 min
#define COUNTDOWN_TIME 10000ul // Set timer
char
szString[20];
byte
mins, secs;
unsigned long
timeTemp,
timeNow,
timeStart,
timeElapsed,
timeLeft;
// End of constructor list
const char *string_list =
"05 min\n"
"10 min\n"
"15 min\n"
"\n"
"About";
uint8_t current_selection = 1;
void setup(void) {
// stepper.setMaxSpeed(1000);
// stepper.setSpeed(50);
// RELAY SETTINGS
// pinMode(pinRele, OUTPUT);
// Rotary encoder or buttons
u8g2.begin(/*Select=*/ A2, /*Right/Next=*/ A4, /*Left/Prev=*/ A5, /*Up=*/ A0, /*Down=*/ A1, /*Home/Cancel=*/ A3); // Arduboy DevKit
// Font Type config
u8g2.setFont(u8g2_font_6x12_tr);
u8g2.clearDisplay();
Serial.begin(9600);
}
void loop(void) {
current_selection = u8g2.userInterfaceSelectionList(
"Curing Station V1.0",
current_selection,
string_list);
if ( current_selection == 1 ) {
DoCountdown();
}
if ( current_selection == 2 ) {
}
if ( current_selection == 3 ) {
}
if ( current_selection == 5 ) {
u8g2.userInterfaceMessage(
"About:",
"Curing system",
"design by Xmodpt",
"ver: 1.0");
}
}
void DoCountdown()
{
timeStart = millis();
mins = 1;
secs = 1;
//u8g2.clearBuffer();
static unsigned long
lastTimeNow = 0;
static byte
lastsecs = 1;
timeNow = millis();
timeElapsed = timeNow - timeStart;
// if( mins == 0 && secs == 0 )
// return;
timeLeft = COUNTDOWN_TIME - timeElapsed;
mins = (byte)(timeLeft / 60000ul);
timeTemp = timeLeft - (mins * 60000);
secs = (byte)(timeTemp / 1000ul);
timeTemp = timeTemp - (secs * 1000ul);
if( mins == 0 && secs == 0 )
{
u8g2.clearDisplay();
u8g2.setCursor( 15, 45 );
sprintf( szString, "DONE" );
u8g2.print( szString );
Serial.println( szString );
}
else if( secs != lastsecs )
{
lastsecs = secs;
u8g2.setCursor( 20,45 );
sprintf( szString, "%02d:%02d", mins, secs );
Serial.println( szString );
u8g2.clearBuffer();
u8g2.print( szString );
}
u8g2.sendBuffer();
}
obrigado