#include "state.h" #include "../device.h" #include #include // this is me being lazy const char name[] = __FILE_NAME__; // so when a button is pressed it updates the state to the new one static void pressPwrMethod(Device_t *device) { printf("turning off device\n"); setDeviceStateToOff(device); } static void pressStrInputMethod(Device_t *device) { // check to see if the entered string is the one to enter the debug state if (strcmp(device->entered_string, "dbg") == 0) { printf("entering debug state\n"); setDeviceStateToDebug(device); return; } printf("unknown string %s\n", device->entered_string); } static void pressLockMethod(Device_t *device) { printf("locking device\n"); setDeviceStateToLock(device); } void setDeviceStateToUnlock(Device_t *device) { device->state = (DeviceState_t) { .state_name = name, .methods = (DeviceInterface_t){ .pressPwr = &pressPwrMethod, .pressStrInput = &pressStrInputMethod, .pressLock = &pressLockMethod, }, }; }