# Need help with conversion, please

**URL:** <https://forum.arduino.cc/t/need-help-with-conversion-please/1241229>\
**Category:** Programming\
**Created:** [March 28, 2024, 10:18pm UTC](https://forum.arduino.cc/t/need-help-with-conversion-please/1241229 "2024-03-28T22:18:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phloks](https://avatars.discourse-cdn.com/v4/letter/p/bb73d2/32.png) [@phloks](https://forum.arduino.cc/u/phloks)\
**Post date:** [March 28, 2024, 10:18pm UTC](https://forum.arduino.cc/t/need-help-with-conversion-please/1241229/1 "2024-03-28T22:18:56Z")

</div>

I have this snippet of code:  
(please disregard the fact that the code is not completely correct, in this form it will print in the same place..)

```arduino
  uint8_t ids[] = {(uint8_t)(menuid >> 4), (uint8_t)(menuid & 0xF)};
    for(int i = 0; i < 2; i++) {
      uint8_t id = ids[i];
      ucg.drawString(3,232,0,id);
    }

```

where menuid is a hex number (i.e 0x11).  
This hex number is then split into two integers, that I need to print to a TFT screen.  
I'm getting the error:

> Compilation error: invalid conversion from 'uint8\_t' {aka 'unsigned char'} to 'const char\*' [-fpermissive]

The drawString function requires the text to be printed to be of type const char\*.

I have tried many things, like casting an int to a string, but I simply cannot get it to work properly.  
So my question is: how do I properly convert the int into a const char\* ?

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [March 28, 2024, 10:25pm UTC](https://forum.arduino.cc/t/need-help-with-conversion-please/1241229/2 "2024-03-28T22:25:30Z")

</div>

> [@phloks](#):
>
> not completely correct

OK, that was weird. So you've solved a big problem and now a little problem remains

You are telling it to put both characters at the same screen coordinates.

```arduino
      ucg.drawString(3, 232, 0, id);

```

Try moving the character over according to the loop index, viz:

```arduino
      ucg.drawString(3 + 10 * i, 232, 0, id);

```

If the first two arguments are screen X and screen Y, I go check… yes, that should move the characters over 10 pixels each time, here only once but same idea if you were doing more digits. Adjust 10 for yiu circumstances.

a7

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [March 28, 2024, 11:28pm UTC](https://forum.arduino.cc/t/need-help-with-conversion-please/1241229/4 "2024-03-28T23:28:40Z")

</div>

> [@Delta\_G](#):
>
> Draw string needs a char string,

Yes.

@phloks could use the _print_() method instead.

See

[https://code.google.com/archive/p/ucglib/wikis/reference.wiki](https://code.google.com/archive/p/ucglib/wikis/reference.wiki)

for details.

a7

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 24, 2024, 11:29pm UTC](https://forum.arduino.cc/t/need-help-with-conversion-please/1241229/5 "2024-09-24T23:29:12Z")

</div>

Closed on September 24, 2024, 11:29pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
