Go Down

Topic: 8x64 MAX7219 LED Matrix with MD_MAX72xx.h, pass String via variable,for Cyrillic (Read 248 times) previous topic - next topic

Alkot


Hello Marco and all Others.))

I use 8x64 LED Martix MAXIM MAX7119CWG 1618 FC-16 DISY1 with MD_MAX72xx.h library.
I need 2 things":

1. Send text to matrix via variable. At MD_MAX72xx_Test example I see this function scrollText(char *p) and scrollText("Graphics  ") at loop with text already inside.
 When i try like this:
char myText = "Graphics";// or static *myText = "Graphics"
scrollText(myText); // or scrollText(*myText);
it is not working or it stucks after few letters.


Code: [Select]

void scrollText(char *p)
{
  uint8_t charWidth;
  uint8_t cBuf[8]; // this should be ok for all built-in fonts

  PRINTS("\nScrolling text");
  mx.clear();

  while (*p != '\0')
  {
    charWidth = mx.getChar(*p++, sizeof(cBuf)/sizeof(cBuf[0]), cBuf);

    for (uint8_t i=0; i<charWidth + 1; i++) // allow space between characters
    {
      mx.transform(MD_MAX72XX::TSL);
      if (i < charWidth)
        mx.setColumn(0, cBuf[i]);
      delay(DELAYTIME);
    }
  }
}


2. I want to use Cyrillic without replacing original fonts table.
Can I use this function?

Code: [Select]

String utf8rus(String source)
{
  int i,k;
  String target;
  unsigned char n;
  char m[2] = { '0', '\0' };

  k = source.length(); i = 0;
  while (i < k) {
    n = source[i]; i++;
      if (n >= 0xC0) {
      switch (n) {
        case 0xD0: {
          n = source[i]; i++;
          if (n == 0x81) { n = 0xA8; break; }
          if (n >= 0x90 && n <= 0xBF) n = n + 0x2F;
          break;
        }
        case 0xD1: {
          n = source[i]; i++;
          if (n == 0x91) { n = 0xB7; break; }
          if (n >= 0x80 && n <= 0x8F) n = n + 0x6F;
          break;
        }
      }
    }
       m[0] = n; target = target + String(m);
      }
return target;
}


Thank you

marco_c

Code: [Select]
char myText = "Graphics";// or static *myText = "Graphics"
You need to declare an array of characters

Quote
I want to use Cyrillic without replacing original fonts table
Not if you want to display cyrillic characters. They are not in the standard font table.

You should look at the MD_Parola library. There are some cyrillic examples there made by other users.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Alkot

I replaced fonts for Cyrillic one (attached) . And it works with showCharset() function but not with scrollText(). ScrollText() sees Cyrillic from sketch as UTF8, as duoble byte, as two characters. That is why we need this function utf8rus(String source) to convert Cyrillic string from UTF8 to win1251.
But now i have a problem to convert String to Char. String.toCharArray() - does not convert to char properly for ScrollText(). 

Go Up