DesignSpark.Pmod¶
Python library to support using Pmods with a Raspberry Pi and the DesignSpark Pmod HAT.
Features include:
- Simple interfaces for supported Pmods
- Checking that Pmod and port capabilities match
- Checking for port usage conflicts
- Usage examples
Supported Pmods¶
The following modules are currently supported with the DesignSpark Raspberry Pi Pmod HAT:
- PmodACL2 3-axis Accelerometer
- PmodAD1 12-bit ADC
- PmodGPS GPS Module
- PmodHB3 2A H-bridge Driver
- PmodISNS20 20A Current Sensor
- PmodKYPD 16-Button Keypad
- PmodLS1 Line Follower Sensor Interface
- PmodMIC3 MEMS Microphone Module
- PmodOLEDrgb 96x64 RGB OLED Display 1
- PmodSWT Four Slides Switches
- PmodTC1 K Type Thermocouple Module with Wire
- PmodACL2 3-axis Accelerometer
- PmodGPS GPS Satellite Receiver
- PmodKYPD 16-Button Keypad
- PmodLS1 Line Follower Sensor
- PmodSWT Four Slides Switches
1 Builds on the excellent luma.oled and luma.core libraries from Richard Hull and contributors.
Installation¶
DesignSpark.Pmod can be installed from PyPi using pip. See the documentation for details.
Documentation¶
Installation and API documentation, along with examples, can be found at:
http://designspark-pmod.readthedocs.io
For Pmod HAT documentation, including the reference manual and schematic, see:
https://reference.digilentinc.com/reference/add-ons/pmod-hat/start
Table of Contents¶
Installation¶
This guide assumes that you are running Raspbian Stretch.
First enable SPI and configure the UART:
pi@raspberrypi:~$ sudo raspi-config
Selecting:
- Option 5 - Interfacing
- P4 - SPI
- Enable → YES
- P6 - Serial
- Would you like a login shell to be accessible over serial? → No
- Would you like the serial port hardware to be enabled? → Yes
Then exit raspi-config.
Next update the package lists:
pi@raspberrypi:~$ sudo apt-get update
Then install the Raspbian dependencies:
pi@raspberrypi:~$ sudo apt-get install python-pip python-dev libfreetype6-dev libjpeg-dev build-essential
Finally, install DesignSpark.Pmod and dependencies from PyPi:
pi@raspberrypi:~$ sudo pip install designspark.pmod
Pmod Information¶
Details of currently supported Pmods can be found below.
ACL2¶
The Pmod ACL2 is a 3-axis MEMS accelerometer powered by the Analog Devices ADXL362. By communicating with the chip via the SPI protocol, users may receive up to 12 bits of resolution for each axis of acceleration. Additionally, this module offers freefall detection as well as power saving features through its motion activated sleep and wake modes.
Features:
- 3-axis MEMS accelerometer
- Up to 12 bits of resolution per axis
- User-selectable resolution
- Activity/inactivity monitoring
- Low current consumption at <2 μA at 100Hz
- Free-fall detection
AD1¶
The Digilent Pmod AD1 (Revision G) is a two channel 12-bit analog-to-digital converter that features Analog Devices’ AD7476A. With a sampling rate of up to 1 million samples per second, this Pmod™ is capable of excelling in even the most demanding audio applications.
Features:
- Two channel 12-bit analog-to-digital converter
- Simultaneous A/D conversion at up to one MSa per channel
- Two 2-pole Sallen-Key anti-alias filters
- Small PCB size for flexible designs 0.95 in × 0.8 in (2.4 cm × 2.0 cm)
Note
Only a single channel (A1) is supported at present due to the way that SPI is configured.
GPS¶
The Pmod GPS can provide satellite-positioning accuracy to any embedded system. By communicating through UART with the GlobalTop FGPMMOPA6H GPS module, users may benefit from the 3-meter accuracy for any long term traveling.
Features:
- Ultra-sensitive GPS module (-165 dBm)
- Add 3m 2D satellite positioning accuracy to any embedded system
- Low power consumption
- Up to 10Hz update rate
- NMEA (default) and RTCM protocols available
HB3¶
The Pmod HB3 utilizes a full H-Bridge circuit to allow users to drive DC motors from the system board. Two external pins are provided on the Pmod for sensor feedback on the DC motor, if desired.
Features:
- 2A H-bridge circuit
- Drive a DC motor with operation voltage up to 12V
- Screw terminal blocks for connection to the motor
- Separate header for external motor feedback
ISNS20¶
The Digilent Pmod ISNS20 (Revision A) is a small current sense module with a digital SPI interface. The board combines an Allegro ACS722 Hall Effect current sensor with a 12-bit analog-to-digital converter from Texas Instruments. The Pmod ISNS20 is quick, accurate, and easy to use for a variety of applications.
Features:
- High accuracy current sensor
- Measure current with 120Hz/20kHz/80kHz jumper selections
- ±20A DC or AC input
- Accurate to within ±2%
- 12-bit ADC
KYPD¶
The Pmod KYPD is a 16-button keypad arranged in a hexidecimal format (0-F). By digitally driving a column line to a logic low level and digitally reading each of the rows, users can determine which button is currently pressed.
Features:
- 16 momentary push-buttons
- Can detect simultaneous button presses
- Isolated rows and columns
LS1¶
The Digilent Pmod LS1 allows users to receive signals from multiple optical sensors, such as the popular combination of an IR LED with an IR sensor used in line-following robots.
Features:
- Infrared light detector with on-board sensitivity adjustment
- Interface with up to four reflective or transmissive photo detectors
- Works with Digilent IR Proximity Sensor
MIC3¶
The Digilent Pmod MIC3 (Revision A) is small microphone module with a digital interface. With a Knowles Acoustics SPA2410LR5H-B MEMs microphone and Texas Instrument’s ADCS7476 12-bit Analog-to-Digital Converter, you can capture your audio inputs with ease.
Features:
- MEMS Microphone module with digital interface
- Transform audio inputs with 12-bit A/D converter
- Adjust incoming volume with on-board potentiometer
- Up to 1 MSPS of data
OLEDrgb¶
The Digilent Pmod OLEDrgb (Revision B) is an organic RGB LED module with a 96×64 pixel display capable of 16-bit color resolution.
Features:
- 96×64 pixel RGB OLED screen
- 0.8“ x 0.5” graphical display
- 16-bit color resolution
- Two low-power display shutdown modes
SWT¶
The Pmod SWT provides users with four slide switches for up to 16 different binary logic inputs to for the attached system board.
Features:
- 4 slide switches
- Add user input to host board or project
- Static binary logic input
TC1¶
The Digilent Pmod TC1 (Revision A) is a cold-junction thermocouple-to-digital converter module designed for a classic K-Type thermocouple wire. With Maxim Integrated’s MAX31855, this module reports the measured temperature in 14-bits with 0.25°C resolution.
Features:
- K-type thermocouple-to-digital converter
- Wide temperature range of -73°C to 482°C with provided wire
- ±2°C accuracy from -200°C to 700°C
- 14-bit with 0.25°C resolution
- Cold-junction temperature compensation
Basic Examples¶
AD1¶
12-bit analog-to-digital converter.
Print volts out to the terminal¶
Read ADC channel A1, print the voltage measured out to the terminal, sleep for 0.8s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Read ADC channel A1 and print volts out.
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
adc = createPmod('AD1','JBA')
time.sleep(0.1)
try:
while True:
volts = adc.readA1Volts()
print(volts)
#val = adc.readA1()
#print(val)
time.sleep(0.8)
except KeyboardInterrupt:
pass
finally:
adc.cleanup()
Requirements
- PmodAD1 module connected to port JBA
- A voltage source connected to ADC channel A1
HB3¶
2A H-bridge circuit for DC motor drive up to 12V.
Spin motor¶
This example:
- Spins the motor forwards for 20 seconds
- Commands the motor to stop and pauses for 2 seconds
- Spins the motor in reverse for 20 seconds
- Commands the motor to stop and pauses for 2 seconds
- Ramps up the speed across 100 steps in the forward direction
- Ramps down the speed across 100 steps in the forward direction
- Ramps up speed across 100 steps in the reverse direction
- Ramps down the speed across 100 steps in the reverse direction
- Loops back to (1)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Spin motor forwards then backwards.
Ramp speed up and then down in forward direction.
Ramp speed up and then down in reverse direction.
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
motor = createPmod('HB3','JAA')
try:
while True:
print('fwd')
motor.forward(20)
time.sleep(2)
motor.stop()
time.sleep(2)
print('rev')
motor.reverse(20)
time.sleep(1)
motor.stop()
time.sleep(2)
print ('ramp up fwd')
for i in range(100):
motor.forward(i)
time.sleep(.1)
print ('ramp down fwd')
for i in range(100):
motor.forward(100-i)
time.sleep(.1)
motor.stop()
time.sleep(2)
print ('ramp up rev')
for i in range(100):
motor.reverse(i)
time.sleep(.1)
print ('ramp down rev')
for i in range(100):
motor.reverse(100-i)
time.sleep(.1)
except KeyboardInterrupt:
pass
finally:
motor.cleanup()
Requirements
- PmodHB3 module connected to port JAA
- DC motor
- Motor power supply
ISNS20¶
±20A DC or AC input, high accuracy current sensor.
Print milliamps out to the terminal¶
Read the current sense module, print the milliamps out to the terminal, sleep for 0.8s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Read current and print out milliamps.
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
isens = createPmod('ISNS20','JBA')
time.sleep(0.1)
try:
while True:
mA = isens.readMilliAmps()
print(mA)
time.sleep(0.8)
except KeyboardInterrupt:
pass
finally:
isens.cleanup()
Requirements
- PmodISNS20 module connected to port JBA
- Suitable current source, e.g. a power supply and load
MIC3¶
Knowles Acoustics SPA2410LR5H-B MEMs microphone and Texas Instrument’s ADCS7476 12-bit Analog-to-Digital Converter.
Display mic level¶
Print a continous sound level reading out to the terminal.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Print a continous sound level reading out.
"""
from DesignSpark.Pmod.HAT import createPmod
import time
s = ':'
lut = [s]
for i in range(128):
s+=':'
lut.append(s)
if __name__ == '__main__':
mic = createPmod('MIC3','JBA')
time.sleep(0.1)
try:
while True:
int = mic.readIntegerValue()
#print(int)
print(lut[int>>5])
snd = mic.readPhysicalValue()
#print(snd)
#time.sleep(0.01)
except KeyboardInterrupt:
pass
finally:
mic.cleanup()
Requirements
- PmodMIC3 module connected to port JBA
OLEDrgb¶
Organic RGB LED module with a 96×64 pixel display capable of 16-bit color resolution.
Display text in a bounding box¶
Display the text “Hello, World!” in a bounding box.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Display Hello, World! in bounding box.
"""
from DesignSpark.Pmod.HAT import createPmod
from luma.core.render import canvas
from luma.oled.device import ssd1331
if __name__ == '__main__':
try:
oled = createPmod('OLEDrgb','JA')
device = oled.getDevice()
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
draw.text((16,20), "Hello, World!", fill="white")
while True:
pass
except KeyboardInterrupt:
pass
finally:
oled.cleanup()
Luma.Core & Luma.OLED API:
luma.core.render.canvas,
luma.oled.device.ssd1331.
Requirements
- PmodOLEDrgb connected to port JA
PmodTC1¶
A cold-junction thermocouple-to-digital converter module designed for a classic K-Type thermocouple wire. Features a temperature range of -73°C to 482°C with provided wire.
Print celsius out to the terminal¶
Print the celsius reading out to the terminal, sleep for 0.8s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Print the celsius reading out.
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
therm = createPmod('TC1','JBA')
time.sleep(0.1)
try:
while True:
cel = therm.readCelcius()
print(cel)
#intn = therm.readInternal()
#print(intn)
time.sleep(0.8)
except KeyboardInterrupt:
pass
finally:
therm.cleanup()
Requirements
- PmodTC1 module connected to port JBA
PmodACL2¶
A 3-axis MEMS accelerometer module. Features the Analog Devices ADXL362 device with Measurement ranges ±2g, ±4g, ±8g. Up to 12-bit resolution on each axis.
Print axis out to the terminal¶
Print the axis reading out to the terminal, sleep for 0.5s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Read and print out accelerometer values.
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
ACL2 = createPmod('ACL2','JB')
time.sleep(0.1)
# print(hex(ACL2.getDeviceID())) # Device test. 0xAD will be expected.
# ACL2.setRange(ACL2.SENSOR_RANGE_8G) # default setting: +/- 4G
# maxz = 0
try:
while True:
x,y,z,t = ACL2.getXYZT()
print(x,y,z,t)
time.sleep(0.8)
# if maxz < z:
# maxz = z
except KeyboardInterrupt:
pass
finally:
ACL2.cleanup()
# print(maxz)
Requirements
- PmodACL2 module connected to port JB
PmodGPS¶
A GlobalTop FGPMMOPA6H GPS antenna module to receive position data from GPS satellites.
Print date, time, and location out to the terminal¶
Print the date, time, and location reading out to the terminal, sleep for 0.5s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Read GPS and print position, speed, and GPS time
"""
from DesignSpark.Pmod.HAT import createPmod
import time
# import webbrowser
if __name__ == '__main__':
GPS = createPmod('GPS','JCA') # UART port is only available on JCA
time.sleep(0.1)
try:
while True:
"""
LINE = GPS.getGPSLine()
print(LINE)
time.sleep(0.5)
"""
GPS.gpsUpdate()
print(GPS.getGPSPosData())
time.sleep(0.5)
except KeyboardInterrupt:
pass
finally:
#day,month,year,hour,minute,sec,LatDeg,LogDeg,PDOP = GPS.getGPSPosData()
#url = "https://google.com/maps?q={},{}"
#url = url.format(LatDeg,LogDeg)
GPS.cleanup()
#webbrowser.open(url)
Requirements
- PmodGPS module connected to port JCA
- View of the sky or external antenna connected to the module
- …takes time to obtain a fix and get the data
PmodSWT¶
Four slides switches for up to 16x different binary logic inputs.
Print switches out to the terminal¶
Read the four switches and print out to the terminal, sleep for 0.5s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Read switch status
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
SWT = createPmod('SWT','JAA')
time.sleep(0.1)
try:
while True:
print(SWT.GetStatus(1),SWT.GetStatus(2),SWT.GetStatus(3),SWT.GetStatus(4))
time.sleep(0.5)
except KeyboardInterrupt:
pass
finally:
SWT.cleanup()
Requirements
- PmodSWT module connected to port JAA
PmodLS1¶
A line follower robot interface system board.
Print received signals from optical sensor out to the terminal¶
Print the signals from multiple optical sensors out to the terminal, sleep for 0.5s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Read Sensor status
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
LS1 = createPmod('LS1','JAA')
time.sleep(0.1)
try:
while True:
print(LS1.GetAllStatus())
time.sleep(0.5)
except KeyboardInterrupt:
pass
finally:
LS1.cleanup()
Requirements
- PmodLS1 module connected to port JAA
PmodKYPD¶
A 16-button keypad.
Print character out to the terminal¶
Print the key presses out to the terminal, sleep for 0.5s and repeat.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 RS Components Ltd
# SPDX-License-Identifier: MIT License
"""
Print keypad presses
"""
from DesignSpark.Pmod.HAT import createPmod
import time
if __name__ == '__main__':
KYPD = createPmod('KYPD','JA')
time.sleep(0.1)
try:
# set default key map
KYPD.setKeyMapDefault()
# set User Key Map
# keyMap=[['A','B','C','D'],['E','F','G','H'],['I','J','K','L'],['M','N','O','P']]
# KYPD.setKeyMap(keyMap)
# get keyMap
print(KYPD.getKeyMap())
while True:
# print(KYPD.getColRow())
print(KYPD.getKey())
time.sleep(0.5)
except KeyboardInterrupt:
pass
finally:
KYPD.cleanup()
Requirements
- PmodKYPD module connected to port JA
Advanced Examples¶
OLEDrgb¶
Organic RGB LED module with a 96×64 pixel display capable of 16-bit color resolution.
Analogue clock¶
Display an analogue clock face with date and time.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2014-17 Richard Hull and contributors
# See LICENSE.rst for details.
# PYTHON_ARGCOMPLETE_OK
"""
An analog clockface with date & time.
Ported from:
https://gist.github.com/TheRayTracer/dd12c498e3ecb9b8b47f#file-clock-py
"""
import math
import time
import datetime
from DesignSpark.Pmod.HAT import createPmod
from luma.core.render import canvas
def posn(angle, arm_length):
dx = int(math.cos(math.radians(angle)) * arm_length)
dy = int(math.sin(math.radians(angle)) * arm_length)
return (dx, dy)
def main():
today_last_time = "Unknown"
while True:
now = datetime.datetime.now()
today_date = now.strftime("%d %b %y")
today_time = now.strftime("%H:%M:%S")
if today_time != today_last_time:
today_last_time = today_time
with canvas(device) as draw:
now = datetime.datetime.now()
today_date = now.strftime("%d %b %y")
margin = 4
cx = 30
cy = min(device.height, 64) / 2
left = cx - cy
right = cx + cy
hrs_angle = 270 + (30 * (now.hour + (now.minute / 60.0)))
hrs = posn(hrs_angle, cy - margin - 7)
min_angle = 270 + (6 * now.minute)
mins = posn(min_angle, cy - margin - 2)
sec_angle = 270 + (6 * now.second)
secs = posn(sec_angle, cy - margin - 2)
draw.ellipse((left + margin, margin, right - margin, min(device.height, 64) - margin), outline="white")
draw.line((cx, cy, cx + hrs[0], cy + hrs[1]), fill="white")
draw.line((cx, cy, cx + mins[0], cy + mins[1]), fill="white")
draw.line((cx, cy, cx + secs[0], cy + secs[1]), fill="red")
draw.ellipse((cx - 2, cy - 2, cx + 2, cy + 2), fill="white", outline="white")
draw.text((2 * (cx + margin), cy - 8), today_date, fill="yellow")
draw.text((2 * (cx + margin), cy), today_time, fill="yellow")
time.sleep(0.1)
if __name__ == "__main__":
oled = createPmod('OLEDrgb','JA')
try:
device = oled.getDevice()
main()
except KeyboardInterrupt:
pass
finally:
oled.cleanup()
Game of Life¶
Conway’s Game of Life.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2014-17 Richard Hull and contributors
# See LICENSE.rst for details.
# PYTHON_ARGCOMPLETE_OK
"""
Conway's game of life.
Adapted from:
http://codereview.stackexchange.com/a/108121
"""
import time
from random import randint
from DesignSpark.Pmod.HAT import createPmod
from luma.core.render import canvas
def neighbors(cell):
x, y = cell
yield x - 1, y - 1
yield x, y - 1
yield x + 1, y - 1
yield x - 1, y
yield x + 1, y
yield x - 1, y + 1
yield x, y + 1
yield x + 1, y + 1
def iterate(board):
new_board = set([])
candidates = board.union(set(n for cell in board for n in neighbors(cell)))
for cell in candidates:
count = sum((n in board) for n in neighbors(cell))
if count == 3 or (count == 2 and cell in board):
new_board.add(cell)
return new_board
def main():
scale = 3
cols = device.width // scale
rows = device.height // scale
initial_population = int(cols * rows * 0.33)
while True:
board = set((randint(0, cols), randint(0, rows)) for _ in range(initial_population))
for i in range(500):
with canvas(device, dither=True) as draw:
for x, y in board:
left = x * scale
top = y * scale
if scale == 1:
draw.point((left, top), fill="white")
else:
right = left + scale
bottom = top + scale
draw.rectangle((left, top, right, bottom), fill="white", outline="black")
if i == 0:
w, h = draw.textsize("Game of Life")
left = (device.width - w) // 2
top = (device.height - h) // 2
draw.rectangle((left - 1, top, left + w + 1, top + h), fill="black", outline="white")
draw.text((left + 1, top), text="Game of Life", fill="white")
if i == 0:
time.sleep(3)
board = iterate(board)
if __name__ == "__main__":
try:
oled = createPmod('OLEDrgb','JA')
device = oled.getDevice()
main()
except KeyboardInterrupt:
pass
Requirements
- PmodOLEDrgb connected to port JA
API¶
DesignSpark.Pmod.AD1¶
Interface for PmodAD1 module (AD7476A).
Note
Only a single channel (A1) is supported at present due to the way that SPI is configured.
DesignSpark.Pmod.Error¶
-
exception
DesignSpark.Pmod.Error.Error[source]¶ Bases:
exceptions.ExceptionBase class for exceptions in this library.
-
exception
DesignSpark.Pmod.Error.incorrectModuleName[source]¶ Bases:
DesignSpark.Pmod.Error.ErrorException raised when the module name given does not exist in the module map.
-
exception
DesignSpark.Pmod.Error.incorrectPortName[source]¶ Bases:
DesignSpark.Pmod.Error.ErrorException raised when the port name given does not exist in the port map.
-
exception
DesignSpark.Pmod.Error.portCapabilityConflict[source]¶ Bases:
DesignSpark.Pmod.Error.ErrorException raised when the port is already using shared GPIO pins.
-
exception
DesignSpark.Pmod.Error.portCapabilitySupport[source]¶ Bases:
DesignSpark.Pmod.Error.ErrorException raised when a port does not support the module type.
-
exception
DesignSpark.Pmod.Error.portInUse[source]¶ Bases:
DesignSpark.Pmod.Error.ErrorException raised when the port is already assigned.
DesignSpark.Pmod.HAT¶
Manages Pmod HAT port resources, enforcing correct usage and avoiding conflicts.
DesignSpark.Pmod.HB3¶
Interface for PmodHB3 module.
DesignSpark.Pmod.ISNS20¶
Interface for PmodISNS20 module (ADC7476 + Allegro ACS722).
DesignSpark.Pmod.MIC3¶
Interface for PmodMIC3 (ADCS7476 + Knowles Acoustics SPA2410LR5H-B).
DesignSpark.Pmod.OLEDrgb¶
Interface for PmodOLEDrgb module (ssd1331).
Note
Depends on luma.oled and luma.core.
DesignSpark.Pmod.TC1¶
Interface for PmodTC1 module (MAX31855).
DesignSpark.Pmod.ACL2¶
Interface for Pmod ACL2 module.
DesignSpark.Pmod.GPS¶
Interface for PmodGPS
-
class
DesignSpark.Pmod.GPS.MicropyGPS(local_offset=0, location_formatting='ddm')[source]¶ GPS NMEA Sentence Parser. Creates object that stores all relevant GPS data and statistics. Parses sentences one character at a time using update().
-
SENTENCE_LIMIT= 90¶
-
compass_direction()[source]¶ Determine a cardinal or inter-cardinal direction based on current course. :return: string
-
date_string(formatting='s_mdy', century='20')[source]¶ Creates a readable string of the current date. Can select between long format: Januray 1st, 2014 or two short formats: 11/01/2014 (MM/DD/YYYY) 01/11/2014 (DD/MM/YYYY) :param formatting: string ‘s_mdy’, ‘s_dmy’, or ‘long’ :param century: int delineating the century the GPS data is from (19 for 19XX, 20 for 20XX) :return: date_string string with long or short format date
-
gpgga()[source]¶ Parse Global Positioning System Fix Data (GGA) Sentence. Updates UTC timestamp, latitude, longitude, fix status, satellites in use, Horizontal Dilution of Precision (HDOP), altitude, geoid height and fix status
-
gpgll()[source]¶ Parse Geographic Latitude and Longitude (GLL)Sentence. Updates UTC timestamp, latitude, longitude, and fix status
-
gpgsa()[source]¶ Parse GNSS DOP and Active Satellites (GSA) sentence. Updates GPS fix type, list of satellites used in fix calculation, Position Dilution of Precision (PDOP), Horizontal Dilution of Precision (HDOP), Vertical Dilution of Precision, and fix status
-
gpgsv()[source]¶ Parse Satellites in View (GSV) sentence. Updates number of SV Sentences,the number of the last SV sentence parsed, and data on each satellite present in the sentence
-
gprmc()[source]¶ Parse Recommended Minimum Specific GPS/Transit data (RMC)Sentence. Updates UTC timestamp, latitude, longitude, Course, Speed, Date, and fix status
-
latitude¶ Format Latitude Data Correctly
-
longitude¶ Format Longitude Data Correctly
-
new_fix_time()[source]¶ Updates a high resolution counter with current time when fix is updated. Currently only triggered from GGA, GSA and RMC sentences
-
satellite_data_updated()[source]¶ Checks if the all the GSV sentences in a group have been read, making satellite data complete :return: boolean
-
satellites_visible()[source]¶ Returns a list of of the satellite PRNs currently visible to the receiver :return: list
-
speed_string(unit='kph')[source]¶ Creates a readable string of the current speed data in one of three units :param unit: string of ‘kph’,’mph, or ‘knot’ :return:
-
supported_sentences= {'GLGGA': <function gpgga>, 'GLGLL': <function gpgll>, 'GLGSA': <function gpgsa>, 'GLGSV': <function gpgsv>, 'GLRMC': <function gprmc>, 'GLVTG': <function gpvtg>, 'GNGGA': <function gpgga>, 'GNGLL': <function gpgll>, 'GNGSA': <function gpgsa>, 'GNRMC': <function gprmc>, 'GNVTG': <function gpvtg>, 'GPGGA': <function gpgga>, 'GPGLL': <function gpgll>, 'GPGSA': <function gpgsa>, 'GPGSV': <function gpgsv>, 'GPRMC': <function gprmc>, 'GPVTG': <function gpvtg>}¶
-
time_since_fix()[source]¶ Returns number of millisecond since the last sentence with a valid fix was parsed. Returns 0 if no fix has been found
-
update(new_char)[source]¶ Process a new input char and updates GPS object if necessary based on special characters (‘$’, ‘,’, ‘*’) Function builds a list of received string that are validate by CRC prior to parsing by the appropriate sentence function. Returns sentence type on successful parse, None otherwise
-
DesignSpark.Pmod.SWT¶
Interface for Pmod_SWT
DesignSpark.Pmod.LS1¶
Interface for Pmod_LS1
Change log¶
| Version | Description | Date |
|---|---|---|
| 0.3.0 |
|
26/02/20 |
| 0.2.0 |
|
28/11/17 |
| 0.1.0 |
|
26/11/17 |
The MIT License (MIT)¶
Copyright (c) 2017 RS Components Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.