feat(workspace): implement servo node

This commit is contained in:
Victor Nakoryakov
2017-06-13 17:33:32 +03:00
parent b32719a3de
commit e4eeb92b18
2 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
{{#global}}
#include <Servo.h>
{{/global}}
struct State {
Servo servo;
int configuredPort = -1;
};
{{ GENERATED_CODE }}
void evaluate(NodeId nid, State* state) {
if (!isInputDirty<Inputs::UPD>(nid))
return;
auto port = (int)getValue<Inputs::PORT>(nid);
if (port != state->configuredPort) {
state->servo.attach(port);
state->configuredPort = port;
}
state->servo.write(getValue<Inputs::VAL>(nid) * 180);
}

View File

@@ -0,0 +1,50 @@
{
"description": "",
"links": [],
"nodes": [
{
"boundValues": {},
"description": "",
"id": "HkaMmuTzZ",
"label": "UPD",
"position": {
"x": 266,
"y": 16
},
"type": "xod/patch-nodes/input-pulse"
},
{
"boundValues": {},
"description": "",
"id": "HkmSQOafZ",
"label": "",
"position": {
"x": 138,
"y": 120
},
"type": "xod/patch-nodes/not-implemented-in-xod"
},
{
"boundValues": {},
"description": "",
"id": "S1vGmu6Gb",
"label": "PORT",
"position": {
"x": 10,
"y": 16
},
"type": "xod/patch-nodes/input-number"
},
{
"boundValues": {},
"description": "",
"id": "r1sfQ_6fb",
"label": "VAL",
"position": {
"x": 138,
"y": 16
},
"type": "xod/patch-nodes/input-number"
}
]
}