X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fmain_basic.c;h=b7c110fced6fdddfa51f574e37a53a455318d03a;hb=de72195f371c5d1240309c067e8a43b0484d070a;hp=e4594717e5a4f7858e7ebe333ad5067e9d88ab71;hpb=293827a53b325c2faffddcba380b6f0c19da802a;p=uccvend-snackrom.git diff --git a/ROM2/main_basic.c b/ROM2/main_basic.c index e459471..b7c110f 100644 --- a/ROM2/main_basic.c +++ b/ROM2/main_basic.c @@ -89,7 +89,7 @@ void give_change() { coin_cost(cost); send_ack(); -} +} void send_keypress(u8 key) { /* send a packet of the form KX with X being the key, or R for reset */ @@ -98,7 +98,16 @@ void send_keypress(u8 key) { if (key == KEY_RESET) tx_buffer[1] = 'R'; else - tx_buffer[1] = key+'0'; + tx_buffer[1] = (key%10)+'0'; + tx_buffer[2] = '\n'; + tx_buffer[3] = 0; + send_packet(); +} + +void send_door_msg(bool open) { + wait_for_tx_free(); + tx_buffer[0] = 'D'; + tx_buffer[1] = open?'1':'0'; tx_buffer[2] = '\n'; tx_buffer[3] = 0; send_packet(); @@ -110,12 +119,32 @@ void do_chime() { } int main() { - u16 last_coin_value = coin_value; + u16 last_coin_value; + bool last_door_open; + + chime_start(); + + misc_output = 0; + changer_output = 0x7f; + _io_ports[M6811_PORTA] = 0xc8; + _io_ports[M6811_DDRD] = 0x3e; + _io_ports[M6811_SPCR] = 0x12; + + unlock(); /* enable interrupts */ - /* init coin mech */ - comm_init(); display_init(); + comm_init(); + coinmech_init(); + + last_coin_value = 0; + last_door_open = 0; + while(1) { + if (door_open() != last_door_open) { + last_door_open = door_open(); + send_door_msg(last_door_open); + } + if (rx_queue_state) { switch (msg_buf[0]) { case 'V': @@ -135,6 +164,7 @@ int main() { break; default: /* shrug */ + send_nack(); break; } msg_clr(); @@ -143,7 +173,6 @@ int main() { keypad_read(); if (keypad_pressed()) { send_keypress(last_key); - /* beep? */ } if (coin_value != last_coin_value) {