Line buffer mode. sammple code with MIP8F_SPI_Ver40
Dependencies: MIP8F_SPI_Ver40 mbed
Dependents: MIP8f_FRDM_TransferMode_sample MIP8f_FRDM_Animation_sample
Introduction
Line buffer mode sample with MIP8F_SPI_Ver40 Display some color and monochrome bitmap.
Other information , please refer to https://os.mbed.com/teams/JapanDisplayInc/code/MIP8f_FRDM_sample/
Usage
Copy Setting File and Image to micro SD-CARD. (Same setting File and bitmap of MIP8f_FRDM_sample.)
a) Download the following file corresponding to the target panel, and rename file identifier (.bin -> .zip), and unzip the file on micro SD Card's root directory.
- LPM013M126x (176x176) :/media/uploads/JDI_Mbed_Team/sdcard_176x176.bin
- LPM027M128x (400x240) :/media/uploads/JDI_Mbed_Team/sdcard_400x240.bin
- LPM044M141x (640x480): /media/uploads/JDI_Mbed_Team/sdcard_640x480.bin
b) Insert micro SD-CARD to FRDM-K64F. c) Upload binary file to FRDM-K64F.and push Reset Button.
Other information
refer to Usage on https://os.mbed.com/teams/JapanDisplayInc/code/MIP8f_FRDM_sample/
this Sample Code (.bin)
/media/uploads/JDI_Mbed_Team/mip8f_frdm_linebuffer_sample.k64f.bin
Diff: main.cpp
- Revision:
- 7:c7a676157b4d
- Parent:
- 6:2646a55a0233
- Child:
- 10:167df76b02d0
diff -r 2646a55a0233 -r c7a676157b4d main.cpp --- a/main.cpp Wed Oct 24 02:28:15 2018 +0000 +++ b/main.cpp Wed Oct 31 02:07:57 2018 +0000 @@ -1,9 +1,10 @@ /** * @file main.cpp -* @brief Sample source code for MIP8 diplay. +* @brief Ver3.0 Sample source code for MIP8 diplay. * @details * -* Addtional function is Monochome display by 1bit mode of SPI transfer. +* Ver3.0 Addtional function is font display. this demo code is tha degit is counted up like a meter panel +* ver2.0 Addtional function is Monochome display by 1bit mode of SPI transfer. * * spi-transfer to Display has 3 mode. * 4bit mode is color display, this bit arrange is R,G,B,x. R,G,B = R,G,B subpixel bit. a x bit is Dummy. @@ -34,7 +35,10 @@ #include "Arial12x12.h" #include "Arial24x23.h" #include "Arial28x28.h" +#include "Arial37x36.h" +#include "Arial42x42.h" #include "font_big.h" +#include "Arial94x94.h" //#include "Prototype29x28.h" //#include "Prototype70x86.h" //#include "HGP23x29.h" @@ -59,7 +63,9 @@ DigitalIn TexSW(SW3); //for debug -//Serial pc(USBTX, USBRX); // tx, rx +Serial pc(USBTX, USBRX); // tx, rx + +void SDtex2BUF(char *filepath); //function prototype void SD2BUF(char *filepath); @@ -81,11 +87,15 @@ int blduty = 0; int bloff = 0; int blctrl_sel = 0; //0:40mA, 1:160mA //Y.S +// Readed bitmap format, Color bit size = 1,4,8,(16),24,32 +uint16_t bmp_bitcount; int main() { uint32_t filenum=0; char filepath[40]; + char countup[3+1]; + char KMPH[4+1]; sd.disk_initialize(); HaltSW.Enable(1); @@ -135,42 +145,99 @@ COM60HZ.write(0.5); //add 20161108 BK.period_ms(1); //1ms cycle 20161012 - BK.write(0); //low output 20160725 <- high output + BK.write(1); //low output 20160725 <- high output + + //DIR *d; while(1) { //BITMAPS filenum = CntFile(filepath); //file number read - for( int j = 0; j < 2; j++) + for(uint32_t i=0; i<filenum; i++) { - for(uint32_t i=0; i<filenum; i++) + for( int j = 0; j < 2; j++) { - ReadBmp(filepath,i); + ReadBmp(filepath,0); + while(HaltSW.State()) { // VCOM invert when image is still // pol++; // WD.command( (pol << 6) & 0x40 ); // wait(bk_timer); //1Hz } HaltSW.Clear(); + //1bit trasfer mode = monochro diplay - if( j%2 == 0 ) + if( j%2 == 0 && bmp_bitcount != 8) WD.writeDISP(TrBIT4); else - WD.writeDISP(TrBIT1); - wait(2); + WD.writeDISP(TrBIT1); + //wait(2); + + if( j%2 == 0 ) + { + // for color diaplay + WD.foreground(0x04); + WD.background(0x00); + }else{ + // for monochrome diaplay + WD.foreground(0x0e); + WD.background(0x00); + } + //WD.fillrect(0,115,399,205, WD.get_Background() ); + + sprintf(KMPH,"km/h"); + WD.set_ActualFontWidth(); + WD.set_font((unsigned char*) Arial28x28); + WD.obliqueout(70+200+35,100+20+49,KMPH); + + WD.set_font((unsigned char*) Arial94x94); + WD.set_FixedFontWidth(50); + for(int t=0;t<100;t++) + { + sprintf(countup,"%2d",t); + WD.obliqueout(70+35+48,100+20,countup); + + //1bit trasfer mode = monochro diplay + if( j%2 == 0 /*&& bmp_bitcount != 8*/) + // for color display + WD.writeDISP(100+20,190+20,TrBIT4); + else + // for color diaplay + WD.writeDISP(100+20,190+20,TrBIT1); + + if( j%2 == 0 && t==60) + { + // 60 < t => 80 yellow char + WD.foreground(0x0C); + }else + if( j%2 == 0 && t==80) + { + // 80 < t => 99 rec char + WD.foreground(0x08); + } + //wait(0.5); + } } } } } -//4bit mode +/** +* @brief read a bitmap file in SD. 8color mode +*/ void SD2BUF(char *filepath){ - char R8[1],G8[1],B8[1] ,DUMMY[1]; + char R8[1],G8[1],B8[1] ,DUMMY[1],bc[2]; int RGB; FILE *fp ; + pc.printf("file=%s\n",filepath); fp = fopen(filepath, "rb"); if(fp != NULL) { - for(int i=0; i< 54 ; i++) fscanf(fp,"%c",DUMMY); // Discard Header 54bytes + //for(int i=0; i< 54 ; i++) fscanf(fp,"%c",DUMMY); // Discard Header 54bytes + for(int i=0; i< 28 ; i++) fscanf(fp,"%c",DUMMY); // Discard Header 26bytes + fscanf(fp,"%c",&(bc[0]));fscanf(fp,"%c",&(bc[1]));// color bit size 2bytes + for(int i=0; i< 24 ; i++) fscanf(fp,"%c",DUMMY); // Discard Header 26bytes + bmp_bitcount = bc[0]+bc[1]*256; + for(int y=height-1; y>=0; y--) { for(int x=0; x< width; x++) { //24bit color B 8bit -> G 8bit -> R 8bit fscanf(fp, "%c",B8); @@ -187,6 +254,9 @@ fclose(fp); } +/** +* @brief read a text file in SD. +*/ void SDtex2BUF(char *filepath){ int x,y,font,color; char text[40]; @@ -195,7 +265,6 @@ fp = fopen(filepath, "r"); if(fp != NULL) { -// for(int i=0; i<3; i++){ while(ifEOF != -1){ ifEOF = fscanf(fp,"%d,%d,%d,%d,%[^,],",&x,&y,&font,&color,text); WD.locate(x,y); @@ -211,6 +280,7 @@ fclose(fp); } +/* void DispAllDir(const char *fsrc) { DIR *d = opendir(fsrc); @@ -224,7 +294,11 @@ } closedir(d); } +*/ +/** +* @brief read a bitmap file in SD by file number. +*/ void ReadBmp(const char *fsrc, uint32_t FileNum) { DIR *d = opendir(fsrc); @@ -252,7 +326,6 @@ return counter; } - void OffSequence(void){ BK.write(0); //add 20160712 17:00 WD.background(Black);