This class encapsulates all the algorithms required for the displaying strings and time dependent patterns on the lcd.

Dependents:   200943412_QuickClick

Revision:
16:8d158d39d438
Parent:
15:c14c72342de7
Child:
17:1c52ff51c028
--- a/Display.cpp	Mon Apr 24 09:46:56 2017 +0000
+++ b/Display.cpp	Mon May 01 17:04:13 2017 +0000
@@ -6,13 +6,12 @@
 Display::Display()
 {
      _h = 0;
-     _w = 0.3;
+     _w = 0.2;
      _a = 0; 
-     _v = 0; 
-     x = 0;
-    y = 0; 
-    x0 = 0;
-    y0 = 0;
+     _x = 0;
+    _y = 0; 
+    _x0 = 0;
+    _y0 = 0;
 }
 
 Display::~Display()
@@ -23,30 +22,29 @@
 {
 
      _h = 0;
-     _w = 0.3;
+     _w = 0.2;
      _a = 0;
-     _v = 0; 
-     x = 0; 
-     y = 0; 
-     x0 = 0;
-    y0 = 0; 
+     _x = 0; 
+     _y = 0; 
+     _x0 = 0;
+    _y0 = 0; 
 }
 
 void Display::drawCircle(Controller &pad, N5110 &lcd)
 {  
-    Circle(pad, lcd);  
+    _arc_selector(pad, lcd);  
     //printf("Prev Wait:- %3.2f\n",_w);
-    calculateWait();  
+    _calculateWait();  
     _h++;  
     //printf("Score:- %d\n",_h);
     lcd.clear(); 
     lcd.refresh();
     } 
 
-void Display::calculateWait() 
+void Display::_calculateWait() 
 {  
-   _w = 0.2*exp(-0.0231*_h);  //this equation models how much time the user has to complete action with larger amounts of iterations.
-    
+   _w = 0.2*exp(-0.0231*_h);  //this equation models how much time the user has 
+                            //to complete action with larger amounts of iterations. 
 } 
 
 
@@ -90,12 +88,12 @@
     } 
        
 // function to draw circle
-void Display::Circle(Controller &ctrl ,N5110 &lcd)
+void Display::_arc_selector(Controller &ctrl ,N5110 &lcd)
 {
-  for (int a = 0; a < 8; ++a)
+  for (int _a = 0; _a < 8; ++_a)
         {
     //printf("for loop (a):- %d\n",a);
-    Drawarc(lcd, a);
+    _drawArc(lcd, _a);
     lcd.refresh();
     float Brightness = ctrl.pot_value(); //set brightness to petentiometer value
     lcd.setBrightness(0.0);         
@@ -108,74 +106,74 @@
  
    }   
     
-void Display::Drawarc(N5110 &lcd, int a) { 
-    x = 20;
-    y = 0;
+void Display::_drawArc(N5110 &lcd, int _a) { 
+    _x = 20;
+    _y = 0;
     
     int a1;
     int b1;
-    radiusMod = 1-x; 
-    x0 = 42; 
-    y0 = 24;
+    _radiusMod = 1-_x; 
+    _x0 = 42; 
+    _y0 = 24;
 
-    while(x >= y) { 
+    while(_x >= _y) { 
     
-    switch(a) { 
+    switch(_a) { 
     
-        case 0 : {a1 = y;           //each case statement draws an arc by setting a1 and b1 accordingly
-                  b1 = x * -1;
+        case 0 : {a1 = _y;           //each case statement draws a single octant by setting a1 and b1 accordingly
+                  b1 = _x * -1;
                   break;
                 }            
-        case 1 : {a1 = x;
-                  b1 = y * -1;
+        case 1 : {a1 = _x;
+                  b1 = _y * -1;
                   break;
                 }           
-        case 2 : {a1 = x;
-                  b1 = y;
+        case 2 : {a1 = _x;
+                  b1 = _y;
                   break;
                 }                       
-        case 3 : {a1 = y;
-                  b1 = x;
+        case 3 : {a1 = _y;
+                  b1 = _x;
                   break;
                 }   
-        case 4 : {a1 = y * -1;
-                  b1 = x;
+        case 4 : {a1 = _y * -1;
+                  b1 = _x;
                   break;
                 } 
-        case 5 : {a1 = x * -1;
-                  b1 = y;
+        case 5 : {a1 = _x * -1;
+                  b1 = _y;
                   break;
                 }
-        case 6 : {a1 = x * -1;
-                  b1 = y * -1;
+        case 6 : {a1 = _x * -1;
+                  b1 = _y * -1;
                   break;
                 }                
-        case 7 : {a1 = y * -1;
-                  b1 = x * -1;
+        case 7 : {a1 = _y * -1;
+                  b1 = _x * -1;
                   break;
                 }               
-        default : { a1 = x;
-                b1 = y * -1;
+        default : { a1 = _x;
+                b1 = _y * -1;
                 break;
                 } 
         }
                                   
                               
-            lcd.setPixel( a1 + x0,  b1 + y0); //draws octant depending on a1 and b1
+            lcd.setPixel( a1 + _x0,  b1 + _y0); //draws octant depending on a1 and b1
         
-        y++;   
+        _y++;   
 
    
-        if (radiusMod<0) {
-            radiusMod += 2*y+1;
+        if (_radiusMod<0) {
+            _radiusMod += 2*_y+1;
         } else {
-            x--;
-            radiusMod += 2*(y-x)+1;
+            _x--;
+            _radiusMod += 2*(_y-_x)+1;
         }
-        //printf("a1:- %d\n", a1); 
-        //printf("b1:- %d\n", b1); 
-        //printf("x:- %d\n", x); 
-        //printf("y:- %d\n", y);
-        //printf("radiusMod:- %d\n",radiusMod);
+        //printf("_a1:- %d\n", _a1); 
+        //printf("_b1:- %d\n", _b1); 
+        //printf("_x:- %d\n", _x); 
+        //printf("_y:- %d\n", _y);
+        //printf("_radiusMod:- %d\n",_radiusMod);
     }
-}
+}
\ No newline at end of file