esp32 firmware for a toaster reflow oven WIP!!!!!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
reflower/main/liquid/scene_event.h

99 lines
2.1 KiB

/**
* Scene event structural enum
*
* Created on 2020/01/05.
*/
#ifndef LIQUID_SCENE_EVENT_H
#define LIQUID_SCENE_EVENT_H
// forward declaration
struct Scene;
enum SceneEvent_Kind {
SceneEventKind_Close,
SceneEventKind_OpenChild,
SceneEventKind_RequestRepaint,
SceneEventKind_None,
};
/**
* Scene event, returned from some scene methods.
*
* Use the constructor functions to create this struct.
*/
struct SceneEvent {
/** Event kind enum */
enum SceneEvent_Kind kind;
union {
/* data for Close event kind */
struct {
// Status code
int32_t status;
// Return data on heap
void *data;
} close;
/* Data for Open event kind */
struct {
// Scene (initialized, with options loaded in through the constructor)
struct Scene *scene;
// Tag used by parent to identify the open child
uint32_t tag;
} open;
};
};
/**
* Create empty (null object) scene event.
*
* @return event
*/
static inline struct SceneEvent SceneEvent_None(void)
{
return (struct SceneEvent) {
.kind = SceneEventKind_None,
};
}
/**
* Request scene repaint
*
* @return event
*/
static inline struct SceneEvent SceneEvent_Repaint(void)
{
return (struct SceneEvent) {
.kind = SceneEventKind_RequestRepaint
};
}
/**
* Request a sub-scene to be opened
*
* @param child - child scene
* @param tag - scene tag
* @return event
*/
static inline struct SceneEvent SceneEvent_OpenChild(struct Scene *child, uint32_t tag) {
return (struct SceneEvent) {
.kind = SceneEventKind_OpenChild,
.open = { .scene = child, .tag=tag },
};
}
/**
* Close this scene, returning to parent.
*
* @param status - status number for the parent
* @param data - heap-allocated data for parent, can be NULL; e.g. user input as string.
* @return event
*/
static inline struct SceneEvent SceneEvent_Close(int32_t status, void *data)
{
return (struct SceneEvent) {
.kind = SceneEventKind_Close,
.close = {.status = status, .data=data},
};
}
#endif //LIQUID_SCENE_EVENT_H