Tema: Re: TFT su ST7735 kontroleriu
Autorius: Levas
Data: 2022-02-09 11:16:35
patys source codai (si karta STM32) yra:
http://www.vabolis.lt/2020/05/21/arm0015-stm32cubemx-ekraniuku-bibliotekos-2-dalis/

Kadangi gryna C, tai persirasyti i kita MCU nera problemos.

On 2022.02.09 13:13, Levas wrote:
> > ir tikriausiai supratai, kad yra ST7735 su visokiom raidem ir > pajungimais. Todel ir yra tie define.
> > // If no video, try ALL config options. Tested only with ST7735R, > 160x128, BGR mask.
> // config files may contain errors.
> > //#define ST7735B //Initialization code common to all ST7735B displays
> #define ST7735R //Initialization code common to all ST7735R displays
> > //ST7735R options:
> //#define INITR_GREENTAB
> #define INITR_REDTAB
> //#define INITR_BLACKTAB
> //#define INITR_MINI160x80
> //#define INITR_HALLOWING // Hallowing is simply a 1.44" green tab > upside-down:
> //#define INITR_144GREENTAB
> > > > On 2022.02.09 13:04, Levas wrote:
>> niekas nesigylina i init seka vien todel, kad tai baisu. Tavo >> dokumente, 158 lapas, arba 12 paragrafas.
>>
>> Kazkokia baisi schema. Dar kazkur turetu buti kita schema, kur >> nupaisytas maitblokis (11). Ir dar kazkas:
>> -DC/DC converter
>> -Adjustable VCOM generation
>> -Oscillator for display clock generation
>> -Timing controller
>>
>> Visa sita pornografija konfiguruojama ir reguliuojama skaitmeniskai >> inito metu.
>>
>> Debilnas flow chartas rodo, kad ekranas gali buti 9 buklese >> (iskaiciuojant isjungta is rozetes) ir kad is vieno rezimo reikia >> pereiti naudojant kazkokias sekas. Einan neteisingu keliu, galima >> uztrumpinti maitbloki arba tuos stiprintuvus- per kokius nors >> fantominius maitinimus.
>>
>>
>> Siaip, gamintojas turi rekomendacijas kokie initai turi buti, ir >> kogero reikia ju prisilaikyti. Vienu metu eksperimentavau su tuo, tai >> nieko gero neisiburiau- arba veikia arba niekas nepakinta. Tacia >> neaisku kiek viduje ten kas nors nesigadina.
>>
>>
>> Mano eksperimentu ir paiesku internetuose rezutatas su komentarais:
>> char ST7735_init(void)
>> {
>> #ifdef ST7735B
>> static const uint8_t Bcmd[] = {                        // Init >> commands for 7735B screens
>>      18,                             // 18 commands in list:
>>      ST77XX_SWRESET,   ST_CMD_DELAY, //  1: Software reset, no args, >> w/delay
>>        150,                           //     *50 ms delay
>>      ST77XX_SLPOUT,    ST_CMD_DELAY, //  2: Out of sleep mode, no >> args, w/delay
>>        255,                          //     255 = max (500 ms) delay
>>      ST77XX_COLMOD,  1+ST_CMD_DELAY, //  3: Set color mode, 1 arg + >> delay:
>>        0x05,                         //     16-bit color
>>        10,                           //     10 ms delay
>>      ST7735_FRMCTR1, 3+ST_CMD_DELAY, //  4: Frame rate control, 3 args >> + delay:
>>        0x00,                         //     fastest refresh
>>        0x06,                         //     6 lines front porch
>>        0x03,                         //     3 lines back porch
>>        10,                           //     10 ms delay
>>      ST77XX_MADCTL,  1,              //  5: Mem access ctl >> (directions), 1 arg:
>>        0x08,                         //     Row/col addr, bottom-top >> refresh
>>      ST7735_DISSET5, 2,              //  6: Display settings #5, 2 args:
>>        0x15,                         //     1 clk cycle nonoverlap, 2 >> cycle gate
>>                                      //     rise, 3 cycle osc equalize
>>        0x02,                         //     Fix on VTL
>>      ST7735_INVCTR,  1,              //  7: Display inversion control, >> 1 arg:
>>        0x0,                          //     Line inversion
>>      ST7735_PWCTR1,  2+ST_CMD_DELAY, //  8: Power control, 2 args + >> delay:
>>        0x02,                         //     GVDD = 4.7V
>>        0x70,                         //     1.0uA
>>        10,                           //     10 ms delay
>>      ST7735_PWCTR2,  1,              //  9: Power control, 1 arg, no >> delay:
>>        0x05,                         //     VGH = 14.7V, VGL = -7.35V
>>      ST7735_PWCTR3,  2,              // 10: Power control, 2 args, no >> delay:
>>        0x01,                         //     Opamp current small
>>        0x02,                         //     Boost frequency
>>      ST7735_VMCTR1,  2+ST_CMD_DELAY, // 11: Power control, 2 args + >> delay:
>>        0x3C,                         //     VCOMH = 4V
>>        0x38,                         //     VCOML = -1.1V
>>        10,                           //     10 ms delay
>>      ST7735_PWCTR6,  2,              // 12: Power control, 2 args, no >> delay:
>>        0x11, 0x15,
>>      ST7735_GMCTRP1,16,              // 13: Gamma Adjustments (pos. >> polarity), 16 args + delay:
>>        0x09, 0x16, 0x09, 0x20,       //     (Not entirely necessary, >> but provides
>>        0x21, 0x1B, 0x13, 0x19,       //      accurate colors)
>>        0x17, 0x15, 0x1E, 0x2B,
>>        0x04, 0x05, 0x02, 0x0E,
>>      ST7735_GMCTRN1,16+ST_CMD_DELAY, // 14: Gamma Adjustments (neg. >> polarity), 16 args + delay:
>>        0x0B, 0x14, 0x08, 0x1E,       //     (Not entirely necessary, >> but provides
>>        0x22, 0x1D, 0x18, 0x1E,       //      accurate colors)
>>        0x1B, 0x1A, 0x24, 0x2B,
>>        0x06, 0x06, 0x02, 0x0F,
>>        10,                           //     10 ms delay
>>      ST77XX_CASET,   4,              // 15: Column addr set, 4 args, >> no delay:
>>        0x00, 0x02,                   //     XSTART = 2
>>        0x00, 0x81,                   //     XEND = 129
>>      ST77XX_RASET,   4,              // 16: Row addr set, 4 args, no >> delay:
>>        0x00, 0x02,                   //     XSTART = 1
>>        0x00, 0x81,                   //     XEND = 160
>>      ST77XX_NORON,     ST_CMD_DELAY, // 17: Normal display on, no >> args, w/delay
>>        10,                           //     10 ms delay
>>      ST77XX_DISPON,    ST_CMD_DELAY, // 18: Main screen turn on, no >> args, delay
>>        255 };                        //     255 = max (500 ms) delay
>> #endif
>>
>> #ifdef ST7735R
>> static const uint8_t Rcmd1[] = {                       // 7735R init, >> part 1 (red or green tab)
>>      15,                             // 15 commands in list:
>>      ST77XX_SWRESET,   ST_CMD_DELAY, //  1: Software reset, 0 args, >> w/delay
>>        150,                          //     150 ms delay
>>      ST77XX_SLPOUT,    ST_CMD_DELAY, //  2: Out of sleep mode, 0 args, >> w/delay
>>        255,                          //     500 ms delay
>>      ST7735_FRMCTR1, 3,              //  3: Framerate ctrl - normal >> mode, 3 arg:
>>        0x01, 0x2C, 0x2D,             //     Rate = fosc/(1x2+40) * >> (LINE+2C+2D)
>>      ST7735_FRMCTR2, 3,              //  4: Framerate ctrl - idle >> mode, 3 args:
>>        0x01, 0x2C, 0x2D,             //     Rate = fosc/(1x2+40) * >> (LINE+2C+2D)
>>      ST7735_FRMCTR3, 6,              //  5: Framerate - partial mode, >> 6 args:
>>        0x01, 0x2C, 0x2D,             //     Dot inversion mode
>>        0x01, 0x2C, 0x2D,             //     Line inversion mode
>>      ST7735_INVCTR,  1,              //  6: Display inversion ctrl, 1 >> arg:
>>        0x07,                         //     No inversion
>>      ST7735_PWCTR1,  3,              //  7: Power control, 3 args, no >> delay:
>>        0xA2,
>>        0x02,                         //     -4.6V
>>        0x84,                         //     AUTO mode
>>      ST7735_PWCTR2,  1,              //  8: Power control, 1 arg, no >> delay:
>>        0xC5,                         //     VGH25=2.4C VGSEL=-10 VGH=3 >> * AVDD
>>      ST7735_PWCTR3,  2,              //  9: Power control, 2 args, no >> delay:
>>        0x0A,                         //     Opamp current small
>>        0x00,                         //     Boost frequency
>>      ST7735_PWCTR4,  2,              // 10: Power control, 2 args, no >> delay:
>>        0x8A,                         //     BCLK/2,
>>        0x2A,                         //     opamp current small & >> medium low
>>      ST7735_PWCTR5,  2,              // 11: Power control, 2 args, no >> delay:
>>        0x8A, 0xEE,
>>      ST7735_VMCTR1,  1,              // 12: Power control, 1 arg, no >> delay:
>>        0x0E,
>>      ST77XX_INVOFF,  0,              // 13: Don't invert display, no args
>>      ST77XX_MADCTL,  1,              // 14: Mem access ctl >> (directions), 1 arg:
>>      //check RGB or BGR mode pin D3. C8-RGB, C0-BGR
>>
>>        0xC0,                         //     row/col addr, bottom-top >> refresh
>>
>>      ST77XX_COLMOD,  1,              // 15: set color mode, 1 arg, no >> delay:
>>        0x05 };                       //     16-bit color
>> #endif
>>
>> #ifdef INITR_GREENTAB
>> static const uint8_t Rcmd2green[] = {                  // 7735R init, >> part 2 (green tab only)
>>      2,                              //  2 commands in list:
>>      ST77XX_CASET,   4,              //  1: Column addr set, 4 args, >> no delay:
>>        0x00, 0x02,                   //     XSTART = 0
>>        0x00, 0x7F+0x02,              //     XEND = 127
>>      ST77XX_RASET,   4,              //  2: Row addr set, 4 args, no >> delay:
>>        0x00, 0x01,                   //     XSTART = 0
>>        0x00, 0x9F+0x01 };            //     XEND = 159
>> #endif
>>
>>
>> #ifdef INITR_REDTAB
>> static const uint8_t Rcmd2red[] = {                    // 7735R init, >> part 2 (red tab only)
>>      2,                              //  2 commands in list:
>>      ST77XX_CASET,   4,              //  1: Column addr set, 4 args, >> no delay:
>>        0x00, 0x00,                   //     XSTART = 0
>>        0x00, 0x7F,                   //     XEND = 127
>>      ST77XX_RASET,   4,              //  2: Row addr set, 4 args, no >> delay:
>>        0x00, 0x00,                   //     XSTART = 0
>>        0x00, 0x9F };                 //     XEND = 159
>> #endif
>>
>>
>> #if defined INITR_144GREENTAB || defined INITR_HALLOWING
>> static const uint8_t Rcmd2green144[] = {               // 7735R init, >> part 2 (green 1.44 tab)
>>      2,                              //  2 commands in list:
>>      ST77XX_CASET,   4,              //  1: Column addr set, 4 args, >> no delay:
>>        0x00, 0x00,                   //     XSTART = 0
>>        0x00, 0x7F,                   //     XEND = 127
>>      ST77XX_RASET,   4,              //  2: Row addr set, 4 args, no >> delay:
>>        0x00, 0x00,                   //     XSTART = 0
>>        0x00, 0x7F }  ;               //     XEND = 127
>> #endif
>>
>> #ifdef INITR_MINI160x80
>> static const uint8_t Rcmd2green160x80[] = {            // 7735R init, >> part 2 (mini 160x80)
>>      2,                              //  2 commands in list:
>>      ST77XX_CASET,   4,              //  1: Column addr set, 4 args, >> no delay:
>>        0x00, 0x00,                   //     XSTART = 0
>>        0x00, 0x4F,                   //     XEND = 79
>>      ST77XX_RASET,   4,              //  2: Row addr set, 4 args, no >> delay:
>>        0x00, 0x00,                   //     XSTART = 0
>>        0x00, 0x9F } ;                //     XEND = 159
>> #endif
>>
>> #if defined ST7735R
>> static const uint8_t Rcmd3[] = {                       // 7735R init, >> part 3 (red or green tab)
>>      4,                              //  4 commands in list:
>>      ST7735_GMCTRP1, 16      ,       //  1: Gamma Adjustments (pos. >> polarity), 16 args + delay:
>>        0x02, 0x1c, 0x07, 0x12,       //     (Not entirely necessary, >> but provides
>>        0x37, 0x32, 0x29, 0x2d,       //      accurate colors)
>>        0x29, 0x25, 0x2B, 0x39,
>>        0x00, 0x01, 0x03, 0x10,
>>      ST7735_GMCTRN1, 16      ,       //  2: Gamma Adjustments (neg. >> polarity), 16 args + delay:
>>        0x03, 0x1d, 0x07, 0x06,       //     (Not entirely necessary, >> but provides
>>        0x2E, 0x2C, 0x29, 0x2D,       //      accurate colors)
>>        0x2E, 0x2E, 0x37, 0x3F,
>>        0x00, 0x00, 0x02, 0x10,
>>      ST77XX_NORON,     ST_CMD_DELAY, //  3: Normal display on, no >> args, w/delay
>>        10,                           //     10 ms delay
>>      ST77XX_DISPON,    ST_CMD_DELAY, //  4: Main screen turn on, no >> args w/delay
>>        100 };                        //     100 ms del
>> #endif
>>
>>
>>
>> #if defined ST7735B
>> ST7735_writeinit(Bcmd);
>>
>> #elif defined ST7735R
>>      ST7735_writeinit(Rcmd1);
>>      #if defined INITR_144GREENTAB || defined INITR_HALLOWING
>>          ST7735_writeinit(Rcmd2green144);
>>      #elif defined INITR_MINI160x80
>>          ST7735_writeinit(Rcmd2green160x80);
>>      #else
>>          ST7735_writeinit(Rcmd2red);
>>      #endif
>>      ST7735_writeinit(Rcmd3);
>> #endif
>>
>>
>> return 1;
>>
>> }
>>
>>
>>
>> On 2022.02.08 14:56, Shadowed wrote:
>>> Labos dienos visiems,
>>>
>>> Biškiuką sugalvojau paeksperimentuoti su TFT displėjuku, nedidelis >>> 160x128. Iš karto pasakysiu, kad bibliotekų naudoti nenoriu, >>> nepriklausomai nuo to ar tai Arduino ar STMo kubas, tai vien ST7735 >>> Init() nepaeis. Skaičiau nemažai Interneto šaltinių, ten 95 % naudoja >>> gatavą init'ą, o likę nepaaiškina ką ir kaip daro. Prisegu >>> kontrolerio aprašymą. O klausimai tokie:
>>>
>>> 1. Kas per debilnas "Power flow chart" (68 psl.)... Čia taip suprantu >>> turėtų būti paleidmo/inicializavimo seka, nu bet bl, niekaip >>> nedašunta ką reikia incializuoti. SW reset vienintelis aiškus >>> dalykas. Kad sleep out chingliš kalba yra Power On arba Wake up - >>> supratau.
>>>
>>> 2. Displėjuko inicializavimui manyčiau naudojamos komandos iš 10 >>> skyriaus, 77 psl. Bet čia jos tiesiog išvardintos, ir visai ne >>> inicializavimo eilės tvarka, jos čia tiesiog visos išvardintos. Tai >>> vėl bandau sukti galvą - tai kurias komandas leisti ? Šiaip kažkurias >>> suleidau, pagal savo galvą, tai ekraniukas kažką rodo, bet ne visame >>> plote ir, jei gerai suprantu, juodai baltą vaizdą.
>>>
>>> Tai dabar perskaičiau ką surašiau ir pats matau, kad vienintelis >>> klausimas tai kokia turi būti komandų seka :D. Beje tuos gatavus >>> initus peržiūrėjau, kai kurių komandų net nėra aprašyme. Turbūt dėl >>> to su gatavu init displėjukas vaizdą rodo neteisingai, taip lyg 4 >>> kadrai suspausti viename ekrane su juodais tarpais tarp jų. Kažkas >>> inicializavime nepraeina normaliai, todėl ir sugalvojau pasirašyt >>> savo, be jokių gatavų initų.
>>
>>
> > -- ---
http://www.vabolis.lt
3Dastronomyagricultureaudioautosautos.audiautos.audioautos.binariesautos.bmwautos.clubautos.fordautos.hondacrxautos.japanautos.mercedesautos.opelautos.sportautos.volvoautos.vwaviaavia.binariesbankcardsbinariesbooksbuildingcinemacommercecomp.hardwarecomp.softwarecomp.lietuvinimascomp.networksculturedarbas.ieskaudarbas.siulaudesigneconomicselectronicsfaunafauna.aquafauna.binariesfishingflorafotofoto.binariesgamesgames.csgames.onlinegsmgurmanaihumourhumour.binariesinternetlawmicrosoftmotomusicmusic.binariesmusic.instrumentsmusic.LT.binariesnavigacijaphppoliticsprogrammingrpgsportstudyingsveikatatalktesttranslationtransportationtraveltravel.binariestvunixvideovideo.binarieswatersportswwwwww.flashpdaautos.supermama.ltmobiledarbasretro.3Dretro.agricultureretro.astronomyretro.audioretro.autosretro.autos.audiretro.autos.audioretro.autos.binariesretro.autos.bmwretro.autos.clubretro.autos.fordretro.autos.hondacrxretro.autos.japanretro.autos.mercedesretro.autos.opelretro.autos.sportretro.autos.supermamaretro.autos.supermama.ltretro.autos.volvoretro.autos.vwretro.aviaretro.avia.binariesretro.bankcardsretro.beosretro.binariesretro.booksretro.buildingretro.cinemaretro.commerceretro.compretro.comp.hardwareretro.comp.lietuvinimasretro.comp.networksretro.comp.softwareretro.cultureretro.darbasretro.darbas.ieskauretro.darbas.siulauretro.designretro.economicsretro.electronicsretro.e-vejasretro.faunaretro.fauna.aquaretro.fauna.binariesretro.fishingretro.floraretro.fotoretro.foto.binariesretro.gamesretro.games.csretro.games.onlineretro.games.rpgretro.genealogijaretro.gsmretro.gurmanairetro.humourretro.humour.binariesretro.internetretro.YZFretro.YZF.nebukretro.YZF.nebuk.netikintisretro.YZF.nebuk.netikintis.bukretro.YZF.nebuk.netikintis.buk.tikintisretro.lawretro.microsoftretro.mobileretro.motoretro.musicretro.music.binariesretro.music.instrumentsretro.music.LTretro.music.LT.binariesretro.navigacijaretro.newsretro.news.taisyklesretro.newuserretro.pdaretro.phpretro.politicsretro.programmingretro.rpgretro.sportretro.studyingretro.sveikataretro.talkretro.translationretro.transportationretro.travelretro.travel.binariesretro.tvretro.unixretro.videoretro.video.binariesretro.watersportsretro.wwwretro.www.flashdiylt.rkm.news.announcelt.rkm.news.newuser