Menu

ST7735 text color and font size

Help
Mikam
2018-11-30
2018-12-06
  • Mikam

    Mikam - 2018-11-30

    Hi All
    Using the ST7735 TFT. GCB v98.03.

     GLCDBackground = ST7735_BLACK        'works
     box (0,0,159,127, ST7735_WHITE)             'works
    

    GLCDPrint (10,100,"Hello") ' How do i set the color of text, default appears to be black

    also
    

    GLCDfntDefaultSize = 1 'the size of text does not change only the space between each character

    Thanks

     
  • stan cartwright

    stan cartwright - 2018-11-30

    You could use GLCDDrawString(CharLocX, CharLocY, String [, Optional Colour] )

     
  • Anobium

    Anobium - 2018-12-01

    I agree with Stan.

    You must use GLCDDrawString.

     
  • Mikam

    Mikam - 2018-12-03
     #chip 18F25k80,32
     #option explicit
     #config OSC=INTIO2, MCLRE=OFF, WDT=OFF, BOR=OFF
    
        #include <glcd.h>
        #include <maths.h>
        #DEFINE GLCD_TYPE GLCD_TYPE_ST7735
    
    '------------------------
    'GCB v0.98.03  2018-10-20
    '------------------------
    
       #define GLCD_DI  portc.4       '  Data in | MISO   Not required
       #define GLCD_DO  portc.5       ' Data out | MOSI
       #define GLCD_SCK portc.3       ' Clock Line
       #define GLCD_DC portc.6        ' Data command line
       #define GLCD_CS portc.2        ' Chip select line
       #define GLCD_RESET portc.7     ' Reset line
    
       #define ST7735_HardwareSPI
    
      GLCDRotate 1
    
     '2.05v INT ref
     adcon1.VCFG0=0
     adcon1.VCFG1=1
    
      GLCDBackground = ST7735_BLUE
      GLCDCLS
      wait 1 s
      GLCDfntDefaultSize = 1
    
      box (0,0,159,127, ST7735_WHITE)
      circle(63,31,2,ST7735_blue)
    
      do Forever
    
        GLCDDrawString (30,30,"Hello",ST7735_white)
        filledbox(4,110,100,120, ST7735_blue)
        'GLCDDrawString (30,70,"stringtext",ST7735_WHITE)
    
        wait 1 s
      loop
    
    

    Unable to change color of 'GLCDDrawString' always prints as black, also the size of text does not change #chip 18F25k80,32

    Thanks

     
    • Anobium

      Anobium - 2018-12-03

      Are you saying this does not work?

       
  • Mikam

    Mikam - 2018-12-03

    Yes!
    box and circle work but 'GLCDDrawString' always prints black can't change the color.

     
  • Anobium

    Anobium - 2018-12-03

    Let me look now that you are using this method.

    Check back later.

     
  • Anobium

    Anobium - 2018-12-03

    Please test this. There may be a silly error with the passing of the color. I have updated the method to pass the color correctly.

    add this to your code. Test and let me know the result.

    #define GLCDDrawChar myGLCDDrawChar_ST7735 
    
    '''Draws a character at the specified location on the ST7920 GLCD
    '''@param StringLocX X coordinate for message
    '''@param CharLocY Y coordinate for message
    '''@param Chars String to display
    '''@param LineColour Line Color, either 1 or 0
    Sub myGLCDDrawChar_ST7735(In CharLocX, In CharLocY, In CharCode, Optional In LineColour as word = GLCDForeground )
    
      'CharCode needs to have 16 subtracted, table starts at char 16 not char 0
      CharCode -= 15
    
              'Need to read characters from CharColn (n = 0:7) tables
      '(First 3, ie 0:2 are blank, so can ignore)
      For CurrCharCol = 1 to 5
        Select Case CurrCharCol
          Case 1: ReadTable GLCDCharCol3, CharCode, CurrCharVal
          Case 2: ReadTable GLCDCharCol4, CharCode, CurrCharVal
          Case 3: ReadTable GLCDCharCol5, CharCode, CurrCharVal
          Case 4: ReadTable GLCDCharCol6, CharCode, CurrCharVal
          Case 5: ReadTable GLCDCharCol7, CharCode, CurrCharVal
        End Select
                        For CurrCharRow = 1 to 8
                                  If CurrCharVal.0 = 0 Then
                                            PSet CharLocX + CurrCharCol, CharLocY + CurrCharRow, GLCDBackground
                                  Else
                                            PSet CharLocX + CurrCharCol, CharLocY + CurrCharRow, LineColour
                                  End If
                                  Rotate CurrCharVal Right
                        Next
    
      Next
    
    
    
    End Sub
    
     
  • Mikam

    Mikam - 2018-12-04

    Still not working.

     
    • Anobium

      Anobium - 2018-12-04

      Post the complete the project as a ZIP. I will review online.

       
  • Anobium

    Anobium - 2018-12-04

    This driver was the second driver to be developed... it needed a bit of updating to provide color support, OLED fonts and other things that have been introduced since 2014. :-)

     
  • Mikam

    Mikam - 2018-12-06

    All Good. Thanks

     
  • Anobium

    Anobium - 2018-12-06

    please get the latest driver. I updated glcdcls to include a parameter.

    Ecanvan

    Evan

     

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.