diff --git a/app/raspberry_pi/tests/tb6612/test_rear_wheels.cpp b/app/raspberry_pi/tests/tb6612/test_rear_wheels.cpp index b1be5a53..e65dbed3 100644 --- a/app/raspberry_pi/tests/tb6612/test_rear_wheels.cpp +++ b/app/raspberry_pi/tests/tb6612/test_rear_wheels.cpp @@ -1,35 +1,34 @@ #include -#include "gpiod.hpp" +#include "pigpio.h" +#include "pigpiod_if2.h" + +void setupGPIOMotor(); int main() { - + setupGPIOMotor(); return 0; } void setupGPIOMotor() { int directionChannel; - // Setup GPIO for direction channel - gpiod::chip chip("/dev/gpiochip0"); - int direction_channel = 17; - chip.prepare_request() - .add_line_settings( - gpiod::line::offset(direction_channel), gpiod::line_settings() - .set_direction(gpiod::line::direction::OUTPUT) // Setup the GPIO - .set_debounce_period(std::chrono::microseconds(100)) // 100 Speed - .set_output_value(gpiod::line::value::ACTIVE) // Move wheel - ) - .do_request(); - - std::this_thread::sleep_for(std::chrono::seconds(5)); - - chip.prepare_request() - .add_line_settings( - gpiod::line::offset(direction_channel), gpiod::line_settings() - .set_direction(gpiod::line::direction::OUTPUT) // Setup the GPIO - .set_output_value(gpiod::line::value::INACTIVE) // Stop wheel - ) - .do_request(); + + gpioSetMode(directionChannel, PI_OUTPUT); + + int pinA = 12; + int pinB = 13; + int frequency = 1000; + + gpioSetMode(pinA, PI_OUTPUT); + gpioSetMode(pinB, PI_OUTPUT); + int a = gpioHardwarePWM(pinA, frequency, 0); + int b = gpioHardwarePWM(pinB, frequency, 0); + + int value = 0; + + gpioHardwarePWM(pinB, frequency, static_cast(value)); + gpioHardwarePWM(pinA, frequency, static_cast(value)); + } \ No newline at end of file diff --git a/app/raspberry_pi/xmake.lua b/app/raspberry_pi/xmake.lua index f5a61f98..75603a23 100644 --- a/app/raspberry_pi/xmake.lua +++ b/app/raspberry_pi/xmake.lua @@ -19,7 +19,7 @@ add_requires("imath") if is_plat("linux", "macosx") then -- For the SunFounder Car add_requires("pca9685") - add_requires("tb6612") + add_requires("pigpio") end -- For Functional Programming? @@ -47,7 +47,7 @@ target("raspberry_pi") -- For the SunFounder Car add_packages("rplidar") add_packages("pca9685") - add_packages("tb6612") + add_packages("pigpio") add_headerfiles("include/**.h") @@ -84,7 +84,7 @@ if is_plat("linux") then set_default(false) set_license("LGPL-2.1") - add_packages("tb6612") + add_packages("pigpio") add_files("tests/tb6612/" .. name .. ".cpp") target_end()