46
46
except ImportError :
47
47
pass # not always supported by every board!
48
48
49
+ __version__ = "0.0.0-auto.0"
50
+ __repo__ = "https://github.com/adafruit/CircuitPython_SimpleIO.git"
51
+
52
+
49
53
def tone (pin , frequency , duration = 1 , length = 100 ):
50
54
"""
51
55
Generates a square wave of the specified frequency on a pin
52
56
53
- :param ~microcontroller.Pin Pin : Pin on which to output the tone
57
+ :param ~microcontroller.Pin pin : Pin on which to output the tone
54
58
:param float frequency: Frequency of tone in Hz
55
59
:param int length: Variable size buffer (optional)
56
60
:param int duration: Duration of tone in seconds (optional)
@@ -79,7 +83,6 @@ def tone(pin, frequency, duration=1, length=100):
79
83
dac .stop ()
80
84
81
85
82
-
83
86
def bitWrite (x , n , b ): #pylint: disable-msg=invalid-name
84
87
"""
85
88
Based on the Arduino bitWrite function, changes a specific bit of a value to 0 or 1.
@@ -97,7 +100,6 @@ def bitWrite(x, n, b): #pylint: disable-msg=invalid-name
97
100
return x
98
101
99
102
100
-
101
103
def shift_in (data_pin , clock , msb_first = True ):
102
104
"""
103
105
Shifts in a byte of data one bit at a time. Starts from either the LSB or
@@ -127,6 +129,7 @@ def shift_in(data_pin, clock, msb_first=True):
127
129
i += 1
128
130
return value
129
131
132
+
130
133
def shift_out (data_pin , clock , value , msb_first = True , bitcount = 8 ):
131
134
"""
132
135
Shifts out a byte of data one bit at a time. Data gets written to a data
@@ -194,6 +197,7 @@ def shift_out(data_pin, clock, value, msb_first=True, bitcount=8):
194
197
clock .value = True
195
198
clock .value = False
196
199
200
+
197
201
class DigitalOut :
198
202
"""
199
203
Simple digital output that is valid until reload.
@@ -215,6 +219,7 @@ def value(self):
215
219
def value (self , value ):
216
220
self .iopin .value = value
217
221
222
+
218
223
class DigitalIn :
219
224
"""
220
225
Simple digital input that is valid until reload.
@@ -235,6 +240,7 @@ def value(self):
235
240
def value (self , value ): #pylint: disable-msg=no-self-use, unused-argument
236
241
raise AttributeError ("Cannot set the value on a digital input." )
237
242
243
+
238
244
def map_range (x , in_min , in_max , out_min , out_max ):
239
245
"""
240
246
Maps a number from one range to another.
0 commit comments