本文整理汇总了C++中pwmout_pulsewidth_us函数的典型用法代码示例。如果您正苦于以下问题:C++ pwmout_pulsewidth_us函数的具体用法?C++ pwmout_pulsewidth_us怎么用?C++ pwmout_pulsewidth_us使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pwmout_pulsewidth_us函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pwmout_write
//******************************************************************************
void pwmout_write(pwmout_t* obj, float percent)
{
// Saturate percent if outside of range
if(percent < 0.0) {
percent = 0.0;
} else if(percent > 1.0) {
percent = 1.0;
}
// Resize the pulse width to set the duty cycle
pwmout_pulsewidth_us(obj, (int)(percent*obj->period));
}
示例2: pwmout_pulsewidth_ms
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
{
// raught saturation < 0, quasi-max>
if (ms > MAX_PWM_PERIOD_MS)
{
ms = MAX_PWM_PERIOD_MS;
}
else if (ms < 0)
{
ms = 0;
}
int us = ms * 1000;
pwmout_pulsewidth_us(obj, us);
}
示例3: pwmout_pulsewidth
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
{
// raught saturation < 0, quasi-max>
if (seconds > MAX_PWM_PERIOD_S)
{
seconds = MAX_PWM_PERIOD_S;
}
else if (seconds < 0)
{
seconds = 0;
}
int us = seconds * 1000000;
pwmout_pulsewidth_us(obj,us);
}
示例4: main
//int main_app(IN u16 argc, IN u8 *argv[])
void main(void)
{
int i;
for (i=0; i<4; i++) {
pwmout_init(&pwm_led[i], pwm_led_pin[i]);
pwmout_period_us(&pwm_led[i], PWM_PERIOD);
}
while (1) {
#if USE_FLOAT
for (i=0; i<4; i++) {
pwmout_write(&pwm_led[i], pwms[i]);
pwms[i] += steps[i];
if (pwms[i] >= 1.0) {
steps[i] = -PWM_STEP;
pwms[i] = 1.0;
}
if (pwms[i] <= 0.0) {
steps[i] = PWM_STEP;
pwms[i] = 0.0;
}
}
#else
for (i=0; i<4; i++) {
pwmout_pulsewidth_us(&pwm_led[i], pwms[i]);
pwms[i] += steps[i];
if (pwms[i] >= PWM_PERIOD) {
steps[i] = -PWM_STEP;
pwms[i] = PWM_PERIOD;
}
if (pwms[i] <= 0) {
steps[i] = PWM_STEP;
pwms[i] = 0;
}
}
#endif
// wait_ms(20);
// RtlMsleepOS(25);
pwm_delay();
}
}
示例5: pwmout_write
void pwmout_write(pwmout_t *obj, float percent)
{
if (percent < 0)
{
percent = 0;
}
else if (percent > 1)
{
percent = 1;
}
pwm_signal_t * p_pwm_signal = &(((pwm_t*)obj->pwm_struct)->signal);
p_pwm_signal->duty = percent;
int us = (((int)p_pwm_signal->period_us) * percent);
pwmout_pulsewidth_us(obj, us);
}
示例6: pwmout_pulsewidth_ms
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
{
pwmout_pulsewidth_us(obj, ms * 1000);
}
示例7: pwmout_pulsewidth
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
{
pwmout_pulsewidth_us(obj, seconds * 1000000.0f);
}
示例8: pwmout_pulsewidth
//******************************************************************************
void pwmout_pulsewidth(pwmout_t* obj, float seconds)
{
pwmout_pulsewidth_us(obj, (int)(seconds * 1000000.0));
}