Skip to content

Instantly share code, notes, and snippets.

@bricklife
Last active January 16, 2020 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bricklife/7f57a278a517a429418162463f694f76 to your computer and use it in GitHub Desktop.
Save bricklife/7f57a278a517a429418162463f694f76 to your computer and use it in GitHub Desktop.
Overwriting main.py in LEGO Education SPIKE Prime Hub
import io
f = io.open('main.py', 'w')
f.write('''
import hub
import time
while True:
hub.display.show(hub.Image('00000:00000:00900:00000:00000:'))
time.sleep_ms(500)
hub.display.show(hub.Image('00000:09990:09090:09990:00000:'))
time.sleep_ms(500)
hub.display.show(hub.Image('99999:90009:90009:90009:99999:'))
time.sleep_ms(500)
''')
f.close()
@bricklife
Copy link
Author

bricklife commented Jan 16, 2020

DISCLAIMER

Please use this script at your own risk. I'm not responsible for any damage on your hub.

How to overwrite main.py

  1. Exec the following command in Terminal.app to connect your hub from your Mac
$ screen /dev/tty.LEGOHubXXXX-SerialPort
  1. Press Ctrl-C to enter REPL mode
  2. Press Ctrl-E to enter Paste mode
  3. Copy and paste the above code
  4. Press Ctrl-D to exit Paste mode
  5. Your main.py should be as follows
import hub
import time

while True:
    hub.display.show(hub.Image('00000:00000:00900:00000:00000:'))
    time.sleep_ms(500)
    hub.display.show(hub.Image('00000:09990:09090:09990:00000:'))
    time.sleep_ms(500)
    hub.display.show(hub.Image('99999:90009:90009:90009:99999:'))
    time.sleep_ms(500)

Original main.py

https://gist.github.com/bricklife/8cf5e6f71849c834d749d598cddfe712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment