Convert Byte array to hex strings for UTFT lcd screen

Hi all

I am stuck on a project to print a byte array to a hex string using only the UTFT command set that i have attached as a file.

The command i am trying to duplicate is serial.print(addr*, HEX) in the following code. I have everything printing as is but the serial display is gettng the hex digits while my LCD is getting bytes. This is the code which is basically the DS temperature sensor scanner ported to display on my 7"tft. It is a subrouting called by my main program.*
```
//******************************************************************************
//  LIST ATTACHED TEMPERATURE SENSORS
//*******************************************************************************

#include "Arduino.h"
#include <OneWire.h>
#include <wire.h>
#include "touch.h"
#include <UTFT_Buttons.h>
#include "lcd_util.h"

extern UTouch myTouch;
extern UTFT_Buttons myButtons;

#include <UTFT.h>
extern UTFT myGLCD;

OneWire ds(8); // on pin 8 (4.7k pullup needed)

extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t Dingbats1_XL[];

void monitor_temp() {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;

//  myGLCD.InitLCD();
//  myGLCD.clrScr();
//  myGLCD.drawRect(10,10,799,469);
//  myGLCD.drawRect(140,384,668,459);
//  myGLCD.setFont(BigFont);
//  myButtons.drawButton(6);
//  myButtons.drawButton(7);
//  myGLCD.print ("Touch Screen to continue",240,420);
//  waitForTouch();

drawMenu_sub();
   
 
 
 
  startloop1:

if ( !ds.search(addr)) {
    Serial.println("No more addresses.");
    myGLCD.print("No more addresses.",20,400);
    Serial.println();
    waitForTouch();
   
    myGLCD.clrScr();
    myGLCD.drawRect(10,10,799,469);
    myGLCD.drawRect(140,384,668,459); 
    myButtons.drawButtons();
   
//    myGLCD.print();
    ds.reset_search();
    delay(250);
    return;
}
 
 
  Serial.print("ROM =");
  myGLCD.print("ROM  =",20,40);
  int testvar = 120;
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
    myGLCD.printNumI(addr[i],testvar,40,3,'0');
    testvar = (testvar+60);
  }

if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      myGLCD.print("CRC is not valid!",20,400);
      return;
  }
  Serial.println();

// the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
      Serial.println("  Chip = DS18S20");  // or old DS1820
      myGLCD.print("Chip =DS18S20",20,60);
      type_s = 1;
      break;
    case 0x28:
      Serial.println("  Chip = DS18B20");
      myGLCD.print("Chip =DS18B20",20,60);
      type_s = 0;
      break;
    case 0x22:
      Serial.println("  Chip = DS1822");
      myGLCD.print("Chip =DS1822",20,60);
      type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      myGLCD.print("Device is not a DS18x20 family device.",20,60);
      return;
  }

ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
 
  delay(1000);    // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
 
  present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE);        // Read Scratchpad

Serial.print("  Data = ");
  myGLCD.print("Data =",20,80);
  Serial.print(present, HEX);
  myGLCD.printNumI(present,120,80,3,'0');
  Serial.print(" ");
  int testvar1 = 120;
  for ( i = 0; i < 9; i++) {          // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    myGLCD.printNumI(data[i],testvar1,100,3,'0');
    testvar1 = (testvar1+60);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  myGLCD.print("CRC  =",20,120);
  Serial.print(OneWire::crc8(data, 8), HEX);
  myGLCD.printNumI(OneWire::crc8(data, 8), 120,120);
  Serial.println();

// Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  Serial.print("  Temperature = ");
  myGLCD.print("Temperature =",20,140);
  Serial.print(celsius);
  myGLCD.printNumI(celsius,236,140);
  Serial.print(" Celsius, ");
  myGLCD.print("Celsius",284,140);
  Serial.print(fahrenheit);
  myGLCD.printNumI(fahrenheit,236,160);
  Serial.println(" Fahrenheit");
  myGLCD.print("Fahrenheit",284,160);
  Serial.println();
  myGLCD.print("TAP SCREEN FOR NEXT SENSOR",20,400);
  waitForTouch();
  myGLCD.clrScr();
goto startloop1;

}*
* *in particular it is this section of code i am having trouble with.* *
Serial.print("ROM =");
  myGLCD.print("ROM  =",20,40);
  int testvar = 120;
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
    myGLCD.printNumI(addr[i],testvar,40,3,'0');
    testvar = (testvar+60);
  }

```
can anyone help me in how to get that addr variable into hex string format for myGLCD.print command?
One other thing i have a goto statement creating a loop in the program, as this code is contained in a temperature.cpp file with a corresponding temperature.h for some reason While(1) does not work. I am not sure why.

You should be able to use itoa http://www.cplusplus.com/reference/cstdlib/itoa/ or sprintf to convert addr[i]to a hex character string, and print that on the glcd.