-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from ladyada/master
Add ATtiny8x7 and examples
- Loading branch information
Showing
7 changed files
with
210 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-FileCopyrightText: 2017 Dean Miller for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
# pylint: disable=missing-docstring,invalid-name,too-many-public-methods,too-few-public-methods | ||
|
||
""" | ||
`adafruit_seesaw.attiny8x7` - Pin definition for Adafruit ATtiny8x7 Breakout with seesaw | ||
================================================================================== | ||
""" | ||
|
||
__version__ = "0.0.0-auto.0" | ||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" | ||
|
||
|
||
class ATtiny8x7_Pinmap: | ||
"""This class is automatically used by `adafruit_seesaw.seesaw.Seesaw` when | ||
a ATtiny8x7 Breakout is detected. | ||
It is also a reference for the capabilities of each pin.""" | ||
|
||
#: The pins capable of analog output | ||
analog_pins = (0, 1, 2, 3, 6, 7, 18, 19, 20) | ||
|
||
"""The effective bit resolution of the PWM pins""" | ||
pwm_width = 16 # we dont actually use all 16 bits but whatever | ||
|
||
"""The pins capable of PWM output""" | ||
pwm_pins = (0, 1, 9, 12, 13) | ||
|
||
"""No pins on this board are capable of touch input""" | ||
touch_pins = () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Simple seesaw test reading analog value | ||
# on SAMD09, analog in can be pins 2, 3, or 4 | ||
# on Attiny8x7, analog in can be pins 0, 1, 2, 3, 6, 7, 18, 19, 20 | ||
# | ||
# See the seesaw Learn Guide for wiring details: | ||
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test | ||
|
||
import time | ||
import board | ||
from adafruit_seesaw.seesaw import Seesaw | ||
from adafruit_seesaw.analoginput import AnalogInput | ||
|
||
i2c_bus = board.I2C() | ||
ss = Seesaw(i2c_bus) | ||
|
||
analogin_pin = 2 | ||
analog_in = AnalogInput(ss, analogin_pin) | ||
|
||
while True: | ||
print(analog_in.value) | ||
time.sleep(0.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Simple seesaw test using an LED attached to Pin 5 and a button on pin 2 | ||
# | ||
# See the seesaw Learn Guide for wiring details: | ||
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test | ||
|
||
import time | ||
import board | ||
import digitalio | ||
from adafruit_seesaw.seesaw import Seesaw | ||
from adafruit_seesaw.digitalio import DigitalIO | ||
|
||
i2c_bus = board.I2C() | ||
ss = Seesaw(i2c_bus) | ||
|
||
button_pin = 2 | ||
led_pin = 5 | ||
|
||
button = DigitalIO(ss, button_pin) | ||
button.direction = digitalio.Direction.INPUT | ||
button.pull = digitalio.Pull.UP | ||
|
||
led = DigitalIO(ss, led_pin) | ||
led.direction = digitalio.Direction.OUTPUT | ||
|
||
while True: | ||
# simply set the LED to the same 'value' as the button pin | ||
led.value = button.value | ||
time.sleep(0.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Simple seesaw test reading and writing the internal EEPROM | ||
# The ATtiny8xx series has a true 128 byte EEPROM, the SAMD09 mimics it in flash with 64 bytes | ||
# THE LAST BYTE IS USED FOR I2C ADDRESS CHANGE! | ||
# | ||
# See the seesaw Learn Guide for wiring details: | ||
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test | ||
|
||
import time | ||
import board | ||
from adafruit_seesaw import seesaw | ||
|
||
i2c_bus = board.I2C() | ||
ss = seesaw.Seesaw(i2c_bus) | ||
|
||
val = ss.eeprom_read8(0x02) # read from address 2 | ||
print("Read 0x%02x from EEPROM address 0x02" % val) | ||
|
||
print("Incremening value") | ||
ss.eeprom_write8(0x02, val + 1) | ||
|
||
val = ss.eeprom_read8(0x02) # read from address 2 | ||
print("Second read 0x%02x from EEPROM address 0x02" % val) | ||
|
||
while True: | ||
# Do not write EEPROM in a loop, it has 100k cycle life | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Simple seesaw test writing NeoPixels | ||
# Can use any valid GPIO pin, up to 60 pixels! | ||
# | ||
# See the seesaw Learn Guide for wiring details: | ||
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test | ||
|
||
import time | ||
import board | ||
from rainbowio import colorwheel | ||
from adafruit_seesaw import seesaw, neopixel | ||
|
||
i2c_bus = board.I2C() | ||
ss = seesaw.Seesaw(i2c_bus) | ||
|
||
NEOPIXEL_PIN = 6 # change to any pin | ||
NEOPIXEL_NUM = 30 # no more than 60! | ||
pixels = neopixel.NeoPixel(ss, NEOPIXEL_PIN, NEOPIXEL_NUM) | ||
pixels.brightness = 0.3 # not so brite! | ||
|
||
color_offset = 0 # start at red | ||
|
||
# cycle through all colors along the strip | ||
while True: | ||
for i in range(NEOPIXEL_NUM): | ||
rc_index = (i * 256 // NEOPIXEL_NUM) + color_offset | ||
pixels[i] = colorwheel(rc_index & 255) | ||
pixels.show() | ||
color_offset += 1 | ||
time.sleep(0.01) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Simple seesaw test for writing PWM outputs | ||
# On the SAMD09 breakout these are pins 5, 6, and 7 | ||
# On the ATtiny8x7 breakout these are pins 0, 1, 9, 12, 13 | ||
# | ||
# See the seesaw Learn Guide for wiring details: | ||
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test | ||
|
||
import time | ||
import board | ||
from adafruit_seesaw import seesaw, pwmout | ||
|
||
i2c_bus = board.I2C() | ||
ss = seesaw.Seesaw(i2c_bus) | ||
|
||
PWM_PIN = 9 # change to a valid PWM output! | ||
pwm = pwmout.PWMOut(ss, PWM_PIN) | ||
|
||
while True: | ||
# the API PWM range is 0 to 65535, but we increment by 256 since our | ||
# resolution is often only 8 bits underneath | ||
pwm.duty_cycle = (pwm.duty_cycle + 256) % 65536 | ||
time.sleep(0.01) |