Reading multiple analog values then displaying them on TFT

General discussion on Visual TFT Software.
Post Reply
Author
Message
MohdAyyoub
Posts: 15
Joined: 12 Jul 2018 05:42

Reading multiple analog values then displaying them on TFT

#1 Post by MohdAyyoub » 25 Sep 2018 13:47

Hi,

I have designed a TFT program to display my connected sensors' reading on the screen.
I am using mikromedia+ for STM32 ARM, MCU STM32F407ZG. I am trying to read 4 analog values to display them on the screen.

The problem is, I used the function "strcpy" to copy the reading to my labels after converting the reading to string (using WordToStr), but all 4 labels get assigned with the same value.

Below is the code I have written (commented) to make things clear. Also, I will attach a picture of the screen to fully clarify what I mean.

Code: Select all

      if (TFTflag == 1) 
   {
   TankLevelLabel.Font_Color = 0xFFFFFFF;         //These lines are written to
   TankVolumeLabel.Font_Color = 0xFFFFFFF;        // the Screen in background
   SteamPressureLabel.Font_Color = 0xFFFFFFF;     //(white) colour, to set up
   TemperatureLabel.Font_Color = 0xFFFFFFF;       //space for the new reading

   DrawLabel(&TankLevelLabel);
   DrawLabel(&TankVolumeLabel);
   DrawLabel(&SteamPressureLabel);
   DrawLabel(&TemperatureLabel);                 //Draw in white (same as erase)

   Delay_ms(10);

   TankLevelLabel.Font_Color = 0x0000001;
   TankVolumeLabel.Font_Color = 0x0000001;
   SteamPressureLabel.Font_Color =0x0000001;
   TemperatureLabel.Font_Color = 0x0000001;      //Choose red colour for all 4 labels.

   strcpy(TankLevelLabel.Caption,p1);
   strcpy(TankVolumeLabel.Caption,p2);         //Copy the analog reading string
   strcpy(SteamPressureLabel.Caption,p3);      //to the labels.
   strcpy(TemperatureLabel.Caption,p4);        //My analog values are p1 - p4.

   DrawLabel(&TankLevelLabel);
   DrawLabel(&TankVolumeLabel);
   DrawLabel(&SteamPressureLabel);              //Redraw the labels using the read values
   DrawLabel(&TemperatureLabel);

   TFTflag = 0;                                 //Write every Second (TFTflag is changed to 1 in a timer module)
   }
Why does the code assign the value of p4 to all labels? Is there something I am missing in the code? I have read the strcpy syntax but I could not figure the error out.


Please note that I have read the analog values to LCD and UART and they were working fine. Here is the definition:

Code: Select all

//Obtaining sensor readings and saving them in registers p1, p2, p3, p4:
   ADC_Set_Input_Channel(_ADC_CHANNEL_4);
   WordToStr(ADC1_Get_Sample(4), p1);

   ADC_Set_Input_Channel(_ADC_CHANNEL_5);
   WordToStr(ADC1_Get_Sample(5), p2);

   ADC_Set_Input_Channel(_ADC_CHANNEL_6);
   WordToStr(ADC1_Get_Sample(6), p3);

   ADC_Set_Input_Channel(_ADC_CHANNEL_8);
   WordToStr(ADC1_Get_Sample(6), p4);
Thank you very much in advance.
Regards,
M. Ayoub
Attachments
42539913_669459473424381_2188470555265466368_n.jpg
42539913_669459473424381_2188470555265466368_n.jpg (294.76 KiB) Viewed 988 times

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: Reading multiple analog values then displaying them on T

#2 Post by petar.suknjaja » 26 Sep 2018 15:20

Could you send the zipped project code for review to the
petar.suknjaja@mikroe.com

or upload it here if it's not commercially sensitive.

Kind regards,
Petar

Post Reply

Return to “Visual TFT General”