Skip to content

Commit f644c52

Browse files
kattnitannewt
authored andcommitted
Updated circuit singleton to cpx in express class, README
1 parent 2cf2846 commit f644c52

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ and then use it.
3232

3333
.. code-block :: python
3434
35-
from adafruit_circuitplayground.express import circuit
35+
from adafruit_circuitplayground.express import cpx
3636
3737
while True:
38-
if circuit.button_a:
39-
print("Temperature:", circuit.temperature)
40-
circuit.red_led = circuit.button_b
38+
if cpx.button_a:
39+
print("Temperature:", cpx.temperature)
40+
cpx.red_led = cpx.button_b
4141
4242
Contributing
4343
============

adafruit_circuitplayground/express.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def __init__(self):
5252
5353
.. code-block:: python
5454
55-
from adafruit_circuitplayground.express import circuit
55+
from adafruit_circuitplayground.express import cpx
5656
57-
circuit.pixels[0] = 0x000300
58-
circuit.pixels[9] = 0x030000
57+
cpx.pixels[0] = 0x000300
58+
cpx.pixels[9] = 0x030000
5959
6060
# Wait forever. CTRL-C to quit.
6161
while True:
@@ -82,10 +82,10 @@ def button_a(self):
8282
8383
.. code-block:: python
8484
85-
from adafruit_circuitplayground.express import circuit
85+
from adafruit_circuitplayground.express import cpx
8686
8787
while True:
88-
if circuit.button_a:
88+
if cpx.button_a:
8989
print("Button A pressed!")
9090
"""
9191
return self._a.value
@@ -99,10 +99,10 @@ def button_b(self):
9999
100100
.. code-block:: python
101101
102-
from adafruit_circuitplayground.express import circuit
102+
from adafruit_circuitplayground.express import cpx
103103
104104
while True:
105-
if circuit.button_b:
105+
if cpx.button_b:
106106
print("Button B pressed!")
107107
"""
108108
return self._b.value
@@ -118,11 +118,11 @@ def switch(self):
118118
119119
.. code-block:: python
120120
121-
from adafruit_circuitplayground.express import circuit
121+
from adafruit_circuitplayground.express import cpx
122122
import time
123123
124124
while True:
125-
print("Slide switch:", circuit.switch)
125+
print("Slide switch:", cpx.switch)
126126
time.sleep(1)
127127
"""
128128
return self._switch.value
@@ -138,11 +138,11 @@ def temperature(self):
138138
139139
.. code-block:: python
140140
141-
from adafruit_circuitplayground.express import circuit
141+
from adafruit_circuitplayground.express import cpx
142142
import time
143143
144144
while True:
145-
temperature_c = circuit.temperature
145+
temperature_c = cpx.temperature
146146
temperature_f = temperature_c * 1.8 + 32
147147
print("Temperature celsius:", temperature_c)
148148
print("Temperature farenheit:", temperature_f)
@@ -161,11 +161,11 @@ def light(self):
161161
162162
.. code-block:: python
163163
164-
from adafruit_circuitplayground.express import circuit
164+
from adafruit_circuitplayground.express import cpx
165165
import time
166166
167167
while True:
168-
print("Lux:", circuit.light)
168+
print("Lux:", cpx.light)
169169
time.sleep(1)
170170
"""
171171
return self._light.value
@@ -179,13 +179,13 @@ def red_led(self):
179179
180180
.. code-block:: python
181181
182-
from adafruit_circuitplayground.express import circuit
182+
from adafruit_circuitplayground.express import cpx
183183
import time
184184
185185
while True:
186-
circuit.red_led = True
186+
cpx.red_led = True
187187
time.sleep(1)
188-
circuit.red_led = False
188+
cpx.red_led = False
189189
time.sleep(1)
190190
"""
191191
return self._led.value
@@ -219,9 +219,9 @@ def play_tone(self, frequency, duration):
219219
220220
.. code-block:: python
221221
222-
from adafruit_circuitplayground.express import circuit
222+
from adafruit_circuitplayground.express import cpx
223223
224-
circuit.play_tone(440, 1)
224+
cpx.play_tone(440, 1)
225225
"""
226226
# Play a tone of the specified frequency (hz).
227227
self.start_tone(frequency)
@@ -238,15 +238,15 @@ def start_tone(self, frequency):
238238
239239
.. code-block:: python
240240
241-
from adafruit_circuitplayground.express import circuit
241+
from adafruit_circuitplayground.express import cpx
242242
243243
while True:
244-
if circuit.button_a:
245-
circuit.start_tone(262)
246-
elif circuit.button_b:
247-
circuit.start_tone(294)
244+
if cpx.button_a:
245+
cpx.start_tone(262)
246+
elif cpx.button_b:
247+
cpx.start_tone(294)
248248
else:
249-
circuit.stop_tone()
249+
cpx.stop_tone()
250250
"""
251251
self._speaker_enable.value = True
252252
self._generate_sample()
@@ -262,28 +262,28 @@ def stop_tone(self):
262262
263263
.. code-block:: python
264264
265-
from adafruit_circuitplayground.express import circuit
265+
from adafruit_circuitplayground.express import cpx
266266
267267
while True:
268-
if circuit.button_a:
269-
circuit.start_tone(262)
270-
elif circuit.button_b:
271-
circuit.start_tone(294)
268+
if cpx.button_a:
269+
cpx.start_tone(262)
270+
elif cpx.button_b:
271+
cpx.start_tone(294)
272272
else:
273-
circuit.stop_tone()
273+
cpx.stop_tone()
274274
"""
275275
# Stop playing any tones.
276276
if self.sample is not None and self.sample.playing:
277277
self.sample.stop()
278278
self._speaker_enable.value = False
279279

280280

281-
circuit = Express()
281+
cpx = Express()
282282
"""Object that is automatically created on import.
283283
284284
To use, simply import it from the module:
285285
286286
.. code-block:: python
287287
288-
from adafruit_circuitplayground.express import circuit
288+
from adafruit_circuitplayground.express import cpx
289289
"""

0 commit comments

Comments
 (0)