experimenting with xTaskCreate

This commit is contained in:
99cardz
2024-01-08 16:26:56 +01:00
parent f2253a7cb5
commit e42058bb82
2 changed files with 9 additions and 57 deletions

View File

@@ -20,16 +20,20 @@ Motion::Motion() {
void Motion::begin(void) {
}
// Move forward for a certain amount of time.
void Motion::move(uint32_t moveForMs) {
void moveTask(void * moveForMs) {
analogWrite(MOTOR_LEFT_PIN, 128);
analogWrite(MOTOR_RIGHT_PIN, 128);
vTaskDelay(moveForMs);
vTaskDelay((uint32_t) moveForMs);
analogWrite(MOTOR_LEFT_PIN, 0);
analogWrite(MOTOR_RIGHT_PIN, 0);
}
// Move forward for a certain amount of time.
void Motion::move(uint32_t moveForMs) {
xTaskCreate(moveTask, "Move", configMINIMAL_STACK_SIZE, (void*)moveForMs, 1, NULL);
}
// Rotate clockwise for a certain amount of time.
void Motion::rotateClockwise(uint32_t rotateForMs) {