Conversation
functions to boot
added moveForward updated helt
…nto erick-motor-class
| @@ -0,0 +1,5 @@ | |||
| [.ShellClassInfo] | |||
There was a problem hiding this comment.
This file should not be source controlled
| @@ -0,0 +1,13 @@ | |||
| | |||
There was a problem hiding this comment.
This file should not be source controlled
| return ceil((min(x,1) - in_min) * (out_max - out_min) / (in_max - in_min) + out_min); | ||
| } | ||
|
|
||
| class motor |
There was a problem hiding this comment.
Inconsistent capitalization.
Either all class names should be capitalized or none of them should.
|
|
||
| void setSpeed(float speed) { | ||
|
|
||
| try { |
There was a problem hiding this comment.
It is generally not best practice to use exceptions to catch bugs (eg. out of bounds speed).
Asserts or something similar (since it is running on a teensy) are much faster and perform the same function and can easily be disabled in a release build.
Exceptions are meant for when the error is out of the programmers control eg. failed to allocate memory, failed to open file, etc.
|
|
||
| private: | ||
| float speed; | ||
| int FORWARD_PIN; |
There was a problem hiding this comment.
all caps is convention for a constant variable. Pins should be const
| } | ||
|
|
||
| motor(int set_forward_pin, int set_backward_pin, int set_pwm_pin) { | ||
| FORWARD_PIN = set_forward_pin; |
There was a problem hiding this comment.
Use a member initializor list so that XXX_PIN can be made const
| throw speedRangeOutOfBounds(); | ||
| } | ||
|
|
||
| int speedToHardwareVoltage = int(map(abs(speed), 0.0F, 1.0f, 0, 255)); |
| @@ -0,0 +1 @@ | |||
| {"url": "https://docs.google.com/open?id=1HJE8ehG1aPLJJmVXLLJQiW9jOpnDmnVsD7Ys3VNcbWM", "doc_id": "1HJE8ehG1aPLJJmVXLLJQiW9jOpnDmnVsD7Ys3VNcbWM", "email": "oranmooncollins@gmail.com", "resource_id": "document:1HJE8ehG1aPLJJmVXLLJQiW9jOpnDmnVsD7Ys3VNcbWM"} No newline at end of file | |||
There was a problem hiding this comment.
This file should not be source controlled
MotorPair.cpp
Outdated
|
|
||
| MotorPair::~MotorPair() | ||
| { | ||
| delete left, right; |
There was a problem hiding this comment.
this does not do what you think it does;
it is the equivalent of
delete left;
right; // this has no effect
right is not deleted
MotorPair.h
Outdated
|
|
||
| class MotorPair | ||
| { | ||
| motor *left, *right; |
There was a problem hiding this comment.
It would be better to just use regular objects instead of pointers.
A pointer here doesn't gain us anything.
ref #1
closes #1
Additions