_servo_dummy=newServo();// the dummy is needed so far to avoid conflicts with analog write
_servo=newServo();
...
...
@@ -490,6 +497,142 @@ void CodeRacer::kitt()
/** @} */// end of group lowerlevelfun
//**************************************
//*** Bluetooth ***
//**************************************
/** @defgroup lowerlevelbluetooth Lower level bluetooth methods
* @{
*/
/** @brief starting the bluetooth service for the coderacer if not already started
* @param name the device will be listed by that name in your bluetooth device lists
* @return nothing
*/
voidCodeRacer::bt_start(Stringname)
{
if(false==_bluetoothcreated){
_BTSerial=newBluetoothSerial();
_BTSerial->begin(name);
_bluetoothcreated=true;
}
}
/** @brief enables the code to stop if there was no incoming message for the specified time. This will be checked everytime bt_getXXX or bt_msgavailable is called.
* @param timeout after that duration of milliseconds without an incoming bluetooth message the coderacer will be stopped. 0 means this stoppinf is disabled.
/** @brief enables the code to stop if there was no incoming message for 1 second. This will be checked everytime bt_getXXX or bt_msgavailable is called.
* @return nothing
*/
voidCodeRacer::bt_enable_stopOnLostConnection()
{
_bt_stopOnLostConnection_timeout_ms=1000;
}
/** @brief Disables the code to stop if there was no incoming message for a certain duration of time.
* @return nothing
*/
voidCodeRacer::bt_disable_stopOnLostConnection()
{
_bt_stopOnLostConnection_timeout_ms=0;
}
/** @brief gets the bluetooth message string until a delimiter of 0
* @return will return the string. If nothing is availbale or the service is not started it will return an empty string.
*/
StringCodeRacer::bt_getString()
{
returnbt_getString(0);
}
/** @brief gets the bluetooth message string until a specified delimiter
* @return will return the string. If nothing is availbale or the service is not started it will return an empty string.
/** @brief add a String to a list of Strings that will be ignored if this is received via blue tooth. Ignores means - it will be read from the pipe but not returned to user code. But it will reset the message timeout counter.
* @param stringtoignore the String that has to be ignored. Will be added to the internal list if not already there.
/** @brief removes a String from the list of Strings that will be ignored if this is received via blue tooth. Ignores means - it will be read from the pipe but not returned to user code. But it will reset the message timeout counter.
* @param stringtoignore the String that has to be removed from the ignore list.
/** @brief Clears the list of Strings that will be ignored if this is received via blue tooth. All elements of the list will be deleted from the list.
*/
voidCodeRacer::bt_clearIgnoreList()
{
_bt_ignoremsgs.clear();
}
/** @brief checks if a bluetooth is available. Will also stop the coderacer if there was nor message received for a certain time - and if stopping was enabled .
* @return true if a message is available , false if not message is available or the service was not started
#define US_STOP_ABSTAND_CM 20 // if distance goes below that - stop the racer
//----- {CODES}RACER API -> online: https://doc.itsblue.de/Fenoglio/coderacer/Doku/Doxygen/html/
//-- Some main higher level methods listed below
// void CodeRacer::stop_driving () Stops the racer and sets status LEDs
// void CodeRacer::drive_forward () Sets the speed and the directions of both drives so that it will move forward.
// void CodeRacer::drive_backward () Sets the speed and the directions of both drives so that it will move backward.
// void CodeRacer::turn_left () Will turn the racer to the left for the internally stored time in ms and with the internally stored speed.
// void CodeRacer::turn_right () Will turn the racer to the right for the internally stored time in ms and with the internally stored speed.
// void CodeRacer::start_stop_at_min_distance () Enables to stopp the racer if during a distance measurement the measured distance is smaller then the internally stored minimal distance.
// void CodeRacer::stop_stop_at_min_distance () Disables to stopp the racer if during a distance measurement the measured distance is smaller then the specified minimal distance.
// bool CodeRacer::start_stop () This will return if the codracer is in active mode or not.
// void CodeRacer::servo_set_to_right () Drives the servo to the postion that is defined by #servo_right_pos.
// void CodeRacer::servo_set_to_left () Drives the servo to the postion that is defined by #servo_left_pos.
// void CodeRacer::servo_set_to_center () Drives the servo to the postion that is defined by #servo_center_pos.
// uint8_t CodeRacer::servo_position () Get the actual position of the servo.
// unsigned long CodeRacer::usonic_measure_cm () Measures the distance to the next object in front of the ultra sonic sensor in cm.
//
// ... there are much more ... read the online API for more details.