[riot-notifications] [RIOT-OS/RIOT] U8g2: Refactoring and minor fixes (#10693)

Bas Stottelaar notifications at github.com
Thu Jan 3 10:58:36 CET 2019


basilfx requested changes on this pull request.



> @@ -21,4 +21,7 @@ CFLAGS += -Wno-empty-translation-unit \
           -Wno-overlength-strings \
           -Wno-pointer-arith
 
+# Enable user_ptr for u8g2 for smooth RIOT-OS port
+CFLAGS += -DU8X8_WITH_USER_PTR

Flag double with Makefile.dep?

> @@ -0,0 +1,3 @@
+USEMODULE += xtimer
+FEATURES_REQUIRED += periph_gpio
+CFLAGS += -DU8X8_WITH_USER_PTR

I don't see this flag being used.

>  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;
+    static uint8_t buffer[32]; /* u8g2/u8x8 will never send more than 32 bytes between START_TRANSFER and END_TRANSFER */
+    static size_t index;
+
+    const u8x8_riotos_t u8x8_riot_ptr = u8g2->user_ptr;
+
+    // Check that user_ptr is correctly set
+    if (NULL == u8x8_riot_ptr) {

An assert would be better.

>  
-    i2c_t dev = (i2c_t) u8g2->dev;
+    i2c_t dev = I2C_DEV(u8x8_riot_ptr->device_index);

In most drivers, the I2C_DEV define is moved to where `u8x8_riot_ptr->device_index` is set.

>      /* initialize to I2C */
 #if TEST_OUTPUT == TEST_OUTPUT_I2C
     puts("Initializing to I2C.");
 
     TEST_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_i2c, u8x8_gpio_and_delay_riotos);
 
-    u8g2_SetPins(&u8g2, pins, pins_enabled);
-    u8g2_SetDevice(&u8g2, I2C_DEV(TEST_I2C));
-    u8g2_SetI2CAddress(&u8g2, TEST_ADDR);

How is the address now passed-on?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10693#pullrequestreview-188948484
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190103/71fa7ec1/attachment-0001.html>


More information about the notifications mailing list