+ return rspickle & I2C_COBBOARD_SPK_AUTOHARVEST;
+}
+
+/* pack/deploy spickles depending on mode */
+static void spickle_prepare(uint8_t side)
+{
+ if (cob_count >= 5)
+ spickle_pack(side);
+ else if (is_deployed(side) && !is_autoharvest(side))
+ spickle_mid(side);
+ else if (is_deployed(side) && is_autoharvest(side))
+ spickle_deploy(side);
+ else
+ spickle_pack(side);
+}
+
+void state_set_spickle(uint8_t side, uint8_t flags)
+{
+ if (side == I2C_LEFT_SIDE) {
+ /* preempt current action if not busy */
+ if (lspickle != 0 && flags == 0 &&
+ state_status != I2C_COBBOARD_STATUS_LBUSY)
+ spickle_prepare(I2C_LEFT_SIDE);
+ lspickle = flags;
+ }
+ else {
+ /* preempt current action if not busy */
+ if (rspickle != 0 && flags == 0 &&
+ state_status != I2C_COBBOARD_STATUS_RBUSY)
+ spickle_prepare(I2C_RIGHT_SIDE);
+ rspickle = flags;
+ }