16 lines
443 B
C++
16 lines
443 B
C++
#pragma once
|
|||
|
|
#include <Arduino.h>
|
||
|
|
|
||
|
|
// Stand-in for the Teensy Servo library. Every pulse the robot code writes is
|
||
|
|
// recorded per pin, so the simulation sees exactly what real servos would.
|
||
|
|
class Servo {
|
||
|
|
public:
|
||
|
|
uint8_t attach(int pin);
|
||
|
|
void detach();
|
||
|
|
void writeMicroseconds(int us);
|
||
|
|
void write(int deg) { writeMicroseconds(544 + deg * (2400 - 544) / 180); }
|
||
|
|
bool attached() const { return pin_ >= 0; }
|
||
|
|
|
||
|
|
private:
|
||
|
|
int pin_ = -1;
|
||
|
|
};
|