-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically dispatch the command to the required Actuators
- Loading branch information
1 parent
284a94d
commit 5cc9dd7
Showing
3 changed files
with
141 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include <ArduinoJson.h> | ||
|
||
enum ACTUATOR_TYPE{ | ||
SERVO, | ||
STEPPER | ||
}; | ||
|
||
/** | ||
* All actuators eg. Servos, Steppers, etc. use this to allow for max control | ||
*/ | ||
class Actuator{ | ||
public: | ||
Actuator(ACTUATOR_TYPE actType, int instance) { | ||
instance_num = instance; | ||
type = actType; | ||
}; | ||
|
||
/** | ||
* Called when a packet is received that needs to move the actuator | ||
* @param json The parameters that can change | ||
*/ | ||
virtual void control(JsonArray json) = 0; | ||
|
||
/** | ||
* Convert the type of actuator to a String | ||
*/ | ||
String typeToString(){ | ||
switch(type){ | ||
case SERVO: | ||
return "Servo"; | ||
case STEPPER: | ||
return "Stepper"; | ||
} | ||
}; | ||
|
||
/** | ||
* Get the instance number of the actuator | ||
*/ | ||
int get_instance_num() { return instance_num; }; | ||
|
||
private: | ||
int instance_num; // Instance number of the Actuator | ||
ACTUATOR_TYPE type; // Type of actuator | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters