Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD assignment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
o2-omisanya
DD assignment
Commits
34365647
Commit
34365647
authored
2 years ago
by
o2-omisanya
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
1a4e5015
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
oled-dd.py
+75
-0
75 additions, 0 deletions
oled-dd.py
with
75 additions
and
0 deletions
oled-dd.py
0 → 100644
+
75
−
0
View file @
34365647
Python
3.11
.
1
(
v3
.
11.1
:
a7a450f84a
,
Dec
6
2022
,
15
:
24
:
06
)
[
Clang
13.0
.
0
(
clang
-
1300.0
.
29.30
)]
on
darwin
Type
"
help
"
,
"
copyright
"
,
"
credits
"
or
"
license()
"
for
more
information
.
>>>
//
OLED
Initialization
-
Initialize
OLED
Display
...
static
PyObject
*
oled_init
(
PyObject
*
self
,
PyObject
*
args
)
{
...
int
channel
,
address
,
type
,
flip
,
invert
;
...
...
if
(
!
PyArg_ParseTuple
(
args
,
"
iiiii
"
,
&
channel
,
&
address
,
&
type
,
&
flip
,
&
invert
))
{
...
return
NULL
;
...
}
...
...
int
ret
=
oledInit
(
channel
,
address
,
type
,
flip
,
invert
);
...
return
PyBool_FromLong
(
!
ret
);
...
}
...
...
//
OLED
Shutdown
-
Shutdown
the
OLED
Display
...
static
PyObject
*
oled_shutdown
(
PyObject
*
self
)
{
...
oledShutdown
();
...
Py_RETURN_NONE
;
...
}
...
...
//
OLED
Fill
-
Fill
the
display
with
a
byte
pattern
...
static
PyObject
*
oled_fill
(
PyObject
*
self
,
PyObject
*
args
)
{
...
unsigned
char
pattern
;
...
if
(
!
PyArg_ParseTuple
(
args
,
"
b
"
,
&
pattern
))
{
...
return
NULL
;
...
}
...
return
PyBool_FromLong
(
!
oledFill
(
pattern
));
...
}
...
...
//
OLED
Write
String
-
Writes
a
string
at
the
specified
row
and
column
with
a
specific
size
to
the
display
...
static
PyObject
*
oled_write_string
(
PyObject
*
self
,
PyObject
*
args
)
{
...
int
row
,
column
;
...
char
*
msg
;
...
int
size
;
...
if
(
!
PyArg_ParseTuple
(
args
,
"
iisi
"
,
&
row
,
&
column
,
&
msg
,
&
size
))
{
...
printf
(
"
Failed to parse arguments
"
);
...
return
NULL
;
}
return
PyBool_FromLong
(
!
oledWriteString
(
row
,
column
,
msg
,
size
));
}
//
OLED
Draw
Line
-
Draw
a
line
using
the
DDA
algorithm
from
(
x0
,
y0
)
to
(
x1
,
y1
)
static
PyObject
*
oled_draw_line
(
PyObject
*
self
,
PyObject
*
args
)
{
int
x0
,
y0
;
int
x1
,
y1
;
unsigned
char
pixel
;
if
(
!
PyArg_ParseTuple
(
args
,
"
iiiib
"
,
&
x0
,
&
y0
,
&
x1
,
&
y1
,
&
pixel
))
{
return
NULL
;
}
return
PyBool_FromLong
(
!
oledDrawLine
(
x0
,
y0
,
x1
,
y1
,
pixel
));
}
/*
Define
all
the
functions
available
in
the
module
*/
static
struct
PyMethodDef
dd_oled_methods
[]
=
{
{
"
init
"
,
oled_init
,
METH_VARARGS
,
"
Initialize OLED display
"
},
{
"
shutdown
"
,
oled_shutdown
,
METH_NOARGS
,
"
Shutdown OLED display
"
},
{
"
fill
"
,
oled_fill
,
METH_VARARGS
,
"
Fill the OLED frame with a byte pattern
"
},
{
"
write_string
"
,
oled_write_string
,
METH_VARARGS
,
"
Write the given string to the display
"
},
{
"
draw_line
"
,
oled_draw_line
,
METH_VARARGS
,
"
Draw a line at the given position
"
},
{
NULL
,
NULL
,
0
,
NULL
}
};
/*
Define
module
information
*/
static
struct
PyModuleDef
dd_oled_module
=
{
PyModuleDef_HEAD_INIT
,
"
dd_oled
"
,
"
Python interface for the oled module
"
,
-
1
,
dd_oled_methods
};
PyMODINIT_FUNC
PyInit_dd_oled
(
void
)
{
return
PyModule_Create
(
&
dd_oled_module
);
}
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