Menu

ST7735 display or other small color display.

Help
JANIS
2022-04-05
2022-05-05
1 2 > >> (Page 1 of 2)
  • JANIS

    JANIS - 2022-04-05

    I want to create a small project that will be located outdoors. St7735 is written to also work at -30 * C. In real winter, the temperature in Latvia drops below -20 * C. Does anyone have experience with this display, or can you suggest something else?
    I have built one project using this display, I am satisfied. In the project I use PIC16F1938, a microchip (28 pin) used in demo examples. Now I want to use a different chip with less pins. For example, the PIC16F15325 or 16F18446 I purchased. In the old project ST7735 I connected to 161938 as shown in the example so that there is no need to look for problems. What should I consider when choosing chip outputs to connect to this display?

     
    • Anobium

      Anobium - 2022-04-05

      I would get an LGT328p from Aliexpress (I order 10 more today) - fastest 8bit.
      Then, I would use an 18F then either of the chips you have chosen.

       
  • JANIS

    JANIS - 2022-04-05

    Thanks Anobium! However, I choose option 3, stick to my chips :) I ask more about the display ST7735, because this driver has been manufactured for a long time and is still used.

    Thanks!

     
  • stan cartwright

    stan cartwright - 2022-04-05

    It would be cheaper and easier to buy a temp/weather module from ebay.
    they're so cheap why bother build your own?

     
  • JANIS

    JANIS - 2022-04-05

    Stan, Of course, I will build something interesting and individual. I probably chose the wrong pin. the example created on 16f1938 doesn't work. :(

     #chip 16f18446,32
      #option explicit
      #config Osc = INT, MCLRE_ON, CLKOUTEN_OFF '', PLLEN_ON
    
    
     #include <glcd.h>
    
          #define GLCD_TYPE GLCD_TYPE_ST7735
    
         'Pin mappings for SPI
          #define GLCD_DI  portc.4        '  NOT CONNECTED - can loop back if required
             #define GLCD_DO  portb.4        ' > SDA
             #define GLCD_SCK portb.6       ' > SCK
    
             #define GLCD_DC portc.6       ' > A0
               #define GLCD_CS porta.5        ' > CS    p16
             #define GLCD_RESET porta.4     ' > RESET p15
    
       #define ST7735_HardwareSPI    
    
     
  • JANIS

    JANIS - 2022-04-05

    The following is the code from the demo example. I configured the pin incorrectly. There problem. I didn't really understand anything.

     
  • Anobium

    Anobium - 2022-04-06

    I am confused. Are you saying you have this working with a 16F1938 ? I will now assume the answer is yes.


    Well.. the 16F18446 chip is a PPS chip.  How do I know this?  I look in PICInfo and I see the PPSTool button is active which is only active when a chip has PPS, and, PPS1WAY in the config is another clue.
    
    Why is knowing this is a PPS chip?  Because you have you have to setup the PPS for the SPI module.   So, with no PPS configuration you should comment out the constant ST7735_HardwareSPI as this will force use of software SPI.  Does software SPI work?
    

    PPS Setup

    Assuming software SPI works ( you need to ensure this does work. As the software SPI ensure you have connectivity). Then, you need to config PPS. I have used PPSTool - selecting the SDO1, SDI1 and SCK1 for your chip.

    Please check the ports I have assigned!

    'Generated by PIC PPS Tool for Great Cow Basic
    'PPS Tool version: 0.0.6.2
    'PinManager data: Not available (3)
    'Generated for 16f18446
    '
    'Template comment at the start of the config file
    '
    #startup InitPPS, 85
    #define PPSToolPart 16f18446
    
    Sub InitPPS
    
            'Module: MSSP1
            SSP1DATPPS = 0x0014    'RC4 > SDI1
            RB4PPS = 0x0014    'SDO1 > RB4
            RB6PPS = 0x0013    'SCK1 > RB6
            SSP1CLKPPS = 0x000E    'RB6 > SCK1 (bi-directional)
    
    End Sub
    'Template comment at the end of the config file
    

    Now, add this to the program. reinstate the constant ST7735_HardwareSPI and all should work.. a lot faster than the software SPI option.


    Which tab did the ST7735 have? options are shown below.

    #define ST7735TABCOLOR ST7735_BLACKTAB  ' can be ST7735_BLACKTAB, ST7735_GREENTAB or ST7735_REDTAB.  Each tab is a different ST7735 configuration.
    ' you may have to try all three - if you do not know what ST7735 chipset you have.
    
     

    Last edit: Anobium 2022-04-06
  • JANIS

    JANIS - 2022-04-06

    Thanks Anobium Hmm compiler compiles error for this sub. Should I try to choose other pins?

     
    • Anobium

      Anobium - 2022-04-06

      I am guessing without your source code....

       
  • JANIS

    JANIS - 2022-04-06

    Yes, here's this part compiled ok!

     #chip 16f18446,32
      #option explicit
      #config Osc = INT, MCLRE_ON, CLKOUTEN_OFF , PLLEN_ON
    
    
    ';''=====================
    
     #include <glcd.h>
    
          #define GLCD_TYPE GLCD_TYPE_ST7735
    
         'Pin mappings for SPI
        ''  #define GLCD_DI  portc.4        '  NOT CONNECTED - can loop back if required
        ''     #define GLCD_DO  portb.4        ' > SDA
         ''    #define GLCD_SCK portb.6       ' > SCK
    
           ''  #define GLCD_DC portc.6       ' > A0
           ''    #define GLCD_CS porta.5        ' > CS    p16
           ''  #define GLCD_RESET porta.4     ' > RESET p15
    
    
        'Generated by PIC PPS Tool for Great Cow Basic
        'PPS Tool version: 0.0.6.2
        'PinManager data: v1.65.2
        'Generated for 16lf18446
        '
        'Template comment at the start of the config file
        '
        #startup InitPPS, 85
        #define PPSToolPart 16lf18446
    
        Sub InitPPS
    
                'Module: MSSP1
                SSP1DATPPS = 0x0014    'RC4 > SDI1
                SSP1CLKPPS = 0x000E    'RB6 > SCK1
                RB6PPS = 0x0013    'SCK1 > RB6 (bi-directional)
                RB4PPS = 0x0014    'SDO1 > RB4
    
        End Sub
        'Template comment at the end of the config file
    
      #define ST7735_HardwareSPI     ' remove comment out if you want to use software SPI.
       '===================
    

    Here is the part of the demo program to which the compiler finds an error when adding to execution:

      GLCDCLS
          ' GLCDRotate ( LANDSCAPE )     ' optionally you can rotate the screen.
    
    
            Dim CCOUNT, BYTENUMBER as Byte
    
            CCount = 0
            dim longNumber as long
            longNumber = 0 ' max value = 4294967290
            dim wordNumber as Word
            wordNumber = 0
            byteNumber = 0
     ''GLCDROTATE LANDSCAPE_REV
            DO forever
    
                GLCDPrint (0, 0, "PrintStr")
    
                GLCDPrint ( 44 ,  21, "     ")
                GLCDPrint ( 44 ,  29, "     ")
                GLCDPrint ( 44 ,  37, "   ")
    
    
                GLCDPrint ( 44 , 21, longNumber)
                GLCDPrint ( 44 , 29, wordNumber)
                GLCDPrint ( 44 , 37, byteNumber)
    
                GLCDDrawString( 0,8,"DrawStr")
                GLCDDrawChar(64, 8, ( CCount + 31 ) mod 127)
    
                 box 0,0,ST7735_GLCD_WIDTH-1, ST7735_GLCD_HEIGHT-1, ST7735_BLACK
                 box ST7735_GLCD_WIDTH-5, ST7735_GLCD_HEIGHT-5,ST7735_GLCD_WIDTH-1, ST7735_GLCD_HEIGHT-1, ST7735_BLACK
    
                 filledbox 2,30,6,38, wordNumber
               ''  Circle( 25,30,8,1)            ;center
                FilledCircle( 25,30,9,longNumber xor 1)         ;center
              '' FilledCircle( 25,30,9,0x780F)         ;center
    
                 line 0,  ST7735_GLCD_HEIGHT-1 , ST7735_GLCD_WIDTH/2,  (ST7735_GLCD_HEIGHT /2) +1
                 line  ST7735_GLCD_WIDTH/2, (ST7735_GLCD_HEIGHT /2) +1 ,0, (ST7735_GLCD_HEIGHT /2) +1
    
                CCount++
                longNumber = longNumber + 7
                wordNumber = wordNumber + 3
                byteNumber++
    
            LOOP
    
        end
    

    As I mentioned, I started with a standard demo example, first setting up the connection between the display and the microcontroller. When it's ok, I'll continue my program. step by step.

     
  • JANIS

    JANIS - 2022-04-06

    And configuration setting also not valid: PLLEN_ON

     
  • Anobium

    Anobium - 2022-04-06
    1. You are using a different chip. Look in PICINFO. There is no PLLEN_ON. So, remove all the config. You do not need but MCLRE_ON
    2. You have commented out all the GLCD configs / pin mappings.
         'Pin mappings for SPI
        ''  #define GLCD_DI  portc.4        '  NOT CONNECTED - can loop back if required
        ''     #define GLCD_DO  portb.4        ' > SDA
         ''    #define GLCD_SCK portb.6       ' > SCK
    
           ''  #define GLCD_DC portc.6       ' > A0
           ''    #define GLCD_CS porta.5        ' > CS    p16
           ''  #define GLCD_RESET porta.4     ' > RESET p15
    
     
  • JANIS

    JANIS - 2022-04-06

    As usual, careless mistakes make me ... Thanks Anobium! Everything is working now and I have to start implementing the project code :) many questions will start from me in the forum :)

     
    • Anobium

      Anobium - 2022-04-06

      Pleasure.

      When you get the base demo working.. please send to me so I can include in the demo folder.

       
  • stan cartwright

    stan cartwright - 2022-04-06

    So what's the weather like outside? I just look out the window but serious, nice if you got it working. Great when a program works.

     
  • JANIS

    JANIS - 2022-04-06

    Thanks Stan! There is a lot of work in the workplace, but when I have an idea to improve or change something or invent something new and beautiful in the equipment built on PIC and GCB in my home, I have to mature and take action.

     
    • stan cartwright

      stan cartwright - 2022-04-06

      Brill bro. I get a buzz when my code works eventually.
      When I code I create my own problems and fix them. I find it good mind logic exercise.. honest. I don't get annoyed when things don't work as planned. NOT!

       

      Last edit: stan cartwright 2022-04-06
      • stan cartwright

        stan cartwright - 2022-04-06

        I did use a temp/humidity sensor from ebay and Anobium said I was ripped off as it didn't have humidity but I didn't lose sleep over it. It was just an experiment but it made me think why do this when there's cheap ebay alternatives?
        my bike £1 back light turns leds on and off.
        It's hard to think of new projects ideas that's not been done before but some things have not been done on gcb. A lot really... see arduino library's.
        Anobium sorts stuff like VL53L0x laser rangefinder, I think I had to send him one but he did all the work to get it working with gcb and I built an obstacle avoiding robot using it. The whole robot used gcb like interrupt for the stepper motors and the servo for the laser
        I couldn't have bought one for the price it cost me... £15 with nano but it's nice I think to make something from not a kit. This is years ago but it's I made it.
        https://www.youtube.com/watch?v=YO7ghMglLkA

         
  • JANIS

    JANIS - 2022-04-16

    The display cannot display a single line sentence (a sentence consists of a few words). To display a sentence, how should I create a running string correctly? Could you give an example of a small one?

     
    • Anobium

      Anobium - 2022-04-17

      Try changing the fonts set.

      #DEFINE GLCD_OLED_FONT
              GLCDfntDefaultsize = 2
              GLCDFontWidth = 5
      
       
  • stan cartwright

    stan cartwright - 2022-04-17

    I notice my code has #define GLCD_EXTENDEDFONTSET1 in it. Yours doesn't mention fonts.
    As Anobium said define a font. After all your bother I hope it is a nice display.

     
  • JANIS

    JANIS - 2022-04-19

    Thanks Stan and Anobium. You do not understand the question of scrolling text on the display. I asked how to create a scrolling text on the display. I've done it with LED 7-segment indicators.

    But now the next question. Before the project, I try out all the features I will need in the project. I plan to use 2 timers at a time. I've already done this in one other project where I use timer0 and timer1 at the same time. There was no GLCD and I am using pic16f18855. But in this code I want to use GLCD and want to run both timers at the same time.
    With both timers, the display hangs, leaving one side in one color and the other side in another color. :)
    I tried to use timer0, timer3, the same thing happens.

    If use any only 1 timer, it's ok!

    #chip 16f18446,32
    ''  #option explicit
      #config Osc = INT, MCLRE_ON, CLKOUTEN_OFF
    ';''=====================
     #include <glcd.h>
     ;==============================
    #define BUTTON portc.7
    dir portc.7 in
    ;===============================
          #define GLCD_TYPE GLCD_TYPE_ST7735 ''i change BLACKTAB, REDTAB, it doesn't change anything, the display works
    
         'Pin mappings for SPI
          #define GLCD_DI  portc.4        '  NOT CONNECTED - can loop back if required
           #define GLCD_DO  portb.4        ' > SDA
            #define GLCD_SCK portb.6       ' >    SCL  ====SCK
            #define GLCD_DC portc.6       ' >  DC ====    A0
              #define GLCD_CS porta.5        ' > CS ====   p16
           #define GLCD_RESET porta.4     ' > RES===== p15
        'Generated by PIC PPS Tool for Great Cow Basic
        'PPS Tool version: 0.0.6.2
        'PinManager data: v1.65.2
        'Generated for 16lf18446
        'Template comment at the start of the config file
        #startup InitPPS, 85
        #define PPSToolPart 16lf18446
        Sub InitPPS
                'Module: MSSP1
                SSP1DATPPS = 0x0014    'RC4 > SDI1
                SSP1CLKPPS = 0x000E    'RB6 > SCK1
                RB6PPS = 0x0013    'SCK1 > RB6 (bi-directional)
                RB4PPS = 0x0014    'SDO1 > RB4
        End Sub
    
      #define ST7735_HardwareSPI     ' remove comment out if you want to use software SPI.
       '===================
      GLCDCLS
    
    ''==================================================================================
    #define TMR1_16bit
    InitTimer1 osc , PS1_8  '' Timer1 un 3 = 16  bitu timeris (32MHz internal) (32000000/4/ 65536 (16 bit timeris)/8 = 15 reizes overflow sekundee)
    StartTimer 1
    On Interrupt Timer1Overflow Call Timer_1 '' TMR1IE = 1 why do not work?
    ''==============================
    inittimer2 PS2_128, 0''    InitTimer2  , prescaler, postscaler
    
    'Timer2 = 8  bitu timeris (32MHz internal) (32000000/4/ 255 (8 bit timeris)/ 128 = 245 reizes overflow sekundee)
    starttimer 2
    TMR2IE = 1
    ''====================================== 
         #define GLCD_EXTENDEDFONTSET1
          GLCDfntDefaultsize = 3
    
    sec=0:secfull=0:min=0
    ;========================
    
     main:
    if sec<>sec_disp then
    GLCDPrint (2, 2, sec )
    sec_disp=sec
    'end if
    if sec<>sec_disp then
    
          goto main
    
    
    
    sub Timer_1
        secfull++
         ''==================================
       if secfull>14 then
        sec++: secfull=0
        ''=================================
        if sec>59 then sec=0
        end if
    end sub
    
    sub Interrupt '' timer2
    TMR2IF = 0  
    end sub
    

    Then when I try separately, any timer only one, then everything works, the display does not hang.

     
    • Anobium

      Anobium - 2022-04-19

      The code does not compile. See the attachment.

      Errors have been found:

      janis01.gcb (57): Error: If without matching End If
      janis01.gcb (61): Error: If without matching End If


      So, If I ignore those errors but making into comments then we can analyse the scroll.

      The easy way to make the screen scroll would be to use function 0x33 in the datasheet. https://www.waveshare.com/w/upload/e/e2/ST7735S_V1.1_20111121.pdf section 33h. this show how to scroll vertical or horizontal.

       
  • JANIS

    JANIS - 2022-04-19

    I have another question also. When I try Timer 1 and Timer 2 separately, Why can't Timer 1 work with the TMR1IE = 1 flag, I can't write like this?
    Timer 1 should write: On Interrupt Timer1Overflow Call xxxxx

    But Timer 2 can write :TMR2IE = 1
    Then:
    sub Ineterrupt
    TMR2IE = 0
    ...........................................
    ..................................
    end sub

    Why can't it be done with Timer 1?

     
    • Anobium

      Anobium - 2022-04-19

      You need to study the interrupts more. Use PICINFO the Interrupt tab. The interrupts bit are handled correctly if you use the correct On Interrupt method.

      See below.

      #define TMR1_16bit
      InitTimer1 osc , PS1_8  '' Timer1 un 3 = 16  bitu timeris (32MHz internal) (32000000/4/ 65536 (16 bit timeris)/8 = 15 reizes overflow sekundee)
      StartTimer 1
      On Interrupt Timer1Overflow Call Timer_1_ISR 
      TMR1IE = 1
      ''==============================
      inittimer2 PS2_128, 0''    InitTimer2  , prescaler, postscaler
      
      'Timer2 = 8  bitu timeris (32MHz internal) (32000000/4/ 255 (8 bit timeris)/ 128 = 245 reizes overflow sekundee)
      starttimer 2
      On Interrupt Timer2Match Call Timer_2_ISR 
      

      Also. using an ISR method called interrupt will change the behaviour of the interrupt handler. See the help on this. So, in the code above I have correctly called the isr's.

      See if this helps.

       
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.