From 27635a62614a47ef33b4fa043c874f775efc2968 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 15:35:37 -0400 Subject: [PATCH 01/18] Have GP0_1 working --- source/common.c | 6 ++++++ source/examples/python/gpio.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 source/examples/python/gpio.py diff --git a/source/common.c b/source/common.c index 89272ca..10eba21 100644 --- a/source/common.c +++ b/source/common.c @@ -167,6 +167,12 @@ pins_t table[] = { { "DGND", "P9_44", 0, -1, -1}, { "DGND", "P9_45", 0, -1, -1}, { "DGND", "P9_46", 0, -1, -1}, + + // These are for the Blue + { "GPIO1_17", "GP0_1", 49, -1, -1}, + + + { NULL, NULL, 0, 0, 0 } }; diff --git a/source/examples/python/gpio.py b/source/examples/python/gpio.py new file mode 100755 index 0000000..84086a8 --- /dev/null +++ b/source/examples/python/gpio.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# Blinks some gpio pins on the Blue +import Adafruit_BBIO.GPIO as GPIO +import time + +LED = "GP0_1" + +GPIO.setup(LED, GPIO.OUT) + +while True: + GPIO.output(LED, GPIO.HIGH) + time.sleep(0.25) + GPIO.output(LED, GPIO.LOW) + time.sleep(0.25) \ No newline at end of file From b01fb01196ddcd5ec71d923ad83d1fab594f1f2d Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 15:36:09 -0400 Subject: [PATCH 02/18] Removed --force to speed things up --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 877bc1d..ba726e8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -all: build # build2 build3 +all: build3 # build2 build3 time: /usr/bin/ntpdate -b -s -u pool.ntp.org @@ -29,10 +29,10 @@ install2: build2 python2 setup.py install --force build3: - python3 setup.py build --force + python3 setup.py build # --force install3: build3 - python3 setup.py install --force + python3 setup.py install # --force ################################################################################ # c++ library From 6480b0042c78ec8685b9bdd9135a868d7d685142 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 16:09:01 -0400 Subject: [PATCH 03/18] Added GP0 1, 2 and 3 --- source/common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/common.c b/source/common.c index 10eba21..a88636d 100644 --- a/source/common.c +++ b/source/common.c @@ -169,8 +169,10 @@ pins_t table[] = { { "DGND", "P9_46", 0, -1, -1}, // These are for the Blue - { "GPIO1_17", "GP0_1", 49, -1, -1}, - + { "GPO_0", "GP0_0", 57, -1, -1}, + { "GP0_1", "GP0_1", 49, -1, -1}, + { "GP0_2", "GP0_2", 116, -1, -1}, + { "GP0_3", "GP0_3", 113, -1, -1}, { NULL, NULL, 0, 0, 0 } From 9f1c04aefc4c51ddc2f749859dc2f320a6a66d42 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 16:09:28 -0400 Subject: [PATCH 04/18] Flashes 4 LEDs --- source/examples/python/gpio.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/examples/python/gpio.py b/source/examples/python/gpio.py index 84086a8..21046c1 100755 --- a/source/examples/python/gpio.py +++ b/source/examples/python/gpio.py @@ -3,12 +3,14 @@ import Adafruit_BBIO.GPIO as GPIO import time -LED = "GP0_1" +LEDs = ["GP0_0", "GP0_1", "GP0_2", "GP0_3"] -GPIO.setup(LED, GPIO.OUT) +for LED in LEDs: + GPIO.setup(LED, GPIO.OUT) while True: - GPIO.output(LED, GPIO.HIGH) - time.sleep(0.25) - GPIO.output(LED, GPIO.LOW) - time.sleep(0.25) \ No newline at end of file + for LED in LEDs: + GPIO.output(LED, GPIO.HIGH) + time.sleep(0.1) + GPIO.output(LED, GPIO.LOW) + time.sleep(0.1) \ No newline at end of file From 2fc458c409b26804e25979f3cfecb21e51c5acf1 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 16:09:44 -0400 Subject: [PATCH 05/18] Works with button --- source/examples/python/button.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 source/examples/python/button.py diff --git a/source/examples/python/button.py b/source/examples/python/button.py new file mode 100755 index 0000000..a660253 --- /dev/null +++ b/source/examples/python/button.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# Reads the PAUSE button using interupts and sets the LED +# Pin table at https://github.com/beagleboard/beaglebone-blue/blob/master/BeagleBone_Blue_Pin_Table.csv + +# Import PyBBIO library: +import Adafruit_BBIO.GPIO as GPIO +import time + +button="GP0_0" # PAUSE=P8_9, MODE=P8_10 +LED ="GP0_1" + +# Set the GPIO pins: +GPIO.setup(LED, GPIO.OUT) +GPIO.setup(button, GPIO.IN) + +print("Running...") + +while True: + state = GPIO.input(button) + GPIO.output(LED, state) + + GPIO.wait_for_edge(button, GPIO.BOTH) + print("Pressed") \ No newline at end of file From 65db366b08cdb2eca6e1acd080bd37b393df1aee Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 16:52:42 -0400 Subject: [PATCH 06/18] Blinks red and gree LEDs --- source/examples/python/leds.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 source/examples/python/leds.py diff --git a/source/examples/python/leds.py b/source/examples/python/leds.py new file mode 100755 index 0000000..8aa84ef --- /dev/null +++ b/source/examples/python/leds.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# Blinks some gpio pins on the Blue +import Adafruit_BBIO.GPIO as GPIO +import time + +LEDs = ["RED_LED", "GREEN_LED"] + +for LED in LEDs: + GPIO.setup(LED, GPIO.OUT) + +while True: + for LED in LEDs: + GPIO.output(LED, GPIO.HIGH) + time.sleep(0.1) + GPIO.output(LED, GPIO.LOW) + time.sleep(0.1) \ No newline at end of file From 2aefa7c3eddb5874697e4e92025c2dbb9d2b18ea Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 16:53:06 -0400 Subject: [PATCH 07/18] Blinks all 6 GPIOs --- source/examples/python/gpio.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/examples/python/gpio.py b/source/examples/python/gpio.py index 21046c1..20d0279 100755 --- a/source/examples/python/gpio.py +++ b/source/examples/python/gpio.py @@ -3,10 +3,7 @@ import Adafruit_BBIO.GPIO as GPIO import time -LEDs = ["GP0_0", "GP0_1", "GP0_2", "GP0_3"] - -for LED in LEDs: - GPIO.setup(LED, GPIO.OUT) +LEDs = ["GP0_0", "GP0_1", "GP0_2", "GP0_3", "GP1_0", "GP1_1"] while True: for LED in LEDs: From 35718a959b5b73c0774fb3e7d53fd412f1d92ec1 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 16:53:39 -0400 Subject: [PATCH 08/18] Added red and green LEDs --- source/common.c | 4 ++++ source/event_gpio.c | 13 +++++++++++-- source/event_gpio.h | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/source/common.c b/source/common.c index a88636d..2cfb0ab 100644 --- a/source/common.c +++ b/source/common.c @@ -173,6 +173,10 @@ pins_t table[] = { { "GP0_1", "GP0_1", 49, -1, -1}, { "GP0_2", "GP0_2", 116, -1, -1}, { "GP0_3", "GP0_3", 113, -1, -1}, + { "GP1_0", "GP1_0", 98, -1, -1}, + { "GP1_1", "GP1_1", 97, -1, -1}, + { "RED_LED", "RED", 66, -1, -1}, // LEDs + { "GREEN_LED", "GREEN", 67, -1, -1}, { NULL, NULL, 0, 0, 0 } diff --git a/source/event_gpio.c b/source/event_gpio.c index 834239d..6194994 100644 --- a/source/event_gpio.c +++ b/source/event_gpio.c @@ -194,6 +194,10 @@ int open_value_file(unsigned int gpio) // create file descriptor of value file if ((gpio >= USR_LED_GPIO_MIN) && (gpio <= USR_LED_GPIO_MAX)) { snprintf(filename, sizeof(filename), "/sys/class/leds/beaglebone:green:usr%d/brightness", gpio - USR_LED_GPIO_MIN); + } else if(gpio == USR_LED_RED) { // red LED + snprintf(filename, sizeof(filename), "/sys/class/leds/red/brightness"); + } else if(gpio == USR_LED_GREEN) { // green LED + snprintf(filename, sizeof(filename), "/sys/class/leds/green/brightness"); } else { snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/value", gpio); } @@ -247,7 +251,8 @@ BBIO_err gpio_set_direction(unsigned int gpio, unsigned int in_flag) char filename[40]; char direction[10] = { 0 }; - if ((gpio >= USR_LED_GPIO_MIN) && (gpio <= USR_LED_GPIO_MAX)) { + if (((gpio >= USR_LED_GPIO_MIN) && (gpio <= USR_LED_GPIO_MAX)) || + (gpio == USR_LED_RED) || (gpio == USR_LED_GREEN)) { syslog(LOG_DEBUG, "gpio_set_direction: %u not applicable to the USR LED", gpio); return BBIO_OK; // direction is not applicable to the USR LED pins } @@ -324,7 +329,11 @@ BBIO_err gpio_set_value(unsigned int gpio, unsigned int value) if (access(filename, W_OK) < 0) { snprintf(filename, sizeof(filename), "/sys/class/leds/beaglebone:green:%s/brightness", usr_led_trigger[led]); } - + + } else if(gpio == USR_LED_RED) { + snprintf(filename, sizeof(filename), "/sys/class/leds/red/brightness"); + } else if(gpio == USR_LED_GREEN) { + snprintf(filename, sizeof(filename), "/sys/class/leds/green/brightness"); } else { snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/value", gpio); } diff --git a/source/event_gpio.h b/source/event_gpio.h index cd250fa..d5e5d93 100644 --- a/source/event_gpio.h +++ b/source/event_gpio.h @@ -48,6 +48,8 @@ SOFTWARE. #define USR_LED_GPIO_MIN 53 #define USR_LED_GPIO_MAX 56 +#define USR_LED_RED 66 +#define USR_LED_GREEN 67 #define PUD_OFF 0 #define PUD_DOWN 1 From 19a948d97aa730eb30f2a0aa3d5ba3d2dec11691 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 17:54:25 -0400 Subject: [PATCH 09/18] i2c works --- source/examples/python/i2c.py | 12 ++++++++++++ source/examples/python/install.sh | 3 +++ 2 files changed, 15 insertions(+) create mode 100755 source/examples/python/i2c.py create mode 100644 source/examples/python/install.sh diff --git a/source/examples/python/i2c.py b/source/examples/python/i2c.py new file mode 100755 index 0000000..ab9fde6 --- /dev/null +++ b/source/examples/python/i2c.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +# Read a TMP101 sensor + +import smbus +import time +bus = smbus.SMBus(1) +address = 0x49 + +while True: + temp = bus.read_byte_data(address, 0) + print (temp) + time.sleep(0.25) \ No newline at end of file diff --git a/source/examples/python/install.sh b/source/examples/python/install.sh new file mode 100644 index 0000000..b9ad943 --- /dev/null +++ b/source/examples/python/install.sh @@ -0,0 +1,3 @@ +# Here's what you need to install to run these. + +sudo apt-get install python3-smbus From 409653157cd4bcbbbf0abd5c0c591f36049e3c5f Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Fri, 28 Jul 2017 17:55:42 -0400 Subject: [PATCH 10/18] PWD isn't working, yet --- source/examples/python/pwm.old.py | 14 ++++++++++++++ source/examples/python/pwm.py | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 source/examples/python/pwm.old.py mode change 100644 => 100755 source/examples/python/pwm.py diff --git a/source/examples/python/pwm.old.py b/source/examples/python/pwm.old.py new file mode 100644 index 0000000..7edc8fd --- /dev/null +++ b/source/examples/python/pwm.old.py @@ -0,0 +1,14 @@ +import Adafruit_BBIO.PWM as PWM + +#set polarity to 1 on start: +#PWM.start("P9_14", 50, 2000, 1) + +#PWM.start(channel, duty, freq=2000, polarity=0) +#duty values are valid 0 (off) to 100 (on) + +PWM.start("P9_14", 50) +PWM.set_duty_cycle("P9_14", 25.5) +PWM.set_frequency("P9_14", 10) + +PWM.stop("P9_14") +PWM.cleanup() diff --git a/source/examples/python/pwm.py b/source/examples/python/pwm.py old mode 100644 new mode 100755 index 7edc8fd..3d352c8 --- a/source/examples/python/pwm.py +++ b/source/examples/python/pwm.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import Adafruit_BBIO.PWM as PWM #set polarity to 1 on start: @@ -6,9 +7,10 @@ #PWM.start(channel, duty, freq=2000, polarity=0) #duty values are valid 0 (off) to 100 (on) -PWM.start("P9_14", 50) -PWM.set_duty_cycle("P9_14", 25.5) -PWM.set_frequency("P9_14", 10) +SERVO="P9_14" +PWM.start(SERVO, 50) +PWM.set_duty_cycle(SERVO, 25.5) +PWM.set_frequency(SERVO, 10) -PWM.stop("P9_14") +PWM.stop(SERVO) PWM.cleanup() From 87ef745193100ce8b2c2f1d8a83cee49fc413375 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Mon, 31 Jul 2017 15:24:12 -0400 Subject: [PATCH 11/18] Added port setup --- source/examples/python/gpio.py | 2 ++ source/examples/python/{i2c.py => tmp101i2c.py} | 0 2 files changed, 2 insertions(+) rename source/examples/python/{i2c.py => tmp101i2c.py} (100%) diff --git a/source/examples/python/gpio.py b/source/examples/python/gpio.py index 20d0279..8907a9f 100755 --- a/source/examples/python/gpio.py +++ b/source/examples/python/gpio.py @@ -4,6 +4,8 @@ import time LEDs = ["GP0_0", "GP0_1", "GP0_2", "GP0_3", "GP1_0", "GP1_1"] +for LED in LEDs: + GPIO.setup(LED, GPIO.OUT) while True: for LED in LEDs: diff --git a/source/examples/python/i2c.py b/source/examples/python/tmp101i2c.py similarity index 100% rename from source/examples/python/i2c.py rename to source/examples/python/tmp101i2c.py From 354c187e24f4af5d963ceb3d016463e0c82c395a Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Mon, 31 Jul 2017 15:24:42 -0400 Subject: [PATCH 12/18] Switched to apt install --- source/examples/python/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/examples/python/install.sh b/source/examples/python/install.sh index b9ad943..3b7b158 100644 --- a/source/examples/python/install.sh +++ b/source/examples/python/install.sh @@ -1,3 +1,3 @@ # Here's what you need to install to run these. -sudo apt-get install python3-smbus +sudo apt install python3-smbus From 5024694c599979ec13017f48f44ea0070d4b4c59 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Mon, 31 Jul 2017 15:25:29 -0400 Subject: [PATCH 13/18] Added tmp101 to name --- source/examples/python/{tmp101i2c.py => i2ctmp101.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename source/examples/python/{tmp101i2c.py => i2ctmp101.py} (89%) diff --git a/source/examples/python/tmp101i2c.py b/source/examples/python/i2ctmp101.py similarity index 89% rename from source/examples/python/tmp101i2c.py rename to source/examples/python/i2ctmp101.py index ab9fde6..af7df9a 100755 --- a/source/examples/python/tmp101i2c.py +++ b/source/examples/python/i2ctmp101.py @@ -9,4 +9,4 @@ while True: temp = bus.read_byte_data(address, 0) print (temp) - time.sleep(0.25) \ No newline at end of file + time.sleep(0.25) From c5fdf47415c7a103e321b76ced7e17bf3b53242d Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Mon, 31 Jul 2017 15:39:39 -0400 Subject: [PATCH 14/18] Added LED matrix example --- source/examples/python/i2cmatrix.py | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 source/examples/python/i2cmatrix.py diff --git a/source/examples/python/i2cmatrix.py b/source/examples/python/i2cmatrix.py new file mode 100755 index 0000000..d379552 --- /dev/null +++ b/source/examples/python/i2cmatrix.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# Write an 8x8 Red/Green LED matrix +# https://www.adafruit.com/product/902 + +import smbus +import time +bus = smbus.SMBus(1) +matrix = 0x70 + +delay = 1; # Delay between images in s + +bus.write_byte_data(matrix, 0x21, 0) # Start oscillator (p10) +bus.write_byte_data(matrix, 0x81, 0) # Disp on, blink off (p11) +bus.write_byte_data(matrix, 0xe7, 0) # Full brightness (page 15) + +# The first byte is GREEN, the second is RED. +smile = [0x00, 0x3c, 0x00, 0x42, 0x28, 0x89, 0x04, 0x85, + 0x04, 0x85, 0x28, 0x89, 0x00, 0x42, 0x00, 0x3c +] +frown = [0x3c, 0x00, 0x42, 0x00, 0x85, 0x20, 0x89, 0x00, + 0x89, 0x00, 0x85, 0x20, 0x42, 0x00, 0x3c, 0x00 +] +neutral = [0x3c, 0x3c, 0x42, 0x42, 0xa9, 0xa9, 0x89, 0x89, + 0x89, 0x89, 0xa9, 0xa9, 0x42, 0x42, 0x3c, 0x3c +] + +bus.write_i2c_block_data(matrix, 0, frown) +time.sleep(delay) + +bus.write_i2c_block_data(matrix, 0, neutral) +time.sleep(delay) + +bus.write_i2c_block_data(matrix, 0, smile) From 24844800affd8522f13a136080ca7a89213bb416 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Mon, 31 Jul 2017 15:43:21 -0400 Subject: [PATCH 15/18] Removed newline from print --- source/examples/python/i2ctmp101.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/examples/python/i2ctmp101.py b/source/examples/python/i2ctmp101.py index af7df9a..923c0f9 100755 --- a/source/examples/python/i2ctmp101.py +++ b/source/examples/python/i2ctmp101.py @@ -8,5 +8,5 @@ while True: temp = bus.read_byte_data(address, 0) - print (temp) + print (temp, end="\r") time.sleep(0.25) From 47bfe2481379f625ebc6f180e58e2885e70aab4a Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Mon, 31 Jul 2017 16:03:46 -0400 Subject: [PATCH 16/18] Added fade --- source/examples/python/i2cmatrix.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/examples/python/i2cmatrix.py b/source/examples/python/i2cmatrix.py index d379552..c0142e4 100755 --- a/source/examples/python/i2cmatrix.py +++ b/source/examples/python/i2cmatrix.py @@ -25,9 +25,13 @@ ] bus.write_i2c_block_data(matrix, 0, frown) -time.sleep(delay) +for fade in range(0xef, 0xe0, -1): + bus.write_byte_data(matrix, fade, 0) + time.sleep(delay/10) bus.write_i2c_block_data(matrix, 0, neutral) -time.sleep(delay) +for fade in range(0xe0, 0xef, 1): + bus.write_byte_data(matrix, fade, 0) + time.sleep(delay/10) bus.write_i2c_block_data(matrix, 0, smile) From ff54b61fa181802a7fc230ca6594ed7cdcb9b2a8 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Tue, 1 Aug 2017 15:06:06 -0400 Subject: [PATCH 17/18] Adding GPIO defs for uart1 --- source/common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/common.c b/source/common.c index 2cfb0ab..23c85f7 100644 --- a/source/common.c +++ b/source/common.c @@ -178,6 +178,9 @@ pins_t table[] = { { "RED_LED", "RED", 66, -1, -1}, // LEDs { "GREEN_LED", "GREEN", 67, -1, -1}, + { "UT1_0", "P9_26", 14, 1, -1}, + { "UT1_1", "P9_24", 15, 1, -1}, + { NULL, NULL, 0, 0, 0 } }; From e18f5c20c0ca8cbe6a3144c81dde6adb1a2f96a3 Mon Sep 17 00:00:00 2001 From: "Mark A. Yoder" Date: Tue, 1 Aug 2017 15:07:03 -0400 Subject: [PATCH 18/18] Testing UT1_0, not working yet --- source/examples/python/gpio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/examples/python/gpio.py b/source/examples/python/gpio.py index 8907a9f..d9b1e08 100755 --- a/source/examples/python/gpio.py +++ b/source/examples/python/gpio.py @@ -3,8 +3,9 @@ import Adafruit_BBIO.GPIO as GPIO import time -LEDs = ["GP0_0", "GP0_1", "GP0_2", "GP0_3", "GP1_0", "GP1_1"] +LEDs = ["GP0_0", "GP0_1", "GP0_2", "GP0_3", "GP1_0", "GP1_1", "UT1_0"] for LED in LEDs: + print(LED) GPIO.setup(LED, GPIO.OUT) while True: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy