Compare commits

...

23 commits

Author SHA1 Message Date
dherrada
10e9e68db2 Fixed discord invite link 2020-07-08 16:49:04 -04:00
Dan Halbert
bade8c3014
Merge pull request #61 from adafruit/black-update
Black reformatting with Python 3 target.
2020-04-09 21:30:50 -04:00
Kattni Rembor
7ce1f8379d Black reformatting with Python 3 target. 2020-04-09 17:35:34 -04:00
sommersoft
d42628474e build.yml: add black formatting check
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-04-07 16:13:00 -05:00
foamyguy
b4a3e1fdc8
Merge pull request #58 from makermelissa/master
Updating HT16K33 code to work with version 4.0.0
2020-04-03 18:22:07 -05:00
Melissa LeBlanc-Williams
b0f557eeb3 Fixed copy/paste error 2020-03-25 19:08:55 -07:00
Melissa LeBlanc-Williams
6c584a8411 Update brightness for Matrix featherwing 2020-03-25 19:05:34 -07:00
Melissa LeBlanc-Williams
3e26f98dc6 Merge branch 'master' of https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing 2020-03-25 19:01:58 -07:00
Kattni
409cb68256
Merge pull request #60 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2020-03-17 16:24:38 -04:00
dherrada
5133a944ed Ran black, updated to pylint 2.x 2020-03-16 16:41:21 -04:00
sommersoft
5963200856 update code of coduct: discord moderation contact section
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-15 18:30:08 -05:00
foamyguy
eae7a6a969
Merge pull request #59 from sommersoft/patch_coc
Update Code of Conduct
2020-03-13 14:54:10 -05:00
sommersoft
174a05200c update code of conduct 2020-03-13 13:57:21 -05:00
Melissa LeBlanc-Williams
e84f36eb5e Fixes an issue from an update of the ht16k33 2020-03-10 08:47:05 -07:00
Melissa LeBlanc-Williams
4afec77ee8 Updating HT16K33 code to work with version 2.0.0 2020-03-10 08:40:20 -07:00
sommersoft
bcfdb986e6 update pylintrc for black
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-08 19:11:39 -05:00
sommersoft
d765084c12 build.yml: move pylint, black, and Sphinx installs to each repo; add description to 'actions-ci/install.sh'
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-05 10:11:01 -06:00
Melissa LeBlanc-Williams
477e59e41f
Merge pull request #57 from makermelissa/master
Reordered init sequence for MiniTFT for improved stability
2020-02-26 13:42:06 -08:00
Melissa LeBlanc-Williams
2e952dd368 Reordered init sequence for MiniTFT for improved stability 2020-02-26 13:28:29 -08:00
Melissa LeBlanc-Williams
69e5d3a34f
Merge pull request #55 from makermelissa/master
Removed duplicate call to set pullups
2020-02-13 11:05:13 -08:00
Melissa LeBlanc-Williams
e26874439a Removed duplicate call to set pullups 2020-02-13 09:44:01 -08:00
Kattni
6c191db91a
Merge pull request #53 from adafruit/dherrada-patch-2
Updated intersphinx link
2020-02-05 09:29:59 -05:00
dherrada
8e9218e4b4
Updated intersphinx link 2020-02-03 08:54:03 -05:00
30 changed files with 476 additions and 277 deletions

View file

@ -34,11 +34,18 @@ jobs:
with:
repository: adafruit/actions-ci-circuitpython-libs
path: actions-ci
- name: Install deps
- name: Install dependencies
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
run: |
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: Check formatting
run: |
black --check --target-version=py35 .
- name: PyLint
run: |
pylint $( find . -path './adafruit*.py' )

View file

@ -52,7 +52,7 @@ confidence=
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option

View file

@ -1,74 +1,129 @@
# Contributor Covenant Code of Conduct
# Adafruit Community Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
contributors and leaders pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
size, disability, ethnicity, gender identity and expression, level or type of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.
## Our Standards
We are committed to providing a friendly, safe and welcoming environment for
all.
Examples of behavior that contributes to creating a positive environment
include:
* Be kind and courteous to others
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Collaborating with other community members
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* The use of sexualized language or imagery and sexual attention or advances
* The use of inappropriate images, including in a community member's avatar
* The use of inappropriate language, including in a community member's nickname
* Any spamming, flaming, baiting or other attention-stealing behavior
* Excessive or unwelcome helping; answering outside the scope of the question
asked
* Trolling, insulting/derogatory comments, and personal or political attacks
* Promoting or spreading disinformation, lies, or conspiracy theories against
a person, group, organisation, project, or community
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
* Other conduct which could reasonably be considered inappropriate
The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self.
We value many things beyond technical expertise, including collaboration and
supporting others within our community. Providing a positive experience for
other community members can have a much more significant impact than simply
providing the correct answer.
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
Project leaders are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
Project leaders have the right and responsibility to remove, edit, or
reject messages, comments, commits, code, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
permanently any community member for other behaviors that they deem
inappropriate, threatening, offensive, or harmful.
## Moderation
Instances of behaviors that violate the Adafruit Community Code of Conduct
may be reported by any member of the community. Community members are
encouraged to report these situations, including situations they witness
involving other community members.
You may report in the following ways:
In any situation, you may send an email to <support@adafruit.com>.
On the Adafruit Discord, you may send an open message from any channel
to all Community Moderators by tagging @community moderators. You may
also send an open message from any channel, or a direct message to
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
Email and direct message reports will be kept confidential.
In situations on Discord where the issue is particularly egregious, possibly
illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to Discord.
These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the
Adafruit Community Code of Conduct. All reports will be reviewed and
investigated.
2. If the behavior is an egregious violation, the community member who
committed the violation may be banned immediately, without warning.
3. Otherwise, moderators will first respond to such behavior with a warning.
4. Moderators follow a soft "three strikes" policy - the community member may
be given another chance, if they are receptive to the warning and change their
behavior.
5. If the community member is unreceptive or unreasonable when warned by a
moderator, or the warning goes unheeded, they may be banned for a first or
second offense. Repeated offenses will result in the community member being
banned.
## Scope
This Code of Conduct and the enforcement policies listed above apply to all
Adafruit Community venues. This includes but is not limited to any community
spaces (both public and private), the entire Adafruit Discord server, and
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
interaction at a conference.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at support@adafruit.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
when an individual is representing the project or its community. As a community
member, you are representing our community, and are expected to behave
accordingly.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your
own moderation policy so as to avoid confusion.

