Hi Guys,
I got my hands on a neat little Display, a Nokia5110. I want to use it on a Nano, hook up a Voltagedivider and a temperatur Sensor and display the Values on the Display. Displaying the Values in numeric form is easy, but I also want a gauge like feedback displayed.
I started with some Bitmaps (attached) and I could just implement some arrays to visualise the different Values and display them according to the measurments, but I thought it would be much more elegant to come up with some algorithm to do so.
Well, I've tried. This should be close enough to calculate some of the dots: y = ((2.12 * x) - 0.81)/((0.15 * x) + 0.67), but it seems to be not good enough to draw a nice Hyperbola - at least it seems I'm not smart enought to implement it in the right way.
So, anybody who could draw a Hyperbola gets a big hurray from me. Advice and ideas are very much appreciated.
this hint was what I was looking for ... should have asked much earlier.
I can print very nice hyperbolas now:
// Funktion um eine Hyperbel zu zeichnen
// cursor setzen
int xCurStart = 0; int yCurStart = 47;
// Vars für den Cursor
int xCur; int yCur;
// Länge des Graphen in x Richtung
int xLong = map(analogRead(potiPin), 0, 1023, 10, 80);
// Vars für die Berechnungen
float y; float x = 0.01;
for (int i = xCurStart; i < xCurStart + xLong; i++){
y = ((1.92 * x) - 0.14)/((0.06 * x) + 0.32);
// x für die nächste Berechnung vorbereiten
x = x + 0.3;
yCur = yCurStart - y;
xCur = i;
Serial.print("yCur: ");Serial.println(yCur);
display.drawPixel(xCur,yCur,BLACK);
display.display();
delay(100);
}
Thank you guys!
I tweaked the Values a bit to match my original design. To trigger the dots between the hyperbola and the x-axis a simple for-loop is in place to do the "magic". I already hooked up a poti to manipulate the length of the curve.
The problem I had was quite simple and Rob somehow diagnosed it right away. I actually used the x-Position to calcualte y, which resulted in very high y-Values. BTW I wasn't aware that google can process functions (very handy).
I was using GeoGebra to get an idea on how the formula should look like.
For example:
If you have to work with non-linear things one can measure a bunch of states and place some dots in GeoGebra and have GeoGebra come up with a function.