Hi,
I'm trying to build a menu item that uses the takeOverDisplay() function.
The menu item looks like:
void CALLBACK_FUNCTION runDev(int id) {
renderer.takeOverDisplay(devRunner);
}
And my function currently looks like this (messy as hell):
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();
}
}
}
}
}
Currently, nothing prints to the display.
I also have an issue with the section running 'moveServo()', where it only runs for around 2 seconds, rather than the 'agitDur' set from a combination of values from other menu options (menuSetAgitationDurationSeconds and menuSetAgitationDurationMinutes).
This is probably just something small, but the printing to display seems to clear the display, but print nothing.