View file

@ -7,7 +7,7 @@ Introduction
:alt: Documentation Status
.. image :: https://img.shields.io/discord/327254708534116352.svg
:target: https://discord.gg/nBQh6qu
:target: https://adafru.it/discord
:alt: Discord
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing/workflows/Build%20CI/badge.svg

View file

@ -35,11 +35,13 @@ import board
import adafruit_ht16k33.segments as segments
from adafruit_featherwing.led_segments import Segments
class AlphaNumFeatherWing(Segments):
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
<https://www.adafruit.com/product/3139>`_.
Automatically uses the feather's I2C bus."""
def __init__(self, address=0x70, i2c=None):
super().__init__()
if i2c is None:

View file

@ -35,11 +35,13 @@ import board
import adafruit_dotstar as dotstar
from adafruit_featherwing.pixelmatrix import PixelMatrix
class DotStarFeatherWing(PixelMatrix):
"""Class representing a `DotStar FeatherWing
<https://www.adafruit.com/product/3449>`_.
The feather uses pins D13 and D11"""
def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
"""
:param pin clock: The clock pin for the featherwing
@ -49,5 +51,10 @@ class DotStarFeatherWing(PixelMatrix):
super().__init__()
self.rows = 6
self.columns = 12
self._matrix = dotstar.DotStar(clock, data, self.rows * self.columns,
brightness=brightness, auto_write=False)
self._matrix = dotstar.DotStar(
clock,
data,
self.rows * self.columns,
brightness=brightness,
auto_write=False,
)

View file

@ -35,11 +35,13 @@ import board
import busio
import adafruit_gps
class GPSFeatherWing:
"""Class representing an `Ultimate GPS FeatherWing
<https://www.adafruit.com/product/3133>`_.
Automatically uses the feather's UART bus."""
def __init__(self, update_period=1000, baudrate=9600):
"""
:param int update_period: (Optional) The amount of time in milliseconds between
@ -57,8 +59,10 @@ class GPSFeatherWing:
self._uart = busio.UART(board.TX, board.RX, baudrate=baudrate, timeout=timeout)
self._gps = adafruit_gps.GPS(self._uart, debug=False)
# Turn on the basic GGA and RMC info
self._gps.send_command(bytes('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'utf-8'))
self._gps.send_command(bytes('PMTK220,{}'.format(update_period), 'utf-8'))
self._gps.send_command(
bytes("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", "utf-8")
)
self._gps.send_command(bytes("PMTK220,{}".format(update_period), "utf-8"))
def update(self):
"""

View file

@ -34,11 +34,13 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
import board
import adafruit_ina219
class INA219FeatherWing:
"""Class representing an `Adafruit INA219 FeatherWing
<https://www.adafruit.com/product/3650>`_.
Automatically uses the feather's I2C bus."""
def __init__(self, i2c=None):
if i2c is None:
i2c = board.I2C()

View file

@ -46,12 +46,15 @@ class JoyFeatherWing:
"""Class representing an `Adafruit Joy FeatherWing <https://www.adafruit.com/product/3632>`_.
Automatically uses the feather's I2C bus."""
def __init__(self, i2c=None):
if i2c is None:
i2c = board.I2C()
self._seesaw = adafruit_seesaw.seesaw.Seesaw(i2c)
self._seesaw.pin_mode_bulk(BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT,
self._seesaw.INPUT_PULLUP)
self._seesaw.pin_mode_bulk(
BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT,
self._seesaw.INPUT_PULLUP,
)
# Initialise joystick_offset
self._joystick_offset = (0, 0)

View file

@ -31,13 +31,15 @@ Base Class for the AlphaNumeric FeatherWing and 7-Segment FeatherWing helpers_.
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
#pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
class Segments:
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
<https://www.adafruit.com/product/3139>`_.
Automatically uses the feather's I2C bus."""
def __init__(self):
self._segments = None
@ -49,6 +51,10 @@ class Segments:
:type value: str or int or float
"""
# Attempt to round off so we can still display the value
if isinstance(value, float) and len(str(value)) > 5:
value = round(value)
self._segments.print(value)
self._segments.show()
@ -74,7 +80,7 @@ class Segments:
self._segments.fill(1 if fill else 0)
self._segments.show()
else:
raise ValueError('Must set to either True or False.')
raise ValueError("Must set to either True or False.")
@property
def blink_rate(self):
@ -95,8 +101,10 @@ class Segments:
Brightness returns the current display brightness.
0-15 = Dimmest to Brightest Setting
"""
return self._segments.brightness
return round(self._segments.brightness * 15)
@brightness.setter
def brightness(self, brightness):
self._segments.brightness = brightness
if not 0 <= brightness <= 15:
raise ValueError("Brightness must be a value between 0 and 15")
self._segments.brightness = brightness / 15

View file

