Skip to content

Commit

Permalink
Merge pull request #87 from kattni/tweaks
Browse files Browse the repository at this point in the history
Updating for ATtiny8x7
  • Loading branch information
kattni committed Oct 15, 2021
2 parents d8ec773 + b46e79d commit 129a819
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
6 changes: 1 addition & 5 deletions examples/seesaw_analogin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
# 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)
ss = Seesaw(board.I2C())

analogin_pin = 2
analog_in = AnalogInput(ss, analogin_pin)
Expand Down
8 changes: 5 additions & 3 deletions examples/seesaw_digitalio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@

# Simple seesaw test using an LED attached to Pin 5 and a button on pin 2
#
# See the seesaw Learn Guide for wiring details:
# See the seesaw Learn Guide for wiring details.
# For SAMD09:
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
# For ATtiny8x7:
# https://learn.adafruit.com/adafruit-attiny817-seesaw/digital-input

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)
ss = Seesaw(board.I2C())

button_pin = 2
led_pin = 5
Expand Down
15 changes: 6 additions & 9 deletions examples/seesaw_eeprom_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# 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
Expand All @@ -15,14 +12,14 @@
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)
value = ss.eeprom_read8(0x02) # Read from address 2
print("Read 0x%02x from EEPROM address 0x02" % value)

print("Incremening value")
ss.eeprom_write8(0x02, val + 1)
print("Incrementing value")
ss.eeprom_write8(0x02, (value + 1) % 0xFF)

val = ss.eeprom_read8(0x02) # read from address 2
print("Second read 0x%02x from EEPROM address 0x02" % val)
value = ss.eeprom_read8(0x02) # Read from address 2
print("Second read 0x%02x from EEPROM address 0x02" % value)

while True:
# Do not write EEPROM in a loop, it has 100k cycle life
Expand Down
20 changes: 11 additions & 9 deletions examples/seesaw_neopixel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@
# Simple seesaw test writing NeoPixels
# Can use any valid GPIO pin, up to 60 pixels!
#
# See the seesaw Learn Guide for wiring details:
# See the seesaw Learn Guide for wiring details.
# For SAMD09:
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
# For ATtiny8x7:
# https://learn.adafruit.com/adafruit-attiny817-seesaw/neopixel

import time
import board
from rainbowio import colorwheel
from adafruit_seesaw import seesaw, neopixel

i2c_bus = board.I2C()
ss = seesaw.Seesaw(i2c_bus)
ss = seesaw.Seesaw(board.I2C())

NEOPIXEL_PIN = 19 # Can be any pin
NEOPIXEL_NUM = 12 # No more than 60 pixels!

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!
pixels.brightness = 0.3 # Not so bright!

color_offset = 0 # start at red
color_offset = 0 # Start at red

# cycle through all colors along the strip
# Cycle through all colors along the ring
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)
23 changes: 15 additions & 8 deletions examples/seesaw_pwmout_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@
# 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:
# See the seesaw Learn Guide for wiring details.
# For SAMD09:
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
# For ATtiny8x7:
# https://learn.adafruit.com/adafruit-attiny817-seesaw/pwmout

import time
import board
from adafruit_seesaw import seesaw, pwmout

i2c_bus = board.I2C()
ss = seesaw.Seesaw(i2c_bus)
ss = seesaw.Seesaw(board.I2C())

PWM_PIN = 9 # change to a valid PWM output!
pwm = pwmout.PWMOut(ss, PWM_PIN)
PWM_PIN = 12 # If desired, change to any valid PWM output!
led = pwmout.PWMOut(ss, PWM_PIN)

delay = 0.01
while True:
# the API PWM range is 0 to 65535, but we increment by 256 since our
# 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)
for cycle in range(0, 65535, 256): #
led.duty_cycle = cycle
time.sleep(delay)
for cycle in range(65534, 0, -256):
led.duty_cycle = cycle
time.sleep(delay)

0 comments on commit 129a819

Please sign in to comment.