Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
4702c1f1
Commit
4702c1f1
authored
Nov 20, 2017
by
devsaurus
Browse files
align source from esp8266 port
parent
e2a4c1bc
Changes
2
Show whitespace changes
Inline
Side-by-side
components/modules/u8g2.c
View file @
4702c1f1
// Module for binding the u8g2 library
// Note: This file is intended to be shared between esp8266 and esp32 platform
#include "module.h"
#include "lauxlib.h"
...
...
@@ -10,9 +11,13 @@
#include "u8g2_displays.h"
#include "u8g2_fonts.h"
#ifdef ESP_PLATFORM
// ESP32
#include "spi_common.h"
#include "sdkconfig.h"
#endif
#ifndef CONFIG_LUA_MODULE_U8G2
// ignore unused functions if u8g2 module will be skipped anyhow
#pragma GCC diagnostic ignored "-Wunused-function"
...
...
@@ -616,6 +621,7 @@ static int ldisplay_i2c( lua_State *L, display_setup_fn_t setup_fn )
u8g2_t
*
u8g2
=
(
u8g2_t
*
)
ext_u8g2
;
u8x8_t
*
u8x8
=
(
u8x8_t
*
)
u8g2
;
setup_fn
(
u8g2
,
U8G2_R0
,
u8x8_byte_nodemcu_i2c
,
u8x8_gpio_and_delay_nodemcu
);
/* prepare overlay data */
...
...
@@ -653,24 +659,45 @@ static int ldisplay_spi( lua_State *L, display_setup_fn_t setup_fn )
{
int
stack
=
0
;
#ifndef ESP_PLATFORM
// ESP8266
typedef
struct
{
int
host
;
}
lspi_host_t
;
lspi_host_t
host_elem
;
lspi_host_t
*
host
=
&
host_elem
;
#else
// ESP32
lspi_host_t
*
host
=
NULL
;
#endif
int
host_ref
=
LUA_NOREF
;
int
cs
=
-
1
;
int
dc
=
-
1
;
int
res
=
-
1
;
int
rfb_cb_ref
=
LUA_NOREF
;
int
get_spi_pins
;
if
(
lua_type
(
L
,
++
stack
)
==
LUA_TUSERDATA
)
{
if
(
lua_type
(
L
,
++
stack
)
==
LUA_TUSERDATA
)
{
host
=
(
lspi_host_t
*
)
luaL_checkudata
(
L
,
stack
,
"spi.master"
);
/* reference host object to avoid automatic gc */
lua_pushvalue
(
L
,
stack
);
host_ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
get_spi_pins
=
1
;
}
else
if
(
lua_type
(
L
,
stack
)
==
LUA_TNUMBER
)
{
host
->
host
=
luaL_checkint
(
L
,
stack
);
get_spi_pins
=
1
;
}
else
{
get_spi_pins
=
0
;
stack
--
;
}
if
(
get_spi_pins
)
{
cs
=
luaL_checkint
(
L
,
++
stack
);
dc
=
luaL_checkint
(
L
,
++
stack
);
res
=
luaL_optint
(
L
,
++
stack
,
-
1
);
}
else
stack
--
;
}
if
(
lua_isfunction
(
L
,
++
stack
))
{
lua_pushvalue
(
L
,
stack
);
rfb_cb_ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
...
...
@@ -687,6 +714,7 @@ static int ldisplay_spi( lua_State *L, display_setup_fn_t setup_fn )
u8g2_t
*
u8g2
=
(
u8g2_t
*
)
ext_u8g2
;
u8x8_t
*
u8x8
=
(
u8x8_t
*
)
u8g2
;
setup_fn
(
u8g2
,
U8G2_R0
,
u8x8_byte_nodemcu_spi
,
u8x8_gpio_and_delay_nodemcu
);
/* prepare overlay data */
...
...
components/platform/u8x8_nodemcu_hal.c
View file @
4702c1f1
...
...
@@ -28,7 +28,7 @@ uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
memset
(
(
void
*
)
&
cfg
,
0
,
sizeof
(
cfg
)
);
cfg
.
pin_bit_mask
=
1ULL
<<
u8x8
->
pins
[
idx
];
if
(
idx
==
U8X8_PIN_I2C_CLOCK
||
idx
==
U8X8_PIN_I2C_
CLOCK
)
{
if
(
idx
==
U8X8_PIN_I2C_CLOCK
||
idx
==
U8X8_PIN_I2C_
DATA
)
{
cfg
.
mode
=
GPIO_MODE_OUTPUT_OD
;
cfg
.
pull_up_en
=
GPIO_PULLUP_ENABLE
;
}
else
{
...
...
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