@ -35,11 +35,13 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
import board
import adafruit_ht16k33.matrix as matrix
class MatrixFeatherWing:
"""Class representing an `Adafruit 8x16 LED Matrix FeatherWing
<https://www.adafruit.com/product/3155>`_.
Automatically uses the feather's I2C bus."""
def __init__(self, address=0x70, i2c=None):
if i2c is None:
i2c = board.I2C()
@ -102,7 +104,7 @@ class MatrixFeatherWing:
self._matrix.fill(1 if fill else 0)
self._update()
else:
raise ValueError('Must set to either True or False.')
raise ValueError("Must set to either True or False.")
def shift_right(self, rotate=False):
"""
@ -172,8 +174,10 @@ class MatrixFeatherWing:
Brightness returns the current display brightness.
0-15 = Dimmest to Brightest Setting
"""
return self._matrix.brightness
return round(self._matrix.brightness * 15)
@brightness.setter
def brightness(self, brightness):
self._matrix.brightness = brightness
if not 0 <= brightness <= 15:
raise ValueError("Brightness must be a value between 0 and 15")
self._matrix.brightness = brightness / 15

View file

@ -50,20 +50,23 @@ BUTTON_B = const(9)
Buttons = namedtuple("Buttons", "up down left right a b select")
class MiniTFTFeatherWing:
"""Class representing an `Mini Color TFT with Joystick FeatherWing
<https://www.adafruit.com/product/3321>`_.
Automatically uses the feather's I2C bus."""
_button_mask = ((1 << BUTTON_RIGHT) |
(1 << BUTTON_DOWN) |
(1 << BUTTON_LEFT) |
(1 << BUTTON_UP) |
(1 << BUTTON_SEL) |
(1 << BUTTON_A) |
(1 << BUTTON_B))
#pylint: disable-msg=too-many-arguments
_button_mask = (
(1 << BUTTON_RIGHT)
| (1 << BUTTON_DOWN)
| (1 << BUTTON_LEFT)
| (1 << BUTTON_UP)
| (1 << BUTTON_SEL)
| (1 << BUTTON_A)
| (1 << BUTTON_B)
)
# pylint: disable-msg=too-many-arguments
def __init__(self, address=0x5E, i2c=None, spi=None, cs=None, dc=None):
displayio.release_displays()
if i2c is None:
@ -75,16 +78,17 @@ class MiniTFTFeatherWing:
if dc is None:
dc = board.D6
self._ss = Seesaw(i2c, address)
self._backlight = PWMOut(self._ss, 5)
self._backlight.duty_cycle = 0
self._ss.pin_mode_bulk(self._button_mask, self._ss.INPUT_PULLUP)
self._ss.pin_mode(8, self._ss.OUTPUT)
self._ss.digital_write(8, True) # Reset the Display via Seesaw
self._backlight = PWMOut(self._ss, 5)
self._backlight.duty_cycle = 0
display_bus = displayio.FourWire(spi, command=dc, chip_select=cs)
self.display = ST7735R(display_bus, width=160, height=80, colstart=24,
rotation=270, bgr=True)
self._ss.pin_mode_bulk(self._button_mask, self._ss.INPUT_PULLUP)
#pylint: enable-msg=too-many-arguments
self.display = ST7735R(
display_bus, width=160, height=80, colstart=24, rotation=270, bgr=True
)
# pylint: enable-msg=too-many-arguments
@property
def backlight(self):
@ -108,9 +112,31 @@ class MiniTFTFeatherWing:
try:
button_values = self._ss.digital_read_bulk(self._button_mask)
except OSError:
return Buttons(*[False for button in
(BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT,
BUTTON_A, BUTTON_B, BUTTON_SEL)])
return Buttons(*[not button_values & (1 << button) for button in
(BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT,
BUTTON_A, BUTTON_B, BUTTON_SEL)])
return Buttons(
*[
False
for button in (
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
BUTTON_A,
BUTTON_B,
BUTTON_SEL,
)
]
)
return Buttons(
*[
not button_values & (1 << button)
for button in (
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
BUTTON_A,
BUTTON_B,
BUTTON_SEL,
)
]
)

View file

