Trying to send an int tpo touchscreen as a string

I am using an old touchscreen that requires that text data be sent as a string, thats the library that came with it, im not rewriting it.

I am sending temperature data that is 1 to 3 digits in length

The temps are 0 to 125

The temperature capture code is written and works
The screen display code is written and works

The temp capture is stored as an integer

For testing it is entered manually into an array as

t[0]=112;

The touchscreen display code works,

For testing it is entered manually into an array as

arrayTemps[0] = "112"; //notice the quotes

Here is where i am stuck, the thermistor pin portion of this will provide the t[0]=x, where x is an int

How do I then get that int loaded into arrayTemps[0] as a string so it can go onto the touchscreen ?

thanks

The itoa() function changes an int data type to a string (null terminated character array).

groundFungus:
The itoa() function changes an int data type to a string (null terminated character array).

thanks, tried that, to no avail, perhaps i need an example specific to

t[0]=112

and need to make

arrayTemps[0] = "112"

thanks

void setup() {
// put your setup code here, to run once:
int arrayTemps[20];
int t[20];

t[0] = 59;
t[1] = 112;
t[2] = 89;
t[3] = 114;
t[4] = 106;
t[5] = 98;
t[6] = 73;
t[7] = 84;
t[8] = 99;
t[9] = 134;
t[10] = 123;
t[11] = 143;
t[12] = 113;
t[13] = 156;
t[14] = 83;
t[15] = 87;
t[16] = 59;
t[17] = 145;
t[18] = 93;
t[19] = 99;

arrayTemps[0]="59"; // how do i get the int 59 from t[0] into arrayTemps[0] as a string, instead of placing it in quotes manually ?
}

void loop() {
// put your main code here, to run repeatedly:

}

If your largest integer is three digits, then you can size all the string conversions to 4 characters to hold the three digit characters and the null terminator.

void setup() {
  Serial.begin(115200);
  int t[20] = {59, 112, 89, 114, 106, 98, 73, 84, 99, 134, 123, 143, 113, 156, 83, 87, 59, 145, 93, 99};
  char t_as_string[20][4];//3 digits of t plus null terminator

  for (byte i = 0; i < 20; i++)
  {
    itoa(t[i], t_as_string[i], 10);//base 10
    Serial.println(t_as_string[i]);
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}

i got yours to work with a mod

i run it through yours and then run it one more time and it gets where it needs to go and shows up on the touch screen as data not garbage.

tried to post the code but it shows up weird

and THANK YOU

this is for an old version one seeeduino touch screen, seems to work now
going to take input from 20 thermistors using one pin via a mux ii multplexer into array t
then they go to seeeduino which requires a string not int, due to its library.

#include <stdint.h>
#include <TouchScreen.h> 
#include <TFT.h>

#ifdef SEEEDUINO
  #define YP A2   // must be an analog pin, use "An" notation!
  #define XM A1   // must be an analog pin, use "An" notation!
  #define YM 14   // can be a digital pin, this is A0
  #define XP 17   // can be a digital pin, this is A3 
#endif

#ifdef MEGA
  #define YP A2   // must be an analog pin, use "An" notation!
  #define XM A1   // must be an analog pin, use "An" notation!
  #define YM 54   // can be a digital pin, this is A0
  #define XP 57   // can be a digital pin, this is A3 
#endif 

int arrayTemps[20];
int t[20];

const int TempBarOneTop = 0;
const int left = 308;
const int spacer=16;
const int TempBarHeight=80;
const int TempBarWidth=16;
const int bartextspace=4;
const int font1hi=8;
const int TempBarTwoTop=56; 
const int BeginTextColumn=312;
const int LowBat=0;

//these will be read from user input or defaults
const int MaxColdOpTemp=60;
const int MaxFullOpTemp=102; 
const int MaxChargeTemp=110;
const int MaxOpTemp=123;

//these are hard coded and used to nag user when they exceed safe settings for above
const int nagMaxColdOpTemp=60; 
const int nagMaxFullOpTemp=102; 
const int nagMaxChargeTemp=110;
const int nagMaxOpTemp=123;


void setup()
{
int i;
Tft.init();  //init TFT library
Tft.setDisplayDirect(DOWN2UP);
Tft.drawString("Air  84f in 124f out",TempBarHeight+TempBarWidth+font1hi+20,320,2,WHITE);

}



void loop()
{
drawscreen();
delay(5000);

}


void drawscreen()
{

int i;
int BarColor;

loadtemps();

int iHighBat, sHighBat, iLowBat,sLowBat;

iHighBat=0;
sHighBat="";
iLowBat=999;
sLowBat="";


for (i = 0; i < 20; i++) {

     if (iLowBat>t[i]){
     iLowBat=t[i];
     sLowBat=arrayTemps[i];
     }
     
     if (iHighBat<t[i]){
     iHighBat=t[i];
     sHighBat=arrayTemps[i];
     }

     
}
//draw black wide bar to erase old temps  
Tft.fillRectangle(TempBarHeight+TempBarWidth+font1hi,320,8,320,BLACK); //HAD TO RESET TEMPS TO BLACK OR GARBELD UP ON UPDATE

Tft.drawString("Lo-",TempBarHeight+TempBarWidth+font1hi,320,2,WHITE);
Tft.drawString(sLowBat,TempBarHeight+TempBarWidth+font1hi,260,2,WHITE);
Tft.drawString("f",TempBarHeight+TempBarWidth+font1hi,230,2,WHITE);
Tft.drawString("Hi-",TempBarHeight+TempBarWidth+font1hi,205,2,WHITE);
Tft.drawString(sHighBat,TempBarHeight+TempBarWidth+font1hi,155,2,WHITE);
Tft.drawString("f",TempBarHeight+TempBarWidth+font1hi,110,2,WHITE);

//draw top bars
     for (i = 0; i < 10; i++) {

          if (t[i]<MaxColdOpTemp) { // <60
          BarColor=BLUE;  
          }
    
          else {
               if (t[i]>=MaxColdOpTemp&&t[i]<=MaxFullOpTemp) { // 60 <=102
               BarColor=GREEN;     
               }
      
               else {
                    if (t[i]>MaxFullOpTemp&&t[i]<MaxChargeTemp) { // >102 <110
                    BarColor=YELLOW;     
                    }
        
                    else {
                         if (t[i]>=MaxChargeTemp&&t[i]<MaxOpTemp) { //110 <123
                         BarColor=RED;
                         } 
          
                              else {
                                   if (t[i]>=MaxOpTemp) { //>=123
                                   BarColor=WHITE;
                                   }

                                        else {
                                        BarColor=BLACK;  
                                        }
                                   }
                         }
                    }
               }

  Tft.fillRectangle(TempBarOneTop, left-(i*(spacer+TempBarWidth)), TempBarHeight,TempBarWidth,BarColor);  // top start, left start (320 - values, 320 is left ), height, width, color
  }

//draw black wide bar to erase old temps  
Tft.fillRectangle(TempBarOneTop+TempBarHeight+bartextspace, 320,8,320,BLACK); //HAD TO RESET TEMPS TO BLACK OR GARBELD UP ON UPDATE





//draw temps under top bar
  for (i = 0; i < 10; i++) {


      if (t[i]<100)
      {
       Tft.drawString(arrayTemps[i],TempBarOneTop+TempBarHeight+bartextspace,BeginTextColumn-(i*32)-5,1,WHITE);
      }
      else {
           if (t[i]>=100)
            {
            Tft.drawString(arrayTemps[i],TempBarOneTop+TempBarHeight+bartextspace,BeginTextColumn-(i*32),1,WHITE);
            } 
      }
  }

//draw bottom bars

  for (i = 10; i < 20; i++) {

          if (t[i]<MaxColdOpTemp) { // <60
          BarColor=BLUE;  
          }
    
          else {
               if (t[i]>=MaxColdOpTemp&&t[i]<=MaxFullOpTemp) { // 60 <=102
               BarColor=GREEN;     
               }
      
               else {
                    if (t[i]>MaxFullOpTemp&&t[i]<MaxChargeTemp) { // >102 <110
                    BarColor=YELLOW;     
                    }
        
                    else {
                         if (t[i]>=MaxChargeTemp&&t[i]<MaxOpTemp) { //110 <123
                         BarColor=RED;
                         } 
          
                              else {
                                   if (t[i]>=MaxOpTemp) { //>=123
                                   BarColor=WHITE;
                                   }

                                        else {
                                        BarColor=CYAN;  
                                        }
                                   }
                         }
                    }
               }



    Tft.fillRectangle(TempBarOneTop+TempBarHeight+bartextspace+font1hi+TempBarTwoTop, left-((i-10)*(spacer+TempBarWidth)), TempBarHeight,TempBarWidth,BarColor);
  }

//draw black wide bar to erase old temps
Tft.fillRectangle(TempBarOneTop+TempBarHeight+bartextspace+font1hi+TempBarTwoTop+TempBarHeight+bartextspace+1, 320,8,320,BLACK); //HAD TO RESET TEMPS TO BLACK OR GARBELD UP ON UPDATE

//draw temps under bottom bar

  for (i = 10; i < 20; i++) {


      if (t[i]<100)
      {
       Tft.drawString(arrayTemps[i],TempBarOneTop+TempBarHeight*2+TempBarTwoTop+spacer,BeginTextColumn-((i-10)*32)-5,1,WHITE);
      }
      else {
           if (t[i]>=100)
            {
            Tft.drawString(arrayTemps[i],TempBarOneTop+TempBarHeight*2+TempBarTwoTop+spacer,BeginTextColumn-((i-10)*32),1,WHITE);
            } 
      }
  }

}

void loadtemps()
{
//this is fake data simulating input from 20 thermistors coming soon on one pin via a mux ii multiplexer that has just arrived
//the array will stay and the values will be loaded from the mux every second
t[0] = 69;
t[1] = 112;
t[2] = 89;
t[3] = 114;
t[4] = 106;
t[5] = 98;
t[6] = 73;
t[7] = 84;
t[8] = 99;
t[9] = 134;
t[10] = 123;
t[11] = 143;
t[12] = 113;
t[13] = 156;
t[14] = 83;
t[15] = 87;
t[16] = 59;
t[17] = 145;
t[18] = 93;
t[19] = 99;

//this is the somewhat weird solution that gets the data above into a form that the touch screen can display instaed of garbage
//it loads a second array (arrayTemps) which is used to send data to the screen
//this could later be moved to the screen write code and that array done away with... arrayTemps

char t_as_string[20][4];//3 digits of t plus null terminator

  for (byte i = 0; i < 20; i++)
  {
    itoa(t[i], t_as_string[i], 10);//base 10 // TWO STEPS, i have to put the mux input FROM t[x]into t_as_string[x]
    //itoa(t[i], arrayTemps[i], 10);//base 10
  }

  for (byte i = 0; i < 20; i++)
  {
  arrayTemps[i] =t_as_string[i];// THEN, i have to put t_as_string into arrayTemps, this seems to work, otherwise i get garbage
  }



}

Ill try it, but initially when i made the array char it was garbled on other end, ill check out your solution

Im not sending anything over serial myself, i use the sendstring from the library provided for the screen, im sure it is probably doing that for me, ill check it out.

the tft and touchscreen library are not arduino they are provided via github for this version 1 terrible device that i tossed in box years ago and decided two days ago to make it work :slight_smile:

as for arduino uno i have had it for years, looked at it, made it blink, tossed it back in box, week ago i decided to make something with it, so im a total newb

THANKS!

EDIT: I was trying to modify my sketch and deleted it by mistake, sorry. Here it is back.

int arrayTemps[20];

That can’t be correct if you need to send character strings to the display.

You can to the conversion in one go, if you declare arrayTemps as char* to empty character strings.

void setup() {
  Serial.begin(115200);
  int t[20] = {59, 112, 89, 114, 106, 98, 73, 84, 99, 134, 123, 143, 113, 156, 83, 87, 59, 145, 93, 99};
  //char t_as_string[20][4];//3 digits of t plus null terminator
  char* arrayTemps[20] = {"   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ",
                          "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   ", "   "
                         };//20 blank 3 character strings plus null terminator
   
  for (byte i = 0; i < 20; i++)
  {
    // itoa(t[i], t_as_string[i], 10);//base 10
    itoa(t[i], arrayTemps[i], 10);//base 10
    //Serial.println(t_as_string[i]);
    Serial.println(arrayTemps[i]);
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}

Thanks

Later this afternoon i am going to look at all you posted and how it is working here and see if i can make it perform correctly :slight_smile:

I have looked at this a bit more, and I am somewhat puzzled.

Are you sure the display library is expecting to be passed a null terminated character array aka “string” with small s.

If that is so, I can not understand how with these global declarations

int arrayTemps[20];
int t[20];

this function is is working as intended. arrayTemps can not hold the strings from itoa. I don’t understand why the compiler does not complain.

void loadtemps()
{
  //this is fake data simulating input from 20 thermistors coming soon on one pin via a mux ii multiplexer that has just arrived
  //the array will stay and the values will be loaded from the mux every second
  t[0] = 69;
  t[1] = 112;
  t[2] = 89;
  t[3] = 114;
  t[4] = 106;
  t[5] = 98;
  t[6] = 73;
  t[7] = 84;
  t[8] = 99;
  t[9] = 134;
  t[10] = 123;
  t[11] = 143;
  t[12] = 113;
  t[13] = 156;
  t[14] = 83;
  t[15] = 87;
  t[16] = 59;
  t[17] = 145;
  t[18] = 93;
  t[19] = 99;

  //this is the somewhat weird solution that gets the data above into a form that the touch screen can display instaed of garbage
  //it loads a second array (arrayTemps) which is used to send data to the screen
  //this could later be moved to the screen write code and that array done away with... arrayTemps

  char t_as_string[20][4];//3 digits of t plus null terminator

  for (byte i = 0; i < 20; i++)
  {
    itoa(t[i], t_as_string[i], 10);//base 10 // TWO STEPS, i have to put the mux input FROM t[x]into t_as_string[x]
    //itoa(t[i], arrayTemps[i], 10);//base 10
  }

  for (byte i = 0; i < 20; i++)
  {
    arrayTemps[i] = t_as_string[i]; // THEN, i have to put t_as_string into arrayTemps, this seems to work, otherwise i get garbage
  }
}

I have run into some problems with accessing the arrayTemps strings, after they are filled, with the char* approach.

If the display library is indeed expecting null terminated character arrays, then I would stick with the explicit two dimensional array approach. You can certainly call the target of itoa “arrayTemps”, and only call it using the first index if that makes life easier.

void setup() {
  Serial.begin(115200);
  int t[20] = {59, 112, 89, 114, 106, 98, 73, 84, 99, 134, 123, 143, 113, 156, 83, 87, 59, 145, 93, 99};
  char arrayTemps[20][4];//3 digits of t plus null terminator

  for (byte i = 0; i < 20; i++)
  {
    itoa(t[i], arrayTemps[i], 10);//base 10
    Serial.println(arrayTemps[i]);
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}

pretty sure this is a parallel and not serial screen ?

http://wiki.seeedstudio.com/2.8inch-TFT_Touch_Shield_V1.0/

my mux ii came in i added it and the screen has lines in it, i think they aren't going to be compatible, no big deal its an old terrible display.

says i can disable some/all 4 pins on the mux (which i can do for my implementation of the mux) but i think that still leaves one pin in conflict with the screens D9 - LCD data bit 15 ?

In any case maybe that link to the screen will clarify what im dealing with ?

it appears i will scrap the screen as far as this project goes for a more recent screen that doesnt hog up pins.

still going to play with it and your code to see what happens

For a quick look, it appears that TFT.h does take a null terminated character array.

Syntax
screen.text(text, xPos, yPos);

Parameters
text : char array, the text you want to write on the screen
xPos : int, the location on the x-axis you want to start drawing text to the screen
yPos : int, the location on the y-axis you want to start drawing text to the screen
Returns
none

I think that you can pass screen.txt()

arrayTemps[i]

after it is loaded with the string from itoa.

EDIT: It looks like there may be a different library in use, but

Tft.drawString(arrayTemps[i],TempBarOneTop+TempBarHeight+bartextspace,BeginTextColumn-(i*32)-5,1,WHITE);

looks correct for

drawString(char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor)

i replaced the tft library in the ide with the one from the link, that's the one we have been using.

pretty sure the arduino tft will not work with this screen thats why i never used it before.

i just ordered another uno so i can pursue this for fun, hopefully the mux ii will be on one and this screen on the other and use i2c between them. hopefully, should be here saturday, my novice review of the screen and the mux indicate the i2c pins are free on both

for the heck of it i put the real tft folder back and it wont compile, has issues on every line that starts tft, so i put the other tft folder back, the one from github for this specific screen, so i am stuck with that one.

I'm sure the mux and the 20 thermistors will keep you busy, but I'm still unclear if you can you run the screen with the fixed data set, given that the code you say "works" does not look correct to me. I am really struggling with the pretty image in post #6 having come from arrayTemps which was declared as an integer, and the library expecting a character array.

Did the image come from this?

For testing it is entered manually into an array as
arrayTemps[0] = "112"; //notice the quotes

An intermediate step before the mux would be to run the screen with a varying, but hard coded data set. For example increment all the t array values by one every 5 seconds and display the changing results.

The fixed data was to get the screen laid out, i already got the temps coming in using one thermistor no problem, adding the mux to other code i already wrote and have proven to add more therms shouldnt be an issue.

i think the reason it worked even though it was an int array for the chars is explained below, i did your itoa twice using three vars, the original two and a new third and it somehow fixed it, idk, im still looking into this lol

first example is int and char, second one is int and int

i think 100% of this is i need to read this code lol

#include <stdint.h>
#include <TouchScreen.h> 
#include <TFT.h>

void setup()
{
IntAndChar();
IntAndInt();
}


void IntAndChar(){ //this will display 123 on the screen
  
int StuffToSend;
char* ConvStufftoSend;
StuffToSend=123;
ConvStufftoSend="456";
itoa(StuffToSend,ConvStufftoSend , 10);//base 10
Tft.init();
Tft.setDisplayDirect(DOWN2UP);
Tft.drawString(ConvStufftoSend,100,320,2,WHITE);

}

void IntAndInt(){ //this will display 789 on the screen next line down from above
  
int StuffToSend;
int ConvStufftoSend;
StuffToSend=789;
ConvStufftoSend="321";
itoa(StuffToSend,ConvStufftoSend , 10);//base 10
Tft.init();
Tft.setDisplayDirect(DOWN2UP);
Tft.drawString(ConvStufftoSend,120,320,2,WHITE);

}

cattledog:
I’m sure the mux and the 20 thermistors will keep you busy, but I’m still unclear if you can you run the screen with the fixed data set, given that the code you say “works” does not look correct to me. I am really struggling with the pretty image in post #6 having come from arrayTemps which was declared as an integer, and the library expecting a character array.

Did the image come from this?

An intermediate step before the mux would be to run the screen with a varying, but hard coded data set. For example increment all the t array values by one every 5 seconds and display the changing results.

yes the data on the screen was always coming from an int array that was loaded with QUOTES, the data was not coming from the proper int array that was actually going to hold my real data, that was the problem,

however, the screen picture you saw, came from THE REAL integer array of real (fake) data, it worked after i added the following…

also, i am going back over all this now and seeing if i can make it proper int and char arrays and get it to work now that i see itoa proper use :slight_smile:

EDIT actually as was said previously, the second array is not needed at all if itoa works on the int array holding the gathered data, thats what i am going to try to fix now

//this is the somewhat weird solution that gets the data above into a form that the touch screen can display instaed of garbage
//it loads a second array (arrayTemps) which is used to send data to the screen
//this could later be moved to the screen write code and that array done away with... arrayTemps

char t_as_string[20][4];//3 digits of t plus null terminator

 for (byte i = 0; i < 20; i++)
 {
   itoa(t[i], t_as_string[i], 10);//base 10 // TWO STEPS, i have to put the mux input FROM t[x]into t_as_string[x]
   //itoa(t[i], arrayTemps[i], 10);//base 10
 }

 for (byte i = 0; i < 20; i++)
 {
 arrayTemps[i] =t_as_string[i];// THEN, i have to put t_as_string into arrayTemps, this seems to work, otherwise i get garbage
 }

A serial print version of the IntAndInt() certainly does not print "789".
The Serial print of IntAndChar()is correct with "123"

void setup()
{
Serial.begin(115200);
IntAndChar();
IntAndInt();
}

void loop() {}

void IntAndChar() { //this will display 123 on the screen

int StuffToSend;
char* ConvStufftoSend;
StuffToSend = 123;
ConvStufftoSend = "456";
itoa(StuffToSend, ConvStufftoSend , 10); //base 10
Serial.println(ConvStufftoSend);

}

void IntAndInt() { //this will display 789 on the screen next line down from above

int StuffToSend;
int ConvStufftoSend;
StuffToSend = 789;
ConvStufftoSend = "321";
itoa(StuffToSend, ConvStufftoSend , 10); //base 10
Serial.println(ConvStufftoSend);
}

Are you saying that you see "789" on the screen with the TFT output from IntAndInt()?

Tft.drawString(ConvStufftoSend,120,320,2,WHITE);

THANKS TO ALL THAT HELPED, THIS IS A LOT CLEANER :slight_smile:

Serial print is not being used as far as i know, this is a parallel interface, as far as i know

Rewrote a lot of it, and all of this works now.

using more than one variable as temp scratchpad, can rewrite and reduce that to one probably
instead of loading all then drawing screen, i can load draw, then load draw, using one over and over

#include <stdint.h>
#include <TouchScreen.h> 
#include <TFT.h>

int muxTemps[20]; // 1 to 3 digit temps in F will be gathered from the mux and placed here as integers
char charTemps[1][4]; // this is used via ITOA to load the mux temps into an ascii string to send to the old parallel data display
//scratchpad, dont need 20

const int TempBarOneTop = 0;
const int left = 308;
const int spacer=16;
const int TempBarHeight=80;
const int TempBarWidth=16;
const int bartextspace=4;
const int font1hi=8;
const int TempBarTwoTop=56; 
const int BeginTextColumn=312;
const int LowBat=0;


const int MaxColdOpTemp=60; 
const int MaxFullOpTemp=102;
const int MaxChargeTemp=110; 
const int MaxOpTemp=123; 


const int nagMaxColdOpTemp=60;
const int nagMaxFullOpTemp=102; 
const int nagMaxChargeTemp=110; 
const int nagMaxOpTemp=123; 


void setup()
{
int i;
Tft.init();  //init TFT library
Tft.setDisplayDirect(DOWN2UP);
Tft.drawString("Air  84f in 124f out",TempBarHeight+TempBarWidth+font1hi+20,320,2,WHITE);//hard coded for now
//will be air in and out of unit, thermistors 21 and 22
}


void loop()
{
drawscreen();
delay(5000);
}


void drawscreen()
{
int i, BarColor, iHighBat, iLowBat;


char sHighBat[1][4];//used to write previous high stored as int to display as string
char sLowBat[1][4];//used to write previous low stored as int to display as string

loadtemps();

iHighBat=0;
iLowBat=999;

for (i = 0; i < 20; i++) {
     if (iLowBat>muxTemps[i]){
     iLowBat=muxTemps[i];
     }
     
     if (iHighBat<muxTemps[i]){
     iHighBat=muxTemps[i];
     }
}

itoa(iLowBat,sLowBat[0] , 10);
itoa(iHighBat,sHighBat[0] , 10);

//draw black wide bar to erase old temps  
Tft.fillRectangle(TempBarHeight+TempBarWidth+font1hi,320,8,320,BLACK); //HAD TO RESET TEMPS TO BLACK OR GARBELD UP ON UPDATE

Tft.drawString("Lo-",TempBarHeight+TempBarWidth+font1hi,320,2,WHITE);
Tft.drawString(sLowBat[0],TempBarHeight+TempBarWidth+font1hi,260,2,WHITE);
Tft.drawString("f",TempBarHeight+TempBarWidth+font1hi,230,2,WHITE);
Tft.drawString("Hi-",TempBarHeight+TempBarWidth+font1hi,205,2,WHITE);
Tft.drawString(sHighBat[0],TempBarHeight+TempBarWidth+font1hi,155,2,WHITE);
Tft.drawString("f",TempBarHeight+TempBarWidth+font1hi,110,2,WHITE);

//draw top bars
     for (i = 0; i < 10; i++) {

          if (muxTemps[i]<MaxColdOpTemp) { // <60
          BarColor=BLUE;  
          }
    
          else {
               if (muxTemps[i]>=MaxColdOpTemp&&muxTemps[i]<=MaxFullOpTemp) { // 60 <=102
               BarColor=GREEN;     
               }
      
               else {
                    if (muxTemps[i]>MaxFullOpTemp&&muxTemps[i]<MaxChargeTemp) { // >102 <110
                    BarColor=YELLOW;     
                    }
        
                    else {
                         if (muxTemps[i]>=MaxChargeTemp&&muxTemps[i]<MaxOpTemp) { //110 <123
                         BarColor=RED;
                         } 
          
                              else {
                                   if (muxTemps[i]>=MaxOpTemp) { //>=123
                                   BarColor=WHITE;
                                   }

                                        else {
                                        BarColor=BLACK;  
                                        }
                                   }
                         }
                    }
               }

  Tft.fillRectangle(TempBarOneTop, left-(i*(spacer+TempBarWidth)), TempBarHeight,TempBarWidth,BarColor);  // top start, left start (320 - values, 320 is left ), height, width, color
  }

//draw black wide bar to erase old temps  
Tft.fillRectangle(TempBarOneTop+TempBarHeight+bartextspace, 320,8,320,BLACK); //HAD TO RESET TEMPS TO BLACK OR GARBELD UP ON UPDATE

//draw temps under top bar

for (i = 0; i < 10; i++) {
itoa(muxTemps[i],charTemps[0] , 10);

      if (muxTemps[i]<100) //used to center 2 vs 3 digit temps on bar
      {
       Tft.drawString(charTemps[0],TempBarOneTop+TempBarHeight+bartextspace,BeginTextColumn-(i*32)-5,1,WHITE);
      }
      else {
           if (muxTemps[i]>=100)
            {
            Tft.drawString(charTemps[0],TempBarOneTop+TempBarHeight+bartextspace,BeginTextColumn-(i*32),1,WHITE);
            } 
      }
  }

//draw bottom bars

  for (i = 10; i < 20; i++) {

          if (muxTemps[i]<MaxColdOpTemp) { // <60
          BarColor=BLUE;  
          }
    
          else {
               if (muxTemps[i]>=MaxColdOpTemp&&muxTemps[i]<=MaxFullOpTemp) { // 60 <=102
               BarColor=GREEN;     
               }
      
               else {
                    if (muxTemps[i]>MaxFullOpTemp&&muxTemps[i]<MaxChargeTemp) { // >102 <110
                    BarColor=YELLOW;     
                    }
        
                    else {
                         if (muxTemps[i]>=MaxChargeTemp&&muxTemps[i]<MaxOpTemp) { //110 <123
                         BarColor=RED;
                         } 
          
                              else {
                                   if (muxTemps[i]>=MaxOpTemp) { //>=123
                                   BarColor=WHITE;
                                   }

                                        else {
                                        BarColor=CYAN;  
                                        }
                                   }
                         }
                    }
               }



    Tft.fillRectangle(TempBarOneTop+TempBarHeight+bartextspace+font1hi+TempBarTwoTop, left-((i-10)*(spacer+TempBarWidth)), TempBarHeight,TempBarWidth,BarColor);
  }

//draw black wide bar to erase old temps
Tft.fillRectangle(TempBarOneTop+TempBarHeight+bartextspace+font1hi+TempBarTwoTop+TempBarHeight+bartextspace+1, 320,8,320,BLACK); //HAD TO RESET TEMPS TO BLACK OR GARBELD UP ON UPDATE

//draw temps under bottom bar



  for (i = 10; i < 20; i++) {
itoa(muxTemps[i],charTemps[0] , 10);

      if (muxTemps[i]<100) //used to center 2 vs 3 digit temps on bar
      {
       Tft.drawString(charTemps[0],TempBarOneTop+TempBarHeight*2+TempBarTwoTop+spacer,BeginTextColumn-((i-10)*32)-5,1,WHITE);
      }
      else {
           if (muxTemps[i]>=100)
            {
            Tft.drawString(charTemps[0],TempBarOneTop+TempBarHeight*2+TempBarTwoTop+spacer,BeginTextColumn-((i-10)*32),1,WHITE);
            } 
      }
  }

}

void loadtemps() //this is where mux code will go to get temps from 20 sensors
{
//this is fake data simulating input from 20 thermistors coming soon on one pin via a mux ii multiplexer that has just arrived
//the array will stay and the values will be loaded from the mux every second
muxTemps[0] = 69;
muxTemps[1] = 112;
muxTemps[2] = 89;
muxTemps[3] = 114;
muxTemps[4] = 106;
muxTemps[5] = 98;
muxTemps[6] = 73;
muxTemps[7] = 84;
muxTemps[8] = 99;
muxTemps[9] = 134;
muxTemps[10] = 123;
muxTemps[11] = 143;
muxTemps[12] = 113;
muxTemps[13] = 156;
muxTemps[14] = 83;
muxTemps[15] = 87;
muxTemps[16] = 59;
muxTemps[17] = 145;
muxTemps[18] = 93;
muxTemps[19] = 99;

}