+ if ((msg_buf[1] < '0') || (msg_buf[1] > '9') ||
+ (msg_buf[2] < '0') || (msg_buf[2] > '9')) {
+ msg_buf[1] = msg_buf[2] = '0';
+ motor_reply((char*)&msg_buf[1], MOTOR_NOSLOT);
+ return;
+ }
+
+ slot = (msg_buf[1] - '0') * 10;
+ slot += msg_buf[2] - '0';
+
+ motor_reply((char*)&msg_buf[1], dispense_motor(slot));
+}
+
+void write_to_display() {
+ /* process a message in the form DXXXXXXXXXXX to send to display */
+ u8 i;
+ char buf[10];
+ for (i = 0; i < 10; i++)
+ if (msg_buf[i+1])
+ buf[i] = msg_buf[i+1];
+ else
+ break;
+
+ for (; i < 10; i++) /* pad the rest out with spaces */
+ buf[i] = ' ';
+
+ set_msg(buf);
+ send_ack();
+}
+
+void send_balance() {
+ wait_for_tx_free();
+ tx_buffer[0] = 'C';
+ tx_buffer[1] = have_change?'0':'1';
+ tx_buffer[2] = (coin_value/10000)%10;
+ tx_buffer[3] = (coin_value/1000)%10;
+ tx_buffer[4] = (coin_value/100)%10;
+ tx_buffer[5] = (coin_value/10)%10;
+ tx_buffer[6] = coin_value%10;
+ tx_buffer[7] = '\n';
+ tx_buffer[8] = 0;
+ send_packet();
+}
+
+void give_change() {
+ u16 cost;