midtermDorianFolie

Dependencies:   SLCD TSI mbed

Fork of kl46z_slider_mid_v1 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
dorian505
Date:
Mon Oct 10 02:42:05 2016 +0000
Parent:
1:44dcf262c7dd
Commit message:
midtermDorianFolie

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Oct 01 22:10:10 2016 +0000
+++ b/main.cpp	Mon Oct 10 02:42:05 2016 +0000
@@ -26,6 +26,30 @@
 float tsidata;
 int displayState;
 
+float newtonSqrt(float argument){
+#define MAXITER 20
+    int i = 0;
+    float xnew = 0.0;
+    int itermax = MAXITER;
+    float epsilon = EPSILONC;
+    float xold = argument/2.0;
+    float delta = 1;
+    intmax = 20
+    epsilon = 1e-7
+    #xold = float(a/2.5)# make a guess5
+
+    for interations in range(0,intmax):
+        xnew = 0.5*(xold + (a/xold)) # Calculation
+        delta = abs(xnew-xold) # Compare old and new values
+        
+        if delta < epsilon: # Check for convergence
+            break
+        else:
+            xold = xnew # replace new calculated value to redo the calculation
+    
+   return(xnew);
+}
+
 void initialize_global_vars(){
     pc.printf(PROGNAME);
     // set up DAQ timers
@@ -62,6 +86,7 @@
                 } // if ! buttons
             }// for loop to look at buttons
             ButtonTimer.reset();
+            lcdArgument = tsidata * 100;
             sprintf (lcdData,"%0.4f",tsidata);  
             LCDMess(lcdData); 
             rled = 0.0;
@@ -80,4 +105,4 @@
             lastTouch=tsidata;
         }
     }
-}
\ No newline at end of file
+}