Arduino {code}racer API
... better know the details.

Functions

void CodeRacer::drives_settings (uint8_t drive_left_speed, uint8_t drive_right_speed, unsigned long turn_left_ms, unsigned long turn_right_ms)
 Overwrites some drive settings. This will replace the defaults set by the values in the header file. More...
 
void CodeRacer::set_drives_stop_left_right ()
 Stopps both drives. More...
 
void CodeRacer::set_drives_states_left_right (drivestate stateleft, drivestate stateright)
 Sets both of the drives to a specified drivestate (DRIVESTOP, DRIVEFRWD, DRIVEBACK) More...
 
void CodeRacer::set_drive_left_state (drivestate state)
 Sets the left side drive to the specified drivestate (DRIVESTOP, DRIVEFRWD, DRIVEBACK) More...
 
void CodeRacer::set_drive_right_state (drivestate state)
 Sets the right side drive to the specified drivestate (DRIVESTOP, DRIVEFRWD, DRIVEBACK) More...
 
void CodeRacer::set_drive_state (drivestate state, uint8_t frwdpin, uint8_t backpin)
 Sets the specified drivestate for the drive connected to the sepecified pins (DRIVESTOP, DRIVEFRWD, DRIVEBACK) More...
 
void CodeRacer::set_drives_speed_left_right (uint8_t speedleft, uint8_t speedright)
 Sets the speed for both of the drives. More...
 
void CodeRacer::set_drive_left_speed (uint8_t speed)
 Sets the speed for the left side drive. More...
 
void CodeRacer::set_drive_right_speed (uint8_t speed)
 Sets the speed for the right side drive. More...
 
void CodeRacer::set_drive_speed (uint8_t speed, uint8_t enablepin)
 Sets the speed for the drive of the enable pin connected to the specified pin. More...
 

Detailed Description

Function Documentation

◆ drives_settings()

void CodeRacer::drives_settings ( uint8_t  drive_left_speed,
uint8_t  drive_right_speed,
unsigned long  turn_left_for_ms,
unsigned long  turn_right_for_ms 
)

Overwrites some drive settings. This will replace the defaults set by the values in the header file.

Parameters
drive_left_speedSpeed of the left side drive
drive_right_speedSpeed of the right side drive
turn_left_for_msTime in ms the racer will turn to the left around its center if turn_left() is called
turn_right_for_msTime in ms the racer will turn to the right around its center if turn_right() is called
Returns
nothing

Definition at line 878 of file CodeRacer.cpp.

879 {
880  _drive_left_speed = drive_left_speed;
881  _drive_right_speed = drive_right_speed;
882  _turn_left_for_ms = turn_left_for_ms;
883  _turn_right_for_ms = turn_right_for_ms;
884 }

◆ set_drives_stop_left_right()

void CodeRacer::set_drives_stop_left_right ( )

Stopps both drives.

Returns
nothing

Definition at line 889 of file CodeRacer.cpp.

889  {
890  set_drive_left_state(DRIVESTOP);
891  set_drive_right_state(DRIVESTOP);
892 }

◆ set_drives_states_left_right()

void CodeRacer::set_drives_states_left_right ( drivestate  stateleft,
drivestate  stateright 
)

Sets both of the drives to a specified drivestate (DRIVESTOP, DRIVEFRWD, DRIVEBACK)

Parameters
stateleftdrivestate to set for the left side drive
staterightdrivestate to set for the right side drive
Returns
nothing

Definition at line 899 of file CodeRacer.cpp.

899  {
900  set_drive_left_state(stateleft);
901  set_drive_right_state(stateright);
902 }

◆ set_drive_left_state()

void CodeRacer::set_drive_left_state ( drivestate  state)

Sets the left side drive to the specified drivestate (DRIVESTOP, DRIVEFRWD, DRIVEBACK)

Parameters
statedrivestate to set for the left side drive
Returns
nothing

Definition at line 908 of file CodeRacer.cpp.

908  {
909  set_drive_state(state, _drive_left_frwd_pin, _drive_left_back_pin);
910 }

◆ set_drive_right_state()

void CodeRacer::set_drive_right_state ( drivestate  state)

Sets the right side drive to the specified drivestate (DRIVESTOP, DRIVEFRWD, DRIVEBACK)

Parameters
statedrivestate to set for the right side drive
Returns
nothing

Definition at line 916 of file CodeRacer.cpp.

916  {
917  set_drive_state(state, _drive_right_frwd_pin, _drive_right_back_pin);
918 }

◆ set_drive_state()

void CodeRacer::set_drive_state ( drivestate  state,
uint8_t  frwdpin,
uint8_t  backpin 
)

Sets the specified drivestate for the drive connected to the sepecified pins (DRIVESTOP, DRIVEFRWD, DRIVEBACK)

Parameters
statedrivestate to set for the connected drive
frwdpinPin the forward signal of the drive device driver is connected at
backpinPin the backward signal of the drive device driver is connected at
Returns
nothing

Definition at line 926 of file CodeRacer.cpp.

926  {
927  switch (state) {
928  case DRIVESTOP:
929  digitalWrite(frwdpin, LOW);
930  digitalWrite(backpin, LOW);
931  break;
932  case DRIVEFRWD:
933  digitalWrite(frwdpin, HIGH);
934  digitalWrite(backpin, LOW);
935  break;
936  case DRIVEBACK:
937  digitalWrite(frwdpin, LOW);
938  digitalWrite(backpin, HIGH);
939  break;
940  }
941 }

◆ set_drives_speed_left_right()

void CodeRacer::set_drives_speed_left_right ( uint8_t  speedleft,
uint8_t  speedright 
)

Sets the speed for both of the drives.

The drive will run with that speed afterwards. The direction of the drive has to be specfied with one of the set_drive_state methods before

Parameters
speedleftspeed of the left side drive. 0<=speed<=255
speedrightspeed of the right side drive. 0<=speed<=255
Returns
nothing

Definition at line 950 of file CodeRacer.cpp.

950  {
951  set_drive_left_speed(speedleft);
952  set_drive_right_speed(speedright);
953 }

◆ set_drive_left_speed()

void CodeRacer::set_drive_left_speed ( uint8_t  speed)

Sets the speed for the left side drive.

The drive will run with that speed afterwards. The direction of the drive has to be specfied with one of the set_drive_state methods before

Parameters
speedspeed of the left side drive. 0<=speed<=255
Returns
nothing

Definition at line 961 of file CodeRacer.cpp.

961  {
962  set_drive_speed(speed, _drive_left_enable_pin);
963 }

◆ set_drive_right_speed()

void CodeRacer::set_drive_right_speed ( uint8_t  speed)

Sets the speed for the right side drive.

The drive will run with that speed afterwards. The direction of the drive has to be specfied with one of the set_drive_state methods before

Parameters
speedspeed of the right side drive. 0<=speed<=255
Returns
nothing

Definition at line 971 of file CodeRacer.cpp.

971  {
972  set_drive_speed(speed, _drive_right_enable_pin);
973 }

◆ set_drive_speed()

void CodeRacer::set_drive_speed ( uint8_t  speed,
uint8_t  enablepin 
)

Sets the speed for the drive of the enable pin connected to the specified pin.

The drive will run with that speed afterwards. The direction of the drive has to be specfied with one of the set_drive_state methods before

Parameters
speedspeed of the drive. 0<=speed<=255
enablepinPin the drives device driver enable pin is connected at
Returns
nothing

Definition at line 982 of file CodeRacer.cpp.

982  {
983  _analog_write(enablepin, (int)speed);
984 }