Menu

Invert text ccters

2025-03-17
2025-03-31
  • Gert Klemmensen

    Gert Klemmensen - 2025-03-17

    Hi,

    I am trying to invert a text string on my SH-1106 display.
    Tried with this code:

     GLCDCLS
      GLCDBackground = 1
      GLCDForeground = 0
      GLCDPrint(1, 0 , "Rotary Enc. Demo")
      GLCDPrint(1, 10 , "GCBASIC")
    

    But only the first letter R in Rotary is inverted.
    What am I doing wrong?

     
  • Anobium

    Anobium - 2025-03-17

    Pass the background color as the 4th parameter. Does that resolve?

     
    • Gert Klemmensen

      Gert Klemmensen - 2025-03-18

      Thank you very much for your answer Anobium.

      Didn't even notice there was a fourth parameter in the GLCDPrint command. 😯
      It works in a way, but look at the attached image, there are some spaces between each character that are not inverted.

       
  • Anobium

    Anobium - 2025-03-18

    Looks like this GLCD library needs a quick fix.

    From my scan of the 1106 library.
    - The space character is not inverted
    - The background support is not correct
    - No support for OLED fonts.

    Joe the author has not touched this is many years.

    I can update over the next few days. If you want it fixing.

    Meanwhile... write the text in normal mode... and draw a box around the 'text'

    Evan

     
  • Gert Klemmensen

    Gert Klemmensen - 2025-03-18

    Thanks for the lightning fast reply.

    I would be very happy to get it fixed. I am working on a control where you can change parameters for 4-20mA sensor input with an encoder and here it will be easy to see when the selected parameter is displayed inverted.

    Many thanks in advance!

     
  • Anobium

    Anobium - 2025-03-18

    Give me a day or two.

    Assume it is working in Program and I will release a fix ASAP. So, you can press on.

    meanwhile... draw a filledbox() then GLCDprint into that box. Does that workaround?

     
    • Gert Klemmensen

      Gert Klemmensen - 2025-03-18

      That sounds great.

      Ohh yes, filledbox works fine as a temporary workaround.

       
      • Anobium

        Anobium - 2025-03-18

        OK. I will post again, soon. With a updated/replacement library.

         
        👍
        1
  • Anobium

    Anobium - 2025-03-26

    @Gert.

    Attached is an updated library. You should update your existing library with this new version. See folder GCSTUDIO\GCBASIC\INCLUDE


    The new library implements the following.

    Support for inverted text
    Support for GLCD_OLED_FONTS
    Support to GLCD character width management

    These changes bring the control of the GLCD characters to the same level of control as the ILI9341 and others.


    Example code used.

    #DEFINE GLCD_OLED_FONT  // Define this constant to use GLCD_OLED_FONT, GLCD_OLED_FONTs are smaller, faster and variable width characters, see the HELP.
    #IFNDEF GLCD_OLED_FONT
        //Optionally, pull GCBASIC characters tighter, default is 7 for legacy GLCD fonts.
        // GLCDFontWidth = 6
    #ENDIF
    
    // Normal/default
    GLCDBackground = 0
    GLCDForeground = 1
    GLCDPrint (0, 0, "GCBASIC")
    
    // Inverted
    GLCDBackground = 1
    GLCDForeground = 0
    GLCDPrint (0, 8, "GCBASIC")
    
    // Will show nothing... as GLCDBackground is same as color parameter passed. 
    GLCDBackground = 0
    GLCDForeground = 1
    GLCDPrint (0, 16, "GCBASIC", 0)
    
    // Normal but using color paremeter 
    GLCDBackground = 0
    GLCDForeground = 1
    GLCDPrint (0, 24, "GCBASIC", 1)
    
    // Inverted but using color parameter 
    GLCDBackground = 1
    GLCDForeground = 0
    GLCDPrint (0, 32, "GCBASIC", 0)
    
    // Will show white chars and white background... as GLCDBackground is same as color parameter passed.
    GLCDBackground = 1
    GLCDForeground = 0
    GLCDPrint (0, 40, "GCBASIC", 1)
    
     

    Last edit: Anobium 2025-03-26
  • Gert Klemmensen

    Gert Klemmensen - 2025-03-31

    @Anobium

    This is great! I will update the library and start using it.

    Thank you very much!!

     

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.