Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing depdency problem #6

Merged
merged 3 commits into from May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 16 additions & 13 deletions Dockerfile.template
@@ -1,14 +1,17 @@
FROM resin/%%RESIN_MACHINE_NAME%%-python

#switch on systemd init system in container
ENV INITSYSTEM on

# pip install python deps from requirements.txt
# For caching until requirements.txt changes
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

COPY . /usr/src/app
WORKDIR /usr/src/app

# base-image for python on any machine using a template variable,
# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/
FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3.7-latest-build

# Set our working directory
WORKDIR /usr/src/app

# Copy requirements.txt first for better cache on later pushes
COPY requirements.txt requirements.txt

# pip install python deps from requirements.txt on the resin.io build server
RUN pip install -r requirements.txt

# This will copy all files in our root to the working directory in the container
COPY . ./

CMD ["python", "gpio_example.py"]
32 changes: 16 additions & 16 deletions README.md
@@ -1,17 +1,17 @@
# Basic GPIO with Python on Resin
This is a basic example of GPIO control on the Rasperry Pi using Python
We use the GPIO board pin mapping and we also need few LEDs on two sets of GPIO pin:
Set A: 3,5,7,8,10,11,12,13,15 (pin number)
Set B: 16.18,19,21,22,23,24,26 (pin number)
In this example, the LEDs on two sets will be switched between on and off after one sec. If set A is on then set B is off and vice versa.
All you need to do is :
* clone this repo locally and cd into the folder.
* connect some LEDs to two pin sets
* add the resin remote repo with `git remote add resin git@git.resin.io:myGithubName/myResinAppName.git` , with the correct github and app name, or just copy if from the top right hand corner of your device dashboard on resin.io.
* now just `git push resin master` wait a minute or so for the code to upload and start.
# Basic GPIO with Python on Balena
This is a basic example of GPIO control on the Rasperry Pi using Python

We use the GPIO board pin mapping and we also need few LEDs on two sets of GPIO pin:

Set A: 3,5,7,8,10,11,12,13,15 (pin number)
Set B: 16.18,19,21,22,23,24,26 (pin number)

In this example, the LEDs on two sets will be switched between on and off after one sec. If set A is on then set B is off and vice versa.

All you need to do is :

* clone this repo locally and cd into the folder.
* connect some LEDs to two pin sets
* add the resin remote repo with `git remote add balena git@git.balena-cloud.com:myGithubName/myResinAppName.git` , with the correct github and app name, or just copy if from the top right hand corner of your device dashboard on resin.io.
* now just `git push balena master` wait a minute or so for the code to upload and start.
* enjoy the all the LED goodness...
58 changes: 27 additions & 31 deletions gpio_example.py
@@ -1,32 +1,28 @@
#!/usr/bin/python

import RPi.GPIO as GPIO
import time
#import logging

#logging.basicConfig(format='%(levelname)s-%(asctime)s: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.DEBUG,filename='/App/gpio.log')

# Set GPIO mode: GPIO.BCM or GPIO.BOARD
GPIO.setmode(GPIO.BOARD)

# GPIO pins list based on GPIO.BOARD
gpioList1 = [3,5,7,8,10,11,12,13,15]
gpioList2 = [16,18,19,21,22,23,24,26]

# Set mode for each gpio pin
GPIO.setup(gpioList1, GPIO.OUT)
GPIO.setup(gpioList2, GPIO.OUT)

while True:
# Change gpio pins in list 1 from low to high and list 2 from high to low
GPIO.output(gpioList1, 1)
GPIO.output(gpioList2, 0)
time.sleep(1)

# Change gpio pin in list 1 from high to low and list 2 from low to high
GPIO.output(gpioList1, 0)
GPIO.output(gpioList2, 1)
time.sleep(1)

# Reset all gpio pin
#!/usr/bin/python
import RPi.GPIO as GPIO
from time import sleep

# Set GPIO mode: GPIO.BCM or GPIO.BOARD
GPIO.setmode(GPIO.BOARD)

# GPIO pins list based on GPIO.BOARD
gpioList1 = [3,5,7,8,10,11,12,13,15]
gpioList2 = [16,18,19,21,22,23,24,26]

# Set mode for each gpio pin
GPIO.setup(gpioList1, GPIO.OUT)
GPIO.setup(gpioList2, GPIO.OUT)

while True:
# Change gpio pins in list 1 from low to high and list 2 from high to low
GPIO.output(gpioList1, 1)
GPIO.output(gpioList2, 0)
sleep(1)

# Change gpio pin in list 1 from high to low and list 2 from low to high
GPIO.output(gpioList1, 0)
GPIO.output(gpioList2, 1)
sleep(1)

# Reset all gpio pin
GPIO.cleanup()
3 changes: 2 additions & 1 deletion requirements.txt
@@ -1 +1,2 @@
RPi.Gpio
RPi.Gpio==0.7.1