-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArduinoUno.hpp
More file actions
87 lines (87 loc) · 1.74 KB
/
ArduinoUno.hpp
File metadata and controls
87 lines (87 loc) · 1.74 KB
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
86
87
/* microflo_component yaml
name: ArduinoUno
description: Convenient definition of pins available on Arduino Uno
icon: "microchip"
inports:
in:
type: all
description: ''
outports:
pin0:
type: all
description: ""
pin1:
type: all
description: ""
pin2:
type: all
description: ""
pin3:
type: all
description: ""
pin4:
type: all
description: ""
pin5:
type: all
description: ""
pin6:
type: all
description: ""
pin7:
type: all
description: ""
pin8:
type: all
description: ""
pin9:
type: all
description: ""
pin10:
type: all
description: ""
pin11:
type: all
description: ""
pin12:
type: all
description: ""
pin13:
type: all
description: ""
pina0:
type: all
description: ""
pina1:
type: all
description: ""
pina2:
type: all
description: ""
pina3:
type: all
description: ""
pina4:
type: all
description: ""
pina5:
type: all
description: ""
microflo_component */
class ArduinoUno : public Component {
public:
ArduinoUno() : Component(outPorts, ArduinoUnoPorts::OutPorts::pina5+1) {}
virtual void process(Packet in, MicroFlo::PortId port) {
const MicroFlo::PortId digitalPins = 14;
const MicroFlo::PortId analogPins = 6;
if (port == ArduinoUnoPorts::InPorts::in) {
for (MicroFlo::PortId outPort=0; outPort < digitalPins+analogPins; outPort++) {
// Emit 0 for A0, 1 for A1, and so on
const long val = (outPort < digitalPins) ? outPort : outPort - digitalPins;
send(Packet(val), outPort);
}
}
}
private:
Connection outPorts[ArduinoUnoPorts::OutPorts::pina5+1];
};