 #include <Servo.h>
+#include <inttypes.h>
+#include <signal.h>
 
-Servo main_signal;
+Signal main_signal=Signal(1300, 1750, 2200, 11);
 Servo secondary_signal;
 
-int MAIN_SIGNAL_MIN = 1300;
-int MAIN_SIGNAL_MAX = 1750;
-int MAIN_SIGNAL_DURATION_MS = 2200;
-int main_signal_timestep_ms;
-boolean main_signal_done=false;
-unsigned int main_signal_next_time_ms;
-int main_signal_value;
+// int MAIN_SIGNAL_MIN = 1300;
+// int MAIN_SIGNAL_MAX = 1750;
+// int MAIN_SIGNAL_DURATION_MS = 2200;
+// int main_signal_timestep_ms;
+// boolean main_signal_done=false;
+// unsigned int main_signal_next_time_ms;
+// int main_signal_value;
 
 int SECONDARY_SIGNAL_MIN = 1150;
 int SECONDARY_SIGNAL_MAX = 1750;
-int SECONDARY_SIGNAL_DURATION_MS = 2200;
+int SECONDARY_SIGNAL_DURATION_MS = 1200;
 int secondary_signal_timestep_ms;
 boolean secondary_signal_done=false;
 unsigned int secondary_signal_next_time_ms;

}


void perhaps_update_main_signal() {
  if (millis() > main_signal_next_time_ms && !main_signal_done) {
    main_signal_value++;
    if (main_signal_value > MAIN_SIGNAL_MAX) {
      main_signal_done = true;
      main_signal.detach();
      return;
    }
    main_signal_next_time_ms += main_signal_timestep_ms;
    main_signal.writeMicroseconds(main_signal_value);
  }
}


void perhaps_update_secondary_signal() {



void loop() {
  uint64_t now=millis();
  main_signal.update(now);
  // perhaps_update_main_signal();
  perhaps_update_secondary_signal();
}