@ -35,11 +35,13 @@ import board
import neopixel
from adafruit_featherwing.pixelmatrix import PixelMatrix
class NeoPixelFeatherWing(PixelMatrix):
"""Class representing a `NeoPixel FeatherWing
<https://www.adafruit.com/product/2945>`_.
The feather uses pins D6 by default"""
def __init__(self, pixel_pin=board.D6, brightness=0.1):
"""
:param pin pixel_pin: The pin for the featherwing
@ -48,9 +50,13 @@ class NeoPixelFeatherWing(PixelMatrix):
super().__init__()
self.rows = 4
self.columns = 8
self._matrix = neopixel.NeoPixel(pixel_pin, self.rows * self.columns,
brightness=brightness, auto_write=False,
pixel_order=neopixel.GRB)
self._matrix = neopixel.NeoPixel(
pixel_pin,
self.rows * self.columns,
brightness=brightness,
auto_write=False,
pixel_order=neopixel.GRB,
)
def shift_up(self, rotate=False):
"""
@ -83,7 +89,7 @@ class NeoPixelFeatherWing(PixelMatrix):
time.sleep(.1)
"""
super().shift_down(rotate) # Up and down are reversed
super().shift_down(rotate) # Up and down are reversed
def shift_down(self, rotate=False):
"""
@ -116,4 +122,4 @@ class NeoPixelFeatherWing(PixelMatrix):
time.sleep(.1)
"""
super().shift_up(rotate) # Up and down are reversed
super().shift_up(rotate) # Up and down are reversed

View file

@ -32,12 +32,14 @@ Base Class for the `NeoPixel FeatherWing <https://www.adafruit.com/product/2945>
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
#pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
class PixelMatrix:
"""Base Class for DotStar and NeoPixel FeatherWings
The feather uses pins D13 and D11"""
def __init__(self):
self.rows = 0
self.columns = 0
@ -74,18 +76,18 @@ class PixelMatrix:
"""
if isinstance(indices, int):
if not 0 <= indices < self.rows * self.columns:
raise ValueError('The index of {} is out of range'.format(indices))
raise ValueError("The index of {} is out of range".format(indices))
return indices
if isinstance(indices, slice):
return indices
if len(indices) == 2:
x, y = indices
if not 0 <= x < self.columns:
raise ValueError('The X value of {} is out of range'.format(x))
raise ValueError("The X value of {} is out of range".format(x))
if not 0 <= y < self.rows:
raise ValueError('The Y value of {} is out of range'.format(y))
raise ValueError("The Y value of {} is out of range".format(y))
return y * self.columns + x
raise ValueError('Index must be 1 or 2 number')
raise ValueError("Index must be 1 or 2 number")
def _update(self):
"""
@ -120,7 +122,9 @@ class PixelMatrix:
for y in range(0, self.rows):
last_pixel = self._matrix[(y + 1) * self.columns - 1] if rotate else 0
for x in range(self.columns - 1, 0, -1):
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x - 1]
self._matrix[y * self.columns + x] = self._matrix[
y * self.columns + x - 1
]
self._matrix[y * self.columns] = last_pixel
self._update()
@ -133,7 +137,9 @@ class PixelMatrix:
for y in range(0, self.rows):
last_pixel = self._matrix[y * self.columns] if rotate else 0
for x in range(0, self.columns - 1):
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x + 1]
self._matrix[y * self.columns + x] = self._matrix[
y * self.columns + x + 1
]
self._matrix[(y + 1) * self.columns - 1] = last_pixel
self._update()
@ -144,9 +150,13 @@ class PixelMatrix:
:param rotate: (Optional) Rotate the shifted pixels to bottom (default=False)
"""
for x in range(0, self.columns):
last_pixel = self._matrix[(self.rows - 1) * self.columns + x] if rotate else 0
last_pixel = (
self._matrix[(self.rows - 1) * self.columns + x] if rotate else 0
)
for y in range(self.rows - 1, 0, -1):
self._matrix[y * self.columns + x] = self._matrix[(y - 1) * self.columns + x]
self._matrix[y * self.columns + x] = self._matrix[
(y - 1) * self.columns + x
]
self._matrix[x] = last_pixel
self._update()
@ -159,7 +169,9 @@ class PixelMatrix:
for x in range(0, self.columns):
last_pixel = self._matrix[x] if rotate else 0
for y in range(0, self.rows - 1):
self._matrix[y * self.columns + x] = self._matrix[(y + 1) * self.columns + x]
self._matrix[y * self.columns + x] = self._matrix[
(y + 1) * self.columns + x
]
self._matrix[(self.rows - 1) * self.columns + x] = last_pixel
self._update()

View file

