The pause and unpause features are in a single function in order to dynamically "allocate" memory for the pause state and "free" it when resumed. Otherwise, the variables declared there have to be global which means those memory locations will never be free for other use:
static struct {
unsigned bowl : 2;
unsigned arm : 2;
unsigned water : 1;
unsigned pump : 1;
unsigned dosage : 1;
unsigned dryer : 1;
unsigned long wait;
unsigned long fill;
unsigned long drain;
unsigned long autodose;
unsigned long autoarm;
} context;
I forget the exact amount, but depending on the chip you only have something like 368 bytes of memory, so we have to be extremely contentious of that constraint.
Actually, we had discussed this before, but we could save the state to EEPROM in the pause function, and restore it in the unpause function.
That would allow us to:
- Break up pause/unpause, eliminating the recursion issue
- Free up global memory
- If needed, power off the CatGenie by removing the processing unit and/or unplugging it after pausing. You could use this to clean the water sensor or get the scoop unstuck while the program is running. The startup code can then look in the EEPROM to see if there was pause state saved and either go back into pause mode or just automatically restore the pause state (effectively unease).
errors you say?
--
C Anthony
Yeah, probably the 'possible' recursive call. Didn't fix it, the patch just changes too much.
The actual errors (one is enough) deal with being out of memory. The XC8 compiler does not optimize memory well, hence the issue. Instead, use the HI-TECH C compiler. You can "eval" the software for free for 45 days.