cauqleuir madre

Dependencies:   SDFileSystem mbed TFTLCD

Committer:
Danton
Date:
Sat Feb 02 21:18:57 2013 +0000
Revision:
58:672e16b6b5a4
Parent:
57:ed9db2bcd1bf
We have Ads

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Danton 56:51410b4b1078 1 #include "imaginator.h"
Danton 56:51410b4b1078 2 void superDisplay()
Danton 56:51410b4b1078 3 {
Danton 56:51410b4b1078 4 HX8340S_LCD lcd( p9, p14, p13, p11);
Danton 56:51410b4b1078 5 lcd.Initialize();
Danton 56:51410b4b1078 6 lcd.ClearScreen();
Danton 56:51410b4b1078 7 }
Danton 56:51410b4b1078 8 void superSd(unsigned char*buffer,unsigned int *offset,int bytes,const char *path)
Danton 56:51410b4b1078 9 {
Danton 56:51410b4b1078 10 SDFileSystem sd(p11, p12, p13, p8, "sd"); // the pinout on the mbed Cool Components workshop board
Danton 56:51410b4b1078 11 FILE *fp =fopen(path, "r");
Danton 56:51410b4b1078 12
Danton 56:51410b4b1078 13 if(fp == NULL) {
Danton 56:51410b4b1078 14 error("Could not open file\c\n");
Danton 56:51410b4b1078 15 }
Danton 56:51410b4b1078 16 fseek(fp, *offset,SEEK_SET);
Danton 56:51410b4b1078 17 *offset=*offset+bytes;
Danton 56:51410b4b1078 18 fread((char*)buffer,1,bytes,fp);
Danton 56:51410b4b1078 19 fclose(fp);
Danton 57:ed9db2bcd1bf 20 return;
Danton 56:51410b4b1078 21 }
Danton 56:51410b4b1078 22 void colorCompute(unsigned char*buffer, int* colorBuffer,int sizeOfBuffer)
Danton 56:51410b4b1078 23 {
Danton 56:51410b4b1078 24 int j=0;
Danton 56:51410b4b1078 25 for(int i=0;i<sizeOfBuffer;i=i+4)
Danton 56:51410b4b1078 26 {
Danton 56:51410b4b1078 27 colorBuffer[j]=RGB((buffer[i+2]),(buffer[i+1]),(buffer[i]));
Danton 56:51410b4b1078 28 j++;
Danton 56:51410b4b1078 29 }
Danton 57:ed9db2bcd1bf 30 return;
Danton 56:51410b4b1078 31 }
Danton 56:51410b4b1078 32 void pickUpLine(unsigned char*buffer, int* colorBuffer,int sizeOfBuffer,int sizeOfLine,const char *path, unsigned int *absPtr)
Danton 56:51410b4b1078 33 {
Danton 56:51410b4b1078 34 superSd(buffer,absPtr,sizeOfBuffer,path);
Danton 56:51410b4b1078 35 colorCompute(buffer,colorBuffer,sizeOfBuffer);
Danton 57:ed9db2bcd1bf 36 return;
Danton 57:ed9db2bcd1bf 37 }
Danton 57:ed9db2bcd1bf 38 void drawLine(int* color,int y)
Danton 57:ed9db2bcd1bf 39 {
Danton 57:ed9db2bcd1bf 40 HX8340S_LCD lcd(p9, p14, p13, p11);
Danton 57:ed9db2bcd1bf 41 DigitalOut scr(p9);
Danton 57:ed9db2bcd1bf 42 scr=0;
Danton 57:ed9db2bcd1bf 43 int k=0;
Danton 57:ed9db2bcd1bf 44 for(int j=y;j<(16+y);j++)
Danton 57:ed9db2bcd1bf 45 {
Danton 57:ed9db2bcd1bf 46 for(int i=0;i<220;i++)
Danton 57:ed9db2bcd1bf 47 {
Danton 57:ed9db2bcd1bf 48 lcd.DrawPixel(i,j,color[k]);
Danton 57:ed9db2bcd1bf 49 k++;
Danton 57:ed9db2bcd1bf 50 }
Danton 57:ed9db2bcd1bf 51 }
Danton 57:ed9db2bcd1bf 52 scr=1;
Danton 57:ed9db2bcd1bf 53 return;
Danton 57:ed9db2bcd1bf 54 }
Danton 57:ed9db2bcd1bf 55 void bmpFromSDToScreen(const char* path)
Danton 57:ed9db2bcd1bf 56 {
Danton 57:ed9db2bcd1bf 57 unsigned char rawbytes[14080];
Danton 57:ed9db2bcd1bf 58 int color[3520];
Danton 57:ed9db2bcd1bf 59 unsigned int absPtr=54;
Danton 57:ed9db2bcd1bf 60 superDisplay();
Danton 57:ed9db2bcd1bf 61 for(int i=0;i<176;i=i+16)
Danton 57:ed9db2bcd1bf 62 {
Danton 57:ed9db2bcd1bf 63 pickUpLine(rawbytes,color,14080,3520,path,&absPtr);
Danton 57:ed9db2bcd1bf 64 drawLine(color,i);
Danton 57:ed9db2bcd1bf 65 }
Danton 57:ed9db2bcd1bf 66 return;
Danton 56:51410b4b1078 67 }