diff options
author | xengineering <mail2xengineering@protonmail.com> | 2021-06-15 16:44:15 +0200 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2021-06-15 16:44:15 +0200 |
commit | 591097e5a3741432e2acd9c41fadd4eb10678674 (patch) | |
tree | e33b58eede51d6fd2dd644b08a0ca35527f5581c /src/camera.go | |
parent | f77251f132f2c61bc2f6fb6472e31a95badfa210 (diff) | |
download | birdscan-591097e5a3741432e2acd9c41fadd4eb10678674.tar birdscan-591097e5a3741432e2acd9c41fadd4eb10678674.tar.zst birdscan-591097e5a3741432e2acd9c41fadd4eb10678674.zip |
Refactoring: Make Statemachine reusable
Diffstat (limited to 'src/camera.go')
-rw-r--r-- | src/camera.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/camera.go b/src/camera.go index 12a9d54..197aa21 100644 --- a/src/camera.go +++ b/src/camera.go @@ -2,6 +2,10 @@ package main +import ( + "time" +) + type Camera struct { statemachine Machine } @@ -29,10 +33,22 @@ func NewCamera() Camera { }, api: make(chan string), state_listeners: make([]*(chan string), 0), + hook: runCameraHooks, }, } } +func runCameraHooks(last string, next string) { + + if last == "idle" && next == "single_picture" { + // TODO implement launch of python subprocess here + go func() { + time.Sleep(1 * time.Second) + camera.statemachine.SendEvent("single_picture_taken") + }() + } +} + func (cam *Camera) run() { cam.statemachine.Run() } |