aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2020-02-26 08:26:09 -0600
committerRossTheRoss <msattr@gmail.com>2020-02-26 08:26:09 -0600
commita388a4cede7b718889756ea08c1dd56109217076 (patch)
treee49f69b4cc74c3ababdc3d77f7213e4bfe3655b6
parentI hate this (Lab 3 partially working again) (diff)
downloadee2361-a388a4cede7b718889756ea08c1dd56109217076.tar
ee2361-a388a4cede7b718889756ea08c1dd56109217076.tar.gz
ee2361-a388a4cede7b718889756ea08c1dd56109217076.tar.bz2
ee2361-a388a4cede7b718889756ea08c1dd56109217076.tar.lz
ee2361-a388a4cede7b718889756ea08c1dd56109217076.tar.xz
ee2361-a388a4cede7b718889756ea08c1dd56109217076.tar.zst
ee2361-a388a4cede7b718889756ea08c1dd56109217076.zip
e
-rw-r--r--Lab3.X/lab3_main_c.c16
-rw-r--r--Lab3.X/numpad.c11
2 files changed, 19 insertions, 8 deletions
diff --git a/Lab3.X/lab3_main_c.c b/Lab3.X/lab3_main_c.c
index 406f657..fa01c95 100644
--- a/Lab3.X/lab3_main_c.c
+++ b/Lab3.X/lab3_main_c.c
@@ -26,6 +26,11 @@ void delay(long n) {
void setup(void) {
CLKDIVbits.RCDIV = 0; //Set RCDIV=1:1 (default 2:1) 32MHz or FCY/2=16M
AD1PCFG = 0x9fff; //sets all pins to digital I/O
+// T1CON = 0;
+// PR1 = 15999;
+// TMR1 = 0;
+// IFS0bits.T1IF = 0;
+// T1CONbits.TON = 1;
init7seg();
initKeyPad();
}
@@ -33,16 +38,21 @@ void setup(void) {
int main(void) {
setup();
char right, left, temp;
+ unsigned long debounce = 0;
while (1) {
- temp = readKeyPadRAW();
+ if (debounce % 300 == 0)
+ temp = readKeyPadRAW();
+ else
+ temp = '\0';
if (temp != '\0') {
left = right;
right = temp;
}
- showChar7seg(right, LSB);
+ showChar7seg(right, MSB);
delay(200);
- showChar7seg(left, MSB);
+ showChar7seg(left, L4SB);
delay(200);
+ debounce++;
}
}
diff --git a/Lab3.X/numpad.c b/Lab3.X/numpad.c
index 271b324..0768eba 100644
--- a/Lab3.X/numpad.c
+++ b/Lab3.X/numpad.c
@@ -17,7 +17,8 @@ void padDelay(long n) {
char readKeyPadRAW(void) {
int i;
char num;
- num = (!_RB15 << 3) | (!_RB14 << 2) | (!_RB13 << 1) | !_RB12;
+//0
+ num = (_RA0 << 3) | (_RA1 << 2) | (_RA2 << 1) | _RA3;
LATB |= (0b1111 << 12);
for (i = 0; i < 4; i++) {
LATB ^= 0b1 << (15 - i);
@@ -34,7 +35,7 @@ char readKeyPadRAW(void) {
case 0b1011:
return '2';
break;
- case 0b111:
+ case 0b0111:
return '1';
break;
} break;
@@ -49,7 +50,7 @@ char readKeyPadRAW(void) {
case 0b1011:
return '5';
break;
- case 0b111:
+ case 0b0111:
return '4';
break;
} break;
@@ -64,7 +65,7 @@ char readKeyPadRAW(void) {
case 0b1011:
return '8';
break;
- case 0b111:
+ case 0b0111:
return '7';
break;
} break;
@@ -79,7 +80,7 @@ char readKeyPadRAW(void) {
case 0b1011:
return '0';
break;
- case 0b111:
+ case 0b0111:
return 'F';
break;
} break;