本文整理汇总了C++中Motor::set_duty方法的典型用法代码示例。如果您正苦于以下问题:C++ Motor::set_duty方法的具体用法?C++ Motor::set_duty怎么用?C++ Motor::set_duty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Motor
的用法示例。
在下文中一共展示了Motor::set_duty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Aircraft_Init
void Aircraft_Init(void) {
GPIO_InitTypeDef GPIO_InitStructure;
// LCD
#ifdef _DEBUG_WITH_LCD
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_ResetBits(GPIOD , GPIO_Pin_7); //CS=0;
LCD_Initializtion();
LCD_Clear(Blue);
#endif
// 捕获器
tim_throttle.mode_pwm_input(THROTTLE_PIN);
tim_pitch.mode_pwm_input(PITCH_PIN);
tim_yaw.mode_pwm_input(YAW_PIN);
tim_roll.mode_pwm_input(ROLL_PIN);
// 调度器
tim_sch.mode_sch();
// 接收机
receiver.stick_throttle_ = Stick(0.0502,0.0999,0,NEGATIVE_LOGIC);
// 油门最高点,听到确认音
motor1 = Motor(PWM_FREQ,MAX_DUTY,MOTOR1_PWM_TIM,MOTOR1_PWM_CH,MOTOR1_PWM_PIN);
motor2 = Motor(PWM_FREQ,MAX_DUTY,MOTOR2_PWM_TIM,MOTOR2_PWM_CH,MOTOR2_PWM_PIN);
motor3 = Motor(PWM_FREQ,MAX_DUTY,MOTOR3_PWM_TIM,MOTOR3_PWM_CH,MOTOR3_PWM_PIN);
motor4 = Motor(PWM_FREQ,MAX_DUTY,MOTOR4_PWM_TIM,MOTOR4_PWM_CH,MOTOR4_PWM_PIN);
// 电调接上电池,等待2S
Delay(DELAY_1S);
Delay(DELAY_1S);
// 以防万一,再次延迟2S
// Delay(DELAY_1S);
// Delay(DELAY_1S);
// 油门推到最低,等待1S
motor1.set_duty(MIN_DUTY);
motor2.set_duty(MIN_DUTY);
motor3.set_duty(MIN_DUTY);
motor4.set_duty(MIN_DUTY);
Delay(DELAY_1S);
Delay(DELAY_1S);
Delay(DELAY_1S);
// 油门最低点确认音,可以起飞
// LED4
RCC_AHB1PeriphClockCmd(LED4_GPIO_CLK, ENABLE);
GPIO_InitStructure.GPIO_Pin = LED4_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(LED4_GPIO_PORT, &GPIO_InitStructure);
GPIO_ResetBits(LED4_GPIO_PORT,LED4_PIN);
init_flag = 1;
}
示例2: TIM8_UP_TIM13_IRQHandler
void TIM8_UP_TIM13_IRQHandler(void) {
//
TIM_ClearITPendingBit(tim_sch.TIM, TIM_IT_Update);
//
counter++;
if ((counter%2000)==0) {
//GPIO_ToggleBits(LED4_GPIO_PORT, LED4_PIN);
}
//
receiver.update_data(tim_throttle.DutyCycle);
if (init_flag) {
motor1.set_duty(receiver.stick_throttle_.convert_duty_);
motor2.set_duty(receiver.stick_throttle_.convert_duty_);
motor3.set_duty(receiver.stick_throttle_.convert_duty_);
motor4.set_duty(receiver.stick_throttle_.convert_duty_);
}
}