Example of using "Canvas" form "Graphics" library to display 3D graphics.

Dependencies:   BSP_DISCO_F746NG Graphics mbed

Revision:
0:8acbce46eede
Child:
2:ef3093a7a43e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HardwareAccess/Scale.cpp	Sun Nov 06 02:14:34 2016 +0000
@@ -0,0 +1,56 @@
+//
+//  Scale.cpp
+//
+
+#include "Scale.h"
+#include "mbed.h"   // for AnalogIn
+
+#ifdef ARDUINO 
+int scalePin = 1;
+#else
+AnalogIn scaleRead(A1);
+#endif
+
+Scale::Scale()
+{
+    Setup(1.f, 0.4f, 1.f, 8.f);
+}
+
+Scale::Scale(float min, float max)
+{
+    Setup(1.f, 0.4f, min, max);
+}
+
+void Scale::Setup(float scale, float delts, float min, float max)
+{
+    scale = scale;
+    delta = delta;
+    minScale = min;
+    maxScale = max;   
+}
+
+// Simulate scale changing
+float Scale::GetScale()
+{
+    scale += delta;
+
+    if(scale > maxScale)
+        delta *= -1.f;
+
+    if(scale < minScale)
+        delta *= -1.f;
+
+    return scale;
+}
+
+/// Read the scale from a potentiometer attached to analog pin
+float Scale::ReadScale()
+{
+#ifdef ARDUINO
+    scale = analogRead(scalePin);
+#else
+    scale = scaleRead;
+#endif
+
+    return minScale + scale * (maxScale - minScale)/1024.f;
+}
\ No newline at end of file