adafruit_featherwing.ina219_featherwing
¶
Helper for using the INA219 FeatherWing.
- Author(s): Kattni Rembor
-
class
adafruit_featherwing.ina219_featherwing.
INA219FeatherWing
[source]¶ Class representing an Adafruit INA219 FeatherWing.
Automatically uses the feather’s I2C bus.
-
bus_voltage
¶ Bus voltage returns volts.
This example prints the bus voltage with the appropriate units.
from adafruit_featherwing import ina219_featherwing import time ina219 = ina219_featherwing.INA219FeatherWing() while True: print("Bus Voltage: {} V".format(ina219.bus_voltage)) time.sleep(0.5)
-
current
¶ Current returns mA.
This example prints the current with the appropriate units.
from adafruit_featherwing import ina219_featherwing import time ina219 = ina219_featherwing.INA219FeatherWing() while True: print("Current: {} mA".format(ina219.current)) time.sleep(0.5)
-
shunt_voltage
¶ Shunt voltage returns volts.
This example prints the shunt voltage with the appropriate units.
from adafruit_featherwing import ina219_featherwing import time ina219 = ina219_featherwing.INA219FeatherWing() while True: print("Shunt Voltage: {} V".format(ina219.shunt_voltage)) time.sleep(0.5)
-
voltage
¶ Voltage, known as load voltage, is bus voltage plus shunt voltage. Returns volts.
This example prints the voltage with the appropriate units.
from adafruit_featherwing import ina219_featherwing import time ina219 = ina219_featherwing.INA219FeatherWing() while True: print("Voltage: {} V".format(ina219.voltage)) time.sleep(0.5)
-
adafruit_featherwing.joy_featherwing
¶
Helper for using the Joy FeatherWing.
- Author(s): Kattni Rembor
-
class
adafruit_featherwing.joy_featherwing.
JoyFeatherWing
[source]¶ Class representing an Adafruit Joy FeatherWing.
Automatically uses the feather’s I2C bus.
Joy featherwing button A.
This example prints when button A is pressed.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() while True: if wing.button_a: print("Button A pressed!")
Joy featherwing button B.
This example prints when button B is pressed.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() while True: if wing.button_b: print("Button B pressed!")
Joy featherwing button SELECT.
This example prints when button SELECT is pressed.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() while True: if wing.button_select: print("Button SELECT pressed!")
Joy featherwing button X.
This example prints when button X is pressed.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() while True: if wing.button_x: print("Button X pressed!")
Joy featherwing button Y.
This example prints when button Y is pressed.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() while True: if wing.button_y: print("Button Y pressed!")
-
joystick
¶ Joy FeatherWing joystick.
This example zeros the joystick, and prints the coordinates of joystick when it is moved.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() last_x = 0 last_y = 0 wing.zero_joystick() while True: x, y = wing.joystick if (abs(x - last_x) > 3) or (abs(y - last_y) > 3): last_x = x last_y = y print(x, y) time.sleep(0.01)
-
joystick_offset
¶ Offset used to correctly report (0, 0) when the joystick is centered.
Provide a tuple of (x, y) to set your joystick center to (0, 0). The offset you provide is subtracted from the current reading. For example, if your joystick reads as (-4, 0), you would enter (-4, 0) as the offset. The code will subtract -4 from -4, and 0 from 0, returning (0, 0).
This example supplies an offset for zeroing, and prints the coordinates of the joystick when it is moved.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() last_x = 0 last_y = 0 while True: wing.joystick_offset = (-4, 0) x, y = wing.joystick if (abs(x - last_x) > 3) or (abs(y - last_y) > 3): last_x = x last_y = y print(x, y) time.sleep(0.01)
-
zero_joystick
()[source]¶ Zeros the joystick by using current reading as (0, 0). Note: You must not be touching the joystick at the time of zeroing for it to be accurate.
This example zeros the joystick, and prints the coordinates of joystick when it is moved.
from adafruit_featherwing import joy_featherwing import time wing = joy_featherwing.JoyFeatherWing() last_x = 0 last_y = 0 wing.zero_joystick() while True: x, y = wing.joystick if (abs(x - last_x) > 3) or (abs(y - last_y) > 3): last_x = x last_y = y print(x, y) time.sleep(0.01)
adafruit_featherwing.alphanum_featherwing
¶
Helper for using the 14-Segment AlphaNumeric FeatherWing.
- Author(s): Melissa LeBlanc-Williams
-
class
adafruit_featherwing.alphanum_featherwing.
AlphaNumFeatherWing
(address=112)[source]¶ Class representing an Adafruit 14-segment AlphaNumeric FeatherWing.
Automatically uses the feather’s I2C bus.
-
blink_rate
¶ Blink Rate returns the current rate that the text blinks. 0 = Off 1-3 = Successively slower blink rates
This example changes the blink rate and prints out the current setting
from time import sleep from adafruit_featherwing import alphanum_featherwing display = alphanum_featherwing.AlphaNumFeatherWing() display.print('Text') for blink_rate in range(3, -1, -1): display.blink_rate = blink_rate print("Current Blink Rate is {}".format(display.blink_rate)) sleep(4)
-
brightness
¶ Brightness returns the current display brightness. 0-15 = Dimmest to Brightest Setting
This example changes the brightness and prints out the current setting
from time import sleep from adafruit_featherwing import alphanum_featherwing display = alphanum_featherwing.AlphaNumFeatherWing() display.print('Text') for brightness in range(0, 16): display.brightness = brightness print("Current Brightness is {}".format(display.brightness)) sleep(0.2)
-
fill
(fill)[source]¶ Change all Segments on or off :param bool fill: True turns all segments on, False turns all segments off
This example alternates between all filled and all empty segments.
from time import sleep from adafruit_featherwing import alphanum_featherwing display = alphanum_featherwing.AlphaNumFeatherWing() while True: display.fill(True) sleep(0.5) display.fill(False) sleep(0.5)
-
adafruit_featherwing.dotstar_featherwing
¶
Helper for using the DotStar FeatherWing.
- Author(s): Melissa LeBlanc-Williams
-
class
adafruit_featherwing.dotstar_featherwing.
DotStarFeatherWing
(clock=<sphinx.ext.autodoc.importer._MockObject object>, data=<sphinx.ext.autodoc.importer._MockObject object>, brightness=0.2)[source]¶ Class representing a DotStar FeatherWing.
The feather uses pins D13 and D11
-
auto_write
¶ Whether or not we are automatically updating If set to false, be sure to call show() to update
This lights DotStars with and without auto_write
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() dotstar.fill() # Clear any lit Dotstars dotstar[0, 0] = (255, 255, 255) # Set White time.sleep(1) dotstar.auto_write = False dotstar[1, 0] = (255, 255, 255) # Set White time.sleep(1) dotstar.show() # Update the DotStars
-
brightness
¶ Overall brightness of the display
This example changes the brightness
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() dotstar.brightness = 0 dotstar.fill(0xFFFFFF) for i in range(0, 6): dotstar.brightness = (i / 10) time.sleep(.2) dotstar.brightness = 0.3
-
fill
(color=0)[source]¶ Fills all of the DotStars with a color or unlit if empty.
Parameters: color (list/tuple or int) – (Optional) The text or number to display (default=0) This example shows various ways of using the fill() function
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() dotstar.fill((255, 255, 255)) # Fill White time.sleep(1) dotstar.fill((255, 255, 255, 0.5)) # Fill White Half Brightness time.sleep(1) dotstar.fill(0xFF0000) # Fill Red time.sleep(1) dotstar.fill() # Clear all lit DotStars
-
shift_down
(rotate=False)[source]¶ Shift all pixels down
Parameters: rotate – (Optional) Rotate the shifted pixels to top (default=False) This example shifts 2 pixels down
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() # Draw Red and Green Pixels dotstar[5, 3] = (255, 0, 0) dotstar[6, 3] = (0, 255, 0) # Rotate it off the screen for i in range(0, 5): dotstar.shift_down(True) time.sleep(.1) time.sleep(1) # Shift it off the screen for i in range(0, 5): dotstar.shift_down() time.sleep(.1)
-
shift_left
(rotate=False)[source]¶ Shift all pixels left
Parameters: rotate – (Optional) Rotate the shifted pixels to the right side (default=False) This example shifts 2 pixels to the left
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() # Draw Red and Green Pixels dotstar[5, 3] = (255, 0, 0) dotstar[6, 3] = (0, 255, 0) # Rotate it off the screen for i in range(0, 11): dotstar.shift_left(True) time.sleep(.1) time.sleep(1) # Shift it off the screen for i in range(0, 11): dotstar.shift_left() time.sleep(.1)
-
shift_right
(rotate=False)[source]¶ Shift all pixels right
Parameters: rotate – (Optional) Rotate the shifted pixels to the left side (default=False) This example shifts 2 pixels to the right
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() # Draw Red and Green Pixels dotstar[5, 3] = (255, 0, 0) dotstar[6, 3] = (0, 255, 0) # Rotate it off the screen for i in range(0, 11): dotstar.shift_right(True) time.sleep(.1) time.sleep(1) # Shift it off the screen for i in range(0, 11): dotstar.shift_right() time.sleep(.1)
-
shift_up
(rotate=False)[source]¶ Shift all pixels up
Parameters: rotate – (Optional) Rotate the shifted pixels to bottom (default=False) This example shifts 2 pixels up
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() # Draw Red and Green Pixels dotstar[5, 3] = (255, 0, 0) dotstar[6, 3] = (0, 255, 0) # Rotate it off the screen for i in range(0, 5): dotstar.shift_up(True) time.sleep(.1) time.sleep(1) # Shift it off the screen for i in range(0, 5): dotstar.shift_up() time.sleep(.1)
-
show
()[source]¶ Update the DotStars. This is only needed if auto_write is set to False This can be very useful for more advanced graphics effects.
This example changes the blink rate and prints out the current setting
import time from adafruit_featherwing import dotstar_featherwing dotstar = dotstar_featherwing.DotStarFeatherWing() dotstar.fill() # Clear any lit Dotstars dotstar.auto_write = False dotstar[0, 0] = (255, 255, 255) # Set White time.sleep(1) dotstar.show() # Update the DotStars
-