Skip to content

Commit 129a819

Browse files
authored
Merge pull request #87 from kattni/tweaks
Updating for ATtiny8x7
2 parents d8ec773 + b46e79d commit 129a819

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

examples/seesaw_analogin_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
# Simple seesaw test reading analog value
55
# on SAMD09, analog in can be pins 2, 3, or 4
66
# on Attiny8x7, analog in can be pins 0, 1, 2, 3, 6, 7, 18, 19, 20
7-
#
8-
# See the seesaw Learn Guide for wiring details:
9-
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
107

118
import time
129
import board
1310
from adafruit_seesaw.seesaw import Seesaw
1411
from adafruit_seesaw.analoginput import AnalogInput
1512

16-
i2c_bus = board.I2C()
17-
ss = Seesaw(i2c_bus)
13+
ss = Seesaw(board.I2C())
1814

1915
analogin_pin = 2
2016
analog_in = AnalogInput(ss, analogin_pin)

examples/seesaw_digitalio_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33

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

912
import time
1013
import board
1114
import digitalio
1215
from adafruit_seesaw.seesaw import Seesaw
1316
from adafruit_seesaw.digitalio import DigitalIO
1417

15-
i2c_bus = board.I2C()
16-
ss = Seesaw(i2c_bus)
18+
ss = Seesaw(board.I2C())
1719

1820
button_pin = 2
1921
led_pin = 5

examples/seesaw_eeprom_test.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# Simple seesaw test reading and writing the internal EEPROM
55
# The ATtiny8xx series has a true 128 byte EEPROM, the SAMD09 mimics it in flash with 64 bytes
66
# THE LAST BYTE IS USED FOR I2C ADDRESS CHANGE!
7-
#
8-
# See the seesaw Learn Guide for wiring details:
9-
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
107

118
import time
129
import board
@@ -15,14 +12,14 @@
1512
i2c_bus = board.I2C()
1613
ss = seesaw.Seesaw(i2c_bus)
1714

18-
val = ss.eeprom_read8(0x02) # read from address 2
19-
print("Read 0x%02x from EEPROM address 0x02" % val)
15+
value = ss.eeprom_read8(0x02) # Read from address 2
16+
print("Read 0x%02x from EEPROM address 0x02" % value)
2017

21-
print("Incremening value")
22-
ss.eeprom_write8(0x02, val + 1)
18+
print("Incrementing value")
19+
ss.eeprom_write8(0x02, (value + 1) % 0xFF)
2320

24-
val = ss.eeprom_read8(0x02) # read from address 2
25-
print("Second read 0x%02x from EEPROM address 0x02" % val)
21+
value = ss.eeprom_read8(0x02) # Read from address 2
22+
print("Second read 0x%02x from EEPROM address 0x02" % value)
2623

2724
while True:
2825
# Do not write EEPROM in a loop, it has 100k cycle life

examples/seesaw_neopixel_test.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,31 @@
44
# Simple seesaw test writing NeoPixels
55
# Can use any valid GPIO pin, up to 60 pixels!
66
#
7-
# See the seesaw Learn Guide for wiring details:
7+
# See the seesaw Learn Guide for wiring details.
8+
# For SAMD09:
89
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
10+
# For ATtiny8x7:
11+
# https://learn.adafruit.com/adafruit-attiny817-seesaw/neopixel
912

1013
import time
1114
import board
1215
from rainbowio import colorwheel
1316
from adafruit_seesaw import seesaw, neopixel
1417

15-
i2c_bus = board.I2C()
16-
ss = seesaw.Seesaw(i2c_bus)
18+
ss = seesaw.Seesaw(board.I2C())
19+
20+
NEOPIXEL_PIN = 19 # Can be any pin
21+
NEOPIXEL_NUM = 12 # No more than 60 pixels!
1722

18-
NEOPIXEL_PIN = 6 # change to any pin
19-
NEOPIXEL_NUM = 30 # no more than 60!
2023
pixels = neopixel.NeoPixel(ss, NEOPIXEL_PIN, NEOPIXEL_NUM)
21-
pixels.brightness = 0.3 # not so brite!
24+
pixels.brightness = 0.3 # Not so bright!
2225

23-
color_offset = 0 # start at red
26+
color_offset = 0 # Start at red
2427

25-
# cycle through all colors along the strip
28+
# Cycle through all colors along the ring
2629
while True:
2730
for i in range(NEOPIXEL_NUM):
2831
rc_index = (i * 256 // NEOPIXEL_NUM) + color_offset
2932
pixels[i] = colorwheel(rc_index & 255)
30-
pixels.show()
3133
color_offset += 1
3234
time.sleep(0.01)

examples/seesaw_pwmout_test.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@
55
# On the SAMD09 breakout these are pins 5, 6, and 7
66
# On the ATtiny8x7 breakout these are pins 0, 1, 9, 12, 13
77
#
8-
# See the seesaw Learn Guide for wiring details:
8+
# See the seesaw Learn Guide for wiring details.
9+
# For SAMD09:
910
# https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout?view=all#circuitpython-wiring-and-test
11+
# For ATtiny8x7:
12+
# https://learn.adafruit.com/adafruit-attiny817-seesaw/pwmout
1013

1114
import time
1215
import board
1316
from adafruit_seesaw import seesaw, pwmout
1417

15-
i2c_bus = board.I2C()
16-
ss = seesaw.Seesaw(i2c_bus)
18+
ss = seesaw.Seesaw(board.I2C())
1719

18-
PWM_PIN = 9 # change to a valid PWM output!
19-
pwm = pwmout.PWMOut(ss, PWM_PIN)
20+
PWM_PIN = 12 # If desired, change to any valid PWM output!
21+
led = pwmout.PWMOut(ss, PWM_PIN)
2022

23+
delay = 0.01
2124
while True:
22-
# the API PWM range is 0 to 65535, but we increment by 256 since our
25+
# The API PWM range is 0 to 65535, but we increment by 256 since our
2326
# resolution is often only 8 bits underneath
24-
pwm.duty_cycle = (pwm.duty_cycle + 256) % 65536
25-
time.sleep(0.01)
27+
for cycle in range(0, 65535, 256): #
28+
led.duty_cycle = cycle
29+
time.sleep(delay)
30+
for cycle in range(65534, 0, -256):
31+
led.duty_cycle = cycle
32+
time.sleep(delay)

0 commit comments

Comments
 (0)