33 #include <libphidget22/phidget22.h>
41 std::function<
void(
int,
double)> duty_cycle_change_handler,
42 std::function<
void(
int,
double)> back_emf_change_handler)
44 PhidgetReturnCode ret;
46 PhidgetDCMotorHandle motor_handle;
48 ret = PhidgetDCMotor_create(&motor_handle);
49 if (ret != EPHIDGET_OK)
52 "Failed to create Motor handle for determining channel "
57 PhidgetHandle handle =
reinterpret_cast<PhidgetHandle
>(motor_handle);
60 is_hub_port_device, 0);
62 ret = Phidget_getDeviceChannelCount(handle, PHIDCHCLASS_DCMOTOR,
67 if (ret != EPHIDGET_OK)
69 throw Phidget22Error(
"Failed to get Motor device channel count", ret);
75 motors_[i] = std::make_unique<Motor>(
76 serial_number, hub_port, is_hub_port_device, i,
77 duty_cycle_change_handler, back_emf_change_handler);
92 return motors_.at(index)->getDutyCycle();
97 motors_.at(index)->setDutyCycle(duty_cycle);
102 return motors_.at(index)->getAcceleration();
107 motors_.at(index)->setAcceleration(acceleration);
112 return motors_.at(index)->getBackEMF();
117 motors_.at(index)->setDataInterval(data_interval_ms);
122 return motors_.at(index)->getBraking();
127 motors_.at(index)->setBraking(braking);