1- import PuppetBlocks
2-
3- import time
4- #Screens -----------------------------------------------------------------------------
5-
6- #blackScreen, whiteScreen
7- PuppetBlocks .Screens .blackScreen (3 )
8- time .sleep (1 )
9- PuppetBlocks .Screens .whiteScreen (3 )
10- time .sleep (1 )
11- PuppetBlocks .Screens .blackScreen (1 )
12-
13- #showImage
14- time .sleep (2 )
15- PuppetBlocks .Screens .showImage ('try.pbm' , 2 )
16-
17- #showtext
18- time .sleep (3 )
19- PuppetBlocks .Screens .showText ('iot' ,1 )
20- time .sleep (1 )
21- PuppetBlocks .Screens .showText ('fun' ,2 )
22- time .sleep (1 )
23- PuppetBlocks .Screens .showText ('hi' ,3 )
24-
25- #Audio -------------------------------------------------------------------------------
26- #synchronousPlay
27- PuppetBlocks .Audio .synchronousPlay ('play.wav' ,False )
28- time .sleep (2 )
29-
30- #asynchronousPlay, pause, resume, stop, isPlaying
31- PuppetBlocks .Audio .asynchronousPlay ('sound.wav' ,False )
32- print ("is playing - " , PuppetBlocks .Audio .isPlaying ())
33- time .sleep (5 )
34- PuppetBlocks .Audio .pause ()
35- time .sleep (3 )
36- PuppetBlocks .Audio .resume ()
37- time .sleep (5 )
38- PuppetBlocks .Audio .stop ()
39- print ("is playing - " , PuppetBlocks .Audio .isPlaying ())
40-
41- #Files -------------------------------------------------------------------------------
42- #fileExists
43- print ("exist - " ,PuppetBlocks .Files .fileExists ('check.pbm' )) #prints False
44- time .sleep (2 )
45-
46- #loadFile
47- PuppetBlocks .Files .loadFile ('check.pbm' , 'https://firebasestorage.googleapis.com/v0/b/puppetblocks.appspot.com/o/scatman.3.pbm?alt=media&token=ae2dcc4d-12d4-405b-8d0b-65eb7d3a8504' )
48- print ("exist - " , PuppetBlocks .Files .fileExists ('check.pbm' )) #should print True
49- time .sleep (1 )
50-
51- #deleteFile
52- PuppetBlocks .Files .deleteFile ('check.pbm' )
53- time .sleep (1 )
54- print ("exist - " ,PuppetBlocks .Files .fileExists ('check.pbm' )) #should print False
55-
56- #renameFile, listFiles
57- print (PuppetBlocks .Files .listFiles ())
58- time .sleep (2 )
59- PuppetBlocks .Files .renameFile ('try.pbm' ,'try1.pbm' )
60- print (PuppetBlocks .Files .listFiles ())
61- time .sleep (5 )
62-
63- #Time --------------------------------------------------------------------------------------------
64- #getTime
65- print (PuppetBlocks .Time .getTime ())
66- a = PuppetBlocks .Time .getTime ()
67-
68- #sleep
69- PuppetBlocks .Time .sleep (2 , PuppetBlocks .Time .SECOND )
70- print (a ) #should be after 2 seconds
71-
72- #addTime, sleepUntil
73- b = PuppetBlocks .Time .addTime (a , 1 , PuppetBlocks .Time .MINUTE )
74- print (b )
75- PuppetBlocks .Time .sleepUntil (b )
76-
77- #Movement ----------------------------------------------------------------------------------------
78- #setPitch, setRotaion, getRotation, getPitch
79- PuppetBlocks .Movement .setPitch (0 ) #down
80- print (PuppetBlocks .Movement .getPitch ())
81- time .sleep (2 )
82- PuppetBlocks .Movement .setRotation (0 ) #left
83- time .sleep (2 )
84- PuppetBlocks .Movement .setRotation (180 ) #right
85- print (PuppetBlocks .Movement .getRotation ())
86-
87- #slidePitch, slideRotation
88- time .sleep (1 )
89- PuppetBlocks .Movement .slidePitch (0 , 5 ) #down
90- print (PuppetBlocks .Movement .getPitch ())
91- time .sleep (2 )
92- PuppetBlocks .Movement .slideRotation (0 , 5 ) #left
93- print (PuppetBlocks .Movement .getRotation ())
94- time .sleep (2 )
95-
96- #recordJoystick, performRecording
97- PuppetBlocks .Movement .recordJoystick ()
98- print ("joystick movement - " ,PuppetBlocks .Movement .__recording )
99- time .sleep (1 )
100- PuppetBlocks .Movement .performRecording ()
101- time .sleep (1 )
102-
103- #preformLive
104- PuppetBlocks .Movement .performLive (5 )
105- PuppetBlocks .Files .renameFile ('try1.pbm' ,'try.pbm' )
1+ #
2+ # @file : burn.py
3+ # @authors : PuppetBlocks team
4+ # @date : 22 February 2023
5+ #
6+ # This file is used for burning ESP32 devices, and not being uploaded to the micro controller.
7+ #
8+ import time
9+
10+ import PuppetBlocks
11+
12+
13+ # ----- Screens: -----
14+
15+ # blackScreen, whiteScreen
16+ PuppetBlocks .Screens .blackScreen (3 )
17+ time .sleep (1 )
18+ PuppetBlocks .Screens .whiteScreen (3 )
19+ time .sleep (1 )
20+ PuppetBlocks .Screens .blackScreen (1 )
21+
22+ # showImage
23+ time .sleep (2 )
24+ PuppetBlocks .Screens .showImage ('try.pbm' , 2 )
25+
26+ # showtext
27+ time .sleep (3 )
28+ PuppetBlocks .Screens .showText ('iot' ,1 )
29+ time .sleep (1 )
30+ PuppetBlocks .Screens .showText ('fun' ,2 )
31+ time .sleep (1 )
32+ PuppetBlocks .Screens .showText ('hi' ,3 )
33+
34+
35+
36+ # ----- Audio: -----
37+
38+ # synchronousPlay
39+ PuppetBlocks .Audio .synchronousPlay ('play.wav' ,False )
40+ time .sleep (2 )
41+
42+ # asynchronousPlay, pause, resume, stop, isPlaying
43+ PuppetBlocks .Audio .asynchronousPlay ('sound.wav' ,False )
44+ print ("is playing - " , PuppetBlocks .Audio .isPlaying ())
45+ time .sleep (5 )
46+ PuppetBlocks .Audio .pause ()
47+ time .sleep (3 )
48+ PuppetBlocks .Audio .resume ()
49+ time .sleep (5 )
50+ PuppetBlocks .Audio .stop ()
51+ print ("is playing - " , PuppetBlocks .Audio .isPlaying ())
52+
53+
54+
55+ # ----- Files: -----
56+
57+ # fileExists
58+ print ("exist - " ,PuppetBlocks .Files .fileExists ('check.pbm' )) #prints False
59+ time .sleep (2 )
60+
61+ # loadFile
62+ PuppetBlocks .Files .loadFile ('check.pbm' , 'https://firebasestorage.googleapis.com/v0/b/puppetblocks.appspot.com/o/scatman.3.pbm?alt=media&token=ae2dcc4d-12d4-405b-8d0b-65eb7d3a8504' )
63+ print ("exist - " , PuppetBlocks .Files .fileExists ('check.pbm' )) #should print True
64+ time .sleep (1 )
65+
66+ # deleteFile
67+ PuppetBlocks .Files .deleteFile ('check.pbm' )
68+ time .sleep (1 )
69+ print ("exist - " ,PuppetBlocks .Files .fileExists ('check.pbm' )) #should print False
70+
71+ # renameFile, listFiles
72+ print (PuppetBlocks .Files .listFiles ())
73+ time .sleep (2 )
74+ PuppetBlocks .Files .renameFile ('try.pbm' ,'try1.pbm' )
75+ print (PuppetBlocks .Files .listFiles ())
76+ time .sleep (5 )
77+
78+
79+
80+ # ----- Time: -----
81+
82+ # getTime
83+ print (PuppetBlocks .Time .getTime ())
84+ a = PuppetBlocks .Time .getTime ()
85+
86+ # sleep
87+ PuppetBlocks .Time .sleep (2 , PuppetBlocks .Time .SECOND )
88+ print (a ) #should be after 2 seconds
89+
90+ # addTime, sleepUntil
91+ b = PuppetBlocks .Time .addTime (a , 1 , PuppetBlocks .Time .MINUTE )
92+ print (b )
93+ PuppetBlocks .Time .sleepUntil (b )
94+
95+
96+ # ----- Movement: -----
97+
98+ # setPitch, setRotaion, getRotation, getPitch
99+ PuppetBlocks .Movement .setPitch (0 ) #down
100+ print (PuppetBlocks .Movement .getPitch ())
101+ time .sleep (2 )
102+ PuppetBlocks .Movement .setRotation (0 ) #left
103+ time .sleep (2 )
104+ PuppetBlocks .Movement .setRotation (180 ) #right
105+ print (PuppetBlocks .Movement .getRotation ())
106+
107+ # slidePitch, slideRotation
108+ time .sleep (1 )
109+ PuppetBlocks .Movement .slidePitch (0 , 5 ) #down
110+ print (PuppetBlocks .Movement .getPitch ())
111+ time .sleep (2 )
112+ PuppetBlocks .Movement .slideRotation (0 , 5 ) #left
113+ print (PuppetBlocks .Movement .getRotation ())
114+ time .sleep (2 )
115+
116+ # recordJoystick, performRecording
117+ PuppetBlocks .Movement .recordJoystick ()
118+ print ("joystick movement - " ,PuppetBlocks .Movement .__recording )
119+ time .sleep (1 )
120+ PuppetBlocks .Movement .performRecording ()
121+ time .sleep (1 )
122+
123+ # preformLive
124+ PuppetBlocks .Movement .performLive (5 )
125+ PuppetBlocks .Files .renameFile ('try1.pbm' ,'try.pbm' )
0 commit comments