Release 1.01

Dependents:   mbed_escm2000

FactoryResetMenu.cpp

Committer:
foxbrianr
Date:
2019-09-12
Revision:
4:7226c43320b5
Child:
5:9f4d4f8ffc00

File content as of revision 4:7226c43320b5:

#include "mbed.h"
#include "FactoryResetMenu.h"
#include "TimeUtilities.h"
#include "ESCMControlApp.h"

#define DEFAULT_DISPLAY 0

FactoryResetMenu::FactoryResetMenu(char* id): Menu(id)
{
    active_selection=0;
}



void FactoryResetMenu::init()
{
    update_needed    = 1;
    active_selection=0;
}

void FactoryResetMenu::display(LCD * lcd) 
{
    static int counter = 5;
    
    if (update_needed) {
        switch(active_selection) {
            
            case 1:
                lcd->cls();
                lcd->locate(1,0);
                lcd->printf("Resetting to Factory Default");
                lcd->locate(1,0);
                counter = 5;
                active_selection=2;
                update_needed=1;
                break;
                
            case 2:
                lcd->locate(2,0);
                lcd->printf("Please wait %d...", counter--);
                if (counter == 0) active_selection=0;
                update_needed=1;
                break;
            
            default:
                lcd->cls();
                lcd->locate(0,0);
                lcd->printf("Press <Set> to Reset");
                update_needed=0;
                break;
        };
    }
    
    displayCurrentTime(lcd);
    displayVersion(lcd);
}

void FactoryResetMenu::pressMode()
{
    // toggle active menu 
    switch(active_selection) {
        
        case 0:
            back();
            break;
        case 1:
            back();
            break;
            
        default:
            active_selection = 0;
            break;
    };

    update_needed = 1;
}

void FactoryResetMenu::pressSet()
{
    // set button advances to next character position OR
    // goes back to normal
    switch(active_selection) {
        
        case 0:
            active_selection = 1;
            addressMap.reset();
            escmEventLog.reset();
            break;
            
        case 1: // press yes
            active_selection = 2;
            break;
            
        case 2: // complete
            //back();
            active_selection = 0;
            break;
            
        default:
            active_selection = 0;
            break;
            
    };
    update_needed = 1;
}