Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- A simple code to display a static 'A' to the Bi-Color LED Matrix 2188.
- *Here Only one color is used!!
- *The rows are selected sequentially, and the column data are loaded.
- */
- #include <avr/io.h>
- #define F_CPU 1000000
- #include <util/delay.h>
- #include <avr/interrupt.h>
- #define GREEN_COLM PORTA
- #define RED_COLM PORTD
- #define ROW PORTB
- #define OFF_FULL_COLM 0xFF
- #define ON_FULL_COLM 0x00
- #define ON_FULL_ROW 0xFF
- #define ON_ROW 1
- #define ON_COLM 0
- #define UP 'u'
- #define LEFT 'l'
- #define DOWN 'd'
- #define RIGHT 'r'
- #define RED_COLOR 'r'
- #define GREEN_COLOR 'g'
- #define BOTH_COLOR 'b'
- #define N 8
- unsigned char sh =7;
- unsigned char sh1 =0;
- const uint64_t IMAGES[] = {
- 0x6666667e66663c00,
- 0x3e66663e66663e00,
- 0x3c66060606663c00,
- 0x3e66666666663e00,
- 0x7e06063e06067e00,
- 0x0606063e06067e00,
- 0x3c66760606663c00,
- 0x6666667e66666600,
- 0x3c18181818183c00,
- 0x1c36363030307800,
- 0x66361e0e1e366600,
- 0x7e06060606060600,
- 0xc6c6c6d6feeec600,
- 0xc6c6e6f6decec600,
- 0x3c66666666663c00,
- 0x06063e6666663e00,
- 0x603c766666663c00,
- 0x66361e3e66663e00,
- 0x3c66603c06663c00,
- 0x18181818185a7e00,
- 0x7c66666666666600,
- 0x183c666666666600,
- 0xc6eefed6c6c6c600,
- 0xc6c66c386cc6c600,
- 0x1818183c66666600,
- 0x7e060c1830607e00,
- 0x0000000000000000,
- 0x7c667c603c000000,
- 0x3e66663e06060600,
- 0x3c6606663c000000,
- 0x7c66667c60606000,
- 0x3c067e663c000000,
- 0x0c0c3e0c0c6c3800,
- 0x3c607c66667c0000,
- 0x6666663e06060600,
- 0x3c18181800180000,
- 0x1c36363030003000,
- 0x66361e3666060600,
- 0x1818181818181800,
- 0xd6d6feeec6000000,
- 0x6666667e3e000000,
- 0x3c6666663c000000,
- 0x06063e66663e0000,
- 0xf0b03c36363c0000,
- 0x060666663e000000,
- 0x3e403c027c000000,
- 0x1818187e18180000,
- 0x7c66666666000000,
- 0x183c666600000000,
- 0x7cd6d6d6c6000000,
- 0x663c183c66000000,
- 0x3c607c6666000000,
- 0x3c0c18303c000000
- };
- const int IMAGES_LEN = sizeof(IMAGES)/8;
- unsigned char symbol[8];
- void draw(uint64_t alpha,char clr){
- int i;
- for(i = 0; i < 8; i++)
- {
- symbol[i] = (alpha>>(8*i)) & 0x000000FF;
- }
- int k;
- for(k=0;k<200;k++){
- for(i=0;i<N;i++)
- {
- ROW = 0;
- if(clr==GREEN_COLOR){
- GREEN_COLM = ~(symbol[i]);
- RED_COLM = OFF_FULL_COLM;
- }
- else if(clr==RED_COLOR){
- GREEN_COLM = OFF_FULL_COLM;
- RED_COLM = ~(symbol[i]);
- }
- else {
- GREEN_COLM = RED_COLM = ~(symbol[i]);
- }
- ROW = 1<<i;
- _delay_us(300);
- }
- }
- }
- void drawSymbolShiftLeftIn(uint64_t alpha,char clr){
- int i;
- for(i = 0; i < 8; i++)
- {
- symbol[i] = (alpha>>(8*i)) & 0x000000FF;
- }
- int k;
- for(k=0;k<200;k++){
- for(i=0;i<N;i++)
- {
- ROW = 0;
- if(clr==GREEN_COLOR){
- GREEN_COLM = ~(symbol[i]<<sh);
- RED_COLM = OFF_FULL_COLM;
- }
- else if(clr==RED_COLOR){
- GREEN_COLM = OFF_FULL_COLM;
- RED_COLM = ~(symbol[i]<<sh);
- }
- else {
- GREEN_COLM = RED_COLM = ~(symbol[i]<<sh);
- }
- ROW = 1<<i;
- _delay_us(300);
- }
- }
- sh--;
- }
- void drawSymbolShiftLeftOut(uint64_t alpha,char clr){
- int i;
- for(i = 0; i < 8; i++)
- {
- symbol[i] = (alpha>>(8*i)) & 0x000000FF;
- }
- int k;
- for(k=0;k<200;k++){
- for(i=0;i<N;i++)
- {
- ROW = 0;
- if(clr==GREEN_COLOR){
- GREEN_COLM = ~(symbol[i]>>sh1);
- RED_COLM = OFF_FULL_COLM;
- }
- else if(clr==RED_COLOR){
- GREEN_COLM = OFF_FULL_COLM;
- RED_COLM = ~(symbol[i]>>sh1);
- }
- else {
- GREEN_COLM = RED_COLM = ~(symbol[i]>>sh1);
- }
- ROW = 1<<i;
- _delay_us(300);
- }
- }
- sh1++;
- }
- void drawSymbolShiftRightIn(uint64_t alpha,char clr){
- int i;
- for(i = 0; i < 8; i++)
- {
- symbol[i] = (alpha>>(8*i)) & 0x000000FF;
- }
- int k;
- for(k=0;k<200;k++){
- for(i=0;i<N;i++)
- {
- ROW = 0;
- if(clr==GREEN_COLOR){
- GREEN_COLM = ~(symbol[i]>>sh);
- RED_COLM = OFF_FULL_COLM;
- }
- else if(clr==RED_COLOR){
- GREEN_COLM = OFF_FULL_COLM;
- RED_COLM = ~(symbol[i]>>sh);
- }
- else {
- GREEN_COLM = RED_COLM = ~(symbol[i]>>sh);
- }
- ROW = 1<<i;
- _delay_us(300);
- }
- }
- sh--;
- }
- void drawSymbolShiftRightOut(uint64_t alpha,char clr){
- int i;
- for(i = 0; i < 8; i++)
- {
- symbol[i] = (alpha>>(8*i)) & 0x000000FF;
- }
- int k;
- for(k=0;k<200;k++){
- for(i=0;i<N;i++)
- {
- ROW = 0;
- if(clr==GREEN_COLOR){
- GREEN_COLM = ~(symbol[i]<<sh1);
- RED_COLM = OFF_FULL_COLM;
- }
- else if(clr==RED_COLOR){
- GREEN_COLM = OFF_FULL_COLM;
- RED_COLM = ~(symbol[i]<<sh1);
- }
- else {
- GREEN_COLM = RED_COLM = ~(symbol[i]<<sh1);
- }
- ROW = 1<<i;
- _delay_us(300);
- }
- }
- sh1++;
- }
- int main(void)
- {
- DDRA = 0xFF; // red
- DDRB = 0xFF; // row
- DDRD = 0xFF; // green
- /* while(1){
- draw(IMAGES[1],GREEN_COLOR);
- }*/
- unsigned char count = 0;
- while(count!=6)
- {
- drawSymbolShiftLeftIn(IMAGES[1],GREEN_COLOR);
- count++;
- }
- while(1)
- {
- drawSymbolShiftLeftOut(IMAGES[1],GREEN_COLOR);
- count++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement