compiling error

Hi
This line give me an error.

  //////////////////////////////////
 //int  M = sqrt(A*A +B*B); 
   int  M = sqrt(UxString2*UxString2 + UxString*UxString);
/////////////////////////////////

invalid operands of types 'char [4]' and 'char [4]' to binary 'operator*'

#include <LCD5110_Graph.h>
LCD5110 lcd(PA4, PA3, PA2, PA0, PA1);
extern unsigned char SmallFont[];

char UxString [4];
char UxString2 [4];
String str;
String str2;

int  UxValue = 0;
int  UxValue2 = 0;
int M = 0;
#include <STM32ADC.h>

STM32ADC myADC(ADC1);

uint8 pins[] = {PA6, PA7};

const int maxSamples = 2;
uint16_t dataPoints[maxSamples];
long sum1, sum2;

void setup() {

  lcd.InitLCD();
  lcd.setFont(SmallFont);

  Serial.begin(115200);

  myADC.calibrate();
  rcc_set_prescaler(RCC_PRESCALER_ADC, RCC_ADCPRE_PCLK_DIV_8);
  pinMode(PA6, INPUT_ANALOG);
  pinMode(PA7, INPUT_ANALOG);

  myADC.setSampleRate(ADC_SMPR_239_5);
  myADC.setScanMode();
  myADC.setPins(pins, 2);
  myADC.setContinuous();
  myADC.setDMA(dataPoints, 2, (DMA_MINC_MODE | DMA_CIRC_MODE), NULL);
  myADC.startConversion();
}

void loop() {

  lcd.clrScr();
  lcd.update();

  UxValue = sum1 / 10; sum1 = 0;// UxValue = analogRead(PA6);
  UxValue2 = sum2 / 10; sum2 = 0;// UxValue2 = analogRead(PA7);

  UxValue = map( UxValue, 0, 4095, 0, 94);
  UxValue2 = map( UxValue2, 0, 4095, 0, 94);
  str = String(UxValue) + "%";
  str2 = String(UxValue2) + "%";
  str.toCharArray(UxString, 4);
  str2.toCharArray(UxString2, 4);

  fillBar( UxValue);   //displays line
  lcd.print(UxString, 2, 0); // displays # in %, position x, y
  fillBar2( UxValue2);   //displays line
  lcd.print(UxString2, 22, 0); // displays # in %, position x, y

  //////////////////////////////////
 //int  M = sqrt(A*A +B*B); 
   int  M = sqrt(UxString2*UxString2 + UxString*UxString);
 lcd.print(M, 42, 0);
 /////////////////////////////////
 
  lcd.update();

  for (int j = 0; j < 10; j++) {
    sum1 = sum1 + dataPoints[0];
    sum2 = sum2 + dataPoints[1];
    delay(1);
  }

  Serial.print(UxValue);
  Serial.print("   ");
  Serial.println(UxValue2);

}

void fillBar(int percent)
{
  percent = map(percent, 0, 100, 0, 90);
  lcd.drawLine(2, 44, percent, 44);//x, y

}

void fillBar2(int percent2)
{
  percent2 = map(percent2, 0, 100, 0, 90);
  lcd.drawLine(2, 46, percent2, 46); //x, y
}

You can't perform arithmetic on a character array. I'm guessing that you really wanted to put UxValue and UxValue2 there??

so I changed to UxValue and UxValue2 and error is; expected initializer before '.' token from this line
void lcd.print(M, 22, 0);

#include <LCD5110_Graph.h>
LCD5110 lcd(PA4, PA3, PA2, PA0, PA1);
extern unsigned char SmallFont[];

char UxString [4];
char UxString2 [4];
String str;
String str2;

int  UxValue = 0;
int  UxValue2 = 0;
//int UxString = 0;
//int UxString2 ;
int M = 0;
#include <STM32ADC.h>

STM32ADC myADC(ADC1);

uint8 pins[] = {PA6, PA7};

const int maxSamples = 2;
uint16_t dataPoints[maxSamples];
long sum1, sum2;

void setup() {

  lcd.InitLCD();
  lcd.setFont(SmallFont);

  Serial.begin(115200);

  myADC.calibrate();
  rcc_set_prescaler(RCC_PRESCALER_ADC, RCC_ADCPRE_PCLK_DIV_8);
  pinMode(PA6, INPUT_ANALOG);
  pinMode(PA7, INPUT_ANALOG);

  myADC.setSampleRate(ADC_SMPR_239_5);
  myADC.setScanMode();
  myADC.setPins(pins, 2);
  myADC.setContinuous();
  myADC.setDMA(dataPoints, 2, (DMA_MINC_MODE | DMA_CIRC_MODE), NULL);
  myADC.startConversion();
}

void loop() {

  lcd.clrScr();
  lcd.update();

  UxValue = sum1 / 10; sum1 = 0;// UxValue = analogRead(PA6);
  UxValue2 = sum2 / 10; sum2 = 0;// UxValue2 = analogRead(PA7);

  UxValue = map( UxValue, 0, 4095, 0, 94);
  UxValue2 = map( UxValue2, 0, 4095, 0, 94);
  str = String(UxValue) + "%";
  str2 = String(UxValue2) + "%";
  str.toCharArray(UxString, 4);
  str2.toCharArray(UxString2, 4);

  fillBar( UxValue);   //displays line
  lcd.print(UxString, 2, 0); // displays # in %, position x, y
  fillBar2( UxValue2);   //displays line
  lcd.print(UxString2, 22, 0); // displays # in %, position x, y

  //////////////////////////////////
 //int  M = sqrt(A*A +B*B); 
// float  M = sqrt(UxString2*UxString2 + UxString*UxString);
  float  M = sqrt(UxValue*UxValue + UxValue2*UxValue2);
void lcd.print(M, 22, 0);

 /////////////////////////////////
 
  lcd.update();

  for (int j = 0; j < 10; j++) {
    sum1 = sum1 + dataPoints[0];
    sum2 = sum2 + dataPoints[1];
    delay(1);
  }

  Serial.print(UxValue);
  Serial.print("   ");
  Serial.println(UxValue2);

}

void fillBar(int percent)
{
  percent = map(percent, 0, 100, 0, 90);
  lcd.drawLine(2, 44, percent, 44);//x, y

}

void fillBar2(int percent2)
{
  percent2 = map(percent2, 0, 100, 0, 90);
  lcd.drawLine(2, 46, percent2, 46); //x, y
}

Why have you decided to put 'void' on that line?

Steve

Just guessing, and it is work with this line, which I added yesterday.

void fillBar3(int percent3)
{
  percent3 = map(percent3, 0, 100, 0, 90);
  lcd.drawLine(2, 44, percent3, 44); //x, y
}

Put down the Arduino.
Open up google.
Type "C++ tutorial".
Do any one of the dozens of perfectly fine C++ tutorials available on the internet.

If you put void in front of a CALL to a function the compiler thinks you're trying to DEFINE a NEW function. And if it's in the wrong place or the wrong thing to do the compiler tells you that you're doing something stupid.

BTW writing programs by guessing is one way to spend a lot of time getting very frustrated. It doesn't work.

Steve

I did, but on LCD I have 2 digit and on serial monitor 4

  lcd.print(MString3, 44, 0);

this is not working

 lcd.print((MString3, 2), 44, 0);

Screen Shot 2021-01-20 at 10.14.25 AM.png

Screen Shot 2021-01-20 at 10.14.25 AM.png