forked from dastels/neo_pixel_state_machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.h
46 lines (37 loc) · 1.02 KB
/
state.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// -*- mode: c++ -*-
// State base class
//
// Copyright (c) 2021 Dave Astels
#ifndef __STATE_H__
#define __STATE_H__
#include <stdint.h>
#include <Adafruit_NeoPixel.h>
#include "config.h"
class StateMachine;
class State {
protected:
StateMachine *_machine;
uint8_t *cached_data;
void update_neopixels(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t white;
private:
char *_name;
public:
State(StateMachine *owner_machine=nullptr, char *name=nullptr);
char *name() { return _name; }
bool is_named(char *name);
virtual void enter(uint8_t *data=nullptr) {}
virtual void exit(uint8_t *data=nullptr) {}
virtual void tick(uint32_t now) {}
virtual void mode_button() {}
virtual void red_button() {}
virtual void green_button() {}
virtual void blue_button() {}
void go_to(char *state_name, uint8_t *data=nullptr);
uint8_t next_value(uint8_t c);
uint8_t previous_value(uint8_t c);
};
#endif