Hyperbola on a 5110 using ADAFRUIT Lib

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.

Best Gerrit

GaugeHyperbola1.gif

GaugeHyperbola2.gif

y = ((2.12 * x) - 0.81)/((0.15 * x) + 0.67)

given the formula above:

  • if x is incremented by 1 => y is incremented by 12-14 so you need to take small steps for x (0.05) to get a continuous pixels
  • if you fill in the formula in google search you get a graph . This might help to find the (x,y) range you want to map upon the display coordinates.

Rob, dank ye wel!

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 very much and: hurray :slight_smile:

Welcome,

I can print very nice hyperbolas now:

can you post a picture?

sure ...

hyperbola-gauge.jpg

looks good!

That's pretty good.

I have been using 5110s for a while but had given up on doing any graphic stuff, even though that is why I got them in the first place.

Thanks

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.

Happy Hacking
Gerrit

link to geoGabra?

geogebra.org

Google for GeoGebra + Trend. You should find some examples which you can load into GeoGebra ...