Skip to content

Commit

Permalink
Merge pull request #102 from OnionIoT/feature/add-python3-gpio
Browse files Browse the repository at this point in the history
Add python3 gpio package
  • Loading branch information
greenbreakfast committed Aug 6, 2024
2 parents 5f2e136 + ef6c6b9 commit 9308813
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 1 deletion.
2 changes: 1 addition & 1 deletion omega2-base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=omega2-base
PKG_VERSION:=23.05.3
PKG_RELEASE:=20240724
PKG_RELEASE:=20240806

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

Expand Down
66 changes: 66 additions & 0 deletions python3-gpio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright (C) 2024 Onion Corporation
#
# Author: Lazar Demin <lazar@onioniot.com>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
PKG_NAME:=python3-gpio
PKG_VERSION:=1.0.0
PKG_RELEASE:=1


PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=HEAD
PKG_SOURCE_URL:=https://github.com/vitiral/gpio.git
PKG_SOURCE_VERSION:=fd8e954321abf2746057f7a4085ba47a5a552e60
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/python/python3-package.mk

define Package/python3-gpio
SECTION:=onion
CATEGORY:=Onion
SUBMENU:=Libraries
TITLE:=Python3 module that provides gpio access via the standard linux sysfs interface
DEPENDS:=+python3-base
endef

define Package/python3-gpio/description
Python3 module that provides gpio access via the standard linux sysfs interface
endef

TARGET_CFLAGS += $(FPIC)
TARGET_LIBS += -l m

MAKE_FLAGS += \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
LIB="$(TARGET_LIBS)" \
PYTHON=$(PYTHON3) \
PYINC="-I $(PYTHON3_INC_DIR)" \
PYLIBS="-lpython$(PYTHON3_VERSION)" \
PYTHON_VERSION=$(PYTHON3_VERSION) \
$(PYTHON3_VARS)

define Build/Compile
$(CP) ./files/* $(PKG_BUILD_DIR)/
$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
endef

define Package/python3-gpio/install
$(INSTALL_DIR) $(1)$(PYTHON3_PKG_DIR)/gpio
$(CP) $(PKG_BUILD_DIR)/gpio/__init__.py $(1)$(PYTHON3_PKG_DIR)/gpio/__init__.py
endef

define Build/Install
true
endef

$(eval $(call BuildPackage,python3-gpio))
40 changes: 40 additions & 0 deletions python3-gpio/Untitled-1.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright (C) 2024 Lazar Demin (lazar@onioniot.com)
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=python-gpio
PKG_VERSION:=1.0.0
PKG_RELEASE:=1

PYPI_NAME:=gpio
PKG_HASH:=fd8e954321abf2746057f7a4085ba47a5a552e60

PKG_LICENSE:=MIT
PKG_MAINTAINER:=Garrett Berg, Phil Howard (phil@pimoroni.com)

include ../pypi.mk
include $(INCLUDE_DIR)/package.mk
include ../python3-package.mk

define Package/python3-gpio
SECTION:=lang
CATEGORY:=Languages
SUBMENU:=Python
TITLE:=provides gpio access via the standard linux sysfs interface
URL:=https://github.com/vitiral/gpio
DEPENDS:=+python3-light
endef

define Package/python3-gpio/description
This library provides gpio access via the standard linux sysfs interface

It is intended to mimick RPIO as much as possible for all features, while also supporting additional (and better named) functionality to the same methods.
endef

$(eval $(call Py3Package,python3-gpio))
$(eval $(call BuildPackage,python3-gpio))
4 changes: 4 additions & 0 deletions python3-gpio/files/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: all

all:
@echo "Do nothing"
13 changes: 13 additions & 0 deletions python3-gpio/patches/001-fmode-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/gpio/__init__.py b/gpio/__init__.py
index c6f37f7..119545d 100644
--- a/gpio/__init__.py
+++ b/gpio/__init__.py
@@ -16,7 +16,7 @@ _open_pins = {}
GPIO_ROOT = '/sys/class/gpio'
GPIO_EXPORT = os.path.join(GPIO_ROOT, 'export')
GPIO_UNEXPORT = os.path.join(GPIO_ROOT, 'unexport')
-FMODE = 'w+' # w+ overwrites and truncates existing files
+FMODE = 'w' # fix: w for write-only sysfs files
IN, OUT = 'in', 'out'
LOW, HIGH = 0, 1

1 change: 1 addition & 0 deletions sdk-profile
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ omega2-base
omega2-ctrl
onion-dt-overlay
python3-spidev
python3-gpio
omega2-lte
"

0 comments on commit 9308813

Please sign in to comment.