send_packet();
}
-int main() {
- u16 last_coin_value;
- bool last_door_open;
- int display_pos;
- unsigned int i;
- char display_buf[11];
- for (display_pos = 0; display_pos < 11; display_pos++)
- display_buf[display_pos] = '\0';
- display_pos = 0;
+u16 last_coin_value;
+bool last_door_open;
+char display_buf[11];
+/* cur_motor[0] is 0 for nothing, or 1..10, or 0xff to say redraw.
+ * cur_motor[1] is 0..9 and only meaningful is cur_motor[0] != 0. */
+u8 cur_motor[2];
- delay(1000);
+int main() {
+ u8 i;
+ for (i = 0; i < 11; i++)
+ display_buf[i] = ' ';
+ display_buf[10] = '\0';
- chime_on();
- for (i = 0; i < 40000; i++) {}
- chime_off();
- for (i = 0; i < 20000; i++) {}
- chime_on();
- for (i = 0; i < 60000; i++) {}
-
changer_output = 0x7f;
- //_io_ports[M6811_PORTA] = 0xc8; /* for talking to coin mech */
- _io_ports[M6811_PORTA] = 0xc0; /* for talking to serial port */
+ _io_ports[M6811_PORTA] = 0xc0; /* display on. talking to serial port */
_io_ports[M6811_DDRA] = 0xfc;
_io_ports[M6811_DDRD] = 0x3e;
_io_ports[M6811_SPCR] = 0x12;
set_misc_output(0x00);
- chime_off(); /* mainly for debugging */
-
display_init();
set_msg(" HELLO ");
comm_init();
coinmech_init();
keypad_init();
-
- chime_count = 100;
- while (chime_count != 0);
-
- set_msg(" CRUEL ");
-
last_coin_value = 0;
last_door_open = 0;
- dispense_motor(22);
+ delay(1000);
+
+ set_msg(" CRUEL ");
- chime_count = 50;
- while (chime_count != 0);
+ delay(1000);
set_msg(" WORLD ");
delay(1000);
- set_msg("*5N4X0RZ* ");
- delay(1000);
+ chime_start();
+
+ cur_motor[0] = 0xff;
while(1) {
+ if (cur_motor[0] == 0xff) { /* signal to say redraw screen */
+ set_msg("*5N4X0RZ* ");
+ cur_motor[0] = 0;
+ }
+
if (door_open() != last_door_open) {
last_door_open = door_open();
send_door_msg(last_door_open);
+ chime_start();
if (last_door_open) {
- chime_on();
set_msg("DOOR OPEND");
- delay(100);
- chime_off();
} else {
- chime_on();
set_msg("DOOR CLOSE");
- delay(100);
- chime_off();
}
}
+ /*
if (rx_queue_state) {
switch (msg_buf[0]) {
case 'V':
ping_pong();
break;
default:
- /* shrug */
+ // shurg
send_nack();
break;
}
msg_clr();
}
+ */
keypad_read();
if (keypad_pressed()) {
- if (last_key == KEY_RESET)
- display_buf[display_pos] = 'R';
- else
- display_buf[display_pos] = '0'+(last_key%10);
- display_pos++;
- display_pos %= 10;
- set_msg(display_buf);
+ if (last_key == KEY_RESET) {
+ cur_motor[0] = 0xff;
+ } else {
+ if (cur_motor[0]) {
+ cur_motor[1] = last_key%10;
+ display_buf[1] = cur_motor[1]+'0';
+ set_msg(display_buf);
+ dispense_motor((cur_motor[0]%10)*10 + cur_motor[1]);
+ set_msg("THANK YOU");
+ display_buf[0] = ' ';
+ display_buf[1] = ' ';
+ cur_motor[0] = 0xff;
+ delay(500);
+ } else {
+ cur_motor[0] = last_key;
+ display_buf[0] = (last_key%10)+'0';
+ set_msg(display_buf);
+ }
+ }
send_keypress(last_key);
}
+ /*
if (coin_value != last_coin_value) {
send_balance();
last_coin_value = coin_value;
}
+ */
}
}
-