From 061430973e82995368d27ff9081391f9475da3c7 Mon Sep 17 00:00:00 2001 From: James McKenzie Date: Mon, 3 Aug 2015 10:34:07 +0100 Subject: fish --- app/code.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 app/code.c (limited to 'app/code.c') diff --git a/app/code.c b/app/code.c new file mode 100644 index 0000000..4d32f7b --- /dev/null +++ b/app/code.c @@ -0,0 +1,98 @@ +#include "project.h" + + +static uint8_t code[16]; +static int code_len; +static int hide; +static int show; + + +void code_display(void) +{ +size_t i; + +#if 0 +lcd_erase_line(0,16); + +if (code_len!=16) + lcd_write("Enter code:",0,0); +else + lcd_write("Code entered:",0,0); +#endif + + for (i=0;ibmRequestType & 0x7F) != 0x41) + return 0; /* Only accept vendor request. */ + + switch (req->bRequest) + { + + case 0x34: + (*buf)[0] = 0x1; + (*buf)[1] = 0; + (*buf)[2] = 0; + (*buf)[3] = 0; + (*buf)[4] = 0x2; + (*buf)[5] = 0; /* iString not used here */ + *len = 6; + return 1; + } + + return 0; + +} + + +void code_tick(void) +{ +if (!show) return; +show--; + if (!show) { + hide++; + code_display(); + } + +} + + + + +void key_event (uint8_t v, int ud) +{ + if (!ud) return; + + if (code_len==sizeof(code)) { + code_len=0; + memset(code,' ',sizeof(code)); + } + + + show=5000; + hide=0; + + code[code_len++]=v; + + + code_display(); + + +} -- cgit v1.2.3