Affichage avr lcd

De HackBBS
Aller à la navigation Aller à la recherche

//------------Main program------------

  1. include <avr/io.h>
  1. include <avr/pgmspace.h>
  1. include <util/delay.h>
  1. include "lcd_lib.h"



//Strings stored in AVR Flash memory

const uint8_t hackbbs[] PROGMEM="HackBBS\0";

const uint8_t curhome[] PROGMEM="Fireworks\0";

const uint8_t customsymbol1[] PROGMEM="ça rox\0";

const uint8_t customsymbol2[] PROGMEM="$\\o/$\0";

const uint8_t customsymbolout[] PROGMEM="Output symbol\0";

const uint8_t shift[] PROGMEM="Korigan\0";

const uint8_t shiftdemo[] PROGMEM="@->--\0";

const uint8_t lcdblank[] PROGMEM="HackBattleBombShot\0";

const uint8_t lcdanimation[] PROGMEM="--_--\0";

const uint8_t msg1[] PROGMEM="HakBBS, plateforme \0"; const uint8_t msg2[] PROGMEM=" de Hacking en \0"; const uint8_t msg3[] PROGMEM=" conditions reelles!!! \0";

// custom LCD characters

const uint8_t backslash[] PROGMEM=

{

0b00000000,//back slash

0b00010000,

0b00001000,

0b00000100,

0b00000010,

0b00000001,

0b00000000,

0b00000000

};

//delay 1s

void delay1s(void)

{

uint8_t i;

for(i=0;i<100;i++)

{

_delay_ms(10);

}

} void WelcomeHackBBS(void)

{

int delay=300;

LCDclr();

CopyStringtoLCD(msg1, 0, 0);

for(uint8_t i=0;i<20;i++)

{

//delay1s(); _delay_ms(delay); LCDshiftRight(1);

//delay1s();

//LCDshiftRight(1);

}

       LCDclr();

CopyStringtoLCD(msg2, 0, 1);

for(uint8_t i=0;i<20;i++)

{

//delay1s(); _delay_ms(delay); LCDshiftRight(1);

//delay1s();

//LCDshiftRight(1);

}

       LCDclr();

CopyStringtoLCD(msg3, 0, 0);

for(uint8_t i=0;i<20;i++)

{

//delay1s(); _delay_ms(delay); LCDshiftRight(1);

//delay1s();

//LCDshiftRight(1);

}

}


//demonstration of shift

void demoshift(void)

{

LCDclr();

CopyStringtoLCD(shift, 3, 0);

delay1s();

CopyStringtoLCD(hackbbs, 3, 1);

for(uint8_t i=0;i<5;i++)

{

delay1s();

LCDshiftLeft(1);

delay1s();

LCDshiftRight(1);

}

}

//demostration of blank

void demolcdblank(void)

{

LCDclr();

CopyStringtoLCD(lcdblank, 0, 0);

for(uint8_t i=0;i<5;i++)

{

LCDblank();

delay1s();

LCDvisible();

delay1s();

}

}

//demonstration of animation

void demoanimation(void)

{

LCDclr();

CopyStringtoLCD(customsymbol1, 0, 0);

CopyStringtoLCD(customsymbol2, 0, 1);

delay1s();

LCDdefinechar(backslash,0);

LCDclr();

CopyStringtoLCD(customsymbolout, 0, 0);

LCDGotoXY(8, 1);

LCDsendChar(0);

delay1s();

LCDclr();

CopyStringtoLCD(lcdanimation, 0, 0);

for(uint8_t i=0;i<3;i++)

{

LCDGotoXY(8, 1);

LCDsendChar(0);

delay1s();

LCDGotoXY(8, 1);

LCDsendChar('-');

delay1s();

LCDGotoXY(8, 1);

LCDsendChar('/');

delay1s();

LCDGotoXY(8, 1);

LCDsendChar('|');

delay1s();

LCDGotoXY(8, 1);

LCDsendChar(0);

delay1s();

LCDGotoXY(8, 1);

LCDsendChar('-');

delay1s();

LCDGotoXY(8, 1);

LCDsendChar('/');

delay1s();

LCDGotoXY(8, 1);

LCDsendChar('|');

delay1s();

}

}



int main(void)

{

LCDinit();//init LCD 8 bit, dual line, cursor right

LCDclr();//clears LCD

CopyStringtoLCD(curhome, 1, 0);//Cursor home and display message

delay1s();

LCDclr();//clears LCD

LCDhome();//cursonr home

while(1)//loop demos

{

WelcomeHackBBS();

//demoshift();

//demolcdblank();

//demoanimation();

}

return 0;

}

//-----------end of main program----------