#!/bin/bash

# Everything from waiting to initially connect, heat up,
# clean nozzle, auto level, etc. and prints bootup.gcode

echo "wait 1"
octoscript-wait 1>/tmp/wait1 2>/tmp/wait2
echo "clean nozzle"
octoscript-clean_nozzle 1>/tmp/cleannoz1 2>/tmp/cleannoz2
echo "auto level"
octoscript-auto_level 1>/tmp/auto1 2>/tmp/auto2
echo "clean bed"
octoscript-clean_bed 1>/tmp/cleanbed1 2>/tmp/cleanbed2
echo "apply glue"
octoscript-apply_glue 1>/tmp/glue1 2>/tmp/glue2
# Ok, setting temp is a bit weird here.
# We can set each of them in motion to the target temp
echo "bed temp"
octoscript bedtemp 68 1>/tmp/bedtemp1 2>/tmp/bedtemp2
echo "temp"
octoscript temp 230 1>/tmp/temp1 2>/tmp/temp2
# There is no way to tell temp to block. We can't send straight gcode via API
# we have to print it, at least for now.
echo "wait 2"
octoscript-wait 1>/tmp/wait1 2>/tmp/wait2
echo "print temp"
octoscript-set_temp 1>/tmp/tempgcode1 2>/tmp/tempgcode2
echo "wait 3"
octoscript-wait 1>/tmp/wait1 2>/tmp/wait2
# Then actually print the bootup.gcode part
echo "print bootup.gcode"
octoscript print bootup.gcode 1>/tmp/bootgcode1 2>/tmp/bootgcode2
echo "wait 4"
octoscript-wait 1>/tmp/wait1 2>/tmp/wait2
# LEDs should indicate cooling state
octoscript-cooling 1>/tmp/cooling1 2>/tmp/cooling2
# LEDs should indicate it is ok to remove part
octoscript-remove 1>/tmp/remove1 2>/tmp/remove2

