1 2 Previous Next 15 Replies Latest reply on Nov 21, 2018 9:17 AM by EvPa_264126

    emWin 5.46 and FlexColor

    EvPa_264126

      I tried to use emWin5.46 to work with QVGA 2.2 TFT SPI 240x320 (ILI9341)

      Color, coordinates, orientation do not match ...

      The result you can see in the photo.

      Any ideas, tips.1.jpg

        • 1. Re: emWin 5.46 and FlexColor
          MoTa_728816

          Hi,

           

          I tried your project and noticed that there are at least two problems

          (1) In GUI_Init() a window command which limit the drawing area has used to

               limit the drawing area to the upper half.

          (2) TFT_orientation is wrong.

           

          So for a quick fix for (2) is adding  "TFT_SetOrientation(1)  in MainTak()

          like below, then at least we can read the letters.

          ========================

          void MainTask(void) {

             

            TFT_SetOrientation(1) ; // <----- here

            GUI_Init();

            TFT_SetOrientation(1) ; // <--- here again

            GUI_SetBkColor(GUI_BLACK);

            GUI_SetColor(GUI_WHITE);

            GUI_Clear();

           

           

            GUI_SetColor(GUI_WHITE);

            GUI_SetFont(&GUI_Font24_ASCII);

            GUI_DispStringHCenterAt("COLOR_DemoLUT - Sample", 160, 5);

            _DemoLUT();

          }

          ========================

          IMG_3057.JPG

           

          But to fix the problem (1) you have to go and fix the library, since all is done in GUI_Init().

           

          moto

          1 of 1 people found this helpful
          • 2. Re: emWin 5.46 and FlexColor
            MoTa_728816

            Hi,

             

            Just for fun.

             

            Attached is my TFT Library demo for ILI9341,

            (You need to re-assign device and pins)

             

            Although without support for RTOS, much lighter than the one you are using.

             

            moto

            1 of 1 people found this helpful
            • 3. Re: emWin 5.46 and FlexColor
              EvPa_264126

              Thanks.

              Now I am trying to learn emWin5.46, in particular FlexColor and SPI.

              I'm trying to figure out how to use emWin settings for FlexColor.

              for example  DISPLAY_ORIENTATION (....) and etc, but  I see no effect

              An example of a simple test:

              int main(void)

              {

              CyGlobalIntEnable; /* Enable global interrupts. */

              SPIM_Start();     

              TFT_SetOrientation(1) ;

              GUI_Init();

              TFT_SetOrientation(1) ;

              GUI_Clear();

              GUI_SetFont(&GUI_Font32_ASCII);

              GUI_DispStringHCenterAt("Hello world", 0, 0);

              GUI_DrawRect(50,50,200,100);

              for(;;)

                  {

                  GUI_Delay(200); 

                  }

              }/* [] END OF FILE */

              Result:

              2.jpg

              • 4. Re: emWin 5.46 and FlexColor
                MoTa_728816

                Hi,

                 

                I found another source of problem,

                which is that in the project the TFT driver was not get reset.

                So I added another GPIO output and reset the TFT before starting initialization.

                 

                Meantime, although I tried to check LCD_ILI9341.c,

                it seems that there is/are something flipping the TFT rotation inside GUI_Init(),

                which is a black box library function.

                So I still need to have TFT_SetOrientation(1) before and after GUI_Init().

                 

                part of main() in main.c

                ========================

                int main(void)

                {

                CyGlobalIntEnable; /* Enable global interrupts. */

                SPIM_Start();    

                 

                   TFT_BL_Write(0) ; /* Turn Backlight off */

                   TFT_nRESET_Write(0) ; /* reset TFT */

                   CyDelay(1000) ;

                   TFT_nRESET_Write(1) ; /* release reset */

                 

                   TFT_SetOrientation(1) ;

                   GUI_Init();

                   TFT_SetOrientation(1) ;

                 

                   GUI_Clear();

                   TFT_BL_Write(1) ; /* Turn Backlight on */

                 

                     MainTask() ;

                 

                ========================

                 

                MainTask() in header01.h

                ========================

                void MainTask(void) {

                  GUI_SetBkColor(GUI_BLACK);

                  GUI_SetColor(GUI_WHITE);

                  GUI_Clear();

                 

                 

                  GUI_SetColor(GUI_WHITE);

                  GUI_SetFont(&GUI_Font24_ASCII);

                  GUI_DispStringHCenterAt("COLOR_DemoLUT - Sample", 160, 5);

                  _DemoLUT();

                }

                ========================

                 

                Anyway after these struggles my modified project seems to do what was expected initially.

                 

                IMG_3059.JPG

                 

                So, I hope that rest is you work!

                 

                moto

                1 of 1 people found this helpful
                • 5. Re: emWin 5.46 and FlexColor
                  MoTa_728816

                  DrawRect, DrawString functions seem to be working,

                  but some adjustment for color would be required.

                  Please refer to the manual of emWin for details.

                   

                  ====================

                     TFT_BL_Write(0) ; /* Turn Backlight off */

                     TFT_nRESET_Write(0) ; /* reset TFT */

                     CyDelay(1000) ;

                     TFT_nRESET_Write(1) ; /* release reset */

                   

                     TFT_SetOrientation(1) ;

                     GUI_Init();

                     TFT_SetOrientation(1) ;

                   

                     GUI_Clear();

                     TFT_BL_Write(1) ; /* Turn Backlight on */

                   

                  GUI_SetFont(&GUI_Font32_ASCII);

                  GUI_DispStringHCenterAt("Hello world", 160, 0);

                  GUI_DrawRect(50,50,100,100);

                  GUI_SetColor(GUI_BLACK) ;

                  GUI_DrawRect(180, 150, 230, 200) ;

                  GUI_SetBkColor(GUI_WHITE) ;

                  GUI_DispStringAt("Here you go!", 10, 130) ;

                   

                  for(;;) {

                      GUI_Delay(200);

                  }

                  ====================

                   

                  IMG_3060.JPG

                   

                  moto

                  1 of 1 people found this helpful
                  • 6. Re: emWin 5.46 and FlexColor
                    EvPa_264126

                    Thank you, I will add a reset later.

                    I see that the colors are inverted.

                    Temporary change in the LCD_ILI9341.C file

                    // Display Function Control

                    TFT_SendCMD (0xB6);

                    TFT_WriteData (0x08); // 0x0A

                    TFT_WriteData (0x82); // 02 A2

                    ---------------------------------

                    It seems yes - is there a problem with initialization (GUI_Init () ??)

                    I do not see a complete screen  ( only half of the screen)

                    and I can’t draw a rectangle with a side of more than 128

                    int main(void)

                    {
                    .......

                    GUI_Clear();   //   MainTask();

                    TFT_SetOrientation(1);

                    GUI_SetFont(&GUI_Font32_ASCII);

                    GUI_SetBkColor(GUI_YELLOW); GUI_SetColor(GUI_RED);

                    for(data=0;data<240;data++)    {GUI_DrawLine(0,0,320,data);  }

                    for(data=0;data<320;data++)    {GUI_DrawLine(0,0,data,240);  }

                    GUI_DrawRoundedRect(5,10,155,100,10);

                    GUI_SetColor(GUI_BLUE);

                    GUI_ClearRect(0,0,320,240);// only half of the screen

                    GUI_DispStringAt("Hello world",0,0);

                    GUI_DrawRect(50,50,200,100);

                    ..................
                    375.jpg

                    • 7. Re: emWin 5.46 and FlexColor
                      MoTa_728816

                      > It seems yes - is there a problem with initialization (GUI_Init () ??)

                      I added a UART and dumped SPI transaction, GUI_Init() is sending following command

                      after calling TFT_Init(orient) ;

                      ==================

                      TFT_Init_Done           This is the end part of TFT_Init()

                       

                      TFT_SendCmd(0x00) No Operation

                      TFT_SendCmd(0x36) Memory Access Control

                      TFT_WriteData(0xA0) 1010_0000 MY=1, MX=0, MV=1, ML=0, BGR=0, MH=0 <--- This line is causing our head ache!

                       

                      TFT_SendCmd(0x00)       No Operation  // following two blocks are specifying the display size, seems to be ok

                      TFT_SendCmd(0x2A) Column Address Set

                      TFT_WriteData(0x00)     SC[15:8] = 0x00    SC = 0x0000

                      TFT_WriteData(0x00)     SC[7:0]  = 0x00

                      TFT_WriteData(0x01)     EC[15:0] = 0x01    EC = 0x013F = 319

                      TFT_WriteData(0x3F)     EC[7:0]  = 0x3F

                       

                      TFT_SendCmd(0x00)       No Operation

                      TFT_SendCmd(0x2B)       Page Address Set

                      TFT_WriteData(0x00)     SP[15:8] = 0x00

                      TFT_WriteData(0x00)     SP[7:0]  = 0x00

                      TFT_WriteData(0x00)     EP[15:8] = 0x00

                      TFT_WriteData(0xEF)     EP[7:0]  = 0xEF = 239

                       

                      TFT_SendCmd(0x00)       No Operation

                      TFT_SendCmd(0x2C)       Memory Write

                      ==================

                       

                      > I do not see a complete screen  ( only half of the screen)

                      > and I can’t draw a rectangle with a side of more than 128

                      I also encountered this problem, but after implementing nRESET sequence

                      it was solved. So I recommend you to connect a GPIO to the reset pin and

                      assert reset, wait a while (I'm waiting 1sec, probably too much), then de-assert reset.

                       

                      Anyway, we are getting close, I hope.

                       

                      moto

                      1 of 1 people found this helpful
                      • 8. Re: emWin 5.46 and FlexColor
                        MoTa_728816

                        Hi,

                         

                        With your modification, my color bar now looks ok.

                        IMG_3061.JPG

                         

                        With my system, which has reset-pin addition, your test routine shows up like below

                        /*************************/

                        GUI_Clear();   //   MainTask();

                        TFT_SetOrientation(1);

                        GUI_SetFont(&GUI_Font32_ASCII);

                        GUI_SetBkColor(GUI_YELLOW); GUI_SetColor(GUI_RED);

                        for(data=0;data<240;data++)    {GUI_DrawLine(0,0,319,data);  }

                        for(data=0;data<320;data++)    {GUI_DrawLine(0,0,data,239);  }

                        GUI_SetColor(GUI_BLACK) ;

                        GUI_DrawRoundedRect(5,10,155,100,10);

                        GUI_SetColor(GUI_BLUE);

                        GUI_ClearRect(0,0,319,239);// only half of the screen

                        GUI_DispStringAt("Hello world",0,0);

                        GUI_DrawRect(50,50,200,100);

                        GUI_DrawRect(200, 150, 250, 200) ;

                        while(1)  ; /* stay here */

                        /*************************/

                        IMG_3062.JPG

                         

                        The library seems to have some problem with drawing loooong rectangle.

                        Probably poor implementation of drawing a long line.

                        The shorter rectangle shows up OK.

                         

                        moto

                        • 9. Re: emWin 5.46 and FlexColor
                          EvPa_264126

                          Thanks for the help.

                          One more question:

                          Have you tried to read the display ID?   ( datasheet 8.3.23. Read ID4 )

                          • 10. Re: emWin 5.46 and FlexColor
                            EvPa_264126

                            Everything turned out to be simple:

                            It is noticeable that the problem appears when working with a large number of  data.

                            I had to rewrite the function void TFT_SendArray (unsigned char * Data, int byteCount); in the LCD_ILI9341.c file

                            I used the function void SPIM_PutArray (const uint8 / uint16 buffer [], uint8 byteCount)

                            uint8 byteCount is a problem, it is not enough for emWin.

                            I just changed it to int.

                            It seems everything worked as it should.

                            Thanks for the help.
                            Eugene

                            3.jpg

                            • 11. Re: emWin 5.46 and FlexColor
                              MoTa_728816

                              Congratulations, you made it!

                               

                              > SPIM_PutArray (const uint8 / uint16 buffer [], uint8 byteCount)

                              But I think this is almost a bug of Cypress Component.

                              For nowaday applications uint8 for length seems to be too short.

                               

                              Anyway, I'm glad that hearing you can proceed now!

                               

                              moto

                              • 12. Re: emWin 5.46 and FlexColor
                                BoTa_264741

                                pavloven,

                                What screen update rate you get with emWin?

                                /odissey1

                                • 13. Re: emWin 5.46 and FlexColor
                                  EvPa_264126

                                  The screen refresh rate is commensurate with projects without emWin.

                                  A little later, I will report the time to execute the GUI_ClearRect somand (0,0,320,240);
                                  or another?

                                  • 14. Re: emWin 5.46 and FlexColor
                                    MoTa_728816

                                    > One more question:

                                    > Have you tried to read the display ID?   ( datasheet 8.3.23. Read ID4 )

                                     

                                    I tried some, but all data came back as 0x00,

                                        ID1: 0x00 ID2: 0x00 ID3:0x00

                                        ID4: 0x00, 0x00, 0x00, 0x00

                                    according to the datasheet EXTC must be high, but from the schematic

                                    I could get for my Adafruit ILI9341 module does not show the connection

                                    around the ILI9341, so, currently I can not tell if my program is doing ok or not.

                                     

                                    Note: For my board, CPOL needed to be 1

                                     

                                    SPI Format CPHA = 0, CPOL = 1

                                    Display Power Mode came back as 0x00, 0x00, 0x65

                                    Display Pixel Format came back as 0x00, 0x00, 0x4E

                                    Display Signal Mode came back as 0x00, 0x00, 0x02, 0xFF...

                                     

                                    SPI Format CPHA = 1, CPOL = 1

                                    Display Power Mode came back as 0x00, 0x00, 0xCA

                                    Display Pixel Format came back as 0x00, 0x00, 0x9C

                                    Display Signal Mode came back as 0x00, 0x00, 0x05, 0xFF...

                                     

                                    Anyway, FYI

                                     

                                    moto

                                    1 2 Previous Next