init
This commit is contained in:
37
src/states/unlock_state.c
Normal file
37
src/states/unlock_state.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "state.h"
|
||||
#include "../device.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
const char name[] = __FILE_NAME__;
|
||||
|
||||
static void pressPwrMethod(Device_t *device) {
|
||||
printf("turning off device\n");
|
||||
setOffState(device);
|
||||
}
|
||||
|
||||
static void pressStrInputMethod(Device_t *device) {
|
||||
if (strcmp(device->entered_string, "dbg") == 0) {
|
||||
printf("entering debug state\n");
|
||||
setDebugState(device);
|
||||
}
|
||||
printf("unknown string %s\n", device->entered_string);
|
||||
}
|
||||
|
||||
static void pressLockMethod(Device_t *device) {
|
||||
printf("locking device\n");
|
||||
setLockState(device);
|
||||
}
|
||||
|
||||
void setUnlockState(Device_t *device) {
|
||||
device->state = (DeviceState_t){
|
||||
.state_name = name,
|
||||
.device = device,
|
||||
.methods = (DeviceInterface_t){
|
||||
.pressPwr = &pressPwrMethod,
|
||||
.pressStrInput = &pressStrInputMethod,
|
||||
.pressLock = &pressLockMethod,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user