add led state off

This commit is contained in:
Wolfgang Hottgenroth 2019-01-24 22:57:41 +01:00
parent be38a8b7d0
commit 459ad36b0d
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
2 changed files with 104 additions and 75 deletions

41
led.c
View File

@ -58,10 +58,10 @@ static inline void selectRow(uint8_t row) {
col3, red: P1.6
*/
typedef enum { BLUE = 0, RED = 1 } tColor;
void selectCol(uint8_t column, tColor color) {
if (color == BLUE) {
switch (color) {
case BLUE:
switch (column) {
case 0:
P1DIR &= ~(BIT6);
@ -96,7 +96,8 @@ void selectCol(uint8_t column, tColor color) {
P2OUT &= ~BIT5;
break;
}
} else {
break;
case RED:
switch (column) {
case 0:
P1DIR &= ~(BIT5 | BIT6);
@ -131,6 +132,35 @@ void selectCol(uint8_t column, tColor color) {
P1OUT &= ~BIT6;
break;
}
break;
case OFF:
switch (column) {
case 0:
P1DIR &= ~(BIT5 | BIT6);
P1OUT &= ~(BIT5 | BIT6);
P2DIR &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
P2OUT &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
break;
case 1:
P1DIR &= ~(BIT5 | BIT6);
P1OUT &= ~(BIT5 | BIT6);
P2DIR &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
P2OUT &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
break;
case 2:
P1DIR &= ~(BIT5 | BIT6);
P1OUT &= ~(BIT5 | BIT6);
P2DIR &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
P2OUT &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
break;
case 3:
P1DIR &= ~(BIT5 | BIT6);
P1OUT &= ~(BIT5 | BIT6);
P2DIR &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
P2OUT &= ~(BIT0 | BIT2 | BIT1 | BIT4 | BIT3 | BIT5);
break;
}
break;
}
}
@ -160,8 +190,5 @@ void ledExec() {
}
void ledInit() {
//selectRow(0);
//selectCol(0, BLUE);
schAdd(ledExec, NULL, 0, 10);
schAdd(ledExec, NULL, 0, 50);
}

2
led.h
View File

@ -8,6 +8,8 @@
#ifndef LED_H_
#define LED_H_
typedef enum { BLUE = 0, RED = 1, OFF = 2 } tColor;
void ledExec();
void ledInit();