Example #1
0
// user input finitestate machine
void USI_fsm(uint8_t button)
{
    switch(button){
        case LEFT:
            deleteStr();
            USI_Init();
            break;
        case UP:
            deleteStr();
            usi_previous();
            break;
        case RIGHT:
            deleteStr();
            if(userTextIndex == (sizeof(LOCK)-2)) // real array elements (\0)
            {
                /* Device Unlocked */
                //if(strcmp_P(userText+sizeof(PIN_str)-1, LOCK) == 0)
                if(USI_pinCheck(userText+sizeof(PIN_str)-1) == 1)
            	{
                    CRD_fsmStart();
                    UCP_Unlock();
                }
                /* Device Locked */
                else
                {
                    printStr((void*)LOCKED_str,FLASH);
                    userTextIndex = 0;
                    UIF_userInputIndex = 0;
                    memcpy_P((void*)userText, (void*)PIN_str, sizeof(PIN_str));
                    userText[sizeof(PIN_str)-1+userTextIndex] = pgm_read_byte(&USI_keys[UIF_userInputIndex]);
                    userText[sizeof(PIN_str)-1+userTextIndex+1] = 0;
                }
            }
            else
            {
                userTextIndex++;
                usi_print();
            }
            break;
        case DOWN:
            deleteStr();
            usi_next();
            break;
        default:
            break;
        }
}
Example #2
0
File: crd.c Project: jim17/memtype
/* Credentials Finite state machine [Start] */
void CRD_fsmStart(void){
    UIF_state = CREDENTIALS;
    deleteStr();
    crd_print();
    UCP_Unlock();
}