Skip to content

Commit a26178c

Browse files
committed
Rewrite imagicharm cirriculum with ruff format and modernize UI
1 parent aaf4883 commit a26178c

24 files changed

Lines changed: 755 additions & 316 deletions

File tree

code/Extra/play-song/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import time
33
from adafruit_circuitplayground.express import cpx
44

5+
56
def play_song(song_number):
67
# 1: Jingle bells
78
# 2: Let It Snow
89

9-
whole_note = 1.5
10+
whole_note = 1.5
1011
half_note = whole_note / 2
1112
quarter_note = whole_note / 4
1213
dotted_quarter_note = quarter_note * 1.5
@@ -67,8 +68,9 @@ def play_song(song_number):
6768
time.sleep(let_it_snow_song[n][1])
6869
cpx.stop_tone()
6970

71+
7072
while True:
71-
if cpx.switch:
73+
if cpx.switch:
7274
play_song(1)
7375
else:
74-
play_song(2)
76+
play_song(2)

code/Extra/range-thermometer/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def set_pixels():
3636
pixels[8] = RED
3737
pixels[9] = RED
3838

39+
3940
set_pixels()
4041

4142

code/Extra/switch-light/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
if cpx.switch:
66
cpx.red_led = True
77
else:
8-
cpx.red_led = False
8+
cpx.red_led = False

code/Level 1 - Intro to CPX/1-blink/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
cpx.red_led = False
1212
time.sleep(0.5)
1313

14-
# Note - anything with a '#' infront is a comment and is ignored
14+
# Note - anything with a '#' infront is a comment and is ignored

code/Level 1 - Intro to CPX/2-lights/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
cpx.pixels.fill((0, 0, 0))
55

66
while True:
7-
87
# notice how these lines are similar
98
cpx.pixels[0] = (255, 0, 0)
109
cpx.pixels[1] = (255, 127, 0)
@@ -18,9 +17,9 @@
1817
cpx.pixels[9] = (0, 0, 100)
1918

2019
# the [] with a number determines which light to turn on
21-
# and the numbers in () deterine the color!
20+
# and the numbers in () deterine the color!
2221
# It says how much (red, green, blue) we want.
2322
# Try changing the numbers!
2423

2524
# this line turns on the lights!
26-
cpx.pixels.show()
25+
cpx.pixels.show()

code/Level 1 - Intro to CPX/3-buttons/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
while True:
44
if cpx.button_a:
5-
cpx.play_tone(329,1)
6-
cpx.play_tone(261,1)
5+
cpx.play_tone(329, 1)
6+
cpx.play_tone(261, 1)
77
elif cpx.button_b:
8-
cpx.play_tone(440,1)
9-
cpx.play_tone(400,1)
8+
cpx.play_tone(440, 1)
9+
cpx.play_tone(400, 1)

code/Level 1 - Intro to CPX/4-touch/main.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77
cpx.stop_tone()
88
continue
99
if cpx.touch_A4:
10-
print('Touched A4!')
10+
print("Touched A4!")
1111
cpx.pixels.fill((15, 0, 0))
1212
cpx.start_tone(262)
1313
elif cpx.touch_A5:
14-
print('Touched A5!')
14+
print("Touched A5!")
1515
cpx.pixels.fill((15, 5, 0))
1616
cpx.start_tone(294)
1717
elif cpx.touch_A6:
18-
print('Touched A6!')
18+
print("Touched A6!")
1919
cpx.pixels.fill((15, 15, 0))
2020
cpx.start_tone(330)
2121
elif cpx.touch_A7:
22-
print('Touched A7!')
22+
print("Touched A7!")
2323
cpx.pixels.fill((0, 15, 0))
2424
cpx.start_tone(349)
2525
elif cpx.touch_A1:
26-
print('Touched A1!')
26+
print("Touched A1!")
2727
cpx.pixels.fill((0, 15, 15))
2828
cpx.start_tone(392)
2929
elif cpx.touch_A2 and not cpx.touch_A3:
30-
print('Touched A2!')
30+
print("Touched A2!")
3131
cpx.pixels.fill((0, 0, 15))
3232
cpx.start_tone(440)
3333
elif cpx.touch_A3 and not cpx.touch_A2:
34-
print('Touched A3!')
34+
print("Touched A3!")
3535
cpx.pixels.fill((5, 0, 15))
3636
cpx.start_tone(494)
3737
elif cpx.touch_A2 and cpx.touch_A3:
@@ -41,4 +41,3 @@
4141
else:
4242
cpx.pixels.fill((0, 0, 0))
4343
cpx.stop_tone()
44-

code/Level 1 - Intro to CPX/5-acceleration/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
x, y, z = cpx.acceleration
1616

1717
print((x, y, z))
18-
18+
1919
if x:
2020
R = R + abs(int(x))
2121
if y:
2222
G = G + abs(int(y))
2323
if z:
2424
B = B + abs(int(z))
2525
cpx.pixels.fill((R, G, B))
26-
time.sleep(0.25)
26+
time.sleep(0.25)

code/Level 1 - Intro to CPX/6-temperature/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66
print("Temperature F:", cpx.temperature * 1.8 + 32)
77
print((cpx.temperature, cpx.temperature * 1.8 + 32))
88
time.sleep(1)
9-

code/Level 2 - Intro to Programming/1-variables/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import board
66
import neopixel
77

8-
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=.2)
8+
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.2)
99

1010
# Colors
1111
BLACK = (0, 0, 0)
@@ -27,10 +27,10 @@
2727
while True:
2828
for i in range(len(pixels)):
2929
pixels[i] = RED
30-
time.sleep(.05)
30+
time.sleep(0.05)
3131
time.sleep(1)
3232

3333
for i in range(len(pixels)):
3434
pixels[i] = GREEN
35-
time.sleep(.05)
35+
time.sleep(0.05)
3636
time.sleep(1)

0 commit comments

Comments
 (0)