so i want to count how long my fire is burning and how long since i last added a log.
i tried with this code below, but obviously i have no idea how to do maths with time - so it doesn’t work:
int startFire, burnTimeTimer, logTimeTimer;
float addSmlLog, minusSmlLog, addBigLog, minusBigLog, totalLogs, totalSmlLogs, totalBigLogs;
float burnTime, lastLogTime, startTime, timeSinceLastLog;
BLYNK_WRITE(V10) { // start/stop fire button
startFire = param.asInt();
if (startFire == 1) {
burnTime = 0;
startTime = now();
burnTimeTimer = timer.setTimeout(10L * 1000L, fireTimer);// timing counts every 10 seconds
fireTimer();
}
else if (startFire == 0) {
burnTime = burnTime;
timer.disable(burnTimeTimer);
}
}
void fireTimer() {
if (startFire == 1) {
burnTime = (now() - startTime);
Blynk.virtualWrite(V14, burnTime);
}
}
and
BLYNK_WRITE(V11) { // add sml log button
addSmlLog = param.asInt();
if (addSmlLog == 1) {
totalSmlLogs = (totalSmlLogs + 1);
totalLogs = (totalLogs + 0.5);
Blynk.virtualWrite(V12, totalSmlLogs);
Blynk.virtualWrite(V20, totalLogs); //
lastLogTimer();
}
}
BLYNK_WRITE(V13) { // minus sml log button
minusSmlLog = param.asInt();
if (minusSmlLog == 1) {
totalSmlLogs = (totalSmlLogs - 1);
totalLogs = (totalLogs - 0.5);
Blynk.virtualWrite(V12, totalSmlLogs); //
Blynk.virtualWrite(V20, totalLogs); //
lastLogTimer();
}
}
BLYNK_WRITE(V18) { // add big log button
addBigLog = param.asInt();
if (addBigLog == 1) {
totalBigLogs = (totalBigLogs + 1);
totalLogs = (totalLogs + 1);
Blynk.virtualWrite(V19, totalBigLogs); //
Blynk.virtualWrite(V20, totalLogs); //
lastLogTimer();
}
}
BLYNK_WRITE(V17) { // minus big log button
minusBigLog = param.asInt();
if (minusBigLog == 1) {
totalBigLogs = (totalBigLogs - 1);
totalLogs = (totalLogs - 1);
Blynk.virtualWrite(V19, totalBigLogs); //
Blynk.virtualWrite(V20, totalLogs); //
lastLogTimer();
}
}
void lastLogTimer() {
if ((addBigLog == 1) || (addSmlLog == 1)) {
timeSinceLastLog = (now() - lastLogTime);
Blynk.virtualWrite(V15, timeSinceLastLog);
lastLogTime = now();
}
}
and i get this crazy looking number for “time since last log”
what do i use instead of float for these time variables?