U8g2: Fix for MAX7219 32x8 module order

Created on 17 Jul 2019  路  3Comments  路  Source: olikraus/u8g2

In my 32x8 the order of the 4 8x8 modules is inverted, thus drawing "abcde" results in "edcba" to be displayed, but of course with characters cut in half at the module boundary.

I've fixed this by adapting U8X8_MSG_DISPLAY_DRAW_TILE in u8x8_d_max7219.c like this:

case U8X8_MSG_DISPLAY_DRAW_TILE:
      /* transfer always has to start at x pos 0 (u8x8 is not supported) */
      /* also y pos has to be 0 */
      /* arg_int is ignored */
      //x = ((u8x8_tile_t *)arg_ptr)->x_pos;

      c = ((u8x8_tile_t *)arg_ptr)->cnt;    /* number of tiles */
      ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
      for( i = 0; i < 8; i++ )
      {
        ptr += c - 1; /* last tile first */
        u8x8_cad_StartTransfer(u8x8);
        for( j = 0; j < c; j++ )
        {
          u8x8_cad_SendCmd(u8x8, i+1);
          u8x8_cad_SendArg(u8x8, *ptr );
          ptr--;
        }
        u8x8_cad_EndTransfer(u8x8);
        ptr += c + 1; /* next row */
      }

      break;

I've seen a few people asking for a solution to this elsewhere. Maybe you can add an option or a max7219_32x8_alt0 entry to make this available to all users?

question

All 3 comments

I think U8G2_MIRROR instead of U8G2_R0 should also solve this problem.
Can you test this?

Simply using U8G2_MIRROR won't solve it. I think some pictures might help at this point.
Here are 3 photos with the result of this:

drawLine(0,0,31,7)
drawPixel(0,7)

Original code, no rotation or mirroring:
OriginalNoMirror

Original code, using U8G2_MIRROR as suggested:
OriginalMirror

With the modification in u8x8_d_max7219.c, no rotation or mirroring:
MyModification

The module order for the chinese MAX7219 is sometimes wrong. Thank you for the fix, it worked for me first time!

For reference, the module I used is found here: https://www.banggood.com/MAX7219-Dot-Matrix-Module-4-in-1-Display-For-Arduino-p-1072083.html?rmmds=myorder&cur_warehouse=CN

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattogodoy picture mattogodoy  路  9Comments

hilsonp picture hilsonp  路  3Comments

13590787364 picture 13590787364  路  3Comments

Robiv8 picture Robiv8  路  5Comments

Audio-Rochey picture Audio-Rochey  路  4Comments