Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
2cfb86b5
Commit
2cfb86b5
authored
Feb 20, 2015
by
devsaurus
Browse files
improve device and page buffer initialization
parent
e3ed4fc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/u8g.c
View file @
2cfb86b5
...
@@ -1029,20 +1029,20 @@ static int lu8g_ssd1306_128x64_i2c( lua_State *L )
...
@@ -1029,20 +1029,20 @@ static int lu8g_ssd1306_128x64_i2c( lua_State *L )
// this consumes heap even when the device is not used at all
// this consumes heap even when the device is not used at all
#if 1
#if 1
// build device entry
// build device entry
lud
->
dev
.
dev_fn
=
u8g_dev_ssd1306_128x64_fn
;
lud
->
dev
=
(
u8g_dev_t
){
u8g_dev_ssd1306_128x64_fn
,
&
(
lud
->
pb
),
U8G_COM_SSD_I2C
};
lud
->
dev
.
dev_mem
=
&
(
lud
->
pb
);
lud
->
dev
.
com_fn
=
U8G_COM_SSD_I2C
;
// populate and allocate page buffer
// then allocate and populate page buffer
// constants taken from u8g_dev_ssd1306_128x64.c:
lud
->
pb
.
width
=
128
;
// WIDTH in u8g_dev_ssd1306_128x64.c
// PAGE_HEIGHT
// | Height
// | | WIDTH
// | | |
lud
->
pb
=
(
u8g_pb_t
){
{
8
,
64
,
0
,
0
,
0
},
128
,
NULL
};
//
if
((
lud
->
pb
.
buf
=
(
void
*
)
c_zalloc
(
lud
->
pb
.
width
))
==
NULL
)
if
((
lud
->
pb
.
buf
=
(
void
*
)
c_zalloc
(
lud
->
pb
.
width
))
==
NULL
)
return
luaL_error
(
L
,
"out of memory"
);
return
luaL_error
(
L
,
"out of memory"
);
lud
->
pb
.
p
.
page_height
=
8
;
// PAGE_HEIGHT in u8g_dev_ssd1306_128x64.c
// and finally init device using specific interface init function
lud
->
pb
.
p
.
total_height
=
64
;
// HEIGHT in u8g_dev_ssd1306_128x64.c
lud
->
pb
.
p
.
page_y0
=
0
;
lud
->
pb
.
p
.
page_y1
=
0
;
lud
->
pb
.
p
.
page
=
0
;
u8g_InitI2C
(
LU8G
,
&
(
lud
->
dev
),
U8G_I2C_OPT_NONE
);
u8g_InitI2C
(
LU8G
,
&
(
lud
->
dev
),
U8G_I2C_OPT_NONE
);
#else
#else
u8g_InitI2C
(
LU8G
,
&
u8g_dev_ssd1306_128x64_i2c
,
U8G_I2C_OPT_NONE
);
u8g_InitI2C
(
LU8G
,
&
u8g_dev_ssd1306_128x64_i2c
,
U8G_I2C_OPT_NONE
);
...
...
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