Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
1c9ee497
Commit
1c9ee497
authored
Apr 23, 2017
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drivers: Replace deprecated Pin.high()/low() methods with .__call__(1/0).
parent
bcf31a39
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
46 deletions
+46
-46
drivers/display/ssd1306.py
drivers/display/ssd1306.py
+11
-11
drivers/nrf24l01/nrf24l01.py
drivers/nrf24l01/nrf24l01.py
+20
-20
drivers/onewire/ds18x20.py
drivers/onewire/ds18x20.py
+3
-3
drivers/sdcard/sdcard.py
drivers/sdcard/sdcard.py
+12
-12
No files found.
drivers/display/ssd1306.py
View file @
1c9ee497
...
...
@@ -139,23 +139,23 @@ class SSD1306_SPI(SSD1306):
def
write_cmd
(
self
,
cmd
):
self
.
spi
.
init
(
baudrate
=
self
.
rate
,
polarity
=
0
,
phase
=
0
)
self
.
cs
.
high
(
)
self
.
dc
.
low
(
)
self
.
cs
.
low
(
)
self
.
cs
(
1
)
self
.
dc
(
0
)
self
.
cs
(
0
)
self
.
spi
.
write
(
bytearray
([
cmd
]))
self
.
cs
.
high
(
)
self
.
cs
(
1
)
def
write_data
(
self
,
buf
):
self
.
spi
.
init
(
baudrate
=
self
.
rate
,
polarity
=
0
,
phase
=
0
)
self
.
cs
.
high
(
)
self
.
dc
.
high
(
)
self
.
cs
.
low
(
)
self
.
cs
(
1
)
self
.
dc
(
1
)
self
.
cs
(
0
)
self
.
spi
.
write
(
buf
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
def
poweron
(
self
):
self
.
res
.
high
(
)
self
.
res
(
1
)
time
.
sleep_ms
(
1
)
self
.
res
.
low
(
)
self
.
res
(
0
)
time
.
sleep_ms
(
10
)
self
.
res
.
high
(
)
self
.
res
(
1
)
drivers/nrf24l01/nrf24l01.py
View file @
1c9ee497
...
...
@@ -66,8 +66,8 @@ class NRF24L01:
ce
.
init
(
ce
.
OUT
,
value
=
0
)
# reset everything
self
.
ce
.
low
(
)
self
.
cs
.
high
(
)
self
.
ce
(
0
)
self
.
cs
(
1
)
self
.
payload_size
=
payload_size
self
.
pipe0_read_addr
=
None
utime
.
sleep_ms
(
5
)
...
...
@@ -109,36 +109,36 @@ class NRF24L01:
self
.
spi
.
init
(
master
,
baudrate
=
baudrate
,
polarity
=
0
,
phase
=
0
)
def
reg_read
(
self
,
reg
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
readinto
(
self
.
buf
,
reg
)
self
.
spi
.
readinto
(
self
.
buf
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
return
self
.
buf
[
0
]
def
reg_write_bytes
(
self
,
reg
,
buf
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
readinto
(
self
.
buf
,
0x20
|
reg
)
self
.
spi
.
write
(
buf
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
return
self
.
buf
[
0
]
def
reg_write
(
self
,
reg
,
value
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
readinto
(
self
.
buf
,
0x20
|
reg
)
ret
=
self
.
buf
[
0
]
self
.
spi
.
readinto
(
self
.
buf
,
value
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
return
ret
def
flush_rx
(
self
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
readinto
(
self
.
buf
,
FLUSH_RX
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
def
flush_tx
(
self
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
readinto
(
self
.
buf
,
FLUSH_TX
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
# power is one of POWER_x defines; speed is one of SPEED_x defines
def
set_power_speed
(
self
,
power
,
speed
):
...
...
@@ -190,11 +190,11 @@ class NRF24L01:
self
.
flush_rx
()
self
.
flush_tx
()
self
.
ce
.
high
(
)
self
.
ce
(
1
)
utime
.
sleep_us
(
130
)
def
stop_listening
(
self
):
self
.
ce
.
low
(
)
self
.
ce
(
0
)
self
.
flush_tx
()
self
.
flush_rx
()
...
...
@@ -204,10 +204,10 @@ class NRF24L01:
def
recv
(
self
):
# get the data
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
readinto
(
self
.
buf
,
R_RX_PAYLOAD
)
buf
=
self
.
spi
.
read
(
self
.
payload_size
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
# clear RX ready flag
self
.
reg_write
(
STATUS
,
RX_DR
)
...
...
@@ -229,17 +229,17 @@ class NRF24L01:
self
.
reg_write
(
CONFIG
,
(
self
.
reg_read
(
CONFIG
)
|
PWR_UP
)
&
~
PRIM_RX
)
utime
.
sleep_us
(
150
)
# send the data
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
readinto
(
self
.
buf
,
W_TX_PAYLOAD
)
self
.
spi
.
write
(
buf
)
if
len
(
buf
)
<
self
.
payload_size
:
self
.
spi
.
write
(
b'
\x00
'
*
(
self
.
payload_size
-
len
(
buf
)))
# pad out data
self
.
cs
.
high
(
)
self
.
cs
(
1
)
# enable the chip so it can send the data
self
.
ce
.
high
(
)
self
.
ce
(
1
)
utime
.
sleep_us
(
15
)
# needs to be >10us
self
.
ce
.
low
(
)
self
.
ce
(
0
)
# returns None if send still in progress, 1 for success, 2 for fail
def
send_done
(
self
):
...
...
drivers/onewire/ds18x20.py
View file @
1c9ee497
...
...
@@ -7,11 +7,11 @@ temperature sensors. It supports multiple devices on the same 1-wire bus.
The following example assumes the ground of your DS18x20 is connected to
Y11, vcc is connected to Y9 and the data pin is connected to Y10.
>>> from
pyb
import Pin
>>> from
machine
import Pin
>>> gnd = Pin('Y11', Pin.OUT_PP)
>>> gnd.
low
()
>>> gnd.
off
()
>>> vcc = Pin('Y9', Pin.OUT_PP)
>>> vcc.
high
()
>>> vcc.
on
()
>>> from ds18x20 import DS18X20
>>> d = DS18X20(Pin('Y10'))
...
...
drivers/sdcard/sdcard.py
View file @
1c9ee497
...
...
@@ -130,7 +130,7 @@ class SDCard:
raise
OSError
(
"timeout waiting for v2 card"
)
def
cmd
(
self
,
cmd
,
arg
,
crc
,
final
=
0
,
release
=
True
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
# create and send the command
buf
=
self
.
cmdbuf
...
...
@@ -150,12 +150,12 @@ class SDCard:
for
j
in
range
(
final
):
self
.
spi
.
write
(
b'
\xff
'
)
if
release
:
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
return
response
# timeout
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
return
-
1
...
...
@@ -164,15 +164,15 @@ class SDCard:
self
.
spi
.
read
(
1
,
0xff
)
# ignore stuff byte
for
_
in
range
(
_CMD_TIMEOUT
):
if
self
.
spi
.
read
(
1
,
0xff
)[
0
]
==
0xff
:
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
return
0
# OK
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
return
1
# timeout
def
readinto
(
self
,
buf
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
# read until start byte (0xff)
while
self
.
spi
.
read
(
1
,
0xff
)[
0
]
!=
0xfe
:
...
...
@@ -186,11 +186,11 @@ class SDCard:
self
.
spi
.
write
(
b'
\xff
'
)
self
.
spi
.
write
(
b'
\xff
'
)
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
def
write
(
self
,
token
,
buf
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
# send: start of block, data, checksum
self
.
spi
.
read
(
1
,
token
)
...
...
@@ -200,7 +200,7 @@ class SDCard:
# check the response
if
(
self
.
spi
.
read
(
1
,
0xff
)[
0
]
&
0x1f
)
!=
0x05
:
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
return
...
...
@@ -208,18 +208,18 @@ class SDCard:
while
self
.
spi
.
read
(
1
,
0xff
)[
0
]
==
0
:
pass
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
def
write_token
(
self
,
token
):
self
.
cs
.
low
(
)
self
.
cs
(
0
)
self
.
spi
.
read
(
1
,
token
)
self
.
spi
.
write
(
b'
\xff
'
)
# wait for write to finish
while
self
.
spi
.
read
(
1
,
0xff
)[
0
]
==
0x00
:
pass
self
.
cs
.
high
(
)
self
.
cs
(
1
)
self
.
spi
.
write
(
b'
\xff
'
)
def
count
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment