-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtm_servo.h
executable file
·85 lines (79 loc) · 2.48 KB
/
Atm_servo.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <Automaton.h>
#include <Servo.h>
class Atm_servo : public Machine {
public:
enum { IDLE, UP, UP_NEXT, DOWN, DOWN_NEXT, FINISHED }; // STATES
enum { EVT_MVUP, EVT_MVDN, EVT_TIMER, ELSE }; // EVENTS
enum { EVT_UP = 181, EVT_DOWN = 182, EVT_SWEEP = 183 }; // EXTERNAL
Atm_servo( void ) : Machine(){};
Atm_servo& begin( int pin, int pos = 0 );
Atm_servo& trace( Stream& stream );
Atm_servo& trigger( int event );
int state( void );
Atm_servo& onChange( Machine& machine, int event = 0 );
Atm_servo& onChange( atm_cb_push_t callback, int idx = 0 );
Atm_servo& onChange( int sub, Machine& machine, int event = 0 );
Atm_servo& onChange( int sub, atm_cb_push_t callback, int idx = 0 );
Atm_servo& onFinish( Machine& machine, int event = 0 );
Atm_servo& onFinish( atm_cb_push_t callback, int idx = 0 );
Atm_servo& step( int degrees, int time = 0 );
Atm_servo& position( int pos );
int position( void );
private:
enum { ENT_IDLE, ENT_UP, ENT_DOWN, ENT_FINISHED }; // ACTIONS
enum { ON_CHANGE, ON_FINISH = 2, CONN_MAX }; // CONNECTORS
atm_connector connectors[CONN_MAX];
int pin;
Servo servo;
atm_timer_millis timer;
int servo_pos, servo_dest;
int step_size, step_time;
int event( int id );
void action( int id );
};
/*
Automaton::ATML::begin - Automaton Markup Language
<?xml version="1.0" encoding="UTF-8"?>
<machines>
<machine name="Atm_servo">
<states>
<IDLE index="0" sleep="1" on_enter="ENT_IDLE">
<EVT_MVUP>UP</EVT_MVUP>
<EVT_MVDN>DOWN</EVT_MVDN>
</IDLE>
<UP index="1" on_enter="ENT_UP">
<EVT_TIMER>UP_NEXT</EVT_TIMER>
</UP>
<UP_NEXT index="2">
<EVT_MVUP>UP</EVT_MVUP>
<EVT_MVDN>DOWN</EVT_MVDN>
<ELSE>FINISHED</ELSE>
</UP_NEXT>
<DOWN index="3" on_enter="ENT_DOWN">
<EVT_TIMER>DOWN_NEXT</EVT_TIMER>
</DOWN>
<DOWN_NEXT index="4">
<EVT_MVUP>UP</EVT_MVUP>
<EVT_MVDN>DOWN</EVT_MVDN>
<ELSE>FINISHED</ELSE>
</DOWN_NEXT>
<FINISHED index="5" on_enter="ENT_FINISHED">
<ELSE>IDLE</ELSE>
</FINISHED>
</states>
<events>
<EVT_MVUP index="0"/>
<EVT_MVDN index="1"/>
<EVT_TIMER index="2"/>
</events>
<connectors>
<CHANGE autostore="0" broadcast="0" dir="PUSH" slots="2"/>
<FINISH autostore="0" broadcast="0" dir="PUSH" slots="1"/>
</connectors>
<methods>
</methods>
</machine>
</machines>
Automaton::ATML::end
*/