1
1
import time
2
2
import machine
3
- from galactic import GalacticUnicorn
4
- from picographics import PicoGraphics , DISPLAY_GALACTIC_UNICORN as DISPLAY
3
+ from cosmic import CosmicUnicorn
4
+ from picographics import PicoGraphics , DISPLAY_COSMIC_UNICORN as DISPLAY
5
5
6
6
# overclock to 200Mhz
7
7
machine .freq (200000000 )
8
8
9
- # create galactic object and graphics surface for drawing
10
- galactic = GalacticUnicorn ()
9
+ # create cosmic object and graphics surface for drawing
10
+ cosmic = CosmicUnicorn ()
11
11
graphics = PicoGraphics (DISPLAY )
12
12
13
13
brightness = 0.5
16
16
# returns the id of the button that is currently pressed or
17
17
# None if none are
18
18
def pressed ():
19
- if galactic .is_pressed (GalacticUnicorn .SWITCH_A ):
20
- return GalacticUnicorn .SWITCH_A
21
- if galactic .is_pressed (GalacticUnicorn .SWITCH_B ):
22
- return GalacticUnicorn .SWITCH_B
23
- if galactic .is_pressed (GalacticUnicorn .SWITCH_C ):
24
- return GalacticUnicorn .SWITCH_C
25
- if galactic .is_pressed (GalacticUnicorn .SWITCH_D ):
26
- return GalacticUnicorn .SWITCH_D
19
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_A ):
20
+ return CosmicUnicorn .SWITCH_A
21
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_B ):
22
+ return CosmicUnicorn .SWITCH_B
23
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_C ):
24
+ return CosmicUnicorn .SWITCH_C
25
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_D ):
26
+ return CosmicUnicorn .SWITCH_D
27
27
return None
28
28
29
29
@@ -33,30 +33,30 @@ def pressed():
33
33
graphics .set_pen (graphics .create_pen (0 , 0 , 0 ))
34
34
graphics .clear ()
35
35
graphics .set_pen (graphics .create_pen (155 , 155 , 155 ))
36
- graphics .text ("PRESS" , 12 , - 1 , - 1 , 1 )
37
- graphics .text ("A B C OR D!" , 2 , 5 , - 1 , 1 )
36
+ graphics .text ("PRESS" , 3 , 6 , - 1 , 1 )
37
+ graphics .text ("A B C OR D!" , 5 , 14 , 32 , 1 , 0 )
38
38
39
39
# brightness up/down
40
- if galactic .is_pressed (GalacticUnicorn .SWITCH_BRIGHTNESS_UP ):
40
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_BRIGHTNESS_UP ):
41
41
brightness += 0.01
42
- if galactic .is_pressed (GalacticUnicorn .SWITCH_BRIGHTNESS_DOWN ):
42
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_BRIGHTNESS_DOWN ):
43
43
brightness -= 0.01
44
44
brightness = max (min (brightness , 1.0 ), 0.0 )
45
45
46
- galactic .set_brightness (brightness )
47
- galactic .update (graphics )
46
+ cosmic .set_brightness (brightness )
47
+ cosmic .update (graphics )
48
48
49
- if pressed () == GalacticUnicorn .SWITCH_A :
49
+ if pressed () == CosmicUnicorn .SWITCH_A :
50
50
import fire as effect
51
51
break
52
- if pressed () == GalacticUnicorn .SWITCH_B :
52
+ if pressed () == CosmicUnicorn .SWITCH_B :
53
53
import supercomputer as effect # noqa: F811
54
54
break
55
- if pressed () == GalacticUnicorn .SWITCH_C :
55
+ if pressed () == CosmicUnicorn .SWITCH_C :
56
56
import rainbow as effect # noqa: F811
57
57
break
58
- if pressed () == GalacticUnicorn .SWITCH_D :
59
- import retroprompt as effect # noqa: F811
58
+ if pressed () == CosmicUnicorn .SWITCH_D :
59
+ import today as effect # noqa: F811
60
60
break
61
61
62
62
# pause for a moment
@@ -79,35 +79,35 @@ def pressed():
79
79
if pressed () is not None :
80
80
machine .reset ()
81
81
82
- sleep_pressed = galactic .is_pressed (GalacticUnicorn .SWITCH_SLEEP )
82
+ sleep_pressed = cosmic .is_pressed (CosmicUnicorn .SWITCH_SLEEP )
83
83
if sleep_pressed and not was_sleep_pressed :
84
84
sleep = not sleep
85
85
86
86
was_sleep_pressed = sleep_pressed
87
87
88
88
if sleep :
89
89
# fade out if screen not off
90
- galactic .set_brightness (galactic .get_brightness () - 0.01 )
90
+ cosmic .set_brightness (cosmic .get_brightness () - 0.01 )
91
91
92
- if galactic .get_brightness () > 0.0 :
92
+ if cosmic .get_brightness () > 0.0 :
93
93
effect .draw ()
94
94
95
95
# update the display
96
- galactic .update (graphics )
96
+ cosmic .update (graphics )
97
97
else :
98
98
effect .draw ()
99
99
100
100
# update the display
101
- galactic .update (graphics )
101
+ cosmic .update (graphics )
102
102
103
103
# brightness up/down
104
- if galactic .is_pressed (GalacticUnicorn .SWITCH_BRIGHTNESS_UP ):
104
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_BRIGHTNESS_UP ):
105
105
brightness += 0.01
106
- if galactic .is_pressed (GalacticUnicorn .SWITCH_BRIGHTNESS_DOWN ):
106
+ if cosmic .is_pressed (CosmicUnicorn .SWITCH_BRIGHTNESS_DOWN ):
107
107
brightness -= 0.01
108
108
brightness = max (min (brightness , 1.0 ), 0.0 )
109
109
110
- galactic .set_brightness (brightness )
110
+ cosmic .set_brightness (brightness )
111
111
112
112
# pause for a moment (important or the USB serial device will fail
113
113
time .sleep (0.001 )
0 commit comments