Skip to content
Snippets Groups Projects
ServoBehaviours.hpp 1.08 KiB
Newer Older
Dave Murray-Rust's avatar
Dave Murray-Rust committed
#ifndef SERVO_BEHAVIOUR_h
#define SERVO_BEHAVIOUR_h
#include "Arduino.h"
#include "Behaviours.h"

#include <Servo.h>

class ServoGoto : public Behaviour {
  Servo _servo;

public:
  ServoGoto(Servo servo, String name = "ServoGoto");
Dave Murray-Rust's avatar
Dave Murray-Rust committed

  char* args();
  String start(String args);
Dave Murray-Rust's avatar
Dave Murray-Rust committed

};

class ServoWiggle : public Behaviour {
  Servo _servo;
  int _start_time = 0;
  int _wiggle_time = 300;
  int _num_wiggles = 5;
  int _wiggles = 0;
  int _wiggle_angle = 0;
  //Calculate wiggle time by multiplying the angle by this...
  int _wiggle_factor = 5;

public:
  ServoWiggle(Servo servo, String name = "ServoWiggle", int slowness=3);
  char* args();
  String start(String args);
Dave Murray-Rust's avatar
Dave Murray-Rust committed

  void update();
Joe Revans's avatar
Joe Revans committed
class ServoRotateReturn : public Behaviour {
  Servo _servo;
  int _start_angle = 0;
  int _end_angle = 180;
  int _delay = 30;
  int _num_rotations = 1;
  int _rotations = 0;
  int _pause = 500;

public:
  ServoRotateReturn(Servo servo, String name="ServoRotateReturn", int delay=30, int pause=500, int start_angle = 2, int end_angle=178 );
  char* args();
  String start(String args);
  void update();
Dave Murray-Rust's avatar
Dave Murray-Rust committed
#endif