summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-12-06 19:17:46 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-12-06 19:17:46 +0100
commit9b0492d105154b580b04ee1d5f8eef686f23cd4a (patch)
treeafd44f3fadbc546dcf4d5d198729da8e332e23a6
parent5b3ab9f2ac3dca746d05f43554a04f17bfcdfce6 (diff)
downloadkbd-9b0492d105154b580b04ee1d5f8eef686f23cd4a.tar
kbd-9b0492d105154b580b04ee1d5f8eef686f23cd4a.zip
Some blinking stuff
-rw-r--r--ardkbd.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ardkbd.c b/ardkbd.c
index 1ccb156..d4515f7 100644
--- a/ardkbd.c
+++ b/ardkbd.c
@@ -11,6 +11,9 @@ static volatile uint8_t kbd_input = 0;
static volatile uint8_t kbd_flags = 0;
+static volatile uint8_t ts = 10;
+
+
#define KBD_FLAG_ERROR (_BV(0))
#define KBD_FLAG_BREAK (_BV(1))
#define KBD_FLAG_EXT (_BV(2))
@@ -84,10 +87,13 @@ ISR(PCINT1_vect) {
if (!(kbd_flags & KBD_FLAG_BREAK)) {
switch (code) {
case KBD_CODE_UP:
- PORTB = 0x20;
+ if (ts > 0)
+ ts--;
break;
case KBD_CODE_DOWN:
+ if (ts < 31)
+ ts++;
PORTB = 0;
break;
}
@@ -109,8 +115,12 @@ int main(void) {
sei();
while(true) {
+ PORTB ^= 0x20;
+
+ uint32_t i;
+ for (i = 0; i < (1 << ts); i++)
+ _delay_ms(1);
}
return 0;
}
-