Différences entre versions de « Rasp-Hack-Led-Backpack-AdaFruit-Librairie »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
Ligne 16 : Ligne 16 :
 
The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and clone it directly using 'git', which is installed by default on most distros.  Simply run the following commands from an appropriate location (ex. "/home/pi"):  
 
The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and clone it directly using 'git', which is installed by default on most distros.  Simply run the following commands from an appropriate location (ex. "/home/pi"):  
  
  <nowiki>   sudo apt-get install git
+
  <nowiki>sudo apt-get install git
    git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
+
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
    cd Adafruit-Raspberry-Pi-Python-Code
+
cd Adafruit-Raspberry-Pi-Python-Code
    cd Adafruit_LEDBackpack</nowiki>
+
cd Adafruit_LEDBackpack</nowiki>
  
 
== Tester la librairie ==
 
== Tester la librairie ==

Version du 11 février 2013 à 20:14

Utiliser la librairie AdaFruit

The Python code to work with Adafruit's LED Backpacks on the Pi is available on Github at https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code

This code should be a good starting point to understanding how you can access SMBus/I2C devices with your Pi, and getting your blinky on.

If you're running Wheezy or something-other-than-Occidentalis, you will need to set up I2C first.

Follow this tutorial to fully enable i2c

Downloading the Code from Github

The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and clone it directly using 'git', which is installed by default on most distros. Simply run the following commands from an appropriate location (ex. "/home/pi"):

sudo apt-get install git
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
cd Adafruit-Raspberry-Pi-Python-Code
cd Adafruit_LEDBackpack

Tester la librairie

Once the code has be downloaded to an appropriate folder, and you have your LED Backpack board properly connected, you can test it out with the following commands (the driver includes a few simple demo programs)

If you're using a rev 2 (512Mb RAM model B) Pi you will have to edit Adafruit_LEDBackpack.py using nano Adafruit_LEDBackpack.py and change the i2c bus over from port #0 to port #1 as it was updated in the second rev to a different number:

self.i2c = Adafruit_I2C(address, bus=smbus.SMBus(0))

to

self.i2c = Adafruit_I2C(address, bus=smbus.SMBus(1))

For 8x8 displays, you can run a simple test with:

 sudo python ex_8x8_pixels.py

Which should result in something like the following:

{{#Widget:Iframe |url=http://www.youtube.com/embed/AYArwe-OkdQ |width=420 |height=315 |border=0 }}

For 4-character, 7-segment displays, you can run a clock demo with:

sudo python ex_7segment_clock.py

Which should result in the following:

{{#Widget:Iframe |url=http://www.youtube.com/embed/AAgTe27reIk |width=420 |height=315 |border=0 }}



Source: AdaFruit

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.