Page 1 of 1

BN Astro Pi Examples

Posted: Sun May 24, 2015 1:03 pm
by ben_nuttall
I've made a few example scripts and stuck them on GitHub: https://github.com/bennuttall/astro-pi-examples/

Examples so far:

- Random Sparkles
- Conway's Game of Life
- Minecraft Colour
- Minecraft Map
- Colour Match

Re: BN Astro Pi Examples

Posted: Sun May 24, 2015 6:00 pm
by OllieT
To get the conway game to work had to change 'ap.set_pixel(x, y ,color)'
to 'ap.set_pixel(x, y, color[0], color[1], color[2])' otherwise a 'set_pixel() takes exactly 6 arguments' error was thrown

Re: BN Astro Pi Examples

Posted: Sun May 24, 2015 6:23 pm
by Davespice
OllieT wrote:To get the conway game to work had to change 'ap.set_pixel(x, y ,color)'
to 'ap.set_pixel(x, y, color[0], color[1], color[2])' otherwise a 'set_pixel() takes exactly 6 arguments' error was thrown
Ah, you may have an older version of the API installed on your Pi.
If you run these commands it will update it to the latest version:

Code: Select all

cd ~/astro-pi-hat
git fetch origin
git reset --hard origin/master
sudo python setup.py install
sudo python3 setup.py install

Re: BN Astro Pi Examples

Posted: Mon May 25, 2015 2:47 am
by ben_nuttall
As Dave said, we changed the API before the v1.0.0 release to allow passing of the colour in either individual r, g, b values or a 3-tuple containing (r, g, b).

Sometimes you just want to have a bunch of colours declared, like black, white, blue, red, green, and pass the colour in.
Sometimes, you're incrementing and decrementing individual RGB colour values in a loop so you want to pass them in separately.

Currently the best way to update your version of the library is to clone it from git and run "sudo python3 setup.py" or "sudo python setup.py" but before long we'll have it packaged in Raspbian.

To find out what version you have, run the following from the command line:

Code: Select all

python3 -c "import astro_pi as ap; print(ap.__version__)"
python -c "import astro_pi as ap; print(ap.__version__)"
I think it was set at v0.0.0 until we released v1.0.0 and there haven't been any code changes since then.