0
String abc ="0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff";

const unsigned char displaydata={reinterpret_cast<const unsigned char*>(abc.c_str())};

display.drawBitmap(displaydata, startX, startY, bmpWidth, bmpHeight, GxEPD_WHITE);

Get error: invalid conversion from 'const unsigned char' to 'unsigned char' [-fpermissive]*

When I write like this

String abc ="0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff";

display.drawBitmap(reinterpret_cast<const unsigned char*>(abc.c_str()), startX, startY, bmpWidth, bmpHeight, GxEPD_WHITE);

No error but black screen no display image

When I write like this

const unsigned char displaydata[]={ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

display.drawBitmap(displaydata, startX, startY, bmpWidth, bmpHeight, GxEPD_WHITE);

It is working

The string data coming from the server is returning to me as stirng, I am trying to reflect it on the screen. I want to convert a string data to const unsigned char with code

So I'm trying to convert

chrisl
  • 16,612
  • 2
  • 18
  • 27
Coder06
  • 1
  • 1

1 Answers1

1

That string is literally the characters 0xff ... while the array is the bytes 0xff...

Where the string contains 4 bytes to say 0,x,f,f (followed by comma and space) the array will have 1 byte the 255 (and no need for a comma or space to delimit).

If you are looking to convert the text hex string to bytes, look at a combination of How to convert an hex string to an array of bytes? and looping through the string.

Abel
  • 265
  • 1
  • 6