MCPcopy Create free account
hub / github.com/SmingHub/Sming / addChannel

Method addChannel

Sming/Libraries/Servo/Servo.cpp:50–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50bool Servo::addChannel(ServoChannel* channel)
51{
52 if(channel == nullptr) {
53 return false;
54 }
55
56 int i = findChannel(channel);
57 if(i >= 0) {
58 return true; // Already added
59 }
60
61 // Find a free channel
62 i = findChannel(nullptr);
63 if(i < 0) {
64 // All channels in use
65 return false;
66 }
67
68 channels[i] = channel;
69 ++channelCount;
70
71 pinMode(channel->getPin(), OUTPUT);
72
73 updateTimer.startOnce();
74 return true;
75}
76
77bool Servo::removeChannel(ServoChannel* channel)
78{

Callers 1

attachMethod · 0.80

Calls 3

getPinMethod · 0.80
startOnceMethod · 0.80
pinModeFunction · 0.50

Tested by

no test coverage detected