summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--digital/io-hub/src/guybrush/top.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/digital/io-hub/src/guybrush/top.c b/digital/io-hub/src/guybrush/top.c
index 8351e2ba..10834ac4 100644
--- a/digital/io-hub/src/guybrush/top.c
+++ b/digital/io-hub/src/guybrush/top.c
@@ -121,6 +121,10 @@ struct top_t
int16_t totem_distance;
/** Close door when out of unloading zone. */
uint8_t close_door;
+ /** Check door is closed once this reach 0. */
+ uint8_t close_door_check;
+ /** Close the door once this reach 0. */
+ uint8_t close_door_wait;
};
/** Global context. */
@@ -140,6 +144,7 @@ top_update (void)
IO_CLR (OUTPUT_DOOR_OPEN);
IO_SET (OUTPUT_DOOR_CLOSE);
top.close_door = 0;
+ top.close_door_check = 250;
}
}
/* If door is closed, cut air to save power. */
@@ -147,6 +152,27 @@ top_update (void)
{
IO_CLR (OUTPUT_DOOR_CLOSE);
}
+ /* Else, test if it should be closed. */
+ else if (top.close_door_check)
+ {
+ top.close_door_check--;
+ if (!top.close_door_check)
+ {
+ IO_SET (OUTPUT_DOOR_OPEN);
+ IO_CLR (OUTPUT_DOOR_CLOSE);
+ top.close_door_wait = 250;
+ }
+ }
+ /* Close door after a delay. */
+ if (top.close_door_wait)
+ {
+ top.close_door_wait--;
+ if (!top.close_door_wait)
+ {
+ IO_CLR (OUTPUT_DOOR_OPEN);
+ IO_SET (OUTPUT_DOOR_CLOSE);
+ }
+ }
}
/** Go collect a totem. */