Private
Public Access
2
0

Merge branch 'pwm' into for-pull

This commit is contained in:
Thomas Ingleby
2014-04-14 17:16:30 +01:00
7 changed files with 388 additions and 0 deletions

View File

@@ -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
View 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;
}

View 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