@ -37,11 +37,13 @@ from collections import namedtuple
import board
import adafruit_ds3231
class RTCFeatherWing:
"""Class representing an `DS3231 Precision RTC FeatherWing
<https://www.adafruit.com/product/3028>`_.
Automatically uses the feather's I2C bus."""
def __init__(self, i2c=None):
if i2c is None:
i2c = board.I2C()
@ -67,7 +69,7 @@ class RTCFeatherWing:
if unit in now:
now[unit] = value
else:
raise ValueError('The specified unit of time is invalid')
raise ValueError("The specified unit of time is invalid")
self._rtc.datetime = self._encode(now)
@ -78,24 +80,41 @@ class RTCFeatherWing:
now = self._get_now()
if unit in now:
return now[unit]
raise ValueError('The specified unit of time is invalid')
raise ValueError("The specified unit of time is invalid")
def _get_now(self):
"""
Return the current date and time in a nice updatable dictionary
"""
now = self._rtc.datetime
return {'second': now.tm_sec, 'minute': now.tm_min, 'hour': now.tm_hour, 'day': now.tm_mday,
'month': now.tm_mon, 'year': now.tm_year, 'weekday': now.tm_wday}
return {
"second": now.tm_sec,
"minute": now.tm_min,
"hour": now.tm_hour,
"day": now.tm_mday,
"month": now.tm_mon,
"year": now.tm_year,
"weekday": now.tm_wday,
}
def _encode(self, date):
"""
Encode the updatable dictionary back into a time struct
"""
now = self._rtc.datetime
return time.struct_time((date['year'], date['month'], date['day'], date['hour'],
date['minute'], date['second'], date['weekday'], now.tm_yday,
now.tm_isdst))
return time.struct_time(
(
date["year"],
date["month"],
date["day"],
date["hour"],
date["minute"],
date["second"],
date["weekday"],
now.tm_yday,
now.tm_isdst,
)
)
def is_leap_year(self, year=None):
"""
@ -104,7 +123,7 @@ class RTCFeatherWing:
:param int year: (Optional) The year to check. If none is provided, current year is used.
"""
if year is None:
year = self._get_time_value('year')
year = self._get_time_value("year")
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
def get_month_days(self, month=None, year=None):
@ -115,7 +134,7 @@ class RTCFeatherWing:
:param int year: (Optional) The year to check. If none is provided, current year is used.
"""
if month is None:
month = self._get_time_value('month')
month = self._get_time_value("month")
leap_year = self.is_leap_year(year)
max_days = (31, 29 if leap_year else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
return max_days[month - 1]
@ -129,18 +148,18 @@ class RTCFeatherWing:
:param int second: (Optional) The second we want to set the time to (default=0)
"""
if not isinstance(second, int) or not 0 <= second < 60:
raise ValueError('The second must be an integer in the range of 0-59')
raise ValueError("The second must be an integer in the range of 0-59")
if not isinstance(minute, int) or not 0 <= minute < 60:
raise ValueError('The minute must be an integer in the range of 0-59')
raise ValueError("The minute must be an integer in the range of 0-59")
if not isinstance(hour, int) or not 0 <= hour < 24:
raise ValueError('The hour must be an integer in the range of 0-23')
raise ValueError("The hour must be an integer in the range of 0-23")
now = self._get_now()
now['hour'] = hour
now['minute'] = minute
now['second'] = second
now["hour"] = hour
now["minute"] = minute
now["second"] = second
self._rtc.datetime = self._encode(now)
def set_date(self, day, month, year):
@ -152,19 +171,21 @@ class RTCFeatherWing:
:param int year: The year we want to set the date to
"""
if not isinstance(year, int):
raise ValueError('The year must be an integer')
raise ValueError("The year must be an integer")
if not isinstance(month, int) or not 1 <= month <= 12:
raise ValueError('The month must be an integer in the range of 1-12')
raise ValueError("The month must be an integer in the range of 1-12")
month_days = self.get_month_days(month, year)
if not isinstance(day, int) or not 1 <= day <= month_days:
raise ValueError('The day must be an integer in the range of 1-{}'.format(month_days))
raise ValueError(
"The day must be an integer in the range of 1-{}".format(month_days)
)
now = self._get_now()
now['day'] = day
now['month'] = month
now['year'] = year
now["day"] = day
now["month"] = month
now["year"] = year
self._rtc.datetime = self._encode(now)
@property
@ -183,99 +204,101 @@ class RTCFeatherWing:
"""
The Current Year
"""
return self._get_time_value('year')
return self._get_time_value("year")
@year.setter
def year(self, year):
if isinstance(year, int):
self._set_time_value('year', year)
self._set_time_value("year", year)
else:
raise ValueError('The year must be an integer')
raise ValueError("The year must be an integer")
@property
def month(self):
"""
The Current Month
"""
return self._get_time_value('month')
return self._get_time_value("month")
@month.setter
def month(self, month):
if isinstance(month, int) and 1 <= month <= 12:
self._set_time_value('month', month)
self._set_time_value("month", month)
else:
raise ValueError('The month must be an integer in the range of 1-12')
raise ValueError("The month must be an integer in the range of 1-12")
@property
def day(self):
"""
The Current Day
"""
return self._get_time_value('day')
return self._get_time_value("day")
@day.setter
def day(self, day):
month_days = self.get_month_days()
if isinstance(day, int) and 1 <= day <= month_days:
self._set_time_value('day', day)
self._set_time_value("day", day)
else:
raise ValueError('The day must be an integer in the range of 1-{}'.format(month_days))
raise ValueError(
"The day must be an integer in the range of 1-{}".format(month_days)
)
@property
def hour(self):
"""
The Current Hour
"""
return self._get_time_value('hour')
return self._get_time_value("hour")
@hour.setter
def hour(self, hour):
if isinstance(hour, int) and 0 <= hour < 24:
self._set_time_value('hour', hour)
self._set_time_value("hour", hour)
else:
raise ValueError('The hour must be an integer in the range of 0-23')
raise ValueError("The hour must be an integer in the range of 0-23")
@property
def minute(self):
"""
The Current Minute
"""
return self._get_time_value('minute')
return self._get_time_value("minute")
@minute.setter
def minute(self, minute):
if isinstance(minute, int) and 0 <= minute < 60:
self._set_time_value('minute', minute)
self._set_time_value("minute", minute)
else:
raise ValueError('The minute must be an integer in the range of 0-59')
raise ValueError("The minute must be an integer in the range of 0-59")
@property
def second(self):
"""
The Current Second
"""
return self._get_time_value('second')
return self._get_time_value("second")
@second.setter
def second(self, second):
if isinstance(second, int) and 0 <= second < 60:
self._set_time_value('second', second)
self._set_time_value("second", second)
else:
raise ValueError('The second must be an integer in the range of 0-59')
raise ValueError("The second must be an integer in the range of 0-59")
@property
def weekday(self):
"""
The Current Day of the Week Value (0-6) where Sunday is 0
"""
return self._get_time_value('weekday')
return self._get_time_value("weekday")
@weekday.setter
def weekday(self, weekday):
if isinstance(weekday, int) and 0 <= weekday < 7:
self._set_time_value('weekday', weekday)
self._set_time_value("weekday", weekday)
else:
raise ValueError('The weekday must be an integer in the range of 0-6')
raise ValueError("The weekday must be an integer in the range of 0-6")
@property
def now(self):

View file

@ -35,11 +35,13 @@ import board
import adafruit_ht16k33.segments as segments
from adafruit_featherwing.led_segments import Segments
class SevenSegmentFeatherWing(Segments):
"""Class representing an `Adafruit 7-Segment LED HT16K33 FeatherWing
<https://www.adafruit.com/product/3140>`_.
Automatically uses the feather's I2C bus."""
def __init__(self, address=0x70, i2c=None):
super().__init__()
if i2c is None:

View file

@ -36,11 +36,13 @@ import board
import adafruit_adxl34x
import adafruit_adt7410
class TempMotionFeatherWing:
"""Class helper representing an `Adafruit ADXL343 + ADT7410 Sensor FeatherWing
<https://www.adafruit.com/product/4147>`_.
Automatically uses the feather's I2C bus."""
def __init__(self, adxl343_address=0x53, adt7410_address=0x48, i2c=None):
if i2c is None:
i2c = board.I2C()

View file

@ -2,7 +2,8 @@
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
# -- General configuration ------------------------------------------------
@ -10,9 +11,9 @@ sys.path.insert(0, os.path.abspath('..'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
]
# Uncomment the below if you use native CircuitPython modules such as
@ -21,32 +22,39 @@ extensions = [
autodoc_mock_imports = ["board", "busio", "displayio", "adafruit_st7735r"]
intersphinx_mapping = {
'python': ('https://docs.python.org/3.4', None),
'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),
'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
"python": ("https://docs.python.org/3.4", None),
"BusDevice": (
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
None,
),
"Register": (
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
None,
),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]
source_suffix = '.rst'
source_suffix = ".rst"
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# General information about the project.
project = u'Adafruit FeatherWing Library'
copyright = u'2017 Scott Shawcroft'
author = u'Scott Shawcroft'
project = "Adafruit FeatherWing Library"
copyright = "2017 Scott Shawcroft"
author = "Scott Shawcroft"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'1.0'
version = "1.0"
# The full version, including alpha/beta/rc tags.
release = u'1.0'
release = "1.0"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -58,7 +66,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
# The reST default role (used for this markup: `text`) to use for all
# documents.
@ -70,7 +78,7 @@ default_role = "any"
add_function_parentheses = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
@ -84,59 +92,62 @@ todo_emit_warnings = True
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
if not on_rtd: # only import and set the theme if we're building docs locally
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
except:
html_theme = 'default'
html_theme_path = ['.']
html_theme = "default"
html_theme_path = ["."]
else:
html_theme_path = ['.']
html_theme_path = ["."]
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'
html_favicon = "_static/favicon.ico"
# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitFeatherwingLibrarydoc'
htmlhelp_basename = "AdafruitFeatherwingLibrarydoc"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'AdafruitfeatherwingLibrary.tex', u'Adafruitfeatherwing Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitfeatherwingLibrary.tex",
"Adafruitfeatherwing Library Documentation",
author,
"manual",
),
]
# -- Options for manual page output ---------------------------------------
@ -144,8 +155,13 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'Adafruitfeatherwinglibrary', u'Adafruit featherwing Library Documentation',
[author], 1)
(
master_doc,
"Adafruitfeatherwinglibrary",
"Adafruit featherwing Library Documentation",
[author],
1,
)
]
# -- Options for Texinfo output -------------------------------------------
@ -154,7 +170,13 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitfeatherwingLibrary', u'Adafruit featherwing Library Documentation',
author, 'AdafruitfeatherwingLibrary', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitfeatherwingLibrary",
"Adafruit featherwing Library Documentation",
author,
"AdafruitfeatherwingLibrary",
"One line description of project.",
"Miscellaneous",
),
]

View file

@ -7,35 +7,35 @@ from adafruit_featherwing import alphanum_featherwing
display = alphanum_featherwing.AlphaNumFeatherWing()
#Fill and empty all segments
# Fill and empty all segments
for count in range(0, 3):
display.fill(True)
sleep(0.5)
display.fill(False)
sleep(0.5)
#Display a number and text
# Display a number and text
display.print(1234)
sleep(1)
display.print('Text')
display.print("Text")
#Change brightness
# Change brightness
for brightness in range(0, 16):
display.brightness = brightness
sleep(0.1)
#Change blink rate
# Change blink rate
for blink_rate in range(3, 0, -1):
display.blink_rate = blink_rate
sleep(4)
display.blink_rate = 0
#Show a counter using decimals
# Show a counter using decimals
count = 975.0
while count < 1025:
count += 1
display.print(count)
sleep(0.1)
#Show the Marquee
display.marquee('This is a really long message!!! ', 0.2)
# Show the Marquee
display.marquee("This is a really long message!!! ", 0.2)

View file

@ -12,15 +12,17 @@ dotstar = dotstar_featherwing.DotStarFeatherWing()
def remap(vector):
return int(((255 * vector + 85) * 0.75) + 0.5)
# Calculate the Hue rotation starting with Red as 0 degrees
def rotate(degrees):
cosA = cos(radians(degrees))
sinA = sin(radians(degrees))
red = cosA + (1.0 - cosA) / 3.0
green = 1./3. * (1.0 - cosA) + sqrt(1./3.) * sinA
blue = 1./3. * (1.0 - cosA) - sqrt(1./3.) * sinA
green = 1.0 / 3.0 * (1.0 - cosA) + sqrt(1.0 / 3.0) * sinA
blue = 1.0 / 3.0 * (1.0 - cosA) - sqrt(1.0 / 3.0) * sinA
return (remap(red), remap(green), remap(blue))
palette = []
pixels = []

View file

@ -14,11 +14,12 @@ dotstar = dotstar_featherwing.DotStarFeatherWing()
def random_color():
return random.randrange(0, 8) * 32
# Fill screen with random colors at random brightnesses
for i in range(0, 5):
dotstar.fill((random_color(), random_color(), random_color()))
dotstar.brightness = random.randrange(2, 10) / 10
sleep(.2)
sleep(0.2)
# Set display to 30% brightness
dotstar.brightness = 0.3
@ -28,7 +29,7 @@ for x in range(0, dotstar.columns):
for y in range(dotstar.rows - 1, -1, -1):
dotstar[x, y] = (y * 42, 255, y * 42, 1)
#Rotate everything left 36 frames
# Rotate everything left 36 frames
for i in range(0, 36):
dotstar.shift_down(True)
@ -57,4 +58,4 @@ while True:
x = random.randrange(0, dotstar.columns)
y = random.randrange(0, dotstar.rows)
dotstar[x, y] = (random_color(), random_color(), random_color())
sleep(.1)
sleep(0.1)

View file

