author Dobrica Pavlinusic Sat, 15 Oct 2016 18:01:24 +0000 (20:01 +0200) committer Dobrica Pavlinusic Sat, 15 Oct 2016 18:01:24 +0000 (20:01 +0200)
 main.c patch | blob | history

diff --git a/main.c b/main.c
index 17a4c16..181cde5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-#define F_CPU 11059200ul
+#define F_CPU 16000000L

#include <avr/io.h>
#include <util/delay.h>
@@ -101,14 +101,14 @@ char saved_letter(){

// start by creating a "letter" variable which defines pin states
uint8_t letter=0;
-    if(regD&(1<<PD0)){letter|=(1<<7);} // letter 1 (voltage MSB)
-    if(regD&(1<<PD2)){letter|=(1<<6);} // letter 2
-    if(regD&(1<<PD3)){letter|=(1<<5);} // letter 3
-    if(regD&(1<<PD4)){letter|=(1<<4);} // letter 4
-    if(regD&(1<<PD5)){letter|=(1<<3);} // letter 5 (current MSB)
-    if(regD&(1<<PD6)){letter|=(1<<2);} // letter 6
-    if(regD&(1<<PD7)){letter|=(1<<1);} // letter 7
-    if(regB&(1<<PB0)){letter|=(1<<0);} // letter 8
+    if(regC&(1<<PC0)){letter|=(1<<7);} // letter 1 (voltage MSB)
+    if(regC&(1<<PC3)){letter|=(1<<6);} // letter 2
+    if(regC&(1<<PC4)){letter|=(1<<5);} // letter 3
+    if(regD&(1<<PD2)){letter|=(1<<4);} // letter 4
+    if(regB&(1<<PB3)){letter|=(1<<3);} // letter 5 (current MSB)
+    if(regD&(1<<PD4)){letter|=(1<<2);} // letter 6
+    if(regD&(1<<PD3)){letter|=(1<<1);} // letter 7
+    if(regD&(1<<PD5)){letter|=(1<<0);} // letter 8

// try to match expected pin states
if (letter==0b10000000) {return '1';}
@@ -128,14 +128,14 @@ char saved_number(){
// returned value will be in ASCII
// returns 0 if no letter is selected, or if it's confusing
int segments=0;
-    if(regC&(1<<PC5)){segments|=(1<<7);} // A (MSB)
-    if(regC&(1<<PC4)){segments|=(1<<6);} // B
-    if(regC&(1<<PC3)){segments|=(1<<5);} // C
-    if(regC&(1<<PC2)){segments|=(1<<4);} // D
-    if(regC&(1<<PC1)){segments|=(1<<3);} // E
-    if(regC&(1<<PC0)){segments|=(1<<2);} // F
-    if(regB&(1<<PB2)){segments|=(1<<1);} // G (LSB)
-    //if(regB&(1<<PB1)){}//H
+    if(regC&(1<<PC1)){segments|=(1<<7);} // A (MSB)
+    if(regC&(1<<PC5)){segments|=(1<<6);} // B
+    if(regD&(1<<PD7)){segments|=(1<<5);} // C
+    if(regB&(1<<PB1)){segments|=(1<<4);} // D
+    if(regB&(1<<PB2)){segments|=(1<<3);} // E
+    if(regC&(1<<PC2)){segments|=(1<<2);} // F
+    if(regD&(1<<PD6)){segments|=(1<<1);} // G (LSB)
+    //if(regB&(1<<PB0)){}//H

if(segments==0b00001000) {return '9';}
if(segments==0b00000000) {return '8';}