 # X Y graph.

On oscilloscope we have for DC voltage a dot moved from center (zero x and y ) by Ux and Uy, in my case wil be a line similar as on post #12.

I have two lines with one variable each , percent and volt, I need one line with two variables.

If you know how a Lissajous figure is drawn, what’s the problem?

It is better to observe the line than a dot.
Almost there.

`````` void fillBar(int percent) // X
{
percent = map(percent, 0, 100, 2, 81);
myGLCD.drawLine(2, 44, percent, 44);

}
void fillBar2(int volt) // Y ?
{
volt = map(volt, 0, 100, 2, 81);
myGLCD.drawLine(2, 40, volt, 40);
}
void fillBar(int percent),fillBar2(int volt))
{
myGLCD.drawLine(2, 44, percent, volt);
}
``````

only 2 errors

nokia_xy_4:92:20: error: expected constructor, destructor, or type conversion before ';' token
void fillBar(int percent),fillBar2(int volt))
^
nokia_xy_4:92:45: error: expected initializer before ')' token
void fillBar(int percent),fillBar2(int volt))
^
exit status 1
expected constructor, destructor, or type conversion before ';' token

line92

``````void fillBar(int percent),fillBar2(int volt))
``````

And now we’re back to reply #9.

Yes, but with less errors.
With this line only 1 error.

``````void (fillBar(int percent)) && (fillBar2(int volt))
``````

nokia_xy_4:96:29: error: expected initializer before '&&' token
void (fillBar(int percent)) && (fillBar2(int volt))
^~
exit status 1
expected initializer before '&&' token

This is turning into a Month Python sketch.
What on Earth do you imagine a logical AND does in there?I

Yes, but with less errors.
With this line only 1 error.

``````void (fillBar(int percent)) && (fillBar2(int volt))
``````

nokia_xy_4:96:29: error: expected initializer before '&&' token
void (fillBar(int percent)) && (fillBar2(int volt))
^~
exit status 1
expected initializer before '&&' token

TheMemberFormerlyKnownAsAWOL:
This is turning into a Month Python sketch.
What on Earth do you imagine a logical AND does in there?I

For now is reducing # of errors

My guess is that this is close to what you intended. At least it compiles without error for an UNO. To compile for a “Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), STLink, 72Mhz (Normal), Smallest (default)” you will have to pick different pin names.

``````#include <LCD5110_Graph.h>

LCD5110 myGLCD(8, 9, 10, 12, 11);
// LCD5110 myGLCD(PA4, PA3, PA2, PA0, PA1);

extern unsigned char SmallFont[];
extern unsigned char TinyFont[];

// int LDRpin = PA6;
// int LDRpin2 = PA7;
int LDRpin = A0;
int LDRpin2 = A1;

int volt;
char lightString ;
char lightString2 ;

String str;
String str2;

int lightIntensity = 0;
int lightIntensity2 = 0;

void setup()
{
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}

void loop()
{
myGLCD.clrScr();

lightIntensity = map(lightIntensity, 0, 4095, 0, 100);
lightIntensity2 = map(lightIntensity2, 0, 4095, 0, 100);

str = String(lightIntensity) + "%";
str2 = String(lightIntensity2) + "%";

//str.toCharArray(lightString, 4);
str.toCharArray(lightString, 6);
str2.toCharArray(lightString2, 4);

// high line
myGLCD.print(lightString2, 2, 17);
fillBar2(lightIntensity2);

//low line
myGLCD.print(lightString, 2, 32);
fillBar(lightIntensity);

printBar(lightIntensity, lightIntensity2);

myGLCD.update();
delay(100);
}

//..............................................................

void  printBar(int percent, int volt)
{
percent = map(percent, 0, 100, 2, 81);
volt = map(volt, 0, 100, 2, 81);
myGLCD.drawLine(2, 44, percent, volt); // x1 = 2, y1 = 44, x2 = percent, y2=volt;
}

void fillBar(int percent) // X
{
percent = map(percent, 0, 100, 2, 81);
myGLCD.drawLine(2, 44, percent, 44);
}

void fillBar2(int volt) // Y ?
{
volt = map(volt, 0, 100, 2, 81);
myGLCD.drawLine(2, 40, volt, 40);
}
``````

Thanks it is working, just some calibration is needed.
I connected both input to the same potentiometer so line supposed to be all the time at 45 deg as in post #12 and only the length of it should change.

At 0V = 0% should be a dot on left lower corner, I have a viertical line on the left side of the screen from the bottom to the top of it.
At 54% = 1.74V = horizontal line on the bottom , from 0 to 1/2 of with of the screen.
Above 54% the line is going below edge of the screen = negative Y

Let's try asking, what is the intention here?

``````void fillBar(int percent),fillBar2(int volt))
``````

percent = voltage on pin PA6
volt = voltage on pin PA7

tom321:
percent = voltage on pin PA6
volt = voltage on pin PA7

Yes, but what are you trying to do with them in this line?

Look at the picture, short lines are percent and volt, long line should be also short at 45 deg.
Long line = myGLCD.drawLine(2, 44, percent, volt); // x1 = 2, y1 = 44, x2 = percent, y2=volt;

Look at the picture, short lines are percent and volt, long line should be also short at 45 deg.
For 10% on the screen;
percent =10 = OK
volt =10 = OK
long line = 14 (pitagoras formula) = should be 14, but is much longer = not OK = why ?

I founded it, point x=0 and y = 0 it is left upper corner, so this line is working ok.

``````  lcd.drawLine(0, 0, volt, percent);
``````

I was trying to bring it down = not succeeded

``````//lcd.drawLine(2, 44, volt,100 - percent);
``````