The unified diff between revisions [24d5b9f4..] and [5a7404c7..] is displayed below. It can also be downloaded as a raw diff.

#
# old_revision [24d5b9f4dff9135787b198fe1127d9c1e3326b9c]
# new_revision [5a7404c7ee458d3eab4b0548e4bc6b6a8b26135f]
#
# patch "main.c"
#  from [8284ca89102568b2ae6f26e057ab296621f87e6a]
#    to [cffbf353c53aca29609c39daadeb325f98328bd5]
#
============================================================
--- main.c	8284ca89102568b2ae6f26e057ab296621f87e6a
+++ main.c	cffbf353c53aca29609c39daadeb325f98328bd5
@@ -18,6 +18,7 @@
 
 #define SCS (*((volatile unsigned int *) 0xe01fc1a0))
 
+#define BUTTON_PRESSED (!((FP0XVAL) & 0x00010000))
 
 void init_pins(void)
 {
@@ -180,6 +181,53 @@ void menu_handler(void);
 
 void menu_handler(void);
 
+void wait_for_button_pressed(bool target)
+{
+	bool pressed;
+
+	led_set(!target);
+
+	/* Very crude debouncing */
+	timer_delay_ms(100);
+
+	target = target ? TRUE:FALSE;
+
+	do {
+		pressed = BUTTON_PRESSED;
+	} while (pressed != target);
+	led_set(pressed);
+}
+
+void calibrate_escs()
+{
+	wait_for_button_pressed(0);
+
+	putstr("Calibration mode\r\n");
+
+	wait_for_button_pressed(1);
+	wait_for_button_pressed(0);
+
+	set_thrust(0, 1.0);
+	set_thrust(1, 1.0);
+	set_thrust(2, 1.0);
+	set_thrust(3, 1.0);
+	putstr("Max throttle set\r\n");
+
+	wait_for_button_pressed(1);
+	wait_for_button_pressed(0);
+
+	set_thrust(0, 0.0);
+	set_thrust(1, 0.0);
+	set_thrust(2, 0.0);
+	set_thrust(3, 0.0);
+	putstr("Zero throttle set\r\n");
+
+	wait_for_button_pressed(1);
+	wait_for_button_pressed(0);
+
+	putstr("Exit calibration mode\r\n");
+}
+
 int main(void) {
 	init_interrupt();
 	init_uart();
@@ -196,6 +244,9 @@ int main(void) {
 
 	putstr("Your entire life has been a mathematical error... a mathematical error I'm about to correct!\r\n");
 
+	if (BUTTON_PRESSED)
+		calibrate_escs();
+
 	putstr("prompt> ");
 
 	timer_delay_ms(1000);