DoerGPIO 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: DoerGPIO
3
+ Version: 0.1
4
+ Summary: Arduino-based GPIO interface for Python
5
+ Home-page:
6
+ Author: D.J.Whale
7
+ Author-email:
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: pyserial
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: requires-dist
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+ # DoerGPIO
24
+
25
+ An Arduino-based GPIO interface for Python, providing a simple way to interact with GPIO pins through serial communication.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install DoerGPIO
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from DoerGPIO import GPIO
37
+
38
+ # Set up a pin
39
+ GPIO.setmode(GPIO.BOARD)
40
+ GPIO.setup(18, GPIO.OUT)
41
+
42
+ # Control the pin
43
+ GPIO.output(18, GPIO.HIGH)
44
+ ```
45
+
46
+ ## Features
47
+
48
+ - Arduino-based GPIO control
49
+ - Simple and intuitive API
50
+ - Support for both input and output modes
51
+ - Pull-up/pull-down resistor configuration
52
+ - Compatible with Python 3.9+
53
+
54
+ ## Requirements
55
+
56
+ - Python 3.9 or higher
57
+ - pyserial package
58
+ - Arduino board with compatible firmware
59
+
60
+ ## License
61
+
62
+ [Add your license information here]
@@ -0,0 +1,15 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ DoerGPIO.egg-info/PKG-INFO
6
+ DoerGPIO.egg-info/SOURCES.txt
7
+ DoerGPIO.egg-info/dependency_links.txt
8
+ DoerGPIO.egg-info/requires.txt
9
+ DoerGPIO.egg-info/top_level.txt
10
+ doer/GPIO.py
11
+ doer/__init__.py
12
+ doer/neo.py
13
+ doer/ports_unix.py
14
+ doer/ports_win32.py
15
+ doer/portscan.py
@@ -0,0 +1 @@
1
+ pyserial
@@ -0,0 +1 @@
1
+ doer
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include DoerGPIO *.py
doergpio-0.1/PKG-INFO ADDED
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: DoerGPIO
3
+ Version: 0.1
4
+ Summary: Arduino-based GPIO interface for Python
5
+ Home-page:
6
+ Author: D.J.Whale
7
+ Author-email:
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: pyserial
15
+ Dynamic: author
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: requires-dist
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+ # DoerGPIO
24
+
25
+ An Arduino-based GPIO interface for Python, providing a simple way to interact with GPIO pins through serial communication.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install DoerGPIO
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from DoerGPIO import GPIO
37
+
38
+ # Set up a pin
39
+ GPIO.setmode(GPIO.BOARD)
40
+ GPIO.setup(18, GPIO.OUT)
41
+
42
+ # Control the pin
43
+ GPIO.output(18, GPIO.HIGH)
44
+ ```
45
+
46
+ ## Features
47
+
48
+ - Arduino-based GPIO control
49
+ - Simple and intuitive API
50
+ - Support for both input and output modes
51
+ - Pull-up/pull-down resistor configuration
52
+ - Compatible with Python 3.9+
53
+
54
+ ## Requirements
55
+
56
+ - Python 3.9 or higher
57
+ - pyserial package
58
+ - Arduino board with compatible firmware
59
+
60
+ ## License
61
+
62
+ [Add your license information here]
doergpio-0.1/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # DoerGPIO
2
+
3
+ An Arduino-based GPIO interface for Python, providing a simple way to interact with GPIO pins through serial communication.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install DoerGPIO
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from DoerGPIO import GPIO
15
+
16
+ # Set up a pin
17
+ GPIO.setmode(GPIO.BOARD)
18
+ GPIO.setup(18, GPIO.OUT)
19
+
20
+ # Control the pin
21
+ GPIO.output(18, GPIO.HIGH)
22
+ ```
23
+
24
+ ## Features
25
+
26
+ - Arduino-based GPIO control
27
+ - Simple and intuitive API
28
+ - Support for both input and output modes
29
+ - Pull-up/pull-down resistor configuration
30
+ - Compatible with Python 3.9+
31
+
32
+ ## Requirements
33
+
34
+ - Python 3.9 or higher
35
+ - pyserial package
36
+ - Arduino board with compatible firmware
37
+
38
+ ## License
39
+
40
+ [Add your license information here]
@@ -0,0 +1,105 @@
1
+ # anyio/arduino/GPIO.py 21/04/2014 D.J.Whale
2
+ #
3
+ # An ardunio (serial) based GPIO link
4
+
5
+ # CONFIGURATION ========================================================
6
+
7
+ DEBUG = True
8
+ # There was the option to use the serial library pre-installed. This has changed so that we know the python lib in use is the one distributed with the doer library.
9
+ #If you wish to use the built in one instead change the import doerserial to import serial which is below (Approx line 38)
10
+
11
+ MIN_PIN = 0
12
+ MAX_PIN = 27
13
+
14
+ IN = 0
15
+ OUT = 1
16
+ BCM = 0
17
+ BOARD = 1
18
+ HIGH = 1
19
+ LOW = 0
20
+
21
+ PUD_OFF = 20
22
+ PUD_DOWN = 21
23
+ PUD_UP = 22
24
+ VERSION = "Doer.GPIO 0.2"
25
+ RPI_REVISION = 3
26
+ RPI_INFO = {'P1_REVISION': 3, 'RAM': 'Unknown', 'REVISION': '90092', 'TYPE': 'Unknown','PROCESSOR': 'Unknown','MANUFACTURER':'Unknown'}
27
+
28
+
29
+ # OS INTERFACE =========================================================
30
+
31
+ from .. import protocol
32
+ from .. import adaptors
33
+ import DoerGPIO.doer.portscan as portscan
34
+
35
+ #from os import sys, path
36
+ #thisdir = path.dirname(path.abspath(__file__))
37
+ #sys.path.append(thisdir)
38
+
39
+ #import doerserial as serial
40
+
41
+ #Temporarily changing back to normal serial
42
+ import serial
43
+
44
+ # STATIC REDIRECTORS ===================================================
45
+
46
+ # Find out if there is a pre-cached port name.
47
+ # If not, try and find a port by using the portscanner
48
+
49
+ name = portscan.getName()
50
+ if name != None:
51
+ if DEBUG:
52
+ print("Using port:" + name)
53
+ PORT = name
54
+ else:
55
+ name = portscan.find()
56
+ if name == None:
57
+ raise ValueError("No port selected, giving in")
58
+ PORT = name
59
+ print("Your anyio board has been detected")
60
+ print("Now running your program...")
61
+
62
+ BAUD = 230400
63
+
64
+
65
+ s = serial.Serial(PORT)
66
+ s.baudrate = BAUD
67
+ s.parity = serial.PARITY_NONE
68
+ s.databits = serial.EIGHTBITS
69
+ s.stopbits = serial.STOPBITS_ONE
70
+ s.write_timeout = 1
71
+
72
+ s.close()
73
+ s.port = PORT
74
+ s.open()
75
+
76
+
77
+ instance = protocol.GPIOClient(adaptors.SerialAdaptor(s), DEBUG)
78
+
79
+ def setwarnings(option):
80
+ instance.setwarnings(option)
81
+
82
+ def setmode(mode):
83
+ instance.setmode(mode)
84
+
85
+ def setup(channel, mode,pull_up_down=None):
86
+ if type(channel) is list:
87
+ for c in channel:
88
+ instance.setup(c, mode,pull_up_down)
89
+ else:
90
+ instance.setup(channel, mode,pull_up_down)
91
+
92
+ def input(channel):
93
+ return instance.input(channel)
94
+
95
+ def output(channel, value):
96
+ instance.output(channel, value)
97
+
98
+ def analogIn(channel):
99
+ return instance.cake(channel)
100
+
101
+ def cleanup():
102
+ instance.cleanup()
103
+
104
+
105
+ # END
@@ -0,0 +1 @@
1
+
File without changes
@@ -0,0 +1,31 @@
1
+ # ports_unix.py 22/04/2014 D.J.Whale
2
+ #
3
+ # Get a list of ports on a unix system
4
+ # Note that the precise /dev/* filter depends on the platform
5
+
6
+ # SYSTEM AND VERSION VARIANCE ==========================================
7
+
8
+ #this is for linux
9
+ DEV_TTY = "/dev/tty*"
10
+
11
+ #TODO for mac, it's /dev/cua*???
12
+
13
+
14
+ # BODY =================================================================
15
+
16
+ import glob
17
+
18
+ def scan():
19
+ """ scan devices that might be com ports """
20
+ devices = glob.glob(DEV_TTY)
21
+ #print("found " + str(len(devices)) + " devices")
22
+ return devices
23
+
24
+
25
+ # TEST HARNESS =========================================================
26
+
27
+ if __name__ == "__main__":
28
+ d = scan()
29
+ print(str(d))
30
+
31
+ # END
@@ -0,0 +1,46 @@
1
+ # ports_win32.py 22/04/2014 D.J.Whale
2
+ #
3
+ # Scan the windows registry to find a list of COM ports
4
+
5
+ try:
6
+ import _winreg as registry # python2
7
+ except ImportError:
8
+ import winreg as registry # python3
9
+
10
+ KEY = r"HARDWARE\DEVICEMAP\SERIALCOMM"
11
+
12
+ def scan():
13
+ ports = []
14
+
15
+ reg = registry.ConnectRegistry(None, registry.HKEY_LOCAL_MACHINE)
16
+ try:
17
+ key = registry.OpenKey(reg, KEY)
18
+ except:
19
+ # If there is no SERIALCOMM registry entry
20
+ # it means this computer has never seen a serial port.
21
+ # Best action is to return an empty ports list.
22
+ # When the device is inserted, windows will create the entry for us.
23
+ return ports
24
+
25
+ i = 0
26
+ while True:
27
+ try:
28
+ value = registry.EnumValue(key, i)
29
+ name, value, vtype = value
30
+ print("port[" + str(i) + "]:" + str(value))
31
+ ports.append(value)
32
+ i += 1
33
+
34
+ except EnvironmentError:
35
+ break
36
+
37
+ return ports
38
+
39
+
40
+ # TESTER
41
+
42
+ if __name__ == "__main__":
43
+ d = find()
44
+ print(str(d))
45
+
46
+ # END
@@ -0,0 +1,201 @@
1
+ # portscan.py 22/04/2014 D.J.Whale
2
+ #
3
+ # Prompt user and find a newly inserted com port
4
+ # Appropriately configured this should work on mac an linux
5
+
6
+ import time
7
+
8
+ # CONFIGURATION ========================================================
9
+
10
+ # The file that will be created to cache the found port name
11
+ CACHE_NAME = "portscan.cache"
12
+
13
+ # The time, in seconds, to wait for any drivers to unload.
14
+ # When the user presses ENTER after the "remove device" message,
15
+ # it sometimes takes some computers a little bit of time to safely
16
+ # unload the driver. This prevents false readings.
17
+ DRIVER_UNLOAD_TIME = 2
18
+
19
+ # The time, in seconds, to wait for any drivers to load.
20
+ # When the user presses ENTER after the "insert device" message,
21
+ # it sometimes takes some computers a little bit of time to safely
22
+ # load the driver. This prevents false readings.
23
+
24
+ DRIVER_LOAD_TIME = 4
25
+
26
+ def message(msg):
27
+ print(msg)
28
+
29
+ def nl():
30
+ print("\n")
31
+
32
+
33
+ # SYSTEM AND VERSION VARIANCE ==========================================
34
+
35
+ import sys
36
+ import os
37
+
38
+ if sys.version_info.major >= 3:
39
+ ask = input
40
+ else:
41
+ ask = raw_input
42
+
43
+ if os.name == 'nt': #sys.platform == 'win32':
44
+ import DoerGPIO.doer.ports_win32 as ports
45
+ elif os.name == 'posix':
46
+ import DoerGPIO.doer.ports_unix as ports
47
+ else:
48
+ raise ImportError("No port lister available for:" + os.name)
49
+
50
+
51
+ # HELPERS ==============================================================
52
+
53
+ def getYesNo(msg):
54
+ """ Ask user for yes/no and return a boolean """
55
+ answer = ask(msg + " (Y/N)")
56
+ answer = answer.upper()
57
+ if answer in ['YES', 'Y']:
58
+ return True
59
+ return False
60
+
61
+ def getAdded(before, after):
62
+ """ Find any items in 'after' that are not in 'before' """
63
+
64
+ #message("before:" + str(before))
65
+ #message("after:" + str(after))
66
+
67
+ # Any items in 'before' are removed from 'after'
68
+ # The remaining list is of the newly added items
69
+
70
+ for b in before:
71
+ try:
72
+ i = after.index(b)
73
+ after.remove(b)
74
+ except ValueError:
75
+ pass
76
+
77
+ #message("new:" + str(after))
78
+ return after
79
+
80
+
81
+ # BODY =================================================================
82
+
83
+ def scan():
84
+ """ scan devices repeatedly until new one found, or user gives in """
85
+ message("Scanning for serial ports")
86
+ while True:
87
+ # prompt to remove device
88
+ ask("remove device, then press ENTER")
89
+
90
+ message("scanning...")
91
+ time.sleep(DRIVER_UNLOAD_TIME) # to allow driver to unload
92
+ before = ports.scan()
93
+ beforec = len(before)
94
+ message("found " + str(beforec) + " devices")
95
+
96
+ # prompt to insert device
97
+ ask("plug in device, then press ENTER")
98
+
99
+ message("scanning...")
100
+ time.sleep(DRIVER_LOAD_TIME) # to allow driver to load
101
+ after = ports.scan()
102
+ afterc = len(after)
103
+ message("found " + str(afterc) + " devices")
104
+
105
+ # diff the lists
106
+ added = getAdded(before, after)
107
+
108
+ if len(added) == 0:
109
+ # No new ones, try again?
110
+ message("no new devices detected")
111
+ yes = getYesNo("Try again?")
112
+ if yes:
113
+ continue
114
+ return None
115
+
116
+ elif len(added) > 1:
117
+ # Show a menu and get a choice
118
+ while True:
119
+ message("more than one new device found")
120
+ for i in range(len(added)):
121
+ message(str(i+1) + ":" + added[i])
122
+ a = ask("which device do you want to try?")
123
+ try:
124
+ a = int(a)
125
+ if a < 1 or a > len(added):
126
+ message("out of range, try again")
127
+ continue
128
+ a -= 1
129
+ return added[a]
130
+ except:
131
+ pass
132
+
133
+ else:
134
+ # only 1 new, select it
135
+ message("found 1 new device")
136
+ dev = added[0]
137
+ message("selected:" + dev)
138
+ return dev
139
+
140
+
141
+ def remember(device):
142
+ """ Remember this device for next time """
143
+ # prompt if you want it remembered
144
+ yes = getYesNo("Do you want this device to be remembered?")
145
+
146
+ if yes:
147
+ # Remember it
148
+ f = open(CACHE_NAME, "w")
149
+ f.write(device + "\n")
150
+ f.close()
151
+
152
+ def find():
153
+ """ Try to find a newly inserted device, by prompting user """
154
+ dev = scan()
155
+ if dev != None:
156
+ remember(dev)
157
+ return dev
158
+
159
+ def forget():
160
+ """forget the remembered cached name if stored"""
161
+ # Remove any existing cache file
162
+ try:
163
+ os.remove(CACHE_NAME)
164
+ except:
165
+ pass
166
+
167
+ def getName():
168
+ """read the remembered cached named, None if none stored"""
169
+ try:
170
+ f = open(CACHE_NAME, "r")
171
+ name = f.readline().strip()
172
+ f.close()
173
+ return name
174
+ except IOError:
175
+ message("could not open cache file")
176
+ return None
177
+
178
+ def main():
179
+ message("*" * 79)
180
+ message("SERIAL PORT SCANNER PROGRAM")
181
+ message("*" * 79)
182
+
183
+ n = getName()
184
+ if n == None:
185
+ message("No name remembered")
186
+ else:
187
+ message("Already remembered:" + n)
188
+ message("forgetting...")
189
+ forget()
190
+
191
+ d = find()
192
+ if d == None:
193
+ message("nothing found")
194
+ else:
195
+ message("found device:" + d)
196
+
197
+ # TESTER
198
+ if __name__ == "__main__":
199
+ main()
200
+
201
+ # END
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
doergpio-0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
doergpio-0.1/setup.py ADDED
@@ -0,0 +1,23 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="DoerGPIO",
5
+ version="0.1", # Using the version from your GPIO.py
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "pyserial", # Required for serial communication
9
+ ],
10
+ author="D.J.Whale",
11
+ author_email="", # You should add your email here
12
+ description="Arduino-based GPIO interface for Python",
13
+ long_description=open("README.md").read(),
14
+ long_description_content_type="text/markdown",
15
+ url="", # You should add your repository URL here
16
+ classifiers=[
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ ],
22
+ python_requires=">=3.9",
23
+ )