derp

Dependencies:   FastPWM3 mbed

Revision:
16:46703e957b30
Parent:
15:8eb1dfbf0d41
Child:
17:77e5b417e6ef
Child:
18:1215f085b60f
Child:
21:3bfff547c5e2
--- a/main.cpp	Tue Apr 19 03:26:15 2016 +0000
+++ b/main.cpp	Tue Apr 19 05:46:29 2016 +0000
@@ -42,13 +42,15 @@
 
 DigitalIn throttle_in(PB_8);
 PositionSensorEncoder pos(CPR, 0);
+Serial pc(USBTX, USBRX);
 
 int adval1, adval2;
 float ia, ib, ic, alpha, beta, q;
 double vq = 0.0, q_integral = 0.0, last_q = 0.0;
-float throttle = 0.0f;
 
-int edge_seen = 0, watchdog_divider = 0;
+float throttle_scaler = 0.0f;
+
+int state = 0;
  
 extern "C" void TIM1_UP_TIM10_IRQHandler(void) {
     if (TIM1->SR & TIM_SR_UIF) {
@@ -78,13 +80,13 @@
         beta = 1 / sqrtf(3.0f) * u + 2 / sqrtf(3.0f) * v;
         
         q = -alpha * sin_p - beta * cos_p;
-        
-        float throttle_scaler;
                 
         if (throttle_in.read() == 0) {
+            state = 0;
             throttle_scaler = 0.0f;
             en = 0;
         } else {
+            state = 1;
             throttle_scaler = 1.0f;
             en = 1;
         }
@@ -184,6 +186,12 @@
     
     throttle_in.mode(PullUp);
     
+    pc.baud(115200);
+    
+    pc.printf("%s\n\r", "THE DENTIST controller Rev. A");
+    
     for (;;) {
+        pc.printf("%d %f\n\r", state, throttle_scaler);
+        wait_ms(100);
     }
 }