本文整理汇总了C++中PWM::set方法的典型用法代码示例。如果您正苦于以下问题:C++ PWM::set方法的具体用法?C++ PWM::set怎么用?C++ PWM::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PWM
的用法示例。
在下文中一共展示了PWM::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: light_init
void LIGHT::light_init()
{
//pwm initialized outside
//PWM head(PWM::pwm1, 0); //PWM for head lights
//PWM tail(PWM::pwm2, 0); //PWM for tail lights
hl_mode=OFF;
data_rcv.headlights=true;
head.set(0);
tail.set(0);
}
示例2: chk_light
void LIGHT::chk_light(void)
{
if(hl_mode_change==true)
{
hl_mode_change=false;
switch(hl_mode)
{
case AUTO:
head.set(100-io_other_snr_data.light); //Automatic head lights
tail.set(10);
break;
case ON:
head.set(100); //Head light On
tail.set(10); //Tail light On - DIM
break;
case OFF:
head.set(0); //Head light Off
tail.set(0); //Tail light Off
break;
default:
head.set(0); //Head light Off
tail.set(0); //Tail light Off
break;
}
}
if(hl_mode==AUTO)
{
head.set(100-io_other_snr_data.light);
}
if(data_rcv.speed_dir_data==true)
{
data_rcv.speed_dir_data=false;
if(io_speed.brake==SPEED_STOP || io_speed.brake==SPEED_EMERGENCY_STOP )
{
//printf("\nI am STOPPED !");
tail.set(100);
brake=true;
}
else
{
brake=false;
}
if(io_speed.dir==DIR_REV && brake==false)
{
if(flicker==true) //Tail light blinking
{
tail.set(0);
flicker=false;
}
else
{
tail.set(100);
flicker=true;
}
//printf("\nI am taking REVERSE !"); //Debugging
}
if(io_speed.dir==DIR_FWD && brake==false)
{
hl_mode_change=true; //Go to default state
//printf("\nI am going FORWARD !"); //Debugging
}
}
if(data_rcv.chkpt_data==true)
{
flick_cnt++; //Head light blink
if(flick_cnt%2)
head.set(100);
else
head.set(0);
if(flick_cnt>=6)
{
flick_cnt=0;
hl_mode_change=true;
data_rcv.chkpt_data=false;
}
}
if(dest_reached==true)
{
if(flicker==true) //Head and Tail light blinking
{
head.set(0);
tail.set(0);
flicker=false;
}
else
{
head.set(100);
tail.set(100);
flicker=true;
}
}
}