本文整理汇总了C++中setPower函数的典型用法代码示例。如果您正苦于以下问题:C++ setPower函数的具体用法?C++ setPower怎么用?C++ setPower使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setPower函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeAutomovement
int executeAutomovement(motorGroup *group, int debugStartCol) {
switch (group->moving) {
case TARGET:
if (group->posPID.kP != 0) {
int powerLimit = (group->autoStillSpeeding && errorLessThan(group, group->autoSSmargin) ? group->stillSpeed : 127); //limit power if autoStillSpeeding conditions are met
group->posPID.integralMax = powerLimit;
int PIDpower = PID_runtime(group->posPID, getPosition(group), debugStartCol);
setPower(group, copysign(PIDpower, limit(fabs(PIDpower), 0, powerLimit)));
}
break;
case MANEUVER:
if (group->forward == (getPosition(group) < group->targetPos)) {
group->maneuverTimer = resetTimer();
setPower(group, group->movePower);
}
else if (time(group->maneuverTimer) > group->maneuverTimeout) {
setPower(group, group->endPower);
group->moving = NO;
}
break;
case DURATION:
if (time(group->maneuverTimer) > group->moveDuration) {
setPower(group, group->endPower);
group->moving = NO;
}
else {
setPower(group, group->movePower);
}
break;
}
return getPower(group); //TODO: be better
}
示例2: initDEVICE
int initDEVICE(DEVICE *ret) {
int i=0;
if( startConnectionUE9(&ret->ue9) != 0 )
{
return -1;
}
for(i=0;i<4;i++)
{
ret->activeTrack[i]=false;
ret->activeTrackSensor[i]=false;
}
ret->trafficLightStatus=4;
if(setLights(ret) != 0)
return -2;
if( setPower( ret,0,false) !=0)
return -2;
if( setPower( ret,1,false) !=0)
return -2;
if( setPower( ret,2,false) !=0)
return -2;
if( setPower( ret,3,false) !=0)
return -2;
return 0;
}
示例3: handle_power_command
int handle_power_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
if (argc > 1)
{
return ERROR_INVALID_ARGUMENTS;
}
if (argc == 1)
{
if (strcmp(args[0], "on") == 0)
{
setPower(1);
}
else if (strcmp(args[0], "off") == 0)
{
setPower(0);
} else
{
command_print(cmd_ctx, "arg is \"on\" or \"off\"");
return ERROR_INVALID_ARGUMENTS;
}
}
command_print(cmd_ctx, "Target power %s", savePower ? "on" : "off");
return ERROR_OK;
}
示例4: disablePID
bool ElevatorModule::calibrate() {
if(!m_Enabled)
return false;
std::cout << "in calibrate" << std::endl;
Timer timeOut, timeOut2;
timeOut.Start();
bool renablePID = false;
disablePID();
if(m_PIDController->IsEnabled()){
renablePID = true;
}
while(!getButton()) {
if(timeOut.Get() > MAX_ELEVATOR_CALIBRATE_TIME_DOWN) {
throw CalibrationError(this, "ElevatorModule::calibrate()" , "calibrate timed out");
}
setPower(CALIBRATE_ELEVATOR_DOWN);
Wait(0.005);
}
std::cout << "After first loop" << std::endl;
setPower(0);
m_Encoder->Reset();
timeOut2.Start();
while(timeOut2.Get() < MAX_ELEVATOR_CALIBRATE_TIME_UP) {
setPower(CALIBRATE_ELEVATOR_UP);
Wait(0.005);
}
std::cout << "after second" << std::endl;
setPower(0);
if(getButton()) {
throw CalibrationError(this, "ElevatorModule::calibrate()" ,"check your button");
}
if(m_Encoder->PIDGet() < MIN_ELEVATOR_DISTANCE_CALIBRATE) {
throw CalibrationError(this, "ElevatorModule::calibrate()" , "check your encoder");
}
if(renablePID)
m_PIDController->Enable();
m_Calibration_Is_Done = true;
std::cout << "Done with Calibrate" << std::endl;
return true;
}
示例5: main
/*! \brief main
*/
int main(void)
{
//! temporary duty value
uint8_t duty;
//! temporary time counter
uint32_t time_counter;
init();
startFan(potzRead());
while (1)
{
duty = potzRead();
if (duty < MIN_PWM_DUTY)
{
duty = MIN_PWM_DUTY;
}
// do not update power when starting
if (g_fan.starting == FALSE)
{
setPower(duty);
}
// stalled rotor : power off, wait and restart
if (g_fan.stall == TRUE)
{
// power off
setPower(0);
// reset time counter
ATOMIC_BLOCK(ATOMIC_FORCEON)
{
g_time_counter = 0;
}
// wait until delay finished
do
{
ATOMIC_BLOCK(ATOMIC_FORCEON)
{
time_counter = g_time_counter;
}
}
while (time_counter <= STALL_RETRY_TIME);
// start up the fan again
startFan(duty);
}
}
示例6: printf
void CVFD::wake_up() {
printf("CVFD::wake_up>\n");
if (atoi(g_settings.lcd_setting_dim_time) > 0) {
printf("1\n");
timeout_cnt = atoi(g_settings.lcd_setting_dim_time);
atoi(g_settings.lcd_setting_dim_brightness) > 0 ?
setBrightness(g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS]) : setPower(1);
}
else
{
printf("2\n");
setPower(1);
}
printf("CVFD::wake_up<\n");
}
示例7: moveForDuration
//#subregion durational movement
void moveForDuration(motorGroup *group, int power, int duration, bool runConcurrently=true, int endPower=128) { //if endPower>127, will finish with stillSpeed
group->movePower = power;
group->moveDuration = duration;
group->moving = DURATION;
group->maneuverTimer = resetTimer();
group->endPower = (endPower>127 ? calcStillSpeed(group, power>0) : endPower);
setPower(group, group->movePower);
if (!runConcurrently) {
wait1Msec(duration);
setPower(group, group->endPower);
group->moving = NO;
}
}
示例8: atoi
void CLCD::wake_up()
{
if (g_info.hw_caps->display_type == HW_DISPLAY_LINE_TEXT) {
if (atoi(g_settings.lcd_setting_dim_time.c_str()) > 0) {
timeout_cnt = atoi(g_settings.lcd_setting_dim_time.c_str());
g_settings.lcd_setting_dim_brightness > -1 ?
setBrightness(g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS]) : setPower(1);
}
else
setPower(1);
if(g_settings.lcd_info_line){
switch_name_time_cnt = g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] + 10;
}
}
}
示例9: setColorMode
void HueLight::updateStates(const QVariantMap &statesMap)
{
// color mode
if (statesMap.value("colormode").toString() == "hs") {
setColorMode(ColorModeHS);
} else if (statesMap.value("colormode").toString() == "ct") {
setColorMode(ColorModeCT);
} else if (statesMap.value("colormode").toString() == "xy") {
setColorMode(ColorModeXY);
}
// effect (none, colorloop)
if (statesMap.value("effect").toString() == "none") {
setEffect("none");
} else if (statesMap.value("effect").toString() == "colorloop") {
setEffect("color loop");
}
setReachable(statesMap.value("reachable").toBool());
// alert (none, select, lselect)
setAlert(statesMap.value("alert").toString());
setBrigtness(statesMap.value("bri").toInt());
setCt(statesMap.value("ct").toInt());
setPower(statesMap.value("on").toBool());
setSat(statesMap.value("sat").toInt());
setHue(statesMap.value("hue").toInt());
if (!statesMap.value("xy").toList().isEmpty())
setXy(QPointF(statesMap.value("xy").toList().first().toFloat(), statesMap.value("xy").toList().last().toFloat()));
emit stateChanged();
}
示例10: Error_init
void A110x2500Radio::begin(uint8_t address, channel_t channel, power_t power)
{
gDataTransmitting = false;
gDataReceived = false;
Task_Params taskParams;
Error_Block eb;
Error_init(&eb);
GateMutex_construct(&mygate, NULL);
sem = Semaphore_create(0, NULL, &eb);
// Configure the radio and set the default address, channel, and TX power.
A110LR09Init(&gPhyInfo, &gSpi, gGdo);
setAddress(address);
setChannel(channel);
setPower(power);
Task_Params_init(&taskParams);
taskParams.priority = Task_numPriorities - 1;
taskParams.stackSize = 0x800;
Task_create(serviceInterrupt, &taskParams, &eb);
attachInterrupt(RF_GDO0, gdo0Isr, FALLING);
sleep();
}
示例11: fmax
void DriveModule::drive(double throttle, double angle) {
throttle = driveFunc.transformThrottle(throttle);
angle = driveFunc.transformAngle(angle);
double leftMotorOutput = 0;
double rightMotorOutput = 0;
if(throttle > 0.0) {
angle = -angle;
if(angle < 0.0) {
leftMotorOutput = (throttle + angle);
rightMotorOutput = fmax(throttle, -angle);
}
else {
leftMotorOutput = fmax(throttle, angle);
rightMotorOutput = (throttle - angle);
}
}
else {
if(angle > 0.0) {
leftMotorOutput = -fmax(-throttle, angle);
rightMotorOutput = throttle + angle;
//std::cout << rightMotorOutput << std::endl;
}
else {
leftMotorOutput = throttle - angle;
rightMotorOutput = -fmax(-throttle,-angle);
}
}
setPower(leftMotorOutput, rightMotorOutput);
}
示例12: initPower
void initPower( void )
{
chMtxInit( &g_mutex );
setPower( 0 );
chThdCreateStatic( waPower, sizeof(waPower), NORMALPRIO, Power, NULL );
}
示例13: pinMode
void Motor::setControlPin(int control_pin_)
{
controlPin = control_pin_;
pinMode(controlPin, OUTPUT);
setPower(0);
}
示例14: setCeLow
void nrf24l01p::rxMode()
{
setCeLow();
writeRegister(CONFIG, _BV(EN_CRC) | _BV(CRCO)); // Enable CRC (2bytes)
delayMicroseconds(100);
writeRegister(EN_AA, 0x00); // Disable auto acknowledgment
writeRegister(EN_RXADDR, 0x01); // Enable first data pipe
writeRegister(SETUP_AW, 0x03); // 5 bytes address
writeRegister(SETUP_RETR, 0xFF); // 15 retransmit, 4000us pause
writeRegister(RF_CH, 0x00); // channel 8
setBitrate(NRF24L01_BR_250K);
setPower(mPower);
writeRegister(STATUS, 0x70); // Clear status register
writeRegister(RX_PW_P0, 0x0A); // RX payload of 10 bytes
writeRegister(FIFO_STATUS, 0x00); // Nothing useful for write command
delay(50);
flushTx();
flushRx();
delayMicroseconds(100);
writeRegister(CONFIG, _BV(EN_CRC) | _BV(CRCO) | _BV(PWR_UP) );
delayMicroseconds(100);
writeRegister(CONFIG, _BV(EN_CRC) | _BV(CRCO) | _BV(PWR_UP) | _BV(PRIM_RX) );
delayMicroseconds(130);
setCeHigh();
delayMicroseconds(100);
}
示例15: reduce_phase2
void * reduce_phase2(const void * _exp)
{
if(isA(_exp, Integer()))
return domainCast(_exp, Real());
else if(isA(_exp, Real()) || isA(_exp, Var()))
return copy(_exp);
else if(isA(_exp, Sum()) || isA(_exp, Product()))
{
void * s = copy(_exp);
size_t i;
for(i = 0; i < size(s); ++i)
{
delete(argv(s, i));
setArgv(s, i, reduce_phase2(argv(_exp, i)));
}
return s;
}
else if(isA(_exp, Pow()))
{
void * p = copy(_exp);
delete(base(p));
delete(power(p));
setBase(p, reduce_phase2(base(_exp)));
setPower(p, reduce_phase2(power(_exp)));
return p;
}
else if(isOf(_exp, Apply_1()))
{
void * f = copy(_exp);
delete(arg(f));
setArg(f, reduce_phase2(arg(_exp)));
return f;
}
assert(0);
}