maix::peripheral::pwm

maix.peripheral.pwm module

This is maix::peripheral::pwm module of MaixCDK.
All of these elements are in namespace maix::peripheral::pwm.

For MaixCDK developer: DO NOT edit this doc file manually, this doc is auto generated!

Module

No module

Enum

Variable

Function

Class

PWM

Peripheral pwm class

C++ defination code:

class PWM

__init__

PWM constructor

item description
type func
param pin: direction [in], pwm id, int type, like 0, 1, 2 etc.
freq: direction [in], pwm frequency, unit: Hz. int type. default is 1000
duty: direction [in], pwm duty. double type. range is [0, 100], default is 0.
enable: direction [in], enable pwm output right now. bool type. default is true, if false, you need to call enable() to enable pwm output.
duty_val: direction [in], pwm duty value, int type. default -1 means not set and auto calculate by freq and duty.
This arg directly set pwm duty value, if set, will ignore duty arg.
duty_val = duty / 100 * T_ns, T_ns = 1 / freq * 1000000000.
throw If args error or init pwm failed, will throw err::Exception
static False

C++ defination code:

PWM(int id, int freq = 1000, double duty = 0, bool enable = true, int duty_val = -1)

duty

get or set pwm duty

item description
type func
param duty: direction [in], pwm duty, double type, value in [0, 100], default -1 means only read.
return current duty, float type, if set and set failed will return -err::Err
static False

C++ defination code:

double duty(double duty = -1)

duty_val

set pwm duty value

item description
type func
param duty_val: direction [in], pwm duty value. int type. default is -1
duty_val > 0 means set duty_val
duty_val == -1 or not set, return current duty_val
return int type
when get duty_val, return current duty_val, else return -err::Err code.
static False

C++ defination code:

int duty_val(int duty_val = -1)

freq

get or set pwm frequency

item description
type func
param freq: direction [in], pwm frequency. int type. default is -1
freq >= 0, set freq
freq == -1 or not set, return current freq
return int type, current freq, if set and set failed will return -err::Err
static False

C++ defination code:

int freq(int freq = -1)

enable

set pwm enable

item description
type func
return err::Err type, err.Err.ERR_NONE means success
static False

C++ defination code:

err::Err enable()

disable

set pwm disable

item description
type func
return err::Err type, err.Err.ERR_NONE means success
static False

C++ defination code:

err::Err disable()

is_enabled

get pwm enable status

item description
type func
return bool type, true means enable, false means disable
static False

C++ defination code:

bool is_enabled()