pkg: u8g2: update package structure + version
This commit is contained in:
parent
46938f6153
commit
5c9566264e
@ -1,11 +1,16 @@
|
|||||||
PKG_NAME=u8g2
|
PKG_NAME=u8g2
|
||||||
PKG_URL=https://github.com/olikraus/u8g2
|
PKG_URL=https://github.com/olikraus/u8g2
|
||||||
PKG_VERSION=4dc79943020d9512207aea4cf914740556173793
|
PKG_VERSION=f08ff974c03e5c848bc5d2ae3fddb6a97897881a
|
||||||
PKG_LICENSE=BSD-2-Clause
|
PKG_LICENSE=BSD-2-Clause
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
all: git-download
|
all: git-download
|
||||||
|
cp $(RIOTBASE)/pkg/u8g2/src/Makefile $(PKG_BUILDDIR)/Makefile
|
||||||
|
cp $(RIOTBASE)/pkg/u8g2/src/csrc/Makefile $(PKG_BUILDDIR)/csrc/Makefile
|
||||||
|
cp $(RIOTBASE)/pkg/u8g2/src/csrc/u8g2_riotos.c $(PKG_BUILDDIR)/csrc/u8g2_riotos.c
|
||||||
|
cp $(RIOTBASE)/pkg/u8g2/src/sys/sdl/common/Makefile $(PKG_BUILDDIR)/sys/sdl/common/Makefile
|
||||||
|
cp $(RIOTBASE)/pkg/u8g2/src/sys/utf8/common/Makefile $(PKG_BUILDDIR)/sys/utf8/common/Makefile
|
||||||
"$(MAKE)" -C $(PKG_BUILDDIR)
|
"$(MAKE)" -C $(PKG_BUILDDIR)
|
||||||
|
|
||||||
include $(RIOTBASE)/pkg/pkg.mk
|
include $(RIOTBASE)/pkg/pkg.mk
|
||||||
|
|||||||
@ -2,5 +2,5 @@ INCLUDES += -I$(PKGDIRBASE)/u8g2/csrc
|
|||||||
|
|
||||||
# Link SDL if enabled.
|
# Link SDL if enabled.
|
||||||
ifneq (,$(filter u8g2_sdl,$(USEMODULE)))
|
ifneq (,$(filter u8g2_sdl,$(USEMODULE)))
|
||||||
LINKFLAGS += `sdl-config --libs`
|
LINKFLAGS += `sdl2-config --libs`
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -53,7 +53,7 @@ u8g2_SetDevice(&u8g2, SPI_DEV(0));
|
|||||||
For targets without an I2C or SPI, virtual displays are available. These displays are part of U8g2, but are not compiled by default.
|
For targets without an I2C or SPI, virtual displays are available. These displays are part of U8g2, but are not compiled by default.
|
||||||
|
|
||||||
* By adding `USEMODULE += u8g2_utf8`, a terminal display is used as virtual display, using UTF8 block characters that are printed to stdout.
|
* By adding `USEMODULE += u8g2_utf8`, a terminal display is used as virtual display, using UTF8 block characters that are printed to stdout.
|
||||||
* By adding `USEMODULE += u8g2_sdl`, a SDL virtual display will be used. This is only available on native targets that have SDL installed. It uses `sdl-config` to find the headers and libraries. Note that RIOT-OS builds 32-bit binaries and requires 32-bit SDL libraries.
|
* By adding `USEMODULE += u8g2_sdl`, a SDL virtual display will be used. This is only available on native targets that have SDL installed. It uses `sdl2-config` to find the headers and libraries. Note that RIOT-OS builds 32-bit binaries and requires 32-bit SDL libraries.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
```
|
```
|
||||||
|
|||||||
83
pkg/u8g2/patches/0001-add-RIOT-OS-interface.patch
Normal file
83
pkg/u8g2/patches/0001-add-RIOT-OS-interface.patch
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
From a17e644521b91d5f5fc35e567375ac5998f24b66 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Bas Stottelaar <basstottelaar@gmail.com>
|
||||||
|
Date: Sun, 11 Mar 2018 22:13:10 +0100
|
||||||
|
Subject: [PATCH 1/1] add RIOT-OS interface.
|
||||||
|
|
||||||
|
---
|
||||||
|
csrc/u8g2.h | 3 +++
|
||||||
|
csrc/u8x8.h | 17 ++++++++++++++---
|
||||||
|
2 files changed, 17 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/csrc/u8g2.h b/csrc/u8g2.h
|
||||||
|
index 48239709..c8934cf7 100644
|
||||||
|
--- a/csrc/u8g2.h
|
||||||
|
+++ b/csrc/u8g2.h
|
||||||
|
@@ -388,6 +388,9 @@ void u8g2_ClearDisplay(u8g2_t *u8g2);
|
||||||
|
#define u8g2_SetMenuDownPin(u8g2, val) u8x8_SetMenuDownPin(u8g2_GetU8x8(u8g2), (val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#define u8g2_SetPins(u8x8,pins,pins_enabled) u8x8_SetPins(u8g2_GetU8x8(&u8g2), pins, pins_enabled)
|
||||||
|
+#define u8g2_SetDevice(u8x8,device) u8x8_SetDevice(u8g2_GetU8x8(&u8g2), device)
|
||||||
|
+
|
||||||
|
/*==========================================*/
|
||||||
|
/* u8g2_setup.c */
|
||||||
|
|
||||||
|
diff --git a/csrc/u8x8.h b/csrc/u8x8.h
|
||||||
|
index bbeff59f..ae65bbb1 100644
|
||||||
|
--- a/csrc/u8x8.h
|
||||||
|
+++ b/csrc/u8x8.h
|
||||||
|
@@ -111,6 +111,8 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
+#include "periph/gpio.h"
|
||||||
|
+
|
||||||
|
#if defined(__GNUC__) && defined(__AVR__)
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#endif
|
||||||
|
@@ -174,9 +176,9 @@ uint8_t u8x8_pgm_read_esp(const uint8_t * addr); /* u8x8_8x8.c */
|
||||||
|
# define U8X8_PROGMEM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#ifdef ARDUINO
|
||||||
|
-#define U8X8_USE_PINS
|
||||||
|
-#endif
|
||||||
|
+//#ifdef ARDUINO
|
||||||
|
+//#define U8X8_USE_PINS
|
||||||
|
+//#endif
|
||||||
|
|
||||||
|
/*==========================================*/
|
||||||
|
/* U8X8 typedefs and data structures */
|
||||||
|
@@ -342,6 +344,10 @@ struct u8x8_struct
|
||||||
|
#ifdef U8X8_USE_PINS
|
||||||
|
uint8_t pins[U8X8_PIN_CNT]; /* defines a pinlist: Mainly a list of pins for the Arduino Envionment, use U8X8_PIN_xxx to access */
|
||||||
|
#endif
|
||||||
|
+
|
||||||
|
+gpio_t* pins;
|
||||||
|
+uint32_t pins_enabled;
|
||||||
|
+uint32_t dev;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef U8X8_WITH_USER_PTR
|
||||||
|
@@ -371,6 +377,8 @@ struct u8x8_struct
|
||||||
|
#define u8x8_SetMenuDownPin(u8x8, val) u8x8_SetPin((u8x8),U8X8_PIN_MENU_DOWN,(val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#define u8x8_SetPins(u8x8,pins,pins_enabled) {(u8x8)->pins = (pins); (u8x8)->pins_enabled = (pins_enabled);}
|
||||||
|
+#define u8x8_SetDevice(u8x8,device) ((u8x8)->dev = device)
|
||||||
|
|
||||||
|
/*==========================================*/
|
||||||
|
|
||||||
|
@@ -973,6 +981,9 @@ extern const uint8_t u8x8_font_pxplustandynewtv_u[] U8X8_FONT_SECTION("u8x8_font
|
||||||
|
|
||||||
|
/* end font list */
|
||||||
|
|
||||||
|
+extern uint8_t u8x8_byte_riotos_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||||
|
+extern uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||||
|
+extern uint8_t u8x8_byte_riotos_hw_i2c(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.14.2
|
||||||
|
|
||||||
@ -1,76 +0,0 @@
|
|||||||
From 5c168fc6d96d8dc84907e667a70b3a85b8402270 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Peter Kietzmann <peter.kietzmann@haw-hamburg.de>
|
|
||||||
Date: Wed, 6 Sep 2017 20:23:56 +0200
|
|
||||||
Subject: [PATCH 1/3] u8g2: add RIOT makefiles
|
|
||||||
|
|
||||||
---
|
|
||||||
Makefile | 22 ++++++++++++++++++++++
|
|
||||||
csrc/Makefile | 3 +++
|
|
||||||
sys/sdl/common/Makefile | 5 +++++
|
|
||||||
sys/utf8/common/Makefile | 3 +++
|
|
||||||
4 files changed, 33 insertions(+)
|
|
||||||
create mode 100644 Makefile
|
|
||||||
create mode 100644 csrc/Makefile
|
|
||||||
create mode 100644 sys/sdl/common/Makefile
|
|
||||||
create mode 100644 sys/utf8/common/Makefile
|
|
||||||
|
|
||||||
diff --git a/Makefile b/Makefile
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..ec64fab
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/Makefile
|
|
||||||
@@ -0,0 +1,22 @@
|
|
||||||
+DIRS += csrc
|
|
||||||
+
|
|
||||||
+# SDL can be used as a virtual display, but is for native target only.
|
|
||||||
+ifneq (,$(filter u8g2_sdl,$(USEMODULE)))
|
|
||||||
+ DIRS += sys/sdl/common
|
|
||||||
+endif
|
|
||||||
+
|
|
||||||
+# UTF8 virtual display is not part of core. Therefore it is a separate module.
|
|
||||||
+ifneq (,$(filter u8g2_utf8,$(USEMODULE)))
|
|
||||||
+ DIRS += sys/utf8/common
|
|
||||||
+endif
|
|
||||||
+
|
|
||||||
+# Compiling U8g2 will generate a lot of compiler warnings, which are treated
|
|
||||||
+# as errors. For the sake of simplicity, ignore them.
|
|
||||||
+CFLAGS += -Wno-empty-translation-unit \
|
|
||||||
+ -Wno-newline-eof \
|
|
||||||
+ -Wno-unused-parameter \
|
|
||||||
+ -Wno-unused \
|
|
||||||
+ -Wno-overlength-strings \
|
|
||||||
+ -Wno-pointer-arith
|
|
||||||
+
|
|
||||||
+include $(RIOTBASE)/Makefile.base
|
|
||||||
diff --git a/csrc/Makefile b/csrc/Makefile
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..1023a87
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/csrc/Makefile
|
|
||||||
@@ -0,0 +1,3 @@
|
|
||||||
+MODULE = u8g2
|
|
||||||
+
|
|
||||||
+include $(RIOTBASE)/Makefile.base
|
|
||||||
diff --git a/sys/sdl/common/Makefile b/sys/sdl/common/Makefile
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..ce8b90b
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/sys/sdl/common/Makefile
|
|
||||||
@@ -0,0 +1,5 @@
|
|
||||||
+MODULE = u8g2_sdl
|
|
||||||
+
|
|
||||||
+CFLAGS += `sdl-config --cflags`
|
|
||||||
+
|
|
||||||
+include $(RIOTBASE)/Makefile.base
|
|
||||||
diff --git a/sys/utf8/common/Makefile b/sys/utf8/common/Makefile
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..32e7913
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/sys/utf8/common/Makefile
|
|
||||||
@@ -0,0 +1,3 @@
|
|
||||||
+MODULE = u8g2_utf8
|
|
||||||
+
|
|
||||||
+include $(RIOTBASE)/Makefile.base
|
|
||||||
--
|
|
||||||
2.7.4
|
|
||||||
|
|
||||||
@ -1,255 +0,0 @@
|
|||||||
From 6a09e7bee194681f63781dd0af6c154f2f4e519c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Peter Kietzmann <peter.kietzmann@haw-hamburg.de>
|
|
||||||
Date: Wed, 6 Sep 2017 20:26:46 +0200
|
|
||||||
Subject: [PATCH 2/3] add RIOT interface
|
|
||||||
|
|
||||||
---
|
|
||||||
csrc/u8g2.h | 3 +
|
|
||||||
csrc/u8g2_riotos.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
csrc/u8x8.h | 17 +++++-
|
|
||||||
3 files changed, 181 insertions(+), 3 deletions(-)
|
|
||||||
create mode 100644 csrc/u8g2_riotos.c
|
|
||||||
|
|
||||||
diff --git a/csrc/u8g2.h b/csrc/u8g2.h
|
|
||||||
index 6ff3f91..d284619 100644
|
|
||||||
--- a/csrc/u8g2.h
|
|
||||||
+++ b/csrc/u8g2.h
|
|
||||||
@@ -387,6 +387,9 @@ void u8g2_ClearDisplay(u8g2_t *u8g2);
|
|
||||||
#define u8g2_SetMenuDownPin(u8g2, val) u8x8_SetMenuDownPin(u8g2_GetU8x8(u8g2), (val))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#define u8g2_SetPins(u8x8,pins,pins_enabled) u8x8_SetPins(u8g2_GetU8x8(&u8g2), pins, pins_enabled)
|
|
||||||
+#define u8g2_SetDevice(u8x8,device) u8x8_SetDevice(u8g2_GetU8x8(&u8g2), device)
|
|
||||||
+
|
|
||||||
/*==========================================*/
|
|
||||||
/* u8g2_setup.c */
|
|
||||||
|
|
||||||
diff --git a/csrc/u8g2_riotos.c b/csrc/u8g2_riotos.c
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..bd06ccb
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/csrc/u8g2_riotos.c
|
|
||||||
@@ -0,0 +1,164 @@
|
|
||||||
+#include "u8g2.h"
|
|
||||||
+
|
|
||||||
+#include "xtimer.h"
|
|
||||||
+
|
|
||||||
+#include "periph/spi.h"
|
|
||||||
+#include "periph/i2c.h"
|
|
||||||
+#include "periph/gpio.h"
|
|
||||||
+
|
|
||||||
+#include <stdio.h>
|
|
||||||
+
|
|
||||||
+#ifdef SPI_NUMOF
|
|
||||||
+static spi_clk_t u8x8_pulse_width_to_spi_speed(uint32_t pulse_width)
|
|
||||||
+{
|
|
||||||
+ uint32_t cycle_time = 2 * pulse_width;
|
|
||||||
+
|
|
||||||
+ if (cycle_time < 100) {
|
|
||||||
+ return SPI_CLK_10MHZ;
|
|
||||||
+ } else if (cycle_time < 200) {
|
|
||||||
+ return SPI_CLK_5MHZ;
|
|
||||||
+ } else if (cycle_time < 1000) {
|
|
||||||
+ return SPI_CLK_1MHZ;
|
|
||||||
+ } else if (cycle_time < 2500) {
|
|
||||||
+ return SPI_CLK_400KHZ;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return SPI_CLK_100KHZ;
|
|
||||||
+}
|
|
||||||
+#endif /* SPI_NUMOF */
|
|
||||||
+
|
|
||||||
+#ifdef SPI_NUMOF
|
|
||||||
+static spi_mode_t u8x8_spi_mode_to_spi_conf(uint32_t spi_mode)
|
|
||||||
+{
|
|
||||||
+ return (spi_mode_t) spi_mode;
|
|
||||||
+}
|
|
||||||
+#endif /* SPI_NUMOF */
|
|
||||||
+
|
|
||||||
+static void u8x8_enable_pins(gpio_t* pins, uint32_t pins_enabled)
|
|
||||||
+{
|
|
||||||
+ uint8_t i;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < 32; i++) {
|
|
||||||
+ if (pins_enabled & (1 << i)) {
|
|
||||||
+ if (pins[i] != GPIO_UNDEF) {
|
|
||||||
+ if (i < U8X8_PIN_OUTPUT_CNT) {
|
|
||||||
+ gpio_init(pins[i], GPIO_OUT);
|
|
||||||
+ } else {
|
|
||||||
+ gpio_init(pins[i], GPIO_IN);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
+{
|
|
||||||
+ (void) arg_ptr;
|
|
||||||
+
|
|
||||||
+ switch (msg) {
|
|
||||||
+ case U8X8_MSG_GPIO_AND_DELAY_INIT:
|
|
||||||
+ u8x8_enable_pins(u8g2->pins, u8g2->pins_enabled);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_DELAY_MILLI:
|
|
||||||
+ xtimer_usleep(arg_int * 1000);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_DELAY_10MICRO:
|
|
||||||
+ xtimer_usleep(arg_int * 10);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_DELAY_100NANO:
|
|
||||||
+ xtimer_nanosleep(arg_int * 100);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_GPIO_CS:
|
|
||||||
+ if (u8g2->pins_enabled & (1 << U8X8_PIN_CS)) {
|
|
||||||
+ gpio_write(u8g2->pins[U8X8_PIN_CS], arg_int);
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_GPIO_DC:
|
|
||||||
+ if (u8g2->pins_enabled & (1 << U8X8_PIN_DC)) {
|
|
||||||
+ gpio_write(u8g2->pins[U8X8_PIN_DC], arg_int);
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_GPIO_RESET:
|
|
||||||
+ if (u8g2->pins_enabled & (1 << U8X8_PIN_RESET)) {
|
|
||||||
+ gpio_write(u8g2->pins[U8X8_PIN_RESET], arg_int);
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+#ifdef SPI_NUMOF
|
|
||||||
+uint8_t u8x8_byte_riotos_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
+{
|
|
||||||
+ spi_t dev = (spi_t) u8g2->dev;
|
|
||||||
+
|
|
||||||
+ switch (msg) {
|
|
||||||
+ case U8X8_MSG_BYTE_SEND:
|
|
||||||
+ spi_transfer_bytes(dev, GPIO_UNDEF, true,
|
|
||||||
+ arg_ptr, NULL, (size_t)arg_int);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_INIT:
|
|
||||||
+ spi_init_pins(dev);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
+ u8x8_gpio_SetDC(u8g2, arg_int);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
+ spi_acquire(dev, GPIO_UNDEF,
|
|
||||||
+ u8x8_spi_mode_to_spi_conf(u8g2->display_info->spi_mode),
|
|
||||||
+ u8x8_pulse_width_to_spi_speed(u8g2->display_info->sck_pulse_width_ns));
|
|
||||||
+
|
|
||||||
+ u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_enable_level);
|
|
||||||
+ u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->post_chip_enable_wait_ns, NULL);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
+ u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->pre_chip_disable_wait_ns, NULL);
|
|
||||||
+ u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_disable_level);
|
|
||||||
+
|
|
||||||
+ spi_release(dev);
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+#endif /* SPI_NUMOF */
|
|
||||||
+
|
|
||||||
+#ifdef I2C_NUMOF
|
|
||||||
+uint8_t u8x8_byte_riotos_hw_i2c(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
|
||||||
+{
|
|
||||||
+ static uint8_t buffer[255];
|
|
||||||
+ static uint8_t index;
|
|
||||||
+
|
|
||||||
+ i2c_t dev = (i2c_t) u8g2->dev;
|
|
||||||
+
|
|
||||||
+ switch (msg) {
|
|
||||||
+ case U8X8_MSG_BYTE_SEND:
|
|
||||||
+ while (arg_int--) {
|
|
||||||
+ buffer[index++] = *((uint8_t *)arg_ptr++);
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_INIT:
|
|
||||||
+ i2c_init_master(dev, I2C_SPEED_FAST);
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_SET_DC:
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_START_TRANSFER:
|
|
||||||
+ i2c_acquire(dev);
|
|
||||||
+ index = 0;
|
|
||||||
+ break;
|
|
||||||
+ case U8X8_MSG_BYTE_END_TRANSFER:
|
|
||||||
+ i2c_write_bytes(dev, u8x8_GetI2CAddress(u8g2), buffer, index);
|
|
||||||
+ i2c_release(dev);
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+#endif /* I2C_NUMOF */
|
|
||||||
diff --git a/csrc/u8x8.h b/csrc/u8x8.h
|
|
||||||
index a4a99b7..e508664 100644
|
|
||||||
--- a/csrc/u8x8.h
|
|
||||||
+++ b/csrc/u8x8.h
|
|
||||||
@@ -111,6 +111,8 @@
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
+#include "periph/gpio.h"
|
|
||||||
+
|
|
||||||
#if defined(__GNUC__) && defined(__AVR__)
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#endif
|
|
||||||
@@ -174,9 +176,9 @@ uint8_t u8x8_pgm_read_esp(const uint8_t * addr); /* u8x8_8x8.c */
|
|
||||||
# define U8X8_PROGMEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
-#ifdef ARDUINO
|
|
||||||
-#define U8X8_USE_PINS
|
|
||||||
-#endif
|
|
||||||
+//#ifdef ARDUINO
|
|
||||||
+//#define U8X8_USE_PINS
|
|
||||||
+//#endif
|
|
||||||
|
|
||||||
/*==========================================*/
|
|
||||||
/* U8X8 typedefs and data structures */
|
|
||||||
@@ -342,6 +344,10 @@ struct u8x8_struct
|
|
||||||
#ifdef U8X8_USE_PINS
|
|
||||||
uint8_t pins[U8X8_PIN_CNT]; /* defines a pinlist: Mainly a list of pins for the Arduino Envionment, use U8X8_PIN_xxx to access */
|
|
||||||
#endif
|
|
||||||
+
|
|
||||||
+gpio_t* pins;
|
|
||||||
+uint32_t pins_enabled;
|
|
||||||
+uint32_t dev;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef U8X8_WITH_USER_PTR
|
|
||||||
@@ -371,6 +377,8 @@ struct u8x8_struct
|
|
||||||
#define u8x8_SetMenuDownPin(u8x8, val) u8x8_SetPin((u8x8),U8X8_PIN_MENU_DOWN,(val))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#define u8x8_SetPins(u8x8,pins,pins_enabled) {(u8x8)->pins = (pins); (u8x8)->pins_enabled = (pins_enabled);}
|
|
||||||
+#define u8x8_SetDevice(u8x8,device) ((u8x8)->dev = device)
|
|
||||||
|
|
||||||
/*==========================================*/
|
|
||||||
|
|
||||||
@@ -943,6 +951,9 @@ extern const uint8_t u8x8_font_pxplustandynewtv_u[] U8X8_FONT_SECTION("u8x8_font
|
|
||||||
|
|
||||||
/* end font list */
|
|
||||||
|
|
||||||
+extern uint8_t u8x8_byte_riotos_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
|
||||||
+extern uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
|
||||||
+extern uint8_t u8x8_byte_riotos_hw_i2c(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.7.4
|
|
||||||
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
From 4783fcb666569eda64bbba7c4923fb0320ba7bcd Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de>
|
|
||||||
Date: Tue, 7 Nov 2017 16:51:11 +0100
|
|
||||||
Subject: [PATCH 3/3] Change conflicting module name for pkg root directory
|
|
||||||
|
|
||||||
Root directory and csrc both had 'u8g2' module name.
|
|
||||||
---
|
|
||||||
Makefile | 2 ++
|
|
||||||
1 file changed, 2 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/Makefile b/Makefile
|
|
||||||
index ec64fab..419ebdb 100644
|
|
||||||
--- a/Makefile
|
|
||||||
+++ b/Makefile
|
|
||||||
@@ -1,3 +1,5 @@
|
|
||||||
+MODULE = pkg-u8g2
|
|
||||||
+
|
|
||||||
DIRS += csrc
|
|
||||||
|
|
||||||
# SDL can be used as a virtual display, but is for native target only.
|
|
||||||
--
|
|
||||||
2.7.4
|
|
||||||
|
|
||||||
24
pkg/u8g2/src/Makefile
Normal file
24
pkg/u8g2/src/Makefile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
MODULE = pkg-u8g2
|
||||||
|
|
||||||
|
DIRS += csrc
|
||||||
|
|
||||||
|
# SDL can be used as a virtual display, but is for native target only.
|
||||||
|
ifneq (,$(filter u8g2_sdl,$(USEMODULE)))
|
||||||
|
DIRS += sys/sdl/common
|
||||||
|
endif
|
||||||
|
|
||||||
|
# UTF8 virtual display is not part of core. Therefore it is a separate module.
|
||||||
|
ifneq (,$(filter u8g2_utf8,$(USEMODULE)))
|
||||||
|
DIRS += sys/utf8/common
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Compiling U8g2 will generate a lot of compiler warnings, which are treated
|
||||||
|
# as errors. For the sake of simplicity, ignore them.
|
||||||
|
CFLAGS += -Wno-empty-translation-unit \
|
||||||
|
-Wno-newline-eof \
|
||||||
|
-Wno-unused-parameter \
|
||||||
|
-Wno-unused \
|
||||||
|
-Wno-overlength-strings \
|
||||||
|
-Wno-pointer-arith
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
3
pkg/u8g2/src/csrc/Makefile
Normal file
3
pkg/u8g2/src/csrc/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MODULE = u8g2
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
183
pkg/u8g2/src/csrc/u8g2_riotos.c
Normal file
183
pkg/u8g2/src/csrc/u8g2_riotos.c
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2018 Bas Stottelaar <basstottelaar@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup pkg_u8g2
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief U8g2 driver for interacting with RIOT-OS drivers
|
||||||
|
*
|
||||||
|
* @author Bas Stottelaar <basstottelaar@gmail.com>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "u8g2.h"
|
||||||
|
|
||||||
|
#include "xtimer.h"
|
||||||
|
#include "periph/spi.h"
|
||||||
|
#include "periph/i2c.h"
|
||||||
|
#include "periph/gpio.h"
|
||||||
|
|
||||||
|
#ifdef SPI_NUMOF
|
||||||
|
static spi_clk_t u8x8_pulse_width_to_spi_speed(uint32_t pulse_width)
|
||||||
|
{
|
||||||
|
uint32_t cycle_time = 2 * pulse_width;
|
||||||
|
|
||||||
|
if (cycle_time < 100) {
|
||||||
|
return SPI_CLK_10MHZ;
|
||||||
|
} else if (cycle_time < 200) {
|
||||||
|
return SPI_CLK_5MHZ;
|
||||||
|
} else if (cycle_time < 1000) {
|
||||||
|
return SPI_CLK_1MHZ;
|
||||||
|
} else if (cycle_time < 2500) {
|
||||||
|
return SPI_CLK_400KHZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SPI_CLK_100KHZ;
|
||||||
|
}
|
||||||
|
#endif /* SPI_NUMOF */
|
||||||
|
|
||||||
|
#ifdef SPI_NUMOF
|
||||||
|
static spi_mode_t u8x8_spi_mode_to_spi_conf(uint32_t spi_mode)
|
||||||
|
{
|
||||||
|
return (spi_mode_t) spi_mode;
|
||||||
|
}
|
||||||
|
#endif /* SPI_NUMOF */
|
||||||
|
|
||||||
|
static void u8x8_enable_pins(gpio_t* pins, uint32_t pins_enabled)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < 32; i++) {
|
||||||
|
if (pins_enabled & (1 << i)) {
|
||||||
|
if (pins[i] != GPIO_UNDEF) {
|
||||||
|
if (i < U8X8_PIN_OUTPUT_CNT) {
|
||||||
|
gpio_init(pins[i], GPIO_OUT);
|
||||||
|
} else {
|
||||||
|
gpio_init(pins[i], GPIO_IN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||||
|
{
|
||||||
|
(void) arg_ptr;
|
||||||
|
|
||||||
|
switch (msg) {
|
||||||
|
case U8X8_MSG_GPIO_AND_DELAY_INIT:
|
||||||
|
u8x8_enable_pins(u8g2->pins, u8g2->pins_enabled);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_DELAY_MILLI:
|
||||||
|
xtimer_usleep(arg_int * 1000);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_DELAY_10MICRO:
|
||||||
|
xtimer_usleep(arg_int * 10);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_DELAY_100NANO:
|
||||||
|
xtimer_nanosleep(arg_int * 100);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_GPIO_CS:
|
||||||
|
if (u8g2->pins_enabled & (1 << U8X8_PIN_CS)) {
|
||||||
|
gpio_write(u8g2->pins[U8X8_PIN_CS], arg_int);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_GPIO_DC:
|
||||||
|
if (u8g2->pins_enabled & (1 << U8X8_PIN_DC)) {
|
||||||
|
gpio_write(u8g2->pins[U8X8_PIN_DC], arg_int);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_GPIO_RESET:
|
||||||
|
if (u8g2->pins_enabled & (1 << U8X8_PIN_RESET)) {
|
||||||
|
gpio_write(u8g2->pins[U8X8_PIN_RESET], arg_int);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SPI_NUMOF
|
||||||
|
uint8_t u8x8_byte_riotos_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||||
|
{
|
||||||
|
spi_t dev = (spi_t) u8g2->dev;
|
||||||
|
|
||||||
|
switch (msg) {
|
||||||
|
case U8X8_MSG_BYTE_SEND:
|
||||||
|
spi_transfer_bytes(dev, GPIO_UNDEF, true,
|
||||||
|
arg_ptr, NULL, (size_t)arg_int);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_INIT:
|
||||||
|
spi_init_pins(dev);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_SET_DC:
|
||||||
|
u8x8_gpio_SetDC(u8g2, arg_int);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_START_TRANSFER:
|
||||||
|
spi_acquire(dev, GPIO_UNDEF,
|
||||||
|
u8x8_spi_mode_to_spi_conf(u8g2->display_info->spi_mode),
|
||||||
|
u8x8_pulse_width_to_spi_speed(u8g2->display_info->sck_pulse_width_ns));
|
||||||
|
|
||||||
|
u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_enable_level);
|
||||||
|
u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->post_chip_enable_wait_ns, NULL);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_END_TRANSFER:
|
||||||
|
u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->pre_chip_disable_wait_ns, NULL);
|
||||||
|
u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_disable_level);
|
||||||
|
|
||||||
|
spi_release(dev);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif /* SPI_NUMOF */
|
||||||
|
|
||||||
|
#ifdef I2C_NUMOF
|
||||||
|
uint8_t u8x8_byte_riotos_hw_i2c(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||||
|
{
|
||||||
|
static uint8_t buffer[255];
|
||||||
|
static uint8_t index;
|
||||||
|
|
||||||
|
i2c_t dev = (i2c_t) u8g2->dev;
|
||||||
|
|
||||||
|
switch (msg) {
|
||||||
|
case U8X8_MSG_BYTE_SEND:
|
||||||
|
memcpy(&buffer[index], arg_ptr, arg_int);
|
||||||
|
index += arg_int;
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_INIT:
|
||||||
|
i2c_init_master(dev, I2C_SPEED_FAST);
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_SET_DC:
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_START_TRANSFER:
|
||||||
|
i2c_acquire(dev);
|
||||||
|
index = 0;
|
||||||
|
break;
|
||||||
|
case U8X8_MSG_BYTE_END_TRANSFER:
|
||||||
|
i2c_write_bytes(dev, u8x8_GetI2CAddress(u8g2), buffer, index);
|
||||||
|
i2c_release(dev);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif /* I2C_NUMOF */
|
||||||
5
pkg/u8g2/src/sys/sdl/common/Makefile
Normal file
5
pkg/u8g2/src/sys/sdl/common/Makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MODULE = u8g2_sdl
|
||||||
|
|
||||||
|
CFLAGS += `sdl2-config --cflags`
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
3
pkg/u8g2/src/sys/utf8/common/Makefile
Normal file
3
pkg/u8g2/src/sys/utf8/common/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MODULE = u8g2_utf8
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
Loading…
x
Reference in New Issue
Block a user