maix.peripheral.pwm
maix.peripheral.pwm module
You can use
maix.peripheral.pwmto access this module with MaixPy
This module is generated from MaixCDK
Module
No module
Enum
Variable
Function
Class
PWM
| item | doc |
|---|---|
| brief | Peripheral pwm class |
C++ defination code:
class PWM
__init__
| item | doc |
|---|---|
| type | func |
| brief | PWM constructor |
| 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
| item | doc |
|---|---|
| type | func |
| brief | get or set pwm duty |
| 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
| item | doc |
|---|---|
| type | func |
| brief | set pwm duty value |
| 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
| item | doc |
|---|---|
| type | func |
| brief | get or set pwm frequency |
| 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
| item | doc |
|---|---|
| type | func |
| brief | set pwm enable |
| return | err::Err type, err.Err.ERR_NONE means success |
| static | False |
C++ defination code:
err::Err enable()
disable
| item | doc |
|---|---|
| type | func |
| brief | set pwm disable |
| return | err::Err type, err.Err.ERR_NONE means success |
| static | False |
C++ defination code:
err::Err disable()
is_enabled
| item | doc |
|---|---|
| type | func |
| brief | get pwm enable status |
| return | bool type, true means enable, false means disable |
| static | False |
C++ defination code:
bool is_enabled()