diff options
Diffstat (limited to 'two_hosts_auto_powerswitch')
-rw-r--r-- | two_hosts_auto_powerswitch/readme.rst | 41 | ||||
-rw-r--r-- | two_hosts_auto_powerswitch/readme_flowchart.asciio | bin | 0 -> 26794 bytes | |||
-rw-r--r-- | two_hosts_auto_powerswitch/readme_flowchart.txt | 33 |
3 files changed, 74 insertions, 0 deletions
diff --git a/two_hosts_auto_powerswitch/readme.rst b/two_hosts_auto_powerswitch/readme.rst index 7eac7fe..2a4617d 100644 --- a/two_hosts_auto_powerswitch/readme.rst +++ b/two_hosts_auto_powerswitch/readme.rst @@ -122,3 +122,44 @@ in another location, one does not need the associated devices to be on). In my case, the wake-on-lan was an exception to the normal usage of my computer, so I made the skip choice to be in the workflow. + +State machines +============== + +- debouncing buttons state tables:: + + #0 button released [pin change interrupt] -> debounce start [timeout] + -> timeout [button pressed] -> #1 + event button_down + -> timeout [button released] -> #0 + + #1 button pressed [timeout] -> first up [timeout] -> debounce [timeout] + -> timeout [button pressed] -> #1 + -> timeout [button released] -> #0 + event button_up + +Ex of a transition table: +State Event Next state Transition function +stopped play_event playing do_play +playing stop_event stopped do_stop +playing pause_event paused do_pause +paused play_event playing do_resume +paused stop_event stopped do_stop + +ex of fsm implem for another language: +https://github.com/hyperandroid/Automata + +ex of fsm implem in c: +https://github.com/gitrealname/ofsm + +formal description in yaml ? + +fsm0: + initialstate: state0 + state0: + enter: action_enter + exit: action_exit + events: + - event: ok + nextstate: state1 + - event: ... + state1: + ... diff --git a/two_hosts_auto_powerswitch/readme_flowchart.asciio b/two_hosts_auto_powerswitch/readme_flowchart.asciio Binary files differnew file mode 100644 index 0000000..91aa2cc --- /dev/null +++ b/two_hosts_auto_powerswitch/readme_flowchart.asciio diff --git a/two_hosts_auto_powerswitch/readme_flowchart.txt b/two_hosts_auto_powerswitch/readme_flowchart.txt new file mode 100644 index 0000000..6a7ef42 --- /dev/null +++ b/two_hosts_auto_powerswitch/readme_flowchart.txt @@ -0,0 +1,33 @@ +.------------------. .-----------------------. +| Host state | | Serial | .---. +| change detection | | computer state toggle | | A | +'------------------' .---------------. '-----------------------' '---' + | | Computer | | + | | Button toggle |-----------------| + | '---------------' | ^ + v v ----' + .------------. .----------------------. + | Lookup | | Update | + | skip table |-------------------------------->| computer state table | + '------------' '----------------------' + .-------------. .------------. | + | Serial | | Update | | + | skip update |---->| skip table |<----------|-----' + '-------------' '------------' | .---------------. + | | Outlet | + | | Button toggle | + v '---------------' + .---------------. .--------------. | + | Serial | | Update | | + | outlet toggle |---->| Outlet table |<-' + '---------------' '--------------' + | + v + .---------------------. + | Start on/off timers | + '---------------------' + | + v + .--------------. + | Switch relay | + '--------------' |