TiLDA MK3/Get Started: Difference between revisions

From EMF Badge
Jump to navigation Jump to search
No edit summary
No edit summary
Line 39: Line 39:
* You can now close the terminal window (or Putty, if you're on Windows)
* You can now close the terminal window (or Putty, if you're on Windows)


== 5. (Optional) Update your badge ==
== 5. Download some software you'll need ==
'You can skip this step', but since TiLDA is still a work in progress, it's best to update regularly. It's easy, just follow the instructions on https://update.badge.emfcamp.org.
 
You will be downloading some stuff now. It's probably be best if you create some folder somewhere so you don't end up with files all over your Desktop.
 
=== Windows ===
* Python: Go to https://www.python.org/downloads/ and download python version 3.x. After the download is finished you can install it.
* Go to https://bootstrap.pypa.io/get-pip.py and save the file into your folder
* Hold shift, right click on the folder on, and click "open command window here"
* Now type <code>python get-pip.py</code>
* After the install was successful please type <code>pip install pyserial pyusb</code> followed by Enter
 
=== OSX / Linux ===
 
* Python: Open a terminal and type <code>python --version</code>. If you get a version number you're good to go, otherwise go to https://www.python.org/downloads/ and download Python version 3.x. After the download is finished you can install it.
* Go to https://bootstrap.pypa.io/get-pip.py and save the file into your folder
* Use a terminal to go to the folder you created ([http://www.macworld.com/article/2042378/master-the-command-line-navigating-files-and-folders.html this is how you do it]) and type <code>python get-pip.py</code>
* Now type <code>python get-pip.py</code>
* After the install was successful please type <code>pip install pyserial pyusb</code> followed by Enter
 
=== Problems ===
* If you have problems install python, please use google, there are lots of good explanations out there
* For information about how to install <code>pip</code> have a look here: https://pip.pypa.io/en/stable/installing/
 
== 6. (Optional) Update your badge ==
'You can skip this step', but since TiLDA is still a work in progress, it's best to update regularly. So why not do it now? It's easy, just follow the instructions on https://update.badge.emfcamp.org.
 
 
== 5. Run a whole file of code ==
While you can do most things via the terminal like you just did, it's a bit easier to work on a file that you can edit. So let's do that.
* Go to https://raw.githubusercontent.com/emfcamp/micropython/tilda-master/tools/pyboard.py and use your browser to save it as "pyboard.py" into your newly created folder
* Open a text editor. On Windows you can search for <code>Notepad</code>, on OSX there's one called <code>textedit</code> and if you're on Linux you can probably find one by searching for "edit".
* Open a terminal, navigate to the right folder (see step 5 for more info)
** Windows: ToDo
** OSX: type <code>python pyboard.py test.py --device=/dev/tty.usbmodem*</code>
** Linux: type <code>python pyboard.py test.py --device=/dev/ttyACM*</code>


== 5. Download the pyboard.py script ==


== 6. Test that everything is working ==
== 6. Test that everything is working ==

Revision as of 22:32, 25 July 2016

Get started

Hacking your TiLDA badge is easy. We've written it down step by step.

If something goes wrong, the badge can be reset to its out-of-the-box state, so do not be concerned about breaking anything.

1. Connect to your computer

To get started you need to connect your badge to a computer. You can use any MicroUSB cable - the same type that charges most mobile phones nowadays. It doesn't matter whether the batter is plugged in or not, so don't worry about it.

2. Check your badge is found by your computer

Upon connecting the badge to a computer, it should appear as a "mass storage device" just like a USB key or an external hard disk.

Important: Just like any other USB storage device, if you changed or copied anything on the Badge, please make sure to "eject" or "safely remove" before unplugging your badge or pressing the reset button. Otherwise you might lose all your work :(

Windows will require a driver file for the serial port, which is stored on the badge's mass storage. More information

3. Connect to your badge

Windows

  • Please follow the instruction under the "Windows" section on this page: https://micropython.org/doc/tut-repl
  • Once you've installed the driver and Putty and you've connected to your badge you should now be greeted by a line saying "Micropython"

OSX

  • Click the magnifying class in the top right of your screen and type Terminal followed by Enter. A white terminal window should appear.
  • type /dev/tty.usbmodem* (The * is important, so don't let it out) and hit enter
  • You should now be greeted by a line saying "Micropython"

Linux

  • Open a terminal and type screen /dev/ttyACM0
  • You should now be greeted by a line saying "Micropython"

What to do if this step doesn't work?

4. Your first line of Micropython

  • In your terminal (next to the >>>) type print(1 + 1) followed by Enter
  • You should see 2 printed on the screen. Congratulations, you've just written your first line of micropython code!
  • You can now close the terminal window (or Putty, if you're on Windows)

5. Download some software you'll need

You will be downloading some stuff now. It's probably be best if you create some folder somewhere so you don't end up with files all over your Desktop.

Windows

  • Python: Go to https://www.python.org/downloads/ and download python version 3.x. After the download is finished you can install it.
  • Go to https://bootstrap.pypa.io/get-pip.py and save the file into your folder
  • Hold shift, right click on the folder on, and click "open command window here"
  • Now type python get-pip.py
  • After the install was successful please type pip install pyserial pyusb followed by Enter

OSX / Linux

  • Python: Open a terminal and type python --version. If you get a version number you're good to go, otherwise go to https://www.python.org/downloads/ and download Python version 3.x. After the download is finished you can install it.
  • Go to https://bootstrap.pypa.io/get-pip.py and save the file into your folder
  • Use a terminal to go to the folder you created (this is how you do it) and type python get-pip.py
  • Now type python get-pip.py
  • After the install was successful please type pip install pyserial pyusb followed by Enter

Problems

6. (Optional) Update your badge

'You can skip this step', but since TiLDA is still a work in progress, it's best to update regularly. So why not do it now? It's easy, just follow the instructions on https://update.badge.emfcamp.org.


5. Run a whole file of code

While you can do most things via the terminal like you just did, it's a bit easier to work on a file that you can edit. So let's do that.

  • Go to https://raw.githubusercontent.com/emfcamp/micropython/tilda-master/tools/pyboard.py and use your browser to save it as "pyboard.py" into your newly created folder
  • Open a text editor. On Windows you can search for Notepad, on OSX there's one called textedit and if you're on Linux you can probably find one by searching for "edit".
  • Open a terminal, navigate to the right folder (see step 5 for more info)
    • Windows: ToDo
    • OSX: type python pyboard.py test.py --device=/dev/tty.usbmodem*
    • Linux: type python pyboard.py test.py --device=/dev/ttyACM*


6. Test that everything is working

7. Blink

import pyb
led = pyb.LED(1)
led.on()
pyb.delay(500)
led.off()
pyb.delay(500)
led.on()
pyb.delay(500)
led.off()
pyb.delay(500)
led.on()

8. Hello Screen

9. Buttons

10. Your own app

Alternative ways to work with TiLDA

All of the python code which runs on the badge can be modified on the mass storage device, and new apps can be added this way too. Be careful when using text editors to modify files on the device, if the mass storage is not 'safely removed' before removal, corruption of the file being edited can occur.

When writing your own code, it is advised edit code on your computer, then copy it across to the badge, wait for the red 'writing' LED to go out, reset it, and run. This way you don't need to worry about safely removing the badge each time.


To interactively run code on the badge, a python REPL can be accessed via the virtual serial port. Once you have found the serial port, use your favourite serial terminal to connect to the badge. Since the badge will be running the main software, press Ctrl+c to stop it, and the badge will display '>>>' to indicate it is ready to receive commands.

The badge runs micropython, and as a result does not contain everything you may expect from full python. See the micropython docs in the lniks below for more information. The badge has additional APIs, in particular for the LCD, Wifi and IMU, which are also listed below.