Skip to content

Added examples folder and examples file #7

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 18, 2018

Conversation

mrmcwethy
Copy link
Collaborator

#adafruit/circuitpython#493

These examples work with the currently released library.

Added examples files for frame.py, blink.py, simple.py, text.py, wave.py
Also linted project.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks @mrmcwethy !

# Tony DiCola
# The MIT License (MIT)
#
# Copyright (c) 2017 Toni DiCola
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tony

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 <https://www.adafruit.com/product/2946>`_
* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings <https://www.adafruit.com/product/2965>`_

* Author(s): Toni DiCola
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tony

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731.git"
Copy link
Contributor

@deshipu deshipu Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can break long strings just like in C:

__repo__ = ("https://github.com/adafruit/"
            "Adafruit_CircuitPython_IS31FL3731.git")

and then you don't have to disable the line too long warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pylint was complaining about the module description line length

* `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 <https://www.adafruit.com/product/2946>`_
* `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings <https://www.adafruit.com/product/2965>`_

I didn't know how to split a quoted doc string, i decided to allow long lines in this comment area.

Copy link
Contributor

@deshipu deshipu Jan 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just put a newline in place of any space, and indent the new line the same as the previous one.

if frame is None:
return self._frame
if not 0 <= frame <= 8:
raise ValueError("Frame out of range")
self._frame = frame
if show:
self._register(_CONFIG_BANK, _FRAME_REGISTER, frame);
self._register(_CONFIG_BANK, _FRAME_REGISTER, frame)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return None here at the end to get rid of the "inconsistent return statement" warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -173,6 +240,11 @@ def blink(self, rate=None):
self._register(_CONFIG_BANK, _BLINK_REGISTER, rate & 0x07 | 0x08)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

:param color: brightness value 0->255
:param blink: True to blink
:param frame: the frame to set the pixel
"""
if not 0 <= x <= self.width:
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to return None to get rid of the "inconsistent return statement" warning

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

:param color: brightness value 0->255
:param blink: True to blink
:param frame: the frame to set the pixel
"""
if not 0 <= x <= self.width:
return
if not 0 <= y <= self.height:
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -218,13 +300,18 @@ def pixel(self, x, y, color=None, blink=None, frame=None):
else:
bits &= ~(1 << bit)
self._register(frame, _BLINK_OFFSET + addr, bits)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add return None

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -193,15 +265,25 @@ def fill(self, color=None, blink=None, frame=None):
for col in range(18):
self._register(frame, _BLINK_OFFSET + col, data)

def _pixel_addr(self, x, y):
def pixel_addr(self, x, y): #pylint: disable-msg=no-self-use
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use @staticmethod here and drop the self

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

width = 15
height = 7

def _pixel_addr(self, x, y):
def pixel_addr(self, x, y): #pylint: disable-msg=no-self-use
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also @staticmethod

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@deshipu
Copy link
Contributor

deshipu commented Jan 17, 2018

Thank you! It looks good, except for some nitpicks, and some possible fixes for the linter.

@mrmcwethy
Copy link
Collaborator Author

@deshipu if you like my changes, can you merge it?

@@ -67,24 +108,28 @@ def _i2c_write_reg(self, reg, data):
self.i2c.writeto(self.address, buf)
finally:
self.i2c.unlock()
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not needed, since there is no return in that function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, oops

@@ -115,8 +169,17 @@ def autoplay(self, delay=0, loops=0, frames=0):
self._register(_CONFIG_BANK, _AUTOPLAY1_REGISTER, loops << 4 | frames)
self._register(_CONFIG_BANK, _AUTOPLAY2_REGISTER, delay % 64)
self._mode(_AUTOPLAY_MODE | self._frame)
return

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not is not needed either, since the return is empty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -162,17 +234,26 @@ def audio_play(self, sample_rate, audio_gain=0,
self._register(_CONFIG_BANK, _GAIN_REGISTER,
bool(agc_enable) << 3 | bool(agc_fast) << 4 | audio_gain)
self._mode(_AUDIOPLAY_MODE)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not needed too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deshipu ok, one more time.

@deshipu deshipu merged commit c96b31e into adafruit:master Jan 18, 2018
@deshipu
Copy link
Contributor

deshipu commented Jan 18, 2018

Thank you! Sorry for all the nitpicking.

@mrmcwethy
Copy link
Collaborator Author

No reason to be sorry, its better with your comment. i should have done the return stuff instead of the #pylint: disable-msg

tannewt pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 19, 2018
Updating https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731 to 2.1.0 from 1.0.0:
  > Added examples folder and examples file (adafruit/Adafruit_CircuitPython_IS31FL3731#7)
  > [adafruit/Adafruit_CircuitPython_IS31FL3731#3] Remove "TODO" and add description with supported hardware.
  > [adafruit/Adafruit_CircuitPython_IS31FL3731#3] Enable Python syntax highlighting in README examples.
  > [adafruit/Adafruit_CircuitPython_IS31FL3731#3] Remove "TODO" from README.

Updating https://github.com/adafruit/Adafruit_CircuitPython_MCP9808 to 3.1.0 from 3.0.0:
  > added examples folder and .py file

Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 2.1.0 from 2.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#15 from mrmcwethy/examples

Updating https://github.com/adafruit/Adafruit_CircuitPython_HID to 2.1.0 from 2.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_HID#9 from Sigafoos/examples

Updating https://github.com/adafruit/Adafruit_CircuitPython_Register to 1.1.0 from 1.0.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_Register#8 from mrmcwethy/examples
  > Merge pull request adafruit/Adafruit_CircuitPython_Register#7 from tannewt/lint

Updating https://github.com/adafruit/Adafruit_CircuitPython_RTTTL to 2.0.0 from 0.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_RTTTL#1 from mrmcwethy/addexamples

Updating https://github.com/adafruit/Adafruit_CircuitPython_Waveform to 1.1.0 from 1.0.0:
  > added demos for square and sine, fixed square per comment
  > added a square waveform generator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants