Register / Login | Desktop view |
void CALLBACK_FUNCTION runDev(int id) {
renderer.takeOverDisplay(devRunner);
}
void devRunner(unsigned int encoderValue, RenderPressMode clicked) {
int devTime = (menuSetDevTimeSeconds.getCurrentValue() + (menuSetDevTimeMinutes.getCurrentValue() * 60));
int agitDur = (menuSetAgitationDurationSeconds.getCurrentValue() + (menuSetAgitationDurationMinutes.getCurrentValue() * 60));
int agitInt = (menuSetAgitationIntervalSeconds.getCurrentValue() + (menuSetAgitationIntervalMinutes.getCurrentValue() * 60));
int agitCount = 0;
unsigned int agitMillis = 0;
while (devTime >= 0) {
if (interruptCounter > 0) {
portENTER_CRITICAL(&timerMux);
interruptCounter--;
portEXIT_CRITICAL(&timerMux);
// Decrement devTime
devTime--;
// if value reaches to zero, print done and wait for click
if (devTime == 0) {
timerAlarmDisable(timer); // remeber we need to enable it again in start of next devrun
Serial.println("Done");
gfx.clear();
gfx.print("Done!");
// If encoder clicked, give back display
if (clicked) {
renderer.giveBackDisplay();
}
}
}
else {
// Print time remaining to serial
Serial.print("Dev Time Remaining: ");
Serial.println(devTime);
// Print time remaining to LCD
String timeRemaining = (devTime / 60) + ":" + (devTime % 60) / 100;
Serial.println(timeRemaining);
gfx.clear();
gfx.print("Developing..");
gfx.setCursor(0, 32);
gfx.print(timeRemaining);
// If timer reaches the agitation interval, move servo and count down duration
// If agitation frequency is zero, this means no occurance so ignore it
if (agitInt, agitDur > 0) {
if (devTime % agitInt == 0) {
agitCount = agitDur;
}
if (millis() - agitMillis >= agitDur and agitCount > 0) {
agitCount--;
agitMillis = millis();
moveServo();
}
}
}
}
}
u8g2->sendBuffer();
void someTaskFunction() {
// do your task
if(taskShouldRunAgain) taskManager.scheduleOnce(200, someTaskFunction);
}
auto taskId = taskManager.scheduleFixedRate(200, [] {
// do your task here
});