AaronLiddiment / LEDText

FastLED Flexible Text Message Class requires LEDMatrix Class
89 stars 32 forks source link

some help please #14

Open mugginsjm opened 4 years ago

mugginsjm commented 4 years ago

I am trying to dynamically update a 64x8 display using an ethernet socket connection which provides a string output. I am in a total "meltdown" in relation to unsigned char.... etc This code throws up error: invalid conversion from 'unsigned char' to 'char'

unsigned char TxtDemo[] = { EFFECT_HSV "\x00\xff\xff" }; String txt="my text"; strcat( TxtDemo, txt.c_str() );

ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1);

ruohki commented 4 years ago

iam on this topic as i want to do the exact same thing ill post something if i made it work

ruohki commented 4 years ago

Hope this helps

  std::string one = "Hello, ";
  std::string two = "World";
  std::string three = one + two;
  unsigned char* uc = (unsigned char*)three.c_str();
veitk commented 4 years ago

no, unfortunately not....

AaronLiddiment commented 4 years ago

You cannot 'strcat' to your TxtDemo unsigned char array as it has only been defined with enough space for your hard coded characters. So even if you did not have the unsigned/signed errors it would have overwritten memory. You would have to add a suitable dimension in the '[]' to allow for the extra characters.

The next problem is that TxtDemo in the 'strcat' call is not a pointer, you would have to use &TxtDemo[4] and you would also have to cast it to a 'char *'.

unsigned char TxtDemo[256] = { EFFECT_HSV "\x00\xff\xff" }; // 4 chars + null char String txt="my text"; strcat((char *)&TxtDemo[4], txt.c_str()); ScrollingMsg.SetText(&TxtDemo[0], 4 + txt.length());