Modifications

Sauter à la navigation Sauter à la recherche
Ligne 17 : Ligne 17 :     
== Installing the bundle ==
 
== Installing the bundle ==
We're constantly updating and improving our libraries, so we don't (at this time) ship our CircuitPython boards with the full library bundle. Instead, you may find example code that depends on (<code class="prettyprint">import</code>) libraries. Some of these libraries may be available from us at Adafruit, some may be written by community members!
+
We're constantly updating and improving our libraries, so we don't (at this time) ship our CircuitPython boards with the full library bundle. Instead, you may find example code that depends on ({{fname|import}}) libraries. Some of these libraries may be available from us at Adafruit, some may be written by community members!
    
Either way, once you get past the most basic blink scripts, you'll want to know how to get libraries on board. So, lets take a look at this silly example below which uses a SI7021 I2C temperature sensor.
 
Either way, once you get past the most basic blink scripts, you'll want to know how to get libraries on board. So, lets take a look at this silly example below which uses a SI7021 I2C temperature sensor.
   −
<pre><code class="prettyprint lang-python">import adafruit_si7021
+
<syntaxhighlight lang="python">import adafruit_si7021
 
import busio
 
import busio
 
import board
 
import board
Ligne 29 : Ligne 29 :  
print("Temperature:", sensor.temperature)
 
print("Temperature:", sensor.temperature)
 
print("Humidity:", sensor.relative_humidity)
 
print("Humidity:", sensor.relative_humidity)
</code>
+
</syntaxhighlight>
</pre>
+
 
After saving that as <code class="prettyprint">code.py</code> on the drive we see the status NeoPixel flashes that an error has occurred. Opening up the serial console we see that an <code class="prettyprint">ImportError</code> has occurred.
+
After saving that as {{fname|code.py}} on the drive we see the status NeoPixel flashes that an error has occurred. Opening up the serial console we see that an <code class="prettyprint">ImportError</code> has occurred.
    
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-02.png|640px}}
 
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-02.png|640px}}
   −
It says that no module exists named <code class="prettyprint">adafruit_si7021</code>. Thats the library we need to download! Since we bought the sensor from Adafruit its likely there is a library for in <a href="https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest">the official Adafruit bundle</a>. If its not an Adafruit part or its missing, we can also check <a href="https://github.com/adafruit/CircuitPython_Community_Bundle/releases/latest">the Community bundle</a> which has libraries contributed by the community.
+
It says that no module exists named <code class="prettyprint">adafruit_si7021</code>. Thats the library we need to download! Since we bought the sensor from Adafruit its likely there is a library for in [https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest the official Adafruit bundle]. If its not an Adafruit part or its missing, we can also check [https://github.com/adafruit/CircuitPython_Community_Bundle/releases/latest the Community bundle] which has libraries contributed by the community.
    
{{download-box|Cliquer ici pour obtenir la dernière version du bundle d'Adafruit|https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest}}
 
{{download-box|Cliquer ici pour obtenir la dernière version du bundle d'Adafruit|https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest}}
   −
Visiting the bundle release page will show us information on the latest release including a list of all the versions of the included drivers. Scrolling to the bottom of the page will reveal the downloads. We'll download the first zip file which starts with <code class="prettyprint">adafruit-circuitpython-bundle</code>.
+
Visiting the bundle release page will show us information on the latest release including a list of all the versions of the included drivers. Scrolling to the bottom of the page will reveal the downloads. We'll download the first zip file which starts with {{fname|adafruit-circuitpython-bundle}}.
    
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-03.png|640px}}
 
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-03.png|640px}}
Ligne 45 : Ligne 45 :  
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-04.png|640px}}
 
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-04.png|640px}}
   −
After downloading the zip, extract its contents. This is usually done by double clicking on the zip. On Mac OSX as I'm using, it places the file in the same directory as the zip. I usually sort my Downloads by file data so the <code class="prettyprint">lib</code> directory that was contained in the zip ends up next to the zip file.
+
After downloading the zip, extract its contents. This is usually done by double clicking on the zip. On Mac OSX as I'm using, it places the file in the same directory as the zip. I usually sort my Downloads by file data so the {{fname|lib}} directory that was contained in the zip ends up next to the zip file.
    
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-05.png|640px}}
 
{{ADFImage|FEATHER-M0-MicroPython-bibliotheque-05.png|640px}}
29 917

modifications

Menu de navigation