Friday, April 21, 2017

Arduino LCD circular meter

 
As the openGLCD library contains only bar type meters, V & H, I've drew a circular meter to display rpm for my "poor-man-LCD", so it's more appealing and easier to read. A nice impression is given only by the two letters "II" that go around the circular loop. May be someone find it useful.Here is the code:

* DrawCircle - openGLCD API example 
* 
* Example of using: 
* Circle()
*
* Circle(xCenter,yCenter, radius, [color]);

#include

 void setup()
{
        GLCD.Init();
        GLCD.SelectFont(Callibri14);
}

void loop(void)
{
        GLCD.ClearScreen();

        float  rpm  = random(12,1023);             // random values for rpm
        rpm=rpm*1000/244;                              // it should count freq./
        float rd;                                                  // period instead
        rd = (float)rpm/2673.2;                         // angle for "II" position

       GLCD.DrawCircle(GLCD.Right,GLCD.Bottom, 58);
       
        float RD =0.0;
        while (RD < rd) { 
           GLCD.CursorToXY(GLCD.Right-((58*cos(RD))), GLCD.Bottom-(64*sin(RD)));
                GLCD.print(F("II"));
                delay(RD*20);
                GLCD.DrawLine(GLCD.Right,GLCD.Bottom, GLCD.Right-(64*cos(rd)),GLCD.Bottom-(64*sin(rd)));
                RD=RD+0.03;
         }

GLCD.SelectFont(lSansN_22);
GLCD.CursorToXY(GLCD.CenterX+24,GLCD.Bottom-32);
rpm=rpm/10;
GLCD.print(rpm,0);
GLCD.print(F("0"));
GLCD.SelectFont(Callibri14);
delay(4000);
            
}


For 2 Outboards: 2 RPM meters (One "I" going around), 1x Voltmeter (H-bar),
2 hrs counters: