Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
card10
micropython
Commits
43c8f545
Commit
43c8f545
authored
May 22, 2016
by
Radomir Dopieralski
Committed by
Damien George
Jun 3, 2016
Browse files
Options
Downloads
Patches
Plain Diff
drivers/display/ssd1306: update SSD1306_SPI to work with new API
Makes it work on the ESP8266.
parent
ddadbaed
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/display/ssd1306.py
+20
-11
20 additions, 11 deletions
drivers/display/ssd1306.py
with
20 additions
and
11 deletions
drivers/display/ssd1306.py
+
20
−
11
View file @
43c8f545
...
...
@@ -3,6 +3,7 @@
import
time
import
framebuf
# register definitions
SET_CONTRAST
=
const
(
0x81
)
SET_ENTIRE_ON
=
const
(
0xa4
)
...
...
@@ -22,6 +23,7 @@ SET_PRECHARGE = const(0xd9)
SET_VCOM_DESEL
=
const
(
0xdb
)
SET_CHARGE_PUMP
=
const
(
0x8d
)
class
SSD1306
:
def
__init__
(
self
,
height
,
external_vcc
):
self
.
width
=
128
...
...
@@ -91,6 +93,7 @@ class SSD1306:
def
text
(
self
,
string
,
x
,
y
,
col
=
1
):
self
.
framebuf
.
text
(
string
,
x
,
y
,
col
)
class
SSD1306_I2C
(
SSD1306
):
def
__init__
(
self
,
height
,
i2c
,
addr
=
0x3c
,
external_vcc
=
False
):
self
.
i2c
=
i2c
...
...
@@ -114,27 +117,34 @@ class SSD1306_I2C(SSD1306):
def
poweron
(
self
):
pass
# TODO convert this class to use the new hardware API
class
SSD1306_SPI
(
SSD1306
):
def
__init__
(
self
,
height
,
spi
,
dc
,
res
,
cs
=
None
,
external_vcc
=
False
):
rate
=
10
*
1024
*
1024
spi
.
init
(
spi
.
MASTER
,
baudrate
=
rate
,
polarity
=
0
,
phase
=
0
)
dc
.
init
(
dc
.
OUT
,
dc
.
PULL_NONE
,
value
=
0
)
res
.
init
(
res
.
OUT
,
dc
.
PULL_NONE
,
value
=
0
)
if
cs
is
not
None
:
cs
.
init
(
cs
.
OUT
,
cs
.
PULL_NONE
,
value
=
0
)
def
__init__
(
self
,
height
,
spi
,
dc
,
res
,
cs
,
external_vcc
=
False
):
self
.
rate
=
10
*
1024
*
1024
dc
.
init
(
dc
.
OUT
,
value
=
0
)
res
.
init
(
res
.
OUT
,
value
=
0
)
cs
.
init
(
cs
.
OUT
,
value
=
1
)
self
.
spi
=
spi
self
.
dc
=
dc
self
.
res
=
res
self
.
cs
=
cs
super
().
__init__
(
height
,
external_vcc
)
def
write_cmd
(
self
,
cmd
):
self
.
spi
.
init
(
baudrate
=
self
.
rate
,
polarity
=
0
,
phase
=
0
)
self
.
cs
.
high
()
self
.
dc
.
low
()
self
.
spi
.
send
(
cmd
)
self
.
cs
.
low
()
self
.
spi
.
write
(
bytearray
([
cmd
]))
self
.
cs
.
high
()
def
write_data
(
self
,
buf
):
self
.
spi
.
init
(
baudrate
=
self
.
rate
,
polarity
=
0
,
phase
=
0
)
self
.
cs
.
high
()
self
.
dc
.
high
()
self
.
spi
.
send
(
buf
)
self
.
cs
.
low
()
self
.
spi
.
write
(
buf
)
self
.
cs
.
high
()
def
poweron
(
self
):
self
.
res
.
high
()
...
...
@@ -142,4 +152,3 @@ class SSD1306_SPI(SSD1306):
self
.
res
.
low
()
time
.
sleep_ms
(
10
)
self
.
res
.
high
()
time
.
sleep_ms
(
10
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment