cancel
Showing results for 
Search instead for 
Did you mean: 

a variable value

Nmo.1
Associate III

hi every one.

I want to display the amount of ADC on the LCD. How can I show a variable value of ADC1ConvertedValue?

now I can only display a character on LCD.

i want to show: The ADC value is: (amount of the ADC Value)

int main(int argc, char* argv[])
{
	ADC1ConvertedValue = ADC_GetConversionValue(ADC1);
 
 
 
      char Satz1[] = "ADC1ConvertedValue";
	  char Satz2[] = "Hello       ";
	  char Satz3[] = "This is a Test";
	  char Satz4[] = "Navid";
 
	  config_pin();
	  config_ADC();
	  lcd_init();
	  TIM3_Init();
 
	  lcd_set_font(FONT_FIXED_8, NORMAL_SIZE);
	  lcd_moveto_xy(0, 0);
	  lcd_put_string_length(FONT_FIXED_8, NORMAL_SIZE, &Satz1[0], sizeof(Satz1));
 
	  lcd_moveto_xy(2, 0);
	  lcd_put_string_length(FONT_FIXED_16, NORMAL_SIZE, &Satz2[0], sizeof(Satz2));
 
	  lcd_moveto_xy(4, 4);
	  lcd_put_string_length(FONT_FIXED_16, NORMAL_SIZE, &Satz3[0], sizeof(Satz3));
 
	  lcd_moveto_xy(7, 0);
	  lcd_put_string_length(FONT_FIXED_8, NORMAL_SIZE, &Satz4[0], sizeof(Satz4));
 

3 REPLIES 3
TDK
Guru

You need to convert it to a string, then you print that string. sprintf can do the converting.

> lcd_put_string_length(FONT_FIXED_8, NORMAL_SIZE, &Satz1[0], sizeof(Satz1));

The length of the string is strlen(Satz1), not sizeof(Satz1). It may work in this instance, but only if trying to print a null character does nothing.

If you feel a post has answered your question, please click "Accept as Solution".
Nmo.1
Associate III

Thanks a lot. I did as you said, but the LCD doesn't show anything at all. the LCD is on, but all words

int main(int argc, char* argv[])
{
 
	  char str[16];
	  sprintf(str,"%d",ADC_GetConversionValue(0));
 
      char Satz1[] = "ADC1ConvertedValue";
	  char Satz2[] = "Herr Dr.       ";
	  char Satz3[] = "navid ";
	  char Satz4[] = "Uni  ";
 
	  config_pin();
	  config_ADC();
	  lcd_init();
	  TIM3_Init();
 
 
	  lcd_set_font(FONT_FIXED_8, NORMAL_SIZE);
 
	  lcd_moveto_xy(0, 0);
	  lcd_put_string_length(FONT_FIXED_8, NORMAL_SIZE,&str[0], strlen(str));
 
	  lcd_moveto_xy(2, 0);
	  lcd_put_string_length(FONT_FIXED_16, NORMAL_SIZE, &Satz2[0], strlen(Satz2));
 
	  lcd_moveto_xy(4, 4);
	  lcd_put_string_length(FONT_FIXED_16, NORMAL_SIZE, &Satz3[0], strlen(Satz3));
 
	  lcd_moveto_xy(7, 0);
	  lcd_put_string_length(FONT_FIXED_8, NORMAL_SIZE, &Satz4[0], strlen(Satz4));

are deleted.

TDK
Guru

So if you try to display the string "1234" you only see the character "1" on the LCD? That's a different issue than just displaying a number. Maybe I misunderstood the question.

I'm not familiar with the LCD library you're using. Likely the issue is in lcd_put_string_length somewhere. Not sure I want to dive into it.

If you feel a post has answered your question, please click "Accept as Solution".