Hey,
I’m having a hard time finding examples for certain options.
Does anyone have a PWM example?
Hey,
I’m having a hard time finding examples for certain options.
Does anyone have a PWM example?
Hi Ruben, there is a “5. servo control (CORE2)” project template at cloud.husarion.com in Web IDE:
#include "hFramework.h"
#include "hCloudClient.h"
void cfgHandler()
{
platform.ui.loadHtml({Resource::URL, "/ui.html"});
}
void cloudTask() {
sys.delay(5000); //necessary to boot CORE2-ROS (with ASUS Tinker Board), for CORE2 can be commented
platform.begin(&RPi);
platform.ui.setProjectId("@@@PROJECT_ID@@@");
platform.ui.configHandler = cfgHandler;
auto lb1 = platform.ui.label("l1");
platform.ui.onButtonEvent = [](hId id, ButtonEventType type) {
static int cnt = 0;
UiButton b = platform.ui.button("btn1");
if (id == "btn1") {
if (type == ButtonEventType::Pressed) {
hServoModule.servo1.setWidth(1700);
b.setText("pressed %u", cnt++);
} else {
hServoModule.servo1.setWidth(2200);
b.setText("released %u", cnt++);
}
LED3.toggle();
}
};
while(1) {
sys.delay(500);
LED3.toggle();
lb1.setText("uptime %u [ms]", sys.getRefTime());
}
}
void hMain()
{
sys.taskCreate(cloudTask);
hServoModule.enablePower();
while (1) {
sys.delay(250);
LED1.toggle();
}
}