TALAS  0.8.1
Arduino Laser Tank with Bluetooth
Talas Class Reference

Main TALAS class. More...

#include <Talas.h>

Public Member Functions

 Talas (String n)
 Constructor. More...
 

Device Attachments

For use in setup() function.

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...
 

Detailed Description

Main TALAS class.

Laser tank (or basin) controlling code.

Constructor & Destructor Documentation

◆ Talas()

Talas::Talas ( String  n)

Constructor.

Parameters
nTALAS name.

References TALAS_MAX_HEALTH, and TALAS_START_SPEED.

Member Function Documentation

◆ attachBluetooth()

void Talas::attachBluetooth ( )

Attach Bluetooth communication module.

Note
TALAS uses Serial1 for Bluetooth on Arduino Mega.

References BT, BT_SPEED, BT_TIMEOUT, and SERIAL_SPEED.

◆ attachDriver() [1/2]

void Talas::attachDriver ( uint8_t  pinIn1,
uint8_t  pinIn2,
uint8_t  pinIn3,
uint8_t  pinIn4 
)

Attach DC motors driver with constant full speed.

Note
Driver pins ENA and ENB must be closed by jumpers to use this method.
Parameters
pinIn1,pinIn2,pinIn3,pinIn4Arduino pins for driver input.

Referenced by attachDriver().

◆ attachDriver() [2/2]

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.

Note
There must be no jumpers on driver pins ENA and ENB to use this method.
Parameters
pinIn1,pinIn2,pinIn3,pinIn4Arduino pins for driver input.
pinEnA,pinEnBArduino pins for driver "enable" pins. Must be PWM-enabled.

References attachDriver().

◆ attachHealth()

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.

Parameters
pin0pin for red LED 'dead'.
pin1pin for green LED '1 life left'.
pin2pin for green LED '2 lives left'.
pin3pin for green LED '3 lives left'.

References resetHealth().

◆ attachHitDetector()

void Talas::attachHitDetector ( uint8_t  pinHit)

Attach hit detector.

Parameters
pinHitArduino pin for hit detector. Must be analog.

◆ attachTurret() [1/2]

void Talas::attachTurret ( uint8_t  pinLaser)

Attach turret with laser gun only.

Parameters
pinLaserpin for laser gun.

References Turret::attach(), and Turret::reset().

◆ attachTurret() [2/2]

void Talas::attachTurret ( uint8_t  pinLaser,
uint8_t  pinH,
uint8_t  pinV 
)

Attach movable turret with laser gun.

Parameters
pinLaserpin for laser gun.
pinHpin for horizontal servo.
pinVpin for vertical servo.

References Turret::attach(), and Turret::reset().

◆ dispatch()

void Talas::dispatch ( )

◆ faster()

void Talas::faster ( )

Move faster.

Decrease. speed.

Referenced by dispatch().

◆ handleImpulse()

void Talas::handleImpulse ( )

Handle timer interrupt and detect laser impulses.

Usage in Arduino sketch:

ISR(TIMER3_COMPB_vect) {
talas.handleImpulse();
}

References hit(), IMPULSE_VARIANCE, Impulse::length, Impulse::n, and Impulse::value.

◆ health()

uint8_t Talas::health ( )

Get health.

Returns
Health.

◆ hit()

void Talas::hit ( )

Handle hits.

Decrease health and check if dead already.

References Turret::disable(), Turret::enable(), and stop().

Referenced by dispatch(), and handleImpulse().

◆ name() [1/2]

void Talas::name ( String  n)

Set name.

Parameters
nnew name.

References TALAS_MAX_NAME_LENGTH.

◆ name() [2/2]

String Talas::name ( )

Get name.

Returns
Name.

References TALAS_MAX_HEALTH.

Referenced by dispatch().

◆ slower()

void Talas::slower ( )

◆ speed() [1/2]

void Talas::speed ( uint8_t  s)

Set speed.

Parameters
sspeed value.

◆ speed() [2/2]

uint8_t Talas::speed ( )

Get speed.

Returns
Speed.

Referenced by dispatch().


The documentation for this class was generated from the following files: