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)
}
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);
Regards,
M. Ayoub