Tobis Programm forked to not destroy your golden files
Fork of Robocode by
source/movement.cpp
- Committer:
- cittecla
- Date:
- 2017-03-02
- Revision:
- 19:baa8371d55b4
- Parent:
- 18:a82994e67297
- Child:
- 20:859c7aebf8a6
File content as of revision 19:baa8371d55b4:
/** * Movement function library * Handels Movement of the Robot **/ #include "mbed.h" #include "move.h" static double time_counter = 0.0f; static double timer0 = 0.0f; static float correction_value = 1.01f; static float power_value_slow = 0.6f; static float power_value_medium = 0.7f; static float power_value_fast = 0.8f; static float ludicrous_value = 1.0f; //motor stuff DigitalOut enableMotorDriver(PB_2); PwmOut pwmL(PA_8); PwmOut pwmR(PA_9); void move_init() { pwmL.period(0.00005f); // Setzt die Periode auf 50 μs pwmR.period(0.00005f); pwmL = 0.5f; // Setzt die Duty-Cycle auf 50% pwmR = 0.5f; enableMotorDriver = 0; } void move_forward_slow() { pwmL = power_value_slow; pwmR = 1-power_value_slow*correction_value; enableMotorDriver = 1; } void move_forward_medium() { pwmL = power_value_medium; pwmR = 1-power_value_medium*correction_value; enableMotorDriver = 1; } void move_forward_fast() { pwmL = power_value_fast; pwmR = 1-power_value_fast*correction_value; enableMotorDriver = 1; } void move_backward_slow() { pwmL = 1-power_value_slow*correction_value; pwmR = power_value_slow; enableMotorDriver = 1; } void move_backward_medium() { pwmL = 1-power_value_slow*correction_value; pwmR = power_value_slow; enableMotorDriver = 1; } void move_backward_fast() { pwmL = 1-power_value_slow*correction_value; pwmR = power_value_slow; enableMotorDriver = 1; } void stop_movement() { enableMotorDriver = 1; }