@ -23,35 +23,38 @@ while True:
last_print = current
if not gps.has_fix:
# Try again if we don't have a fix yet.
print('Waiting for fix...')
print("Waiting for fix...")
continue
# Print out details about the fix like location, date, etc.
print('=' * 40) # Print a separator line.
print('Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}'.format(
gps.timestamp.tm_mon, # Grab parts of the time from the
gps.timestamp.tm_mday, # struct_time object that holds
gps.timestamp.tm_year, # the fix time. Note you might
gps.timestamp.tm_hour, # not get all data like year, day,
gps.timestamp.tm_min, # month!
gps.timestamp.tm_sec))
print('Latitude: {0:.6f} degrees'.format(gps.latitude))
print('Longitude: {0:.6f} degrees'.format(gps.longitude))
print('Fix quality: {}'.format(gps.fix_quality))
print("=" * 40) # Print a separator line.
print(
"Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}".format(
gps.timestamp.tm_mon, # Grab parts of the time from the
gps.timestamp.tm_mday, # struct_time object that holds
gps.timestamp.tm_year, # the fix time. Note you might
gps.timestamp.tm_hour, # not get all data like year, day,
gps.timestamp.tm_min, # month!
gps.timestamp.tm_sec,
)
)
print("Latitude: {0:.6f} degrees".format(gps.latitude))
print("Longitude: {0:.6f} degrees".format(gps.longitude))
print("Fix quality: {}".format(gps.fix_quality))
# Some attributes beyond latitude, longitude and timestamp are optional
# and might not be present. Check if they're None before trying to use!
if gps.satellites is not None:
print('# satellites: {}'.format(gps.satellites))
print("# satellites: {}".format(gps.satellites))
if gps.altitude is not None:
print('Altitude: {} meters'.format(gps.altitude))
print("Altitude: {} meters".format(gps.altitude))
if gps.speed_knots is not None:
print('Speed (Knots): {} knots'.format(gps.speed_knots))
print("Speed (Knots): {} knots".format(gps.speed_knots))
if gps.speed_mph is not None:
print('Speed (Miles Per Hour): {} MPH'.format(gps.speed_mph))
print("Speed (Miles Per Hour): {} MPH".format(gps.speed_mph))
if gps.speed_kph is not None:
print('Speed (KM Per Hour): {} KPH'.format(gps.speed_kph))
print("Speed (KM Per Hour): {} KPH".format(gps.speed_kph))
if gps.track_angle is not None:
print('Track angle: {} degrees'.format(gps.track_angle))
print("Track angle: {} degrees".format(gps.track_angle))
if gps.horizontal_dilution is not None:
print('Horizontal dilution: {}'.format(gps.horizontal_dilution))
print("Horizontal dilution: {}".format(gps.horizontal_dilution))
if gps.height_geoid is not None:
print('Height geo ID: {} meters'.format(gps.height_geoid))
print("Height geo ID: {} meters".format(gps.height_geoid))

View file

@ -23,4 +23,4 @@ while True:
print("Button Y!")
if wing.button_select:
print("Button SELECT!")
time.sleep(.01)
time.sleep(0.01)

View file

@ -31,4 +31,4 @@ while True:
if buttons.b:
print("Button B!")
time.sleep(.001)
time.sleep(0.001)

View file

@ -12,15 +12,17 @@ neopixel = neopixel_featherwing.NeoPixelFeatherWing()
def remap(vector):
return int(((255 * vector + 85) * 0.75) + 0.5)
# Calculate the Hue rotation starting with Red as 0 degrees
def rotate(degrees):
cosA = cos(radians(degrees))
sinA = sin(radians(degrees))
red = cosA + (1.0 - cosA) / 3.0
green = 1./3. * (1.0 - cosA) + sqrt(1./3.) * sinA
blue = 1./3. * (1.0 - cosA) - sqrt(1./3.) * sinA
green = 1.0 / 3.0 * (1.0 - cosA) + sqrt(1.0 / 3.0) * sinA
blue = 1.0 / 3.0 * (1.0 - cosA) - sqrt(1.0 / 3.0) * sinA
return (remap(red), remap(green), remap(blue))
palette = []
pixels = []

View file

@ -14,11 +14,12 @@ neopixel = neopixel_featherwing.NeoPixelFeatherWing()
def random_color():
return random.randrange(0, 8) * 32
# Fill screen with random colors at random brightnesses
for i in range(0, 5):
neopixel.fill((random_color(), random_color(), random_color()))
neopixel.brightness = random.randrange(2, 10) / 10
sleep(.2)
sleep(0.2)
# Set display to 30% brightness
neopixel.brightness = 0.3
@ -28,13 +29,13 @@ for x in range(0, neopixel.columns):
for y in range(neopixel.rows - 1, -1, -1):
neopixel[x, y] = (y * 63, 255, y * 63)
#Rotate everything left 36 frames
# Rotate everything left 36 frames
for i in range(0, 36):
neopixel.shift_down(True)
sleep(0.1)
# Draw dual gradiant and then update
#neopixel.auto_write = False
# neopixel.auto_write = False
for y in range(0, neopixel.rows):
for x in range(0, 4):
neopixel[x, y] = (y * 16 + 32, x * 8, 0)
@ -61,4 +62,4 @@ while True:
x = random.randrange(0, neopixel.columns)
y = random.randrange(0, neopixel.rows)
neopixel[x, y] = (random_color(), random_color(), random_color())
sleep(.1)
sleep(0.1)

View file

@ -10,26 +10,30 @@ days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satur
# Create the RTC instance:
rtc = rtc_featherwing.RTCFeatherWing()
#pylint: disable-msg=using-constant-test
if True: # Change this to True to set the date and time
rtc.set_time(13, 34) # Set the time (seconds are optional)
# pylint: disable-msg=using-constant-test
if True: # Change this to True to set the date and time
rtc.set_time(13, 34) # Set the time (seconds are optional)
print(rtc.now)
rtc.set_date(16, 1, 2016) # Set the date
rtc.set_date(16, 1, 2016) # Set the date
print(rtc.now)
rtc.year = 2019 # Set just the Year
rtc.year = 2019 # Set just the Year
print(rtc.now)
rtc.month = 2 # Set Just the Month
rtc.month = 2 # Set Just the Month
print(rtc.now)
rtc.hour = 16 # Set just the hour
rtc.hour = 16 # Set just the hour
print(rtc.now)
rtc.weekday = 6 # Set just the day of the week (Sunday = 0)
rtc.weekday = 6 # Set just the day of the week (Sunday = 0)
print(rtc.now)
rtc.unixtime = 1550335257 # Or set the date and time with a unix timestamp
rtc.unixtime = 1550335257 # Or set the date and time with a unix timestamp
# Main loop:
while True:
now = rtc.now
print("The date is {} {}/{}/{}".format(days[now.weekday], now.day, now.month, now.year))
print(
"The date is {} {}/{}/{}".format(
days[now.weekday], now.day, now.month, now.year
)
)
print("The time is {}:{:02}:{:02}".format(now.hour, now.minute, now.second))
print("The UNIX timestamp is {}".format(rtc.unixtime))
print("The number of days in the current month is {}".format(rtc.get_month_days()))
@ -37,4 +41,4 @@ while True:
print("This year is a leap year")
else:
print("This year is not a leap year")
time.sleep(1) # wait a second
time.sleep(1) # wait a second

View file

@ -7,41 +7,41 @@ from adafruit_featherwing import sevensegment_featherwing
display = sevensegment_featherwing.SevenSegmentFeatherWing()
#Fill and empty all segments
# Fill and empty all segments
for count in range(0, 3):
display.fill(True)
sleep(0.5)
display.fill(False)
sleep(0.5)
#Display a number and text
# Display a number and text
display.print(1234)
sleep(1)
display.print('FEED')
display.print("FEED")
#Change brightness
# Change brightness
for brightness in range(0, 16):
display.brightness = brightness
sleep(0.1)
#Change blink rate
# Change blink rate
for blink_rate in range(3, 0, -1):
display.blink_rate = blink_rate
sleep(4)
display.blink_rate = 0
#Show a counter using decimals
# Show a counter using decimals
count = 975.0
while count < 1025:
count += 1
display.print(count)
sleep(0.1)
#Display a Time
# Display a Time
hour = 12
for minute in range(15, 26):
display.print("{}:{}".format(hour, minute))
sleep(1)
#Show the Marquee
display.marquee('Deadbeef 192.168.100.102... ', 0.2)
# Show the Marquee
display.marquee("Deadbeef 192.168.100.102... ", 0.2)

View file

@ -5,9 +5,10 @@ whenever the FeatherWing senses that it has been tapped
import time
from adafruit_featherwing import tempmotion_featherwing
temp_motion = tempmotion_featherwing.TempMotionFeatherWing()
temp_motion.enable_tap_detection()
while True:
if temp_motion.events['tap']:
print("The temperature is %f"%temp_motion.temperature)
if temp_motion.events["tap"]:
print("The temperature is %f" % temp_motion.temperature)
time.sleep(1)

View file

@ -7,6 +7,7 @@ https://github.com/pypa/sampleproject
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
@ -14,54 +15,53 @@ from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read()
setup(
name='adafruit-circuitpython-featherwing',
name="adafruit-circuitpython-featherwing",
use_scm_version=True,
setup_requires=['setuptools_scm'],
description='CircuitPython library that provides FeatherWing specific classes for those that '
'require a significant amount of initialization.',
setup_requires=["setuptools_scm"],
description="CircuitPython library that provides FeatherWing specific classes for those that "
"require a significant amount of initialization.",
long_description=long_description,
long_description_content_type='text/x-rst',
long_description_content_type="text/x-rst",
# The project's main homepage.
url='https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing',
url="https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing",
# Author details
author='Adafruit Industries',
author_email='circuitpython@adafruit.com',
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice',
'adafruit-circuitpython-register', 'adafruit-circuitpython-ina219',
'adafruit-circuitpython-seesaw', 'adafruit-circuitpython-ht16k33',
'adafruit-circuitpython-dotstar', 'adafruit-circuitpython-neopixel',
'adafruit-circuitpython-ds3231', 'adafruit-circuitpython-gps',
'adafruit-circuitpython-adxl34x', 'adafruit-circuitpython-adt7410'],
author="Adafruit Industries",
author_email="circuitpython@adafruit.com",
install_requires=[
"Adafruit-Blinka",
"adafruit-circuitpython-busdevice",
"adafruit-circuitpython-register",
"adafruit-circuitpython-ina219",
"adafruit-circuitpython-seesaw",
"adafruit-circuitpython-ht16k33",
"adafruit-circuitpython-dotstar",
"adafruit-circuitpython-neopixel",
"adafruit-circuitpython-ds3231",
"adafruit-circuitpython-gps",
"adafruit-circuitpython-adxl34x",
"adafruit-circuitpython-adt7410",
],
# Choose your license
license='MIT',
license="MIT",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
'Topic :: System :: Hardware',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Hardware",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
],
# What does your project relate to?
keywords='adafruit ina219 featherwing joy joywing i2c '
'hardware micropython circuitpython',
keywords="adafruit ina219 featherwing joy joywing i2c "
"hardware micropython circuitpython",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=['adafruit_featherwing'],
packages=["adafruit_featherwing"],
)