JDI_MIP on ThunderBoardSense2(Silicon-Labs)
JDI_MIP (LPM013M126A) Sample on ThunderBoard2(Silicon-Labs)
LPM013M126A
Links
https://os.mbed.com/teams/JapanDisplayInc/
https://os.mbed.com/teams/JapanDisplayInc/wiki/MIP-reflective-color-display
main.cpp
- Committer:
- STakayama
- Date:
- 2018-05-16
- Revision:
- 4:588bc9618fff
- Parent:
- 3:79758cbd4a92
- Child:
- 5:79dc134e6033
File content as of revision 4:588bc9618fff:
#include "mbed.h" #include "Si1133.h" #include "SPI_MIP16.h" #include "data.h" Si1133 uv_sensor(PC4, PC5); WatchDisp WD(PK0,PK2,PF7,PA5); //PTC12); // mosi,miso,clk,cs,disp,power(EXTMODE) DigitalOut _lcd_disp(PA8); // DISP DigitalOut _lcd_extmod(PF6); // EXTMODE //_lcd_reset(reset),_lcd_extcom(extcom) InterruptIn UV_INT(PA6); // YV Interrupt DigitalIn PushSW0(PD14); // Switch DigitalIn PushSW1(PD15); // Switch DigitalOut ledPJ14(PJ14); DigitalOut led1(LED1); DigitalOut ledPI0(PI0); DigitalOut ledPI1(PI1); DigitalOut ledPI2(PI2); DigitalOut ledPI3(PI3); DigitalOut ledR(PD11); DigitalOut ledG(PD12); DigitalOut ledB(PD13); uint8_t ccolor_table[] = {Black,Gray,Blue ,LightBlue ,Green ,LightGreen ,Cyan ,LightCyan, Red ,pink,Magenta,LightMagenta,Yellow,LightYellow,LightGray,White}; bool if16 = 0; bool ifMargeTXT = 0; int width =176; int height=176; int test_lcd(void) { int i; // Power On Sequece // _lcd_reset = 0; // _lcd_reset = 1; _lcd_extmod = 1; _lcd_extmod = 0; _lcd_disp = 1; // hontoha 0 // command(0); WD.setWH(width,height); // Default X/Y bool if16 = 1; WD.set16col(if16); // 0= RGB, 1=RGBW WD.setmarge(1); WD.background(White); WD.foreground(LightGreen); WD.clsBUF(); WD.fillrect(i*(width/16), height/2+1, (i+1)*(width/16)-1, height , ccolor_table[15-i]); _lcd_disp = 1; return 0; } void uv_init_proc(void) { ; } int main() { ledPJ14 =1; ledPI0 =1; ledPI1 =1; ledPI2 =1; ledPI3 =1; UV_INT.fall(&uv_init_proc); test_lcd(); if (!uv_sensor.open()) printf("Device Error detected!\n"); int i; while(1){ i++; for (int j=0; j<0x100000;j++) ; led1 = (i%8==0)?(1):(0); // ledR = (i%1==0)?(1):(0); // ledG = (i%2==0)?(1):(0); // ledB = (i%4==0)?(1):(0); printf("aaa %d\n\r",i); float light_level = (float)uv_sensor.get_light_level(); printf("Lux = %.3f\n", (float)light_level); //Print the current UV index float uv_index = (float)uv_sensor.get_uv_index(); printf("UV index = %.3f\n", (float) uv_index); //Sleep for 0.5 seconds wait(0.5); } } /* MIP Main Reference #include "stdio.h" #include "string" #include "mbed.h" #include "SPI_MIP8.h" #include "SDFileSystem.h" #include "StateSW.h" #include "TglSW.h" #include "Arial28x28.h" #include "Prototype29x28.h" #include "Prototype70x86.h" #include "HGP23x29.h" #include "HGP15x19.h" #include "symbol.h" #define ON 1 #define OFF 0 //K64F SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // mosi,miso,sck,cs memLCD8 WD(PTD2,PTD3,PTD1,PTD0,PTC4,PTD3); //PTC12); // mosi,miso,clk,cs,disp,power TglSW HaltSW(PTA4); // SW3 InterruptIn OffSW(SW2); DigitalIn TexSW(SW3); void SD2BUF(char *filepath); void SetMenu(void); void OffSequence(void); void DispAllDir(const char *fsrc); void ReadBmp(const char *fsrc, uint32_t FileNum); uint32_t CntFile(const char *fsrc); int Menu = 0; bool if16 = 0; bool ifMargeTXT = 0; int width =400; int height=240; int main() { uint32_t filenum=0; char filepath[40]; char pol; if(OffSW==0) if16 = 1; //16color MODE else if16 = 0; if(TexSW==0) ifMargeTXT = 1; ifMargeTXT = 0; WD.setmarge(1); sd.disk_initialize(); HaltSW.Enable(1); FILE *fp = fopen("/sd/settings.txt", "rb"); if(fp != NULL) { fscanf(fp, "%d",&width); fscanf(fp, "%d",&height); sprintf(filepath,"/sd/%dx%d",width,height); //DispAllDir("/sd/180x180") } else{ width =180; height=180; sprintf(filepath,"/sd/180x180"); //DispAllDir("/sd/180x180") } fclose(fp); OffSW.fall(&OffSequence); // OFF Sequence WD.setWH(width,height); WD.background(Black); WD.clsBUF(); WD.writeDISP(); WD.SwDisp(1); while(HaltSW.State()){} HaltSW.Clear(); // WD.background(White); // WD.clsBUF(); // for (int i=0; i<8; i++) WD.fillrect(i*26+6,16, i*26+6+20, 36, i*2); // WD.writeDISP(); // wait(0.5); // while(HaltSW.State()){} // HaltSW.Clear(); while(1){ //BITMAPS filenum = CntFile(filepath); for(uint32_t i=0; i<filenum; i++){ ReadBmp(filepath,i); while(HaltSW.State()){ // VCOM invert when image is still pol++; WD.command( (pol << 6) & 0x40 ); wait(1); //1Hz } // Brink // for(char j = 0; j < 8; j++){ // pol = j&0x01; // EnterOrLeave = (j+1)&0x01; // WD.command( (pol << 6) | (EnterOrLeave << 3) ); // wait(0.2); // } HaltSW.Clear(); WD.writeDISP(); wait(2); } } } void SD2BUF(char *filepath){ char R8[1],G8[1],B8[1] ,DUMMY[1]; int RGB; FILE *fp ; fp = fopen(filepath, "rb"); if(fp != NULL) { for(int i=0; i< 54 ; i++) fscanf(fp,"%c",DUMMY); // Discard Header 54bytes 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); fscanf(fp, "%c",G8); fscanf(fp, "%c",R8); RGB = RGB8(*R8,*G8,*B8); //6bit(8bit) MIP MASK 0000 1110 WD.pixel(x,y,RGB); } if( y!=0) // The last data column doesn't need padding for(int x=(width*3)%4; (x%4 !=0); x++) fscanf(fp, "%c",DUMMY); // 4byte boundery for every column } } fclose(fp); } void SDtex2BUF(char *filepath){ int x,y,font,color; char text[40]; int ifEOF; FILE *fp ; 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); WD.foreground(color); if (font ==1) WD.set_font((unsigned char*) HGP15x19); else if (font ==2) WD.set_font((unsigned char*) HGP23x29); else if (font ==3) WD.set_font((unsigned char*) Arial28x28); else WD.set_font((unsigned char*) Prototype70x86); WD.printf("%s",text); } } fclose(fp); } void OffSequence(void){ WD.background(Black); WD.clsBUF(); WD.SwDisp(0); WD.writeDISP(); WD.writeDISP(); } void DispAllDir(const char *fsrc) { DIR *d = opendir(fsrc); struct dirent *p; char filepath[40]; while ((p = readdir(d)) != NULL) { sprintf(filepath, "%s/%s",fsrc,p->d_name); SD2BUF(filepath); WD.writeDISP(); } closedir(d); } void ReadBmp(const char *fsrc, uint32_t FileNum) { DIR *d = opendir(fsrc); struct dirent *p; char filepath[40]; for(uint32_t i=0; i< FileNum; i++) readdir(d); if ((p = readdir(d)) != NULL) { sprintf(filepath, "%s/%s",fsrc,p->d_name); SD2BUF(filepath); if(ifMargeTXT){ sprintf(filepath, "%s_txt/%s.txt",fsrc,p->d_name); SDtex2BUF(filepath); } } closedir(d); } uint32_t CntFile(const char *fsrc) { DIR *d = opendir(fsrc); uint32_t counter = 0; while (readdir(d)!= NULL) counter++; closedir(d); return counter; } */