Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: widgets/EACompass.cpp
- Revision:
- 7:6cf21b018420
- Parent:
- 4:f8f7f4f9c58d
--- a/widgets/EACompass.cpp	Thu May 06 23:32:14 2010 +0000
+++ b/widgets/EACompass.cpp	Mon Nov 01 13:07:40 2010 +0000
@@ -32,6 +32,9 @@
     
     // Now draw the pointer.
     _drawPointer(lcd);
+    
+    // Next draw the angle value.
+    _drawAngle(lcd);
 }
 
 void EACompass::update(EALCD& lcd, float angle)
@@ -45,6 +48,7 @@
     lcd.setPen(p);    
 
     _drawPointer(lcd);
+    _drawAngle(lcd);
     
     p.setColor(oldColour);
     lcd.setPen(p);
@@ -53,6 +57,7 @@
     setAngle(angle);
     
     _drawPointer(lcd);
+    _drawAngle(lcd);
 }
 
 void EACompass::_drawPointer(EALCD& lcd)
@@ -73,3 +78,24 @@
     // Draw ball at north end.
     lcd.drawFilledEllipse(x1-5, y1-5, 10, 10);
 }
+
+void EACompass::_drawAngle(EALCD& lcd)
+{
+    short tx = x() + (diameter()/2);
+    short ty = y() + diameter();
+
+    EAFont font;
+    
+    font.load("/local/small.fnt");   
+    lcd.setFont(font);  
+
+    /*
+    REVISIT - formatting string to draw heading.
+    char angleBuffer[5];
+    float angleDeg = (angle() * 180)/PI;
+    sprintf(angleBuffer, "%03.0f", angleDeg);
+    
+    lcd.drawText(tx, ty, angleBuffer);
+    */
+    
+}