diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2011-10-11 21:50:49 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2011-10-11 21:50:49 +0200 |
commit | 324c5ba9098c1010d0aa8c1e26b95509878ce9f2 (patch) | |
tree | f6ef2d537decaa2e1af6d4b9c4c31161b22333ec /liboctopus/python | |
download | mini-octopus-324c5ba9098c1010d0aa8c1e26b95509878ce9f2.tar.gz mini-octopus-324c5ba9098c1010d0aa8c1e26b95509878ce9f2.zip |
Mini-Octopus build from r@171
Diffstat (limited to 'liboctopus/python')
-rw-r--r-- | liboctopus/python/.gitignore | 2 | ||||
-rw-r--r-- | liboctopus/python/Makefile | 19 | ||||
-rw-r--r-- | liboctopus/python/demos/adc.py | 19 | ||||
-rw-r--r-- | liboctopus/python/demos/blink.py | 22 | ||||
-rw-r--r-- | liboctopus/python/demos/blink_all.py | 58 | ||||
-rw-r--r-- | liboctopus/python/demos/blink_i2c.py | 29 | ||||
-rw-r--r-- | liboctopus/python/demos/blink_lauf.py | 67 | ||||
-rw-r--r-- | liboctopus/python/demos/blink_status.py | 26 | ||||
-rw-r--r-- | liboctopus/python/demos/eeprom_i2c.py | 36 | ||||
-rw-r--r-- | liboctopus/python/octopus.i | 5 |
10 files changed, 283 insertions, 0 deletions
diff --git a/liboctopus/python/.gitignore b/liboctopus/python/.gitignore new file mode 100644 index 0000000..5b2c896 --- /dev/null +++ b/liboctopus/python/.gitignore @@ -0,0 +1,2 @@ +octopus.py +octopus_wrap.c diff --git a/liboctopus/python/Makefile b/liboctopus/python/Makefile new file mode 100644 index 0000000..e0e6f29 --- /dev/null +++ b/liboctopus/python/Makefile @@ -0,0 +1,19 @@ +CC=gcc +CFLAGS= -fPIC +CFLAGS+=-I.. +CFLAGS+=`python-config --cflags` +LDFLAGS=`pkg-config --libs libusb` + +all: octopus.o octopus_wrap.o + gcc -fPIC -shared octopus_wrap.o octopus.o $(LDFLAGS) -o _octopus.so + +octopus_wrap.o: + swig -python octopus.i + $(CC) -c -o octopus_wrap.o octopus_wrap.c $(CFLAGS) + +octopus.o: + $(CC) -c -o octopus.o ../octopus.c $(CFLAGS) + +.PHONY: clean +clean: + rm -vf octopus.o octopus.py _octopus.so octopus_wrap.o octopus.pyc octopus_wrap.c diff --git a/liboctopus/python/demos/adc.py b/liboctopus/python/demos/adc.py new file mode 100644 index 0000000..5e55ab7 --- /dev/null +++ b/liboctopus/python/demos/adc.py @@ -0,0 +1,19 @@ + + +from octopus import * +import time + + +op=octopus_context() +octopus_init(op) +octopus_open(op) +octopus_adc_init(op, 33) +octopus_adc_ref(op, 2) + +while 1: + value = octopus_adc_get(op, 33) + callin = "Value %i" % value + print callin + time.sleep(1) + + diff --git a/liboctopus/python/demos/blink.py b/liboctopus/python/demos/blink.py new file mode 100644 index 0000000..3e454af --- /dev/null +++ b/liboctopus/python/demos/blink.py @@ -0,0 +1,22 @@ +#blink.py +#laesst die led1 (26) blinken + + +from octopus import * +import time + + +op=octopus_context() +octopus_init(op) +octopus_open(op) +octopus_io_init(op,26) + +octopus_io_set_pin_direction_out(op,26) + +while 1: + octopus_io_set_pin(op,26,1) + time.sleep(1) + octopus_io_set_pin(op,26,0) + time.sleep(1) + + diff --git a/liboctopus/python/demos/blink_all.py b/liboctopus/python/demos/blink_all.py new file mode 100644 index 0000000..32c963b --- /dev/null +++ b/liboctopus/python/demos/blink_all.py @@ -0,0 +1,58 @@ +#blink_all.py +#laesst die led1 - led6 auf einmal blinken + +import sys + +sys.path.append("../../libs/python") + +from octopus import * +import time + + +op=octopus_context() +octopus_init(op) +octopus_open(op) +octopus_io_init(op,26) +octopus_io_init(op,27) +octopus_io_init(op,28) +octopus_io_init(op,29) +octopus_io_init(op,30) +octopus_io_init(op,31) +octopus_io_init(op,32) + +octopus_io_set_pin_direction_out(op,26) +octopus_io_set_pin_direction_out(op,27) +octopus_io_set_pin_direction_out(op,28) +octopus_io_set_pin_direction_out(op,29) +octopus_io_set_pin_direction_out(op,30) +octopus_io_set_pin_direction_out(op,31) +octopus_io_set_pin_direction_out(op,32) + +octopus_io_set_pin(op,26,0) +octopus_io_set_pin(op,27,0) +octopus_io_set_pin(op,28,0) +octopus_io_set_pin(op,29,0) +octopus_io_set_pin(op,30,0) +octopus_io_set_pin(op,31,0) +octopus_io_set_pin(op,32,0) + + + + +while 1: + octopus_io_set_pin(op,26,1) + octopus_io_set_pin(op,27,1) + octopus_io_set_pin(op,28,1) + octopus_io_set_pin(op,29,1) + octopus_io_set_pin(op,30,1) + octopus_io_set_pin(op,31,1) + octopus_io_set_pin(op,32,1) + time.sleep(1) + octopus_io_set_pin(op,26,0) + octopus_io_set_pin(op,27,0) + octopus_io_set_pin(op,28,0) + octopus_io_set_pin(op,29,0) + octopus_io_set_pin(op,30,0) + octopus_io_set_pin(op,31,0) + octopus_io_set_pin(op,32,0) + time.sleep(1) diff --git a/liboctopus/python/demos/blink_i2c.py b/liboctopus/python/demos/blink_i2c.py new file mode 100644 index 0000000..5fd4cb9 --- /dev/null +++ b/liboctopus/python/demos/blink_i2c.py @@ -0,0 +1,29 @@ +# blink_i2c.py +# laesst die led des i2c (0x10) blinken + +import sys +sys.path.append("..\\..\\libs\\python") + +from octopus import * +import time + + +op=octopus_context() +octopus_init(op) +octopus_open(op) +octopus_i2c_init(op) +octopus_i2c_set_bitrate(op,3) # 100khz + + +octopus_i2c_send_start(op) + +while 1: + #octopus_i2c_receive_byte(op,0x10,1) + octopus_i2c_send_byte(op,0x20,1) + octopus_i2c_send_byte(op,1,1) + time.sleep(1) + octopus_i2c_send_byte(op,0x20,1) + octopus_i2c_send_byte(op,0,1) + time.sleep(1) + + diff --git a/liboctopus/python/demos/blink_lauf.py b/liboctopus/python/demos/blink_lauf.py new file mode 100644 index 0000000..00f73e7 --- /dev/null +++ b/liboctopus/python/demos/blink_lauf.py @@ -0,0 +1,67 @@ +#blink_lauf.py +#laesst alle leds nacheinander blinken + +from octopus import * +import time + + +op=octopus_context() +octopus_init(op) +octopus_open(op) +octopus_io_init(op,26) +octopus_io_init(op,27) +octopus_io_init(op,28) +octopus_io_init(op,29) +octopus_io_init(op,30) +octopus_io_init(op,31) +octopus_io_init(op,32) + +octopus_io_set_pin_direction_out(op,26) +octopus_io_set_pin_direction_out(op,27) +octopus_io_set_pin_direction_out(op,28) +octopus_io_set_pin_direction_out(op,29) +octopus_io_set_pin_direction_out(op,30) +octopus_io_set_pin_direction_out(op,31) +octopus_io_set_pin_direction_out(op,32) + +octopus_io_set_pin(op,26,0) +octopus_io_set_pin(op,27,0) +octopus_io_set_pin(op,28,0) +octopus_io_set_pin(op,29,0) +octopus_io_set_pin(op,30,0) +octopus_io_set_pin(op,31,0) +octopus_io_set_pin(op,32,0) + + + + +while 1: + octopus_io_set_pin(op,26,1) + time.sleep(1) + octopus_io_set_pin(op,26,0) + time.sleep(0.5) + octopus_io_set_pin(op,27,1) + time.sleep(1) + octopus_io_set_pin(op,27,0) + time.sleep(0.5) + octopus_io_set_pin(op,28,1) + time.sleep(1) + octopus_io_set_pin(op,28,0) + time.sleep(0.5) + octopus_io_set_pin(op,29,1) + time.sleep(1) + octopus_io_set_pin(op,29,0) + time.sleep(0.5) + octopus_io_set_pin(op,30,1) + time.sleep(1) + octopus_io_set_pin(op,30,0) + time.sleep(0.5) + octopus_io_set_pin(op,31,1) + time.sleep(1) + octopus_io_set_pin(op,31,0) + time.sleep(0.5) + octopus_io_set_pin(op,32,1) + time.sleep(1) + octopus_io_set_pin(op,32,0) + time.sleep(0.5) + diff --git a/liboctopus/python/demos/blink_status.py b/liboctopus/python/demos/blink_status.py new file mode 100644 index 0000000..c4b0945 --- /dev/null +++ b/liboctopus/python/demos/blink_status.py @@ -0,0 +1,26 @@ +# blink_status.py +# laesst die status led (11) blinken + +import sys +sys.path.append("..\\..\\libs\\python") + + +from octopus import * +import time + + +op=octopus_context() +octopus_init(op) +octopus_open(op) +octopus_io_init(op,11) + +octopus_io_set_pin_direction_out(op,11) + +octopus_io_set_pin(op,11,0) + + +while 1: + octopus_io_set_pin(op,11,1) + time.sleep(1) + octopus_io_set_pin(op,11,0) + time.sleep(1) diff --git a/liboctopus/python/demos/eeprom_i2c.py b/liboctopus/python/demos/eeprom_i2c.py new file mode 100644 index 0000000..17707a4 --- /dev/null +++ b/liboctopus/python/demos/eeprom_i2c.py @@ -0,0 +1,36 @@ +# blink_i2c.py +# laesst die led des i2c (0x10) blinken + +from octopus import * +import time + + +op=octopus_context() +octopus_init(op) +octopus_open(op) +octopus_i2c_init(op) +octopus_i2c_set_bitrate(op,3) # 100khz + + +octopus_i2c_send_start(op) +octopus_i2c_send_byte(op,0xae,1) +octopus_i2c_send_byte(op,1,1) +octopus_i2c_send_byte(op,0,1) +octopus_i2c_send_byte(op,0x77,1) +octopus_i2c_send_stop(op) + + + +octopus_i2c_send_start(op) +octopus_i2c_send_byte(op,0xae,1) +octopus_i2c_send_byte(op,1,1) +octopus_i2c_send_byte(op,0,1) +octopus_i2c_send_start(op) + +octopus_i2c_send_byte(op,0xaf,1) + +print octopus_i2c_receive_byte(op,1,1) + +octopus_i2c_send_stop(op) + + diff --git a/liboctopus/python/octopus.i b/liboctopus/python/octopus.i new file mode 100644 index 0000000..4999a19 --- /dev/null +++ b/liboctopus/python/octopus.i @@ -0,0 +1,5 @@ +%module octopus +%{ +#include "../octopus.h" +%} +%include "../octopus.h" |