|
1 | 1 | ############ |
2 | 2 | Installation |
3 | 3 | ############ |
4 | | -You can use the ``codebug_tether`` Python 3 API by either: |
5 | 4 |
|
6 | | -* Installing with ``pip`` |
7 | | -* Copying the ``codebug_tether`` module into your project directory. |
| 5 | +Setting up CodeBug |
| 6 | +================== |
| 7 | +In order to use CodeBug with codebug_tether you need to program CodeBug |
| 8 | +with ``codebug_tether.cbg`` (|firmwaredownload|). |
8 | 9 |
|
9 | | -CodeBug Tether depends on pyserial. |
| 10 | +To do this, hold down button A and plug in CodeBug via USB --- it should |
| 11 | +appear as a USB drive --- then copy the ``codebug_tether.cbg`` file onto it. |
| 12 | +CodeBug is now ready to be used via serial USB. Press button B to exit |
| 13 | +programming mode. |
10 | 14 |
|
11 | | -It is reccomended that you install using virtual environments. |
| 15 | +.. note:: When CodeBug is connected to a computer via USB is should now |
| 16 | + appear as a serial device. To reprogram CodeBug: hold down |
| 17 | + button A and (re)plug it into a USB port. |
12 | 18 |
|
13 | 19 |
|
14 | | -Setting up CodeBug |
15 | | ------------------- |
16 | | -In order to communicate with CodeBug over Serial USB you need to program CodeBug with |
17 | | -``codebug_tether.cbg`` (|firmwaredownload|). |
18 | | -To do this, plug in CodeBug via USB while holding button A --- it should |
19 | | -appear as a USB drive --- then copy onto it the ``codebug_tether.cbg`` file. |
20 | | -CodeBug is now ready to be used via serial USB. Press button B to exit |
21 | | -programming mode. |
| 20 | +Install codebug_tether on Windows |
| 21 | +================================= |
| 22 | +.. note:: These instructions are based on `The Hitchhikers Guide to Python: Installing Python on Windows <http://docs.python-guide.org/en/latest/starting/install/win/>`_ |
| 23 | + |
| 24 | +Install Python |
| 25 | +-------------- |
| 26 | +Download and install the latest verson of Python 3 from `here <https://www.python.org/downloads/windows/>`_. |
| 27 | +Make sure you tick the *Add Python 3 to environment variables* checkbox. |
| 28 | + |
| 29 | +Install codebug_tether |
| 30 | +---------------------- |
| 31 | +To install codebug_tether, open up a command prompt and type:: |
| 32 | + |
| 33 | + pip install codebug_tether |
| 34 | + |
| 35 | +To test it has worked, plug in CodeBug and open a Python shell by typing:: |
| 36 | + |
| 37 | + python |
| 38 | + |
| 39 | +Your command prompt should have changed to:: |
| 40 | + |
| 41 | + >>> _ |
| 42 | + |
| 43 | +Now type:: |
| 44 | + |
| 45 | + >>> import codebug_tether |
| 46 | + >>> codebug = codebug_tether.CodeBug() |
| 47 | + >>> codebug.set_pixel(2, 2, 1) |
| 48 | + |
| 49 | +The middle pixel on your CodeBug should light up. |
| 50 | + |
| 51 | + |
| 52 | +Install codebug_tether on OSX |
| 53 | +============================= |
| 54 | +.. note:: These instructions are based on `The Hitchhikers Guide to Python: Installing Python on Mac OS X <http://docs.python-guide.org/en/latest/starting/install/osx/>`_ |
22 | 55 |
|
23 | | -When CodeBug is connected to a computer via USB is should now appear as a |
24 | | -serial device (``/dev/ttyACM0`` on Linux). |
| 56 | +Install Python |
| 57 | +-------------- |
| 58 | +Download and install `Xcode <https://developer.apple.com/xcode/download/>`_ (if you haven't already) and then enable the command line tools by running (in a terminal):: |
25 | 59 |
|
| 60 | + xcode-select --install |
26 | 61 |
|
| 62 | +Now install Homebrew (a package manager for OSX):: |
27 | 63 |
|
28 | | -Installing with ``pip`` |
29 | | ------------------------ |
30 | | -.. warning:: Consider using virtual environments. |
| 64 | + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
31 | 65 |
|
32 | | -Make sure ``pip`` is installed:: |
| 66 | +The script will explain what changes it will make and prompt you before the installation begins. Once you’ve installed Homebrew, insert the Homebrew directory at the top of your **PATH** environment variable. You can do this by adding the following line at the bottom of your ~/.profile file:: |
33 | 67 |
|
34 | | - sudo apt-get install python3-pip |
| 68 | + export PATH=/usr/local/bin:/usr/local/sbin:$PATH |
35 | 69 |
|
36 | | -Install ``codebug_tether`` using ``pip``:: |
| 70 | +Now, we can install Python 3:: |
37 | 71 |
|
38 | | - sudo pip-3.2 install pyserial codebug_tether |
| 72 | + brew install python3 |
39 | 73 |
|
| 74 | +This will take a minute or two. |
40 | 75 |
|
41 | | -Installing with ``pip`` (with Virtual Environments) |
42 | | ---------------------------------------------------- |
43 | | -.. note :: Generally, it's best to install packages into a |
44 | | - `virtual environment <http://docs.python-guide.org/en/latest/dev/virtualenvs/>`_ |
45 | | - when using ``pip`` so that they remain project specific. |
| 76 | +Install codebug_tether |
| 77 | +---------------------- |
| 78 | +To install codebug_tether, open up a terminal and type:: |
46 | 79 |
|
47 | | -Install ``virtualenv``:: |
| 80 | + pip install codebug_tether |
48 | 81 |
|
49 | | - sudo pip-3.2 install virtualenv |
| 82 | +To test it has worked, plug in CodeBug and open a Python shell by typing:: |
50 | 83 |
|
51 | | -Move into your project and create the virtual environment:: |
| 84 | + python |
52 | 85 |
|
53 | | - cd my_project_directory/ |
54 | | - virtualenv-3.2 venv |
| 86 | +Your command prompt should have changed to:: |
| 87 | + |
| 88 | + >>> _ |
| 89 | + |
| 90 | +Now type:: |
| 91 | + |
| 92 | + >>> import codebug_tether |
| 93 | + >>> codebug = codebug_tether.CodeBug() |
| 94 | + >>> codebug.set_pixel(2, 2, 1) |
55 | 95 |
|
56 | | -Activate the virtual environment:: |
| 96 | +The middle pixel on your CodeBug should light up. |
57 | 97 |
|
58 | | - source venv/bin/activate |
59 | 98 |
|
60 | | -You should notice that your command prompt has changed. ``pip`` will now |
61 | | -install all packages into the virtual environment instead of littering |
62 | | -your system files:: |
| 99 | +Install codebug_tether on Linux |
| 100 | +=============================== |
| 101 | +Install Python |
| 102 | +-------------- |
| 103 | +Python should already be installed but for good measure:: |
63 | 104 |
|
64 | | - pip install pyserial codebug_tether |
| 105 | + sudo apt-get install python3 |
65 | 106 |
|
66 | | -Now you can work on your application with ``codebug_tether``. Once |
67 | | -you're done, deactivate the virtual environment:: |
| 107 | +To install pip, securely download `get-pip.py <https://bootstrap.pypa.io/get-pip.py>`_. |
68 | 108 |
|
69 | | - deactivate |
| 109 | +Then run the following:: |
70 | 110 |
|
71 | | -You will not be able to use packages installed in the virtual environment |
72 | | -until you activate it again (`source venv/bin/activate`). |
| 111 | + python get-pip.py |
73 | 112 |
|
74 | 113 |
|
75 | | -Using ``codebug_tether`` without installing |
76 | | ------------------------------------------------ |
77 | | -You may want to use ``codebug_tether`` without installing anything at |
78 | | -all. You can just download and include the ``codebug_tether`` package |
79 | | -in your project and start using it. The quickest way to do this is:: |
| 114 | +Install codebug_tether |
| 115 | +---------------------- |
| 116 | +To install codebug_tether, open up a terminal and type:: |
| 117 | + |
| 118 | + pip install codebug_tether |
| 119 | + |
| 120 | +To test it has worked, plug in CodeBug and open a Python shell by typing:: |
| 121 | + |
| 122 | + python |
| 123 | + |
| 124 | +Your command prompt should have changed to:: |
| 125 | + |
| 126 | + >>> _ |
| 127 | + |
| 128 | +Now type:: |
80 | 129 |
|
81 | | - git clone https://github.com/codebugtools/codebug_tether.git |
82 | | - cp -r codebug_tether/codebug_tether myproject/ |
83 | | - cd myproject/ |
84 | | - python3 |
85 | 130 | >>> import codebug_tether |
| 131 | + >>> codebug = codebug_tether.CodeBug() |
| 132 | + >>> codebug.set_pixel(2, 2, 1) |
| 133 | + |
| 134 | +The middle pixel on your CodeBug should light up. |
0 commit comments