Persistance, and waking from sleep



  • The boilerplate code which is generated from monomake generates:

    <code>
    void AppController::monoWakeFromSleep()
    {
    // Due to a software bug in the wake-up routines, we need to reset here!
    // If not, Mono will go into an infinite loop!
    mono::IApplicationContext::SoftwareResetToApplication();
    // We never reach this point in the code, CPU has reset!
    //
    // (Normally) after sleep, the screen memory has been cleared - tell the label to
    // draw itself again
    helloLabel.scheduleRepaint();
    }
    </code>

    ...so, since a reset is performed, why even have code after the reset? Wouldn't it be more accurate (and less confusing) to just have:

    <code>
    void AppController::monoWakeFromSleep()
    {
    // Due to a software bug in the wake-up routines, we need to reset here!
    // If not, Mono will go into an infinite loop!
    mono::IApplicationContext::SoftwareResetToApplication();
    // We never reach this point in the code, CPU has reset!
    }
    </code>

    OK, onto the real issue... I don't want to perform a reset when the wake button is pressed, and I want to persist some data. Is there a way to do this?



  • @Jeff said in Persistance, and waking from sleep:

    ...so, since a reset is performed, why even have code after the reset? Wouldn't it be more accurate (and less confusing) to just have:

    Maybe, but my thought was to just remove the reset part in future releases of Mono Framework. The concept is that Mono does not have to reset upon wake, so when I fix the bug - you are all free to remove the reset statement.

    OK, onto the real issue... I don't want to perform a reset when the wake button is pressed, and I want to persist some data. Is there a way to do this?

    Mono's CPU (PSoC5) has 2 Kb of EEPROM, which is persistent. But it has limited write cycles. We also plan to reserve some of that memory for Wifi config and other settings. You can see how we plan to utilize the eeprom here:

    https://github.com/getopenmono/mono_framework/blob/master/settings_interface.h

    Otherwise, you should just use the SD Card option. Get a microSD Card, format as FAT32 and you have access to libc's Std I/O functions: fopen, fread, fwrite, fprintf etc. I will write a guide on the developer docs on how to use the SD Card shortly.


Log in to reply