cauqleuir madre
Dependencies: SDFileSystem mbed TFTLCD
main.cpp@26:dd8e83feefb9, 2013-02-02 (annotated)
- Committer:
- Danton
- Date:
- Sat Feb 02 02:56:59 2013 +0000
- Revision:
- 26:dd8e83feefb9
- Parent:
- 25:b81df542785e
- Child:
- 27:bae83e4c9fce
aux en colorcompute
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Danton | 0:a11b3a90c259 | 1 | #include "mbed.h" |
Danton | 0:a11b3a90c259 | 2 | #include "SDFileSystem.h" |
Danton | 2:e205fa129def | 3 | #include "hx8340bs.h" |
Danton | 21:ed9ea3485f93 | 4 | void superDisplay() |
Danton | 21:ed9ea3485f93 | 5 | { |
Danton | 21:ed9ea3485f93 | 6 | HX8340S_LCD lcd( p9, p14, p13, p11); |
Danton | 21:ed9ea3485f93 | 7 | lcd.Initialize(); |
Danton | 21:ed9ea3485f93 | 8 | lcd.ClearScreen(); |
Danton | 22:9e6c02d5f85d | 9 | printf("superDisplay\c\n"); |
Danton | 21:ed9ea3485f93 | 10 | } |
Danton | 21:ed9ea3485f93 | 11 | void superSd(unsigned char*buffer,int offset,int bytes,const char *path) |
Danton | 15:3bfbb557020e | 12 | { |
Danton | 22:9e6c02d5f85d | 13 | printf("superSD\c\n"); |
Danton | 15:3bfbb557020e | 14 | SDFileSystem sd(p11, p12, p13, p8, "sd"); // the pinout on the mbed Cool Components workshop board |
Danton | 21:ed9ea3485f93 | 15 | FILE *fp =fopen(path, "r"); |
Danton | 15:3bfbb557020e | 16 | |
Danton | 15:3bfbb557020e | 17 | if(fp == NULL) { |
Danton | 15:3bfbb557020e | 18 | error("Could not open file\c\n"); |
Danton | 15:3bfbb557020e | 19 | } |
Danton | 15:3bfbb557020e | 20 | //fprintf(fp, "Hello fun SD Card World!\c\n"); |
Danton | 15:3bfbb557020e | 21 | //fread ( void * ptr, size_t size, size_t count, FILE * stream ); |
Danton | 17:3d7951357fd3 | 22 | fseek(fp, offset,SEEK_SET); |
Danton | 21:ed9ea3485f93 | 23 | fread((char*)buffer,1,bytes,fp); |
Danton | 15:3bfbb557020e | 24 | fclose(fp); |
Danton | 15:3bfbb557020e | 25 | |
Danton | 15:3bfbb557020e | 26 | } |
Danton | 21:ed9ea3485f93 | 27 | void colorCompute(unsigned char*buffer, unsigned int* colorBuffer,int offset,int sizeOfBuffer) |
Danton | 21:ed9ea3485f93 | 28 | { |
Danton | 22:9e6c02d5f85d | 29 | printf("ColorCompute\c\n"); |
Danton | 26:dd8e83feefb9 | 30 | int aux= sizeOfBuffer+offset; |
Danton | 26:dd8e83feefb9 | 31 | for(int i=offset;i<aux;i=i+4) |
Danton | 21:ed9ea3485f93 | 32 | { |
Danton | 23:eebe16b5b9c2 | 33 | printf("%d",i); |
Danton | 21:ed9ea3485f93 | 34 | colorBuffer[i]=buffer[i]<<16+buffer[i+1]<<8+buffer[i+2]; |
Danton | 21:ed9ea3485f93 | 35 | } |
Danton | 23:eebe16b5b9c2 | 36 | printf("\n"); |
Danton | 21:ed9ea3485f93 | 37 | } |
Danton | 21:ed9ea3485f93 | 38 | void pickUpLine(unsigned char*buffer, unsigned int* colorBuffer,int sizeOfBuffer,int sizeOfLine,const char *path) |
Danton | 21:ed9ea3485f93 | 39 | { |
Danton | 22:9e6c02d5f85d | 40 | printf("Pickupline\c\n"); |
Danton | 21:ed9ea3485f93 | 41 | int i =54; |
Danton | 25:b81df542785e | 42 | int delta=20; |
Danton | 21:ed9ea3485f93 | 43 | for(int j=0;j<sizeOfLine;j=j+delta) |
Danton | 21:ed9ea3485f93 | 44 | { |
Danton | 21:ed9ea3485f93 | 45 | superSd(buffer,i,sizeOfBuffer,path); |
Danton | 24:1acd0368a592 | 46 | printf("byteofFile%d, pixelnum %d, delta %d",i,j,delta); |
Danton | 21:ed9ea3485f93 | 47 | colorCompute(buffer,colorBuffer,j,sizeOfBuffer); |
Danton | 21:ed9ea3485f93 | 48 | i=i+delta; |
Danton | 21:ed9ea3485f93 | 49 | } |
Danton | 21:ed9ea3485f93 | 50 | |
Danton | 21:ed9ea3485f93 | 51 | } |
Danton | 21:ed9ea3485f93 | 52 | void drawLine(unsigned int* color,int y) |
Danton | 15:3bfbb557020e | 53 | { |
Danton | 15:3bfbb557020e | 54 | HX8340S_LCD lcd( p9, p14, p13, p11); |
Danton | 22:9e6c02d5f85d | 55 | printf("drawline\c\n"); |
Danton | 19:089c4027bfba | 56 | for(int i=0;i<220;i++) |
Danton | 19:089c4027bfba | 57 | { |
Danton | 21:ed9ea3485f93 | 58 | //lcd.DrawPixel(i,y,color[i]); |
Danton | 21:ed9ea3485f93 | 59 | lcd.DrawPixel(i,0,color[i]); |
Danton | 21:ed9ea3485f93 | 60 | lcd.DrawPixel(i,1,color[i]); |
Danton | 21:ed9ea3485f93 | 61 | lcd.DrawPixel(i,2,color[i]); |
Danton | 21:ed9ea3485f93 | 62 | lcd.DrawPixel(i,3,color[i]); |
Danton | 21:ed9ea3485f93 | 63 | lcd.DrawPixel(i,4,color[i]); |
Danton | 21:ed9ea3485f93 | 64 | lcd.DrawPixel(i,5,color[i]); |
Danton | 21:ed9ea3485f93 | 65 | lcd.DrawPixel(i,5,color[i]); |
Danton | 21:ed9ea3485f93 | 66 | lcd.DrawPixel(i,6,color[i]); |
Danton | 21:ed9ea3485f93 | 67 | lcd.DrawPixel(i,7,color[i]); |
Danton | 21:ed9ea3485f93 | 68 | lcd.DrawPixel(i,9,color[i]); |
Danton | 21:ed9ea3485f93 | 69 | lcd.DrawPixel(i,10,color[i]); |
Danton | 21:ed9ea3485f93 | 70 | lcd.DrawPixel(i,11,color[i]); |
Danton | 21:ed9ea3485f93 | 71 | lcd.DrawPixel(i,12,color[i]); |
Danton | 21:ed9ea3485f93 | 72 | lcd.DrawPixel(i,13,color[i]); |
Danton | 21:ed9ea3485f93 | 73 | lcd.DrawPixel(i,14,color[i]); |
Danton | 21:ed9ea3485f93 | 74 | lcd.DrawPixel(i,15,color[i]); |
Danton | 21:ed9ea3485f93 | 75 | lcd.DrawPixel(i,15,color[i]); |
Danton | 21:ed9ea3485f93 | 76 | lcd.DrawPixel(i,16,color[i]); |
Danton | 21:ed9ea3485f93 | 77 | lcd.DrawPixel(i,17,color[i]); |
Danton | 21:ed9ea3485f93 | 78 | lcd.DrawPixel(i,19,color[i]); |
Danton | 21:ed9ea3485f93 | 79 | |
Danton | 19:089c4027bfba | 80 | } |
Danton | 15:3bfbb557020e | 81 | } |
Danton | 21:ed9ea3485f93 | 82 | |
Danton | 21:ed9ea3485f93 | 83 | /*void drawScreen(unsigned char*buffer,unsigned int* colorBuffer,int sizeOfBuffer,int sizeOfLine,const char *path) |
Danton | 21:ed9ea3485f93 | 84 | { |
Danton | 21:ed9ea3485f93 | 85 | for(int i=0; i<176;i++) |
Danton | 21:ed9ea3485f93 | 86 | { |
Danton | 21:ed9ea3485f93 | 87 | pickUpLine |
Danton | 21:ed9ea3485f93 | 88 | } |
Danton | 21:ed9ea3485f93 | 89 | } |
Danton | 21:ed9ea3485f93 | 90 | */ |
Danton | 0:a11b3a90c259 | 91 | int main() { |
Danton | 6:ac9692245a01 | 92 | printf("Hello Stinky World!\c\n"); |
Danton | 0:a11b3a90c259 | 93 | |
Danton | 2:e205fa129def | 94 | //mkdir("/sd/mydir", 0777); |
Danton | 0:a11b3a90c259 | 95 | |
Danton | 15:3bfbb557020e | 96 | |
Danton | 21:ed9ea3485f93 | 97 | unsigned char rawbytes[80]; |
Danton | 21:ed9ea3485f93 | 98 | unsigned int color[220]; |
Danton | 22:9e6c02d5f85d | 99 | superDisplay(); |
Danton | 21:ed9ea3485f93 | 100 | pickUpLine(rawbytes,color,80,220,"/sd/mydir/rose.bmp"); |
Danton | 21:ed9ea3485f93 | 101 | drawLine(color,0); |
Danton | 15:3bfbb557020e | 102 | |
Danton | 0:a11b3a90c259 | 103 | printf("Goodbye World!\c\n"); |
Danton | 0:a11b3a90c259 | 104 | } |