summaryrefslogtreecommitdiff
path: root/firmware/lib/motors/motors.cpp
diff options
context:
space:
mode:
authorEnricoGuccii <partyka.003@proton.me>2026-05-29 23:34:00 +0200
committerEnricoGuccii <partyka.003@proton.me>2026-05-29 23:34:00 +0200
commitd3b283c69e9cf5ac6fe18c25be77a9b0488b9454 (patch)
treeb39c0bda024eb053a0daab7b938be72a7d3e470e /firmware/lib/motors/motors.cpp
parent4bd0a060d100c7fb9ad657c939b954b081b62016 (diff)
new file structure, and buzzer removed
Diffstat (limited to 'firmware/lib/motors/motors.cpp')
-rw-r--r--firmware/lib/motors/motors.cpp146
1 files changed, 0 insertions, 146 deletions
diff --git a/firmware/lib/motors/motors.cpp b/firmware/lib/motors/motors.cpp
deleted file mode 100644
index ba9f828..0000000
--- a/firmware/lib/motors/motors.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-#include <Arduino.h>
-#include "settings.h"
-#include "motors.h"
-
-#define LEFT_CHANNEL 4
-#define RIGHT_CHANNEL 5
-
-#define MOTOR_FREQ 5000
-#define MOTOR_RES 10
-
-int MOTORS::scaleSpeed(int speed)
-{
- return map(speed, 0, 100, 0, (1 << MOTOR_RES) - 1);
-}
-
-MOTORS::MOTORS()
-{
-}
-
-void MOTORS::stop()
-{
- ledcWrite(LEFT_CHANNEL, 0);
- ledcWrite(RIGHT_CHANNEL, 0);
-}
-
-void MOTORS::leftStop()
-{
- ledcWrite(LEFT_CHANNEL, 0);
-}
-
-void MOTORS::rightStop()
-{
- ledcWrite(RIGHT_CHANNEL, 0);
-}
-
-void MOTORS::init()
-{
- ledcSetup(RIGHT_CHANNEL, MOTOR_FREQ, MOTOR_RES);
- ledcAttachPin(EN34, RIGHT_CHANNEL);
-
- ledcSetup(LEFT_CHANNEL, MOTOR_FREQ, MOTOR_RES);
- ledcAttachPin(EN12, LEFT_CHANNEL);
-
- pinMode(IN1, OUTPUT);
- pinMode(IN2, OUTPUT);
- pinMode(IN3, OUTPUT);
- pinMode(IN4, OUTPUT);
-}
-
-void MOTORS::leftForward(int speed, int duration)
-{
- digitalWrite(IN1, HIGH);
- digitalWrite(IN2, LOW);
- ledcWrite(LEFT_CHANNEL, scaleSpeed(speed));
-
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-}
-
-void MOTORS::leftBackward(int speed, int duration)
-{
- digitalWrite(IN1, LOW);
- digitalWrite(IN2, HIGH);
- ledcWrite(LEFT_CHANNEL, scaleSpeed(speed));
-
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-}
-
-void MOTORS::rightForward(int speed, int duration)
-{
- digitalWrite(IN3, HIGH);
- digitalWrite(IN4, LOW);
- ledcWrite(RIGHT_CHANNEL, scaleSpeed(speed));
- ledcWrite(LEFT_CHANNEL, 0);
-
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-}
-
-void MOTORS::rightBackward(int speed, int duration)
-{
- digitalWrite(IN3, LOW);
- digitalWrite(IN4, HIGH);
- ledcWrite(RIGHT_CHANNEL, scaleSpeed(speed));
- ledcWrite(LEFT_CHANNEL, 0);
-
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-}
-
-void MOTORS::forward(int speed, int duration)
-{
- rightForward(speed);
- leftForward(speed);
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-}
-
-void MOTORS::backward(int speed, int duration)
-{
- rightBackward(speed);
- leftBackward(speed);
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-}
-
-void MOTORS::rightTurn(int speed, int duration)
-{
- rightForward(speed);
- leftBackward(speed);
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-}
-
-void MOTORS::leftTurn(int speed, int duration)
-{
- rightBackward(speed);
- leftForward(speed);
- if (duration > 0)
- {
- delay(duration);
- stop();
- }
-} \ No newline at end of file