Upgrade to Pro — share decks privately, control downloads, hide ads and more …

how to use ZY-FGD1442701V1 with mbed

Keiichiro
November 21, 2014

how to use ZY-FGD1442701V1 with mbed

Aitendo 1.44inch TFT ZY-FGD1442701V1(ST7735S)を駆動させる. BusOutで接続. Bitmap画像をSDカードから読み込み.
http://eleclog.quitsq.com/2014/11/zy-fgd1442701v1.html
http://developer.mbed.org/users/9SQ/code/ZY_FGD1442701V1_BusOut_SDHC/

Keiichiro

November 21, 2014
Tweet

More Decks by Keiichiro

Other Decks in Programming

Transcript

  1. ;:'(%7 454 w Πϯν5'5ӷথϞδϡʔϧ w ղ૾౓ɿY w ίϯτϩʔϥνοϓɿ454 w දࣔྖҬɿºNN

    w ઀ଓΠϯλʔϑΣʔεɿCJUύϥϨϧ w NNϐονϐϯ'1$ w IUUQXXXBJUFOEPDPNQSPEVDU →σʔλγʔτɺॳظԽίʔυ ͋Γ! ! ST7735౥ࡌ൛͸ൢചऴྃ! →ඇS൛ͱS൛ͰίϚϯυʹมߋ͋Γ
  2. LCD_Write_CMD(0xE0); // Gamma Adjustment (+Polarity) LCD_Write_Data(0x03); LCD_Write_Data(0x1B); LCD_Write_Data(0x09); LCD_Write_Data(0x0E); LCD_Write_Data(0x32);

    LCD_Write_Data(0x2D); LCD_Write_Data(0x28); LCD_Write_Data(0x2C); LCD_Write_Data(0x2B); LCD_Write_Data(0x29); LCD_Write_Data(0x30); LCD_Write_Data(0x3B); LCD_Write_Data(0x00); LCD_Write_Data(0x01); LCD_Write_Data(0x02); LCD_Write_Data(0x10); LCD_Write_CMD(0xE1); // Gamma Adjustment (-Polarity) LCD_Write_Data(0x03); LCD_Write_Data(0x1B); LCD_Write_Data(0x09); LCD_Write_Data(0x0E); LCD_Write_Data(0x32); LCD_Write_Data(0x2E); LCD_Write_Data(0x28); LCD_Write_Data(0x2C); LCD_Write_Data(0x2B); LCD_Write_Data(0x28); LCD_Write_Data(0x31); LCD_Write_Data(0x3C); LCD_Write_Data(0x00); LCD_Write_Data(0x00); LCD_Write_Data(0x02); LCD_Write_Data(0x10); ! LCD_Write_CMD(0x3A); // Interface Pixel Format LCD_Write_Data(0x05); // 16-bit/pixel ! LCD_Write_CMD(0x2A); // Column Address Set LCD_Write_Data(0x00); LCD_Write_Data(0x02); LCD_Write_Data(0x00); LCD_Write_Data(0x81); LCD_Write_CMD(0x2B); // Row Address Set LCD_Write_Data(0x00); LCD_Write_Data(0x01); LCD_Write_Data(0x00); LCD_Write_Data(0x80); ! wait_ms(100); LCD_Write_CMD(0x2C); // Memory Write } void LCD_Init(void) { LCD_Reset(); ! LCD_Write_CMD(0xB1); // In Normal Mode(Full Colors) Frame rate 80Hz LCD_Write_Data(0x02); LCD_Write_Data(0x35); LCD_Write_Data(0x36); ! LCD_Write_CMD(0xB2); // In Idle Mode(8-colors) LCD_Write_Data(0x02); LCD_Write_Data(0x35); LCD_Write_Data(0x36); ! LCD_Write_CMD(0xB3); // In Partial Mode + Full Colors LCD_Write_Data(0x02); LCD_Write_Data(0x35); LCD_Write_Data(0x36); LCD_Write_Data(0x02); LCD_Write_Data(0x35); LCD_Write_Data(0x36); ! LCD_Write_CMD(0xB4); // Dot Inversion Control LCD_Write_Data(0x03); // Inversion setting in Idle mode and full Colors partial mode ! LCD_Write_CMD(0xC0); // Power Control Setting (GVDD Voltage) LCD_Write_Data(0xA2); // AVDD=5, GVDD=4.6 LCD_Write_Data(0x02); // VGCL=-4.6 LCD_Write_Data(0x84); // MODE=AUTO ! LCD_Write_CMD(0xC1); // Power Control Setting (VGH/VGL Voltage) LCD_Write_Data(0xC5); // VGH and VGL supply power level = 2.4, VGL=-10, VGH=3*AVDD-0.5 ! LCD_Write_CMD(0xC2); // In Normal Mode(Full Colors) APA/DCA LCD_Write_Data(0x0D); // SAP=Small, AP=Large LCD_Write_Data(0x00); // Clock frequency for Booster circuit/1,/3,/1,/1,/1 ! LCD_Write_CMD(0xC3); // In Idle Mode(8-colors) APA/DCA LCD_Write_Data(0x8D); LCD_Write_Data(0xEA); ! LCD_Write_CMD(0xC4); // In Partial Mode(Full Colors) APA/DCA LCD_Write_Data(0x8D); LCD_Write_Data(0xEE); ! LCD_Write_CMD(0xC5); // VCOM LCD_Write_Data(0x05); // -0.55 ! LCD_Write_CMD(0x36); // Memory Data Access Control LCD_Write_Data(0x48); // MX, RGB mode (Row Address Order, RGB color filter panel) BJUFOEP͕ެ։͍ͯ͠ΔॳظԽίʔυΛ ϕʔεʹएׯͷมߋɾ௥Ճ ίϝϯτ ॳظԽ
  3. void LCD_Write_CMD(unsigned char cmd) { CS0=0; RD=1; CD=0; P1=cmd; WR=0;

    WR=1; CS0=1; } ! void LCD_Write_Data(unsigned char d) { CS0=0; RD=1; CD=1; P1=d; WR=0; WR=1; CS0=1; } ! void LCD_Reset(void) { RSTB=1; wait_ms(1); RSTB=0; wait_ms(1); RSTB=1; wait_ms(120); LCD_Write_CMD(0x11); // Sleep Out and Booster On wait_ms(120); } 345# $4 $% 3% 83 ίϚϯυɾσʔλૹ৴ɺϦηοτ 345#
  4. LCD_Write_CMD(0x3A); // Interface Pixel Format LCD_Write_Data(0x05); // 16-bit/pixel LCD_Write_CMD(0x2A); //

    Column Address Set LCD_Write_Data(0x00); LCD_Write_Data(0x02); LCD_Write_Data(0x00); LCD_Write_Data(0x81); LCD_Write_CMD(0x2B); // Row Address Set LCD_Write_Data(0x00); LCD_Write_Data(0x01); LCD_Write_Data(0x00); LCD_Write_Data(0x80); Yɿ02h,81h = 128ྻ! Xɿ01h,80h = 128ߦ ˞ਤ͸ºυοτͷ৔߹
  5. main.cpp BusOut P1(p17, p16, p15, p14, p13, p12, p11, p10);

    DigitalOut CS0(p21); DigitalOut CD(p22); DigitalOut RD(p23); DigitalOut WR(p24); DigitalOut RSTB(p25); ! LocalFileSystem local("local"); ඳը଎౓ɿNTˠ஗͍ ɹˠ-PDBM'JMF4ZTUFN ಺ଂ'MBTI ͔ΒͷGSFBE͕஗͍ • BusOut (pin10-17)
  6. • BusOut (pin10-17) main.cpp BusOut P1(p17, p16, p15, p14, p13,

    p12, p11, p10); DigitalOut CS0(p21); DigitalOut CD(p22); DigitalOut RD(p23); DigitalOut WR(p24); DigitalOut RSTB(p25); ! SDFileSystem sd(p5, p6, p7, p8, "sd"); ! SDHCFileSystem.cpp #230 _spi.frequency(32000000); //32MHz ඳը଎౓ɿNTˠഒ͘Β͍ߴ଎Խ ɹˠ4%'JMF4ZTUFN 4%Χʔυ ͔ΒͷGSFBE͕ߴ଎ ɹɹ 41*.)[
  7. unsigned short pixel; ! for (i=0; i<128*128; i++) { fread(&pixel,

    2, 1, fp); LCD_Write_Data((unsigned char)((pixel & 0xFFFF) >> 8)); LCD_Write_Data((unsigned char)pixel); } unsigned short pixel[128]; ! for (i=0; i<128; i++) { fread(&pixel, 2, 128, fp); for(j=0; j<128; j++) { LCD_Write_Data((unsigned char)((pixel & 0xFFFF) >> 8)); LCD_Write_Data((unsigned char)pixel); } } 185ms 215ms ɾ1pixel(16bit)ͣͭɹbmp565ܗࣜɹ128×128ʹ16384ճΞΫηε ɾ1ߦ(16bit×128ʹ256Byte)ͣͭɹbmp565ܗࣜɹ128ճΞΫηε ΞΫηεճ਺ͱॲཧΛݮΒͯ͠ඳըߴ଎Խ ໿86% 235ms ɾ1Byte(8bit)ͣͭɹbmp555ܗࣜɹ128×128×2ʹ32768ճΞΫηε ໿91% ↓ίϯτϩʔϥͷܗࣜʹ߹ΘͤΔ͜ͱͰॲཧΛݮΒ͢
  8. • port0ͷ࢖༻! PortOut P0(Port0, 0x00000FF0); ͞Βʹߴ଎Խ͢ΔͨΊʹ ϙʔτϨδελΛ௚઀ୟ͘˞ CJU࿈ଓͰग़͍ͯΔ 0 15

    31 27 28 5 6 7 8 29 30 ˞ݫີʹ͸1PSU0VUͰ΋ؒʹॲཧೖͬͯΔͷͰl௚઀zͰ͸ͳ͍ IUUQEFWFMPQFSNCFEPSHVTFSTOYQ@JQOPUFCPPLQBSBMMFMCVTBDDFTT • PortOut (pin30,29,8,7,6,5,28,27)
  9. void LCD_Write_CMD(unsigned char a) { CS0=0; RD=1; CD=0; P0=(unsigned)a<<4; WR=0;

    WR=1; CS0=1; } ! void LCD_Write_Data(unsigned char b) { CS0=0; RD=1; CD=1; P0=(unsigned)b<<4; WR=0; WR=1; CS0=1; } 0 15 31 VOTJHOFEDIBS CJU VOTJHOFE CJU 27 28 5 6 7 8 29 30