The unified diff between revisions [d0420ebd..] and [be147b11..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'stick.c'

#
# old_revision [d0420ebd87c820e33a32b29727989516e15980a8]
# new_revision [be147b11caac304fda1579ac71017eecc3bb79e0]
#
# patch "stick.c"
#  from [b0c0cbffb3863a3992abc1ac1148fc90f019309b]
#    to [4870f5f016221d25b0d8a4d093fda5dbe0f0b30c]
#
============================================================
--- stick.c	b0c0cbffb3863a3992abc1ac1148fc90f019309b
+++ stick.c	4870f5f016221d25b0d8a4d093fda5dbe0f0b30c
@@ -13,29 +13,38 @@
 #include "trig.h"
 #include "motor.h"
 #include "wmp.h"
+#include "status.h"
+#include "watchdog.h"
 
 #define TWO_PI 6.28318531f
 #define PI 3.14159265f
 
-#define MIN_X 15830
-#define MAX_X 28300
-#define CENTRE_X 22100
+#define MIN_X 14700
+#define MAX_X 29700
+#define CENTRE_X 22200
 
-#define MIN_Y 18530
-#define MAX_Y 28200
-#define CENTRE_Y 22100
+#define MIN_Y 14700
+#define MAX_Y 29700
+#define CENTRE_Y 22200
 
-#define MIN_Z 15800
-#define MAX_Z 28304
-#define CENTRE_Z 22100
+#define MIN_Z 14700
+#define MAX_Z 29700
+#define CENTRE_Z 22200
 
-#define MIN_THR 16500
-#define MAX_THR 28275
+#define MIN_THR 15700
+#define MAX_THR 29700
 
-#define MIN_REAL_THR 15830
+#define MIN_REAL_THR 14700
 
 #define CENTRE_ZONE 100
 
+/* With new TX firmware:
+ *             x      y    thr      z
+ * centre: 22192, 22222, 14687, 22196
+ * min:    14686, 14701, 14686, 14687
+ * max:    29740, 29740, 29725, 29725
+ */
+
 /* Full scale is a roll/pitch angle of 30 degrees from the vertical */
 #define SCALE_X (TWO_PI*30.0/360.0 / (MAX_X-CENTRE_X))
 #define SCALE_Y (TWO_PI*30.0/360.0 / (MAX_Y-CENTRE_Y))
@@ -50,8 +59,6 @@ unsigned int stick_counter;
 
 unsigned int stick_counter;
 
-bool armed = FALSE;
-
 void stick_update(float x, float y, float z)
 {
 	float tz = delta_t * z;
@@ -77,6 +84,25 @@ void stick_update(float x, float y, floa
 	dcm_attitude_error(x, y, z);
 }
 
+#ifdef STICK_DEBUG_CALIBRATE
+void stick_debug_calibrate()
+{
+	unsigned int t1 = timer_input(0);
+	unsigned int t2 = timer_input(1);
+	unsigned int t3 = timer_input(2);
+	unsigned int t4 = timer_input(3);
+        putstr("S:(");
+        putint(t1);
+        putstr(",");
+        putint(t2);
+        putstr(",");
+        putint(t3);
+        putstr(",");
+        putint(t4);
+        putstr(")\r\n");
+}
+#endif
+
 void stick_input(void) {
 	float x, y, z, throttle;
 	if (timer_allvalid()) {
@@ -85,18 +111,22 @@ void stick_input(void) {
 		throttle = timer_input(2);
 		z = timer_input(3);
 
-		if (!armed) {
+#ifdef STICK_DEBUG_CALIBRATE
+		if ((stick_counter % 20) == 0)
+			stick_debug_calibrate();
+#endif
+
+		if (!status_armed()) {
 			if ((throttle < MIN_THR) &&
 			    (x > (CENTRE_X - CENTRE_ZONE)) &&
 			    (x < (CENTRE_X + CENTRE_ZONE)) &&
 			    (y > (CENTRE_Y - CENTRE_ZONE)) &&
 			    (y < (CENTRE_Y + CENTRE_ZONE)) &&
 			    (z > (CENTRE_Z - CENTRE_ZONE)) &&
-			    (z < (CENTRE_Z + CENTRE_ZONE)) &&
-			    (wmp_zero == FALSE)) {
-				putstr("ARMED!!!\r\n");
-				armed = TRUE;
-			}
+			    (z < (CENTRE_Z + CENTRE_ZONE)))
+				    status_set_ready(STATUS_MODULE_STICK, TRUE);
+			else
+				    status_set_ready(STATUS_MODULE_STICK,FALSE);
 
 		}
 
@@ -114,10 +144,13 @@ void stick_input(void) {
 		y = 0.0f;
 		z = 0.0f;
 		throttle = 0.0f;
+		status_set_ready(STATUS_MODULE_STICK,FALSE);
 	}
 
 	motor_set_throttle(throttle);
 
+	watchdog_kick(WATCHDOG_STICK);
+
 	/* So the controls are back to front. Let's fix that. */
 	x = -x;
 	y = -y;