1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
| #include <spi.h>
#include <xlcdGre.h>
#include <p18cxxx.h>
#include <timers.h>
#include <delays.h>
#include <stdlib.h>
#include <string.h>
#include "LCDinit.c"
#include "ftoa.c"
#define q 4.8828e-3 // quantum pour un CAN 10bits 0v-5v
/*****/
#pragma config OSC = HS
#pragma config PWRT = ON
#pragma config WDT = OFF, WDTPS = 1
#pragma config LVP = OFF
#pragma config DEBUG = OFF
#pragma config CP0 = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF
#define TRUE 1
#define ButtonPP !PORTAbits.RA4 // RE2 push button
#define ButtonFF !PORTBbits.RB0 // RE0 push button
#define CLEAR_DISPLAY 0x01
void DelayFor18TCY(void);
void DelayPORXLCD(void);
void DelayXLCD(void);
char filename[14] ="Picdem2+ test";
char teststring[15]="End of Testing";
char artist[17]="----------------" ;
char title[17]="----------------" ;
void clear_lcd(int line)
{
char ln;
int x;
if (line==2) ln = 0xC0;
else ln = 0x00;
Delay10KTCYx(5);
SetDDRamAddr(ln); // set line
for (x=0; x<16; x++)
{
Delay10KTCYx(5);
WriteDataXLCD(' '); // write a blank
}
Delay10KTCYx(5);
SetDDRamAddr(ln); // set back to beginning
return;
}
/******************************/
void led(void){
PORTBbits.RB1 = 1;
Delay10KTCYx(100);
PORTBbits.RB1 = 0;
Delay10KTCYx(100);
}
/*************** main starts here **************/
void main (void)
{
char chaine;
float res;
int i;
int somme, result, s, x, y,rs;
//Setup Ports
PORTB = 0b00000000; // Setup PORTB
TRISB = 0b00000001; // RB0 as input. Reset as output
DDRAbits.RA4 = 1; // play/pause
DDRBbits.RB0 = 1; // next track
OpenXLCD(FOUR_BIT & LINES_5X7); // Init the LCD Display
// Set cursor off
Delay10KTCYx(20);
WriteCmdXLCD(DON&CURSOR_OFF&BL INK_OFF);
while(BusyXLCD());
Delay10KTCYx(20);
res=(float)5*q; // calcul simple
ftoa(res,chaine,5,'f'); // convertit en chaine
for (i=0;i<0x1ffff;i++); // petite tempo
putrsXLCD(chaine); // Affichage du résultat sur l'écran
while (!ButtonPP); //wait for keypress
Delay100TCYx(0x01);
while (ButtonPP);
clear_lcd(2); //set and clear second line
Delay10KTCYx(10);
putsXLCD(filename);
while (!ButtonPP); //wait for keypress
Delay100TCYx(0x01);
while (ButtonPP);
clear_lcd(1); //set and clear second line
Delay10KTCYx(10);
putsXLCD(teststring);
while (1)
{
led();
}
} |
Partager