Merge branch 'pwm' into for-pull
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
add_executable (readi2c readi2c.cpp)
|
||||
add_executable (hellomaa hellomaa.cpp)
|
||||
add_executable (cycle-pwm3 cycle-pwm3.cpp)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
target_link_libraries (hellomaa maa)
|
||||
target_link_libraries (readi2c maa)
|
||||
target_link_libraries (cycle-pwm3 maa)
|
||||
|
||||
24
examples/cycle-pwm3.cpp
Normal file
24
examples/cycle-pwm3.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "maa.h"
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
maa::PWM pwm(0, 3);
|
||||
pwm.period_us(200);
|
||||
pwm.enable(1);
|
||||
|
||||
float value = 0.0f;
|
||||
|
||||
while(1) {
|
||||
value = value + 0.01f;
|
||||
pwm.write(value);
|
||||
usleep(50000);
|
||||
if (value >= 1.0f) {
|
||||
value = 0.0f;
|
||||
}
|
||||
float output = pwm.read();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
16
examples/python/cycle-pwm3.py
Normal file
16
examples/python/cycle-pwm3.py
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import pymaa as maa
|
||||
import time
|
||||
|
||||
x = maa.PWM(0,3)
|
||||
x.enable(1);
|
||||
x.period_us(20)
|
||||
value= 0.0
|
||||
|
||||
while True:
|
||||
x.write(value)
|
||||
time.sleep(0.2)
|
||||
value = value +0.01
|
||||
if value >= 1:
|
||||
value = 0.0
|
||||
Reference in New Issue
Block a user