From ea81a0ba754a81526ab2f0f7d41295962105dac4 Mon Sep 17 00:00:00 2001 From: Thomas Ingleby Date: Thu, 1 May 2014 17:08:54 +0100 Subject: [PATCH] examples: Update examples to use newer maa functions * Use maa_init() before any other maa functions are called * Use ioNN instead of gpioXX, Using mapping Signed-off-by: Thomas Ingleby --- examples/blink-io8.c | 3 ++- examples/cycle-pwm3.c | 1 + examples/i2c_HMC5883L.c | 1 + examples/javascript/example.js | 2 +- examples/python/blink-io8.py | 3 ++- examples/python/cycle-pwm3.py | 1 + examples/python/hello_gpio.py | 3 ++- examples/python/readi2c.py | 1 + 8 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/blink-io8.c b/examples/blink-io8.c index a26aba9..6c960a5 100644 --- a/examples/blink-io8.c +++ b/examples/blink-io8.c @@ -29,10 +29,11 @@ int main(int argc, char **argv) { + maa_init(); fprintf(stdout, "MAA Version: %d\nStarting Blinking on IO8\n", maa_get_version()); maa_gpio_context* gpio; - gpio = maa_gpio_init(26); + gpio = maa_gpio_init(8); maa_gpio_dir(gpio, MAA_GPIO_OUT); while (1) { diff --git a/examples/cycle-pwm3.c b/examples/cycle-pwm3.c index f716cf9..0d67a31 100644 --- a/examples/cycle-pwm3.c +++ b/examples/cycle-pwm3.c @@ -29,6 +29,7 @@ int main () { + maa_init(); maa_pwm_context* pwm; pwm = maa_pwm_init(0, 3); if (pwm == NULL) { diff --git a/examples/i2c_HMC5883L.c b/examples/i2c_HMC5883L.c index 653c550..54f450f 100644 --- a/examples/i2c_HMC5883L.c +++ b/examples/i2c_HMC5883L.c @@ -78,6 +78,7 @@ int main(int argc, char **argv) { + maa_init(); float direction = 0; int16_t x = 0, y = 0, z = 0; char rx_tx_buf[MAX_BUFFER_LENGTH]; diff --git a/examples/javascript/example.js b/examples/javascript/example.js index 3ca12a4..3270e02 100644 --- a/examples/javascript/example.js +++ b/examples/javascript/example.js @@ -23,7 +23,7 @@ */ var m = require("maajs") - +m.init(); console.log("maa version: " + m.get_version()); var r = new m.I2C(20, 21); diff --git a/examples/python/blink-io8.py b/examples/python/blink-io8.py index 26ebe3c..5b4f99b 100644 --- a/examples/python/blink-io8.py +++ b/examples/python/blink-io8.py @@ -25,8 +25,9 @@ import pymaa as maa import time +maa.maa_init() x = maa.gpio_t() -maa.gpio_init(x, 26) +maa.gpio_init(x, 8) maa.gpio_dir(x, "out") while True: diff --git a/examples/python/cycle-pwm3.py b/examples/python/cycle-pwm3.py index 290d16f..0adc4b6 100644 --- a/examples/python/cycle-pwm3.py +++ b/examples/python/cycle-pwm3.py @@ -25,6 +25,7 @@ import pymaa as maa import time +maa.maa_init() x = maa.PWM(0,3) x.enable(1); x.period_us(20) diff --git a/examples/python/hello_gpio.py b/examples/python/hello_gpio.py index a5913f9..473156f 100644 --- a/examples/python/hello_gpio.py +++ b/examples/python/hello_gpio.py @@ -24,7 +24,8 @@ import pymaa +pumaa.maa_init() x = pymaa.gpio_t() print(x.pin) -pymaa.gpio_init(x, 20) +pymaa.gpio_init(x, 8) print(x.pin) diff --git a/examples/python/readi2c.py b/examples/python/readi2c.py index 438e259..626cfb7 100644 --- a/examples/python/readi2c.py +++ b/examples/python/readi2c.py @@ -24,6 +24,7 @@ import pymaa +pumaa.maa_init() x = pymaa.I2CSlave(27,28) x.address(0x62) y= " "