![]() |
TALAS
0.8.1
Arduino Laser Tank with Bluetooth
|
Main TALAS class. More...
#include <Talas.h>
Public Member Functions | |
Talas (String n) | |
Constructor. More... | |
Device Attachments | |
void | attachHealth (uint8_t pin0, uint8_t pin1, uint8_t pin2, uint8_t pin3) |
Attach health indicator. More... | |
void | attachDriver (uint8_t pinIn1, uint8_t pinIn2, uint8_t pinIn3, uint8_t pinIn4) |
Attach DC motors driver with constant full speed. More... | |
void | attachDriver (uint8_t pinIn1, uint8_t pinIn2, uint8_t pinIn3, uint8_t pinIn4, uint8_t pinEnA, uint8_t pinEnB) |
Attach DC motors driver with speed control. More... | |
void | attachTurret (uint8_t pinLaser) |
Attach turret with laser gun only. More... | |
void | attachTurret (uint8_t pinLaser, uint8_t pinH, uint8_t pinV) |
Attach movable turret with laser gun. More... | |
void | attachHitDetector (uint8_t pinHit) |
Attach hit detector. More... | |
void | attachBluetooth () |
Attach Bluetooth communication module. More... | |
Name | |
void | name (String n) |
Set name. More... | |
String | name () |
Get name. More... | |
Health Indicator | |
uint8_t | health () |
Get health. More... | |
void | resetHealth () |
Reset health (set health to a maximum value). | |
Hit Detector | |
void | handleImpulse () |
Handle timer interrupt and detect laser impulses. More... | |
void | hit () |
Handle hits. More... | |
Movement | |
void | forward () |
Move forward. | |
void | backward () |
Move backward. | |
void | left () |
Turn left. | |
void | right () |
Turn right. | |
void | stop () |
Stop. | |
void | speed (uint8_t s) |
Set speed. More... | |
uint8_t | speed () |
Get speed. More... | |
void | slower () |
Move slower. More... | |
void | faster () |
Move faster. More... | |
Turret | |
See Turret class reference. | |
void | setTurretRange (uint8_t, uint8_t, uint8_t, uint8_t) |
void | setTurretDelta (uint8_t, uint8_t) |
void | resetTurret () |
uint8_t | getTurretH () |
uint8_t | getTurretV () |
void | turretUp () |
void | turretDown () |
void | turretLeft () |
void | turretRight () |
Laser Gun | |
void | fire () |
Fire laser gun. | |
Bluetooth Commands | |
void | dispatch () |
Dispatch Bluetooth commands. More... | |
Main TALAS class.
Laser tank (or basin) controlling code.
Talas::Talas | ( | String | n | ) |
void Talas::attachBluetooth | ( | ) |
Attach Bluetooth communication module.
References BT, BT_SPEED, BT_TIMEOUT, and SERIAL_SPEED.
void Talas::attachDriver | ( | uint8_t | pinIn1, |
uint8_t | pinIn2, | ||
uint8_t | pinIn3, | ||
uint8_t | pinIn4 | ||
) |
Attach DC motors driver with constant full speed.
pinIn1,pinIn2,pinIn3,pinIn4 | Arduino pins for driver input. |
Referenced by attachDriver().
void Talas::attachDriver | ( | uint8_t | pinIn1, |
uint8_t | pinIn2, | ||
uint8_t | pinIn3, | ||
uint8_t | pinIn4, | ||
uint8_t | pinEnA, | ||
uint8_t | pinEnB | ||
) |
Attach DC motors driver with speed control.
pinIn1,pinIn2,pinIn3,pinIn4 | Arduino pins for driver input. |
pinEnA,pinEnB | Arduino pins for driver "enable" pins. Must be PWM-enabled. |
References attachDriver().
void Talas::attachHealth | ( | uint8_t | pin0, |
uint8_t | pin1, | ||
uint8_t | pin2, | ||
uint8_t | pin3 | ||
) |
Attach health indicator.
Indicator uses digital pins for 4 LEDs.
pin0 | pin for red LED 'dead'. |
pin1 | pin for green LED '1 life left'. |
pin2 | pin for green LED '2 lives left'. |
pin3 | pin for green LED '3 lives left'. |
References resetHealth().
void Talas::attachHitDetector | ( | uint8_t | pinHit | ) |
Attach hit detector.
pinHit | Arduino pin for hit detector. Must be analog. |
void Talas::attachTurret | ( | uint8_t | pinLaser | ) |
Attach turret with laser gun only.
pinLaser | pin for laser gun. |
References Turret::attach(), and Turret::reset().
void Talas::attachTurret | ( | uint8_t | pinLaser, |
uint8_t | pinH, | ||
uint8_t | pinV | ||
) |
Attach movable turret with laser gun.
pinLaser | pin for laser gun. |
pinH | pin for horizontal servo. |
pinV | pin for vertical servo. |
References Turret::attach(), and Turret::reset().
void Talas::dispatch | ( | ) |
Dispatch Bluetooth commands.
Usage in Arduino sketch:
References backward(), BT, BT_STR_TERM, Turret::down(), faster(), fire(), forward(), Turret::getH(), Turret::getV(), hit(), Turret::left(), left(), name(), Turret::reset(), resetHealth(), Turret::right(), right(), slower(), speed(), stop(), TALAS_DISPATCH_DELAY, TALAS_MAX_HEALTH, and Turret::up().
void Talas::faster | ( | ) |
void Talas::handleImpulse | ( | ) |
Handle timer interrupt and detect laser impulses.
Usage in Arduino sketch:
References hit(), IMPULSE_VARIANCE, Impulse::length, Impulse::n, and Impulse::value.
uint8_t Talas::health | ( | ) |
Get health.
void Talas::hit | ( | ) |
Handle hits.
Decrease health and check if dead already.
References Turret::disable(), Turret::enable(), and stop().
Referenced by dispatch(), and handleImpulse().
void Talas::name | ( | String | n | ) |
String Talas::name | ( | ) |
void Talas::slower | ( | ) |
Move slower.
Decrease speed.
References Turret::down(), Turret::getH(), Turret::getV(), Turret::left(), Turret::reset(), Turret::right(), Turret::setDelta(), Turret::setRange(), and Turret::up().
Referenced by dispatch().
void Talas::speed | ( | uint8_t | s | ) |
Set speed.
s | speed value. |
uint8_t Talas::speed | ( | ) |