u8 msg_length; /* length of current_message */
u8 wrap_mode; /* whether to scroll or alternate between msgs */
u8 scroll_point; /* how far through the message we have scrolled */
+bool have_scrolled; /* true after one scroll (used for scroll_msg())*/
/* private prototypes */
void display_send_byte(char c);
void display_update();
void append_msg(char* newmsg, u8 wrap) {
- char* dest = current_message[msg_length];
+ char* dest = current_message+msg_length;
/* equivalent of a string copy */
while (newmsg) {
dest = newmsg;
display_update();
}
+void scroll_msg(char* newmsg) {
+ /* puts a message on display and does not return until the message has
+ * scrolled across once.
+ */
+ set_msg(newmsg, WRAP_SCROLL);
+ have_scrolled = 0;
+ while (!have_scrolled);
+}
+
void display_shift() {
/* update the display for WRAP_SCROLL or WRAP_ALTERNATE modes */
switch (wrap_mode) {
case WRAP_SCROLL:
case WRAP_ALTERNATE:
scroll_point++;
- if (scroll_point >= msg_length) scroll_point = 0;
+ if (scroll_point >= msg_length) {
+ scroll_point = 0;
+ have_scrolled = 1;
+ }
display_update();
break;
}
void display_init();
void append_msg(char* newmsg, u8 wrap);
void set_msg(char* newmsg, u8 wrap);
+void scroll_msg(char* newmsg);
void set_char(char c, u8 pos);
void set_wrap_mode(u8 new_wrap_mode);
void display_refresh();
+#include "display.h"
#include "vend.h"
#define DELAY_MAGIC 20 /* FIXME: number of loops for ~ 1 millisecond (< 256) */
uid = (uid*10) + (last_key%10);
set_char((last_key%10)+'0', 4+uidpos);
}
- return 1;
+ return (uid!=0);
}
-
bool pin_enter() {
u8 pinpos;
/* We ask for a pin, display a PIN: prompt. PINs must be a 4 digit number.
}
void make_request(u8 selection) {
+ set_msg("REQUESTING", WRAP_NONE); /* XXX: maybe this isn't needed? */
switch(server_request(uid, pin, selection)) {
case REQUEST_OK:
set_msg("THANK YOU!", WRAP_NONE);
set_msg("ENTER SELECTION OR INSERT COINS ", WRAP_SCROLL);
selection = 0;
while(1) {
- if (coin_value) {
+ if (coin_value) { /* we have coins inserted */
int prev_coin = 0;
/* alternate between the price and a confirm message */
while (coin_value) {
if (keypad_pressed()) {
switch (last_key) {
case KEY_RESET:
- coin_refund();
+ scroll_msg("PRESS COIN REFUND");
goto reset;
case KEY_0:
switch (server_credit_account(uid, pin, coin_value)) {
#define _TYPES_H_
/* FIXME: are these typedefs right for m68hc11-gcc? */
+/* XXX: see gcc manual for types */
typedef unsigned char u8;
typedef signed char s8;
typedef unsigned short u16;