add matrix structure
This commit is contained in:
		
							
								
								
									
										37
									
								
								led.c
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								led.c
									
									
									
									
									
								
							@@ -11,6 +11,21 @@
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define SIZE 4
 | 
			
		||||
 | 
			
		||||
tColor matrix[SIZE][SIZE] = {
 | 
			
		||||
    { OFF, OFF, OFF, OFF }, 
 | 
			
		||||
    { OFF, OFF, OFF, OFF }, 
 | 
			
		||||
    { OFF, OFF, OFF, OFF },
 | 
			
		||||
    { OFF, OFF, OFF, OFF }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void ledSetMatrix(uint8_t col, uint8_t row, tColor color) {
 | 
			
		||||
    if ((col < SIZE) && (row < SIZE)) {
 | 
			
		||||
        matrix[col][row] = color;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
    row0: P1.3
 | 
			
		||||
    row1: P1.4
 | 
			
		||||
@@ -164,7 +179,8 @@ void selectCol(uint8_t column, tColor color) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ledExec() {
 | 
			
		||||
/*
 | 
			
		||||
void testledExec() {
 | 
			
		||||
 | 
			
		||||
    static uint8_t rowNum = 0;
 | 
			
		||||
    static uint8_t colNum = 0;
 | 
			
		||||
@@ -186,9 +202,26 @@ void ledExec() {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void ledExec() {
 | 
			
		||||
    static uint8_t rowNum = SIZE;
 | 
			
		||||
    static uint8_t colNum = SIZE;
 | 
			
		||||
 | 
			
		||||
    colNum++;
 | 
			
		||||
    if (colNum >= SIZE) {
 | 
			
		||||
        colNum = 0;
 | 
			
		||||
        rowNum++;
 | 
			
		||||
        if (rowNum >= SIZE) {
 | 
			
		||||
            rowNum = 0;
 | 
			
		||||
        }
 | 
			
		||||
        selectRow(rowNum);
 | 
			
		||||
    }
 | 
			
		||||
    selectCol(colNum, matrix[colNum][rowNum]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ledInit() {
 | 
			
		||||
    schAdd(ledExec, NULL, 0, 50);
 | 
			
		||||
    schAdd(ledExec, NULL, 0, 10);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user