Class GlcdBaseDriver

  • All Implemented Interfaces:
    com.ibasco.ucgdisplay.common.drivers.DisplayDriver, GlcdDisplayDriver
    Direct Known Subclasses:
    GlcdDriver

    public abstract class GlcdBaseDriver
    extends java.lang.Object
    implements GlcdDisplayDriver
    Base class for the graphics display driver
    Author:
    Rafael Ibasco
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void begin()
      Simplified setup procedure of the display for the Arduino enviornment.
      protected void checkConfig​(GlcdConfig config)
      Validates the provided configuration instance
      void clear()
      Clears all pixel on the display and the buffer.
      void clearBuffer()
      Clears all pixel in the memory frame buffer.
      void clearDisplay()
      Clears all pixel on the connected display.
      protected GlcdDriverEventHandler createDefaultEventHandler()  
      void drawBox​(int width, int height)
      Draw a box (filled frame), starting at x/y position (upper left edge).
      void drawBox​(int x, int y, int width, int height)
      Draw a box (filled frame), starting at x/y position (upper left edge).
      void drawCircle​(int radius, int options)
      Draw a circle with radus rad at position (x0, y0).
      void drawCircle​(int x, int y, int radius, int options)
      Draw a circle with radus rad at position (x0, y0).
      void drawDisc​(int radius, int options)
      Draw a filled circle with radus rad at position (x0, y0).
      void drawDisc​(int x, int y, int radius, int options)
      Draw a filled circle with radus rad at position (x0, y0).
      void drawEllipse​(int rx, int ry, int options)
      Draw ellipse with radus rx and 'ry' at position (x0, y0).
      void drawEllipse​(int x, int y, int rx, int ry, int options)
      Draw ellipse with radus rx and 'ry' at position (x0, y0).
      void drawFilledEllipse​(int rx, int ry, int options)
      Draw a filled ellipse with radus rx and 'ry' at position (x0, y0).
      void drawFilledEllipse​(int x, int y, int rx, int ry, int options)
      Draw a filled ellipse with radus rx and 'ry' at position (x0, y0).
      void drawFrame​(int width, int height)
      Draw a frame (empty box), starting at x/y position (upper left edge).
      void drawFrame​(int x, int y, int width, int height)
      Draw a frame (empty box), starting at x/y position (upper left edge).
      void drawGlyph​(int x, int y, short encoding)
      Draw a single character.
      void drawGlyph​(short encoding)
      Draw a single character.
      void drawHLine​(int width)
      Draw a horizontal line, starting at x/y position (left edge).
      void drawHLine​(int x, int y, int width)
      Draw a horizontal line, starting at x/y position (left edge).
      void drawLine​(int x1, int y1)
      Draw a line between two points.
      void drawLine​(int x, int y, int x1, int y1)
      Draw a line between two points.
      void drawPixel()
      Draw a pixel at the specified x/y position.
      void drawPixel​(int x, int y)
      Draw a pixel at the specified x/y position.
      void drawPixels​(int x, int y, int width, int height, byte[] buffer)
      Draws pixels on the screen based on the provided pixel buffer.
      void drawPixelsBgra​(int x, int y, int width, int height, byte[] buffer)
      Draws pixels on the screen based on the provided pixel buffer.
      void drawRoundedBox​(int width, int height, int radius)
      Draw a box with round edges, starting at x/y position (upper left edge).
      void drawRoundedBox​(int x, int y, int width, int height, int radius)
      Draw a box with round edges, starting at x/y position (upper left edge).
      void drawRoundedFrame​(int width, int height, int radius)
      Draw a frame with round edges, starting at x/y position (upper left edge).
      void drawRoundedFrame​(int x, int y, int width, int height, int radius)
      Draw a frame with round edges, starting at x/y position (upper left edge).
      void drawString​(int x, int y, java.lang.String value)
      Draw a string.
      void drawString​(java.lang.String value)
      Draw a string.
      void drawTriangle​(int x1, int y1, int x2, int y2)
      Draw a triangle (filled polygon).
      void drawTriangle​(int x0, int y0, int x1, int y1, int x2, int y2)
      Draw a triangle (filled polygon).
      int drawUTF8​(int x, int y, java.lang.String value)
      Draw a string which is encoded as UTF-8.
      int drawUTF8​(java.lang.String value)
      Draw a string which is encoded as UTF-8.
      void drawVLine​(int length)
      Draw a vertical line, starting at x/y position (upper end).
      void drawVLine​(int x, int y, int length)
      Draw a vertical line, starting at x/y position (upper end).
      void drawXBM​(int width, int height, byte[] data)
      Draw a XBM Bitmap.
      void drawXBM​(int x, int y, int width, int height, byte[] data)
      Draw a XBM Bitmap.
      void drawXBM​(int x, int y, int width, int height, java.io.File file)
      Draw a XBM Bitmap.
      void drawXBM​(int width, int height, java.io.File file)
      Draw a XBM Bitmap.
      boolean equals​(java.lang.Object o)  
      java.lang.String exportToPBM()
      Exports a PBM formatted ASCII string representation of the current display buffer
      java.lang.String exportToPBM2()
      Exports a PBM formatted ASCII string representation of the current display buffer
      java.lang.String exportToXBM()
      Exports an XBM formatted ASCII string representati0on of the current display buffer
      java.lang.String exportToXBM2()
      Exports an XBM formatted ASCII string representati0on of the current display buffer.
      void firstPage()
      This command is part of the (picture) loop which renders the content of the display.
      int getAscent()
      Returns the reference height of the glyphs above the baseline (ascent).
      byte[] getBuffer()
      Return the contents of the display buffer.
      int getBufferCurrTileRow()
      Return the intended position for the content of the pixel buffer (page) on the target display.
      int getBufferTileHeight()
      Return the height of the page buffer in tiles.
      int getBufferTileWidth()
      Return the width of the page buffer in tiles (One tile has a width of 8 pixel).
      GlcdConfig getConfig()
      Get the underlying GlcdConfig used by this instance
      int getDescent()
      Returns the reference height of the glyphs below the baseline (descent).
      <T extends GlcdDriverEventHandler>
      T
      getDriverEventHandler()  
      int getHeight()  
      long getId()  
      int getMaxCharHeight()
      Each glyph is stored as a bitmap.
      int getMaxCharWidth()
      Each glyph is stored as a bitmap.
      java.nio.ByteBuffer getNativeBgraBuffer()
      Similar to GlcdDisplayDriver.getNativeBuffer() but this returns a buffer in bgra pixel format.
      java.nio.ByteBuffer getNativeBuffer()
      Returns the pixel buffer that is shared with the native library
      int getStrWidth​(java.lang.String text)
      Return the pixel width of string.
      int getUTF8Width​(java.lang.String text)
      Return the pixel width of an UTF-8 encoded string.
      int getWidth()  
      int hashCode()  
      void initDisplay()
      Reset and configure the display.
      protected void initialize()
      Driver initialization procedures.
      protected boolean isInitialized()  
      int nextPage()
      This command is part of the (picture) loop which renders the content of the display.
      protected void onByteEvent​(U8g2ByteEvent event)
      Called during instruction/data events
      protected void onGpioEvent​(U8g2GpioEvent event)
      Called when a gpio event has occured
      void sendBuffer()
      Send the content of the memory frame buffer to the display.
      void sendCommand​(java.lang.String format, byte... args)
      Send special commands to the display controller.
      int setAutoPageClear​(boolean clear)
      Enables (mode=1) or disables (mode=0) automatic clearing of the pixel buffer by the GlcdDisplayDriver.firstPage() and GlcdDisplayDriver.nextPage() procedures.
      void setBitmapMode​(GlcdBitmapMode mode)
      Defines, whether the bitmap functions will write the background color to solid or transparent.
      void setBufferCurrTileRow​(int row)
      Set the position of the pixel buffer for the sendBuffer command.
      void setClipWindow​(int x0, int y0, int x1, int y1)
      Restricts all graphics output to the specified range.
      void setContrast​(int value)
      Set the contrast or brightness for the display (if supported).
      void setCursor​(int x, int y)  
      void setDisplayRotation​(int rotation)
      Changes the display rotation.
      void setDisplayRotation​(GlcdRotation rotation)
      Changes the display rotation.
      void setDrawColor​(GlcdDrawColor color)
      Defines the bit value (color index) for all drawing functions.
      protected void setDriverEventHandler​(GlcdDriverEventHandler driverEventHandler)  
      void setFlipMode​(boolean enable)
      Some displays support a 180 degree rotation of the internal frame buffer.
      void setFont​(byte[] data)
      Define a u8g2 font for the glyph and string drawing functions.
      void setFont​(GlcdFont font)
      Define a u8g2 font for the glyph and string drawing functions.
      void setFontDirection​(GlcdFontDirection direction)
      The arguments defines the drawing direction of all strings or glyphs.
      void setFontMode​(GlcdFontMode mode)
      Defines, whether the glyph and string drawing functions will write the background color (mode 0/solid, mode = 0) or not (mode 1/transparent, mode = 1).
      void setFontPosBaseline()
      Change the reference position for the glyph and string draw functions.
      void setFontPosBottom()
      Change the reference position for the glyph and string draw functions.
      void setFontPosCenter()
      Change the reference position for the glyph and string draw functions.
      void setFontPosTop()
      Change the reference position for the glyph and string draw functions.
      void setFontRefHeightAll()
      A call to this procedure will define the calculation method for the ascent and descent of the current font.
      void setFontRefHeightExtendedText()
      A call to this procedure will define the calculation method for the ascent and descent of the current font.
      void setFontRefHeightText()
      A call to this procedure will define the calculation method for the ascent and descent of the current font.
      void setMaxClipWindow()
      void setPowerSave​(boolean enable)
      Activates (enable = true) or disables (enable = false) the power save mode of the display.
      void setPrimaryColor​(int color)
      Set the primary color (set bit) for the pixel data on the BGRA buffer.
      void setSecondaryColor​(int color)
      Set the secondary color (unset bit) for the pixel data on the BGRA buffer.
      void updateDisplay()
      Updates all area of the display.
      void updateDisplay​(int x, int y, int width, int height)
      Updates the specified rectangle areaof the display.
      void write​(byte... data)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GlcdBaseDriver

        public GlcdBaseDriver​(GlcdConfig config)
        Create new instance based on the config provided.
        Parameters:
        config - The GlcdConfig associated with this instance
      • GlcdBaseDriver

        protected GlcdBaseDriver​(GlcdConfig config,
                                 boolean virtual)
        Create new instance based on the config provided.
        Parameters:
        config - The GlcdConfig associated with this instance
        virtual - Set to true to enable virtual mode.
      • GlcdBaseDriver

        protected GlcdBaseDriver​(GlcdConfig config,
                                 boolean virtual,
                                 GlcdDriverEventHandler handler,
                                 GlcdDriverAdapter driverAdapter)

        Creates a new instance based on the config provided. If virtual mode is enabled, all generated instructions will be re-routed to the GlcdDriverEventHandler.

        Parameters:
        config - The GlcdConfig associated with this instance
        virtual - Set to true to enable virtual mode. If virtual mode is enabled, all instruction/data events are routed to GlcdDriverEventHandler for further processing.
        handler - The GlcdDriverEventHandler instance that will handle the data and instruction events thrown by the native display driver. If a null value is provided, the U8g2DriverAdapter will be used by default.
    • Method Detail

      • initialize

        protected void initialize()
                           throws GlcdDriverException

        Driver initialization procedures. Sub-classes MUST call this method after call to base constructor. Calling the drawing operations while not initialized will trigger a GlcdDriverException.

        Throws:
        GlcdDriverException - When a driver related exception occurs (e.g. invalid configuration setup)
      • isInitialized

        protected boolean isInitialized()
      • setDriverEventHandler

        protected final void setDriverEventHandler​(GlcdDriverEventHandler driverEventHandler)
      • onByteEvent

        protected void onByteEvent​(U8g2ByteEvent event)
        Called during instruction/data events
        Parameters:
        event - The event details
      • onGpioEvent

        protected void onGpioEvent​(U8g2GpioEvent event)
        Called when a gpio event has occured
        Parameters:
        event - The event details
      • drawBox

        public void drawBox​(int width,
                            int height)
        Description copied from interface: GlcdDisplayDriver

        Draw a box (filled frame), starting at x/y position (upper left edge). The box has width w and height h. Parts of the box can be outside of the display boundaries. This procedure will use the current color (setDrawColor) to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawBox in interface GlcdDisplayDriver
        Parameters:
        width - Width of the box.
        height - Height of the box.
        See Also:
        GlcdDisplayDriver.setDrawColor(GlcdDrawColor)
      • drawBox

        public void drawBox​(int x,
                            int y,
                            int width,
                            int height)
        Description copied from interface: GlcdDisplayDriver

        Draw a box (filled frame), starting at x/y position (upper left edge). The box has width w and height h. Parts of the box can be outside of the display boundaries. This procedure will use the current color (setDrawColor) to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawBox in interface GlcdDisplayDriver
        Parameters:
        x - X-position of upper left edge.
        y - Y-position of upper left edge.
        width - Width of the box.
        height - Height of the box.
      • drawCircle

        public void drawCircle​(int radius,
                               int options)
        Description copied from interface: GlcdDisplayDriver

        Draw a circle with radus rad at position (x0, y0). The diameter of the circle is 2*rad+1. Depending on opt, it is possible to draw only some sections of the circle.

        Possible values for opt are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        These values can be combined with the | operator. This procedure will use the current color (setDrawColor) for drawing.

        Specified by:
        drawCircle in interface GlcdDisplayDriver
        Parameters:
        radius - Defines the size of the circle: Radus = rad
        options - Selects some or all sections of the circle.
        See Also:
        GlcdDisplayDriver.drawCircle(int, int, int, int)
      • drawCircle

        public void drawCircle​(int x,
                               int y,
                               int radius,
                               int options)
        Description copied from interface: GlcdDisplayDriver

        Draw a circle with radus rad at position (x0, y0). The diameter of the circle is 2*rad+1. Depending on opt, it is possible to draw only some sections of the circle.

        Possible values for opt are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        These values can be combined with the | operator. This procedure will use the current color (setDrawColor) for drawing.

        Specified by:
        drawCircle in interface GlcdDisplayDriver
        Parameters:
        x - X-Position of the center of the circle.
        y - Y-Position of the center of the circle.
        radius - Defines the size of the circle: Radus = rad
        options - Selects some or all sections of the circle.
      • drawDisc

        public void drawDisc​(int radius,
                             int options)
        Description copied from interface: GlcdDisplayDriver

        Draw a filled circle with radus rad at position (x0, y0). The diameter of the circle is 2*rad+1. Depending on opt, it is possible to draw only some sections of the disc.

        Possible values for options are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        These values can be combined with the | operator. This procedure will use the current color (GlcdDisplayDriver.setDrawColor(GlcdDrawColor)) for drawing.

        Specified by:
        drawDisc in interface GlcdDisplayDriver
        Parameters:
        radius - Defines the size of the circle: Radus = rad.
        options - Selects some or all sections of the disc.
      • drawDisc

        public void drawDisc​(int x,
                             int y,
                             int radius,
                             int options)
        Description copied from interface: GlcdDisplayDriver

        Draw a filled circle with radus rad at position (x0, y0). The diameter of the circle is 2*rad+1. Depending on opt, it is possible to draw only some sections of the disc.

        Possible values for options are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        These values can be combined with the | operator. This procedure will use the current color (GlcdDisplayDriver.setDrawColor(GlcdDrawColor)) for drawing.

        Specified by:
        drawDisc in interface GlcdDisplayDriver
        Parameters:
        x - X-Position of the center of the disc.
        y - Y-Position of the center of the disc.
        radius - Defines the size of the circle: Radus = rad.
        options - Selects some or all sections of the disc.
      • drawEllipse

        public void drawEllipse​(int rx,
                                int ry,
                                int options)
        Description copied from interface: GlcdDisplayDriver

        Draw ellipse with radus rx and 'ry' at position (x0, y0). rx*ry must be lower than 512 in 8 Bit mode of u8g2.

        Possible values for options are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        The diameter is twice the radius plus one.

        Specified by:
        drawEllipse in interface GlcdDisplayDriver
        Parameters:
        rx - Defines the size of the ellipse.
        ry - Defines the size of the ellipse.
        options - Selects some or all sections of the ellipse.
      • drawEllipse

        public void drawEllipse​(int x,
                                int y,
                                int rx,
                                int ry,
                                int options)
        Description copied from interface: GlcdDisplayDriver

        Draw ellipse with radus rx and 'ry' at position (x0, y0). rx*ry must be lower than 512 in 8 Bit mode of u8g2.

        Possible values for options are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        The diameter is twice the radius plus one.

        Specified by:
        drawEllipse in interface GlcdDisplayDriver
        Parameters:
        x - X-Position of the center of the filled circle.
        y - Y-Position of the center of the filled circle.
        rx - Defines the size of the ellipse.
        ry - Defines the size of the ellipse.
        options - Selects some or all sections of the ellipse.
      • drawFilledEllipse

        public void drawFilledEllipse​(int rx,
                                      int ry,
                                      int options)
        Description copied from interface: GlcdDisplayDriver

        Draw a filled ellipse with radus rx and 'ry' at position (x0, y0). rx*ry must be lower than 512 in 8 Bit mode of u8g2.Depending on opt, it is possible to draw only some sections of the disc.

        Possible values for options are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        These values can be combined with the | operator.

        Specified by:
        drawFilledEllipse in interface GlcdDisplayDriver
        Parameters:
        rx - X-the size of the ellipse.
        ry - Y- the size of the ellipse.
        options - Selects some or all sections of the ellipse.
      • drawFilledEllipse

        public void drawFilledEllipse​(int x,
                                      int y,
                                      int rx,
                                      int ry,
                                      int options)
        Description copied from interface: GlcdDisplayDriver

        Draw a filled ellipse with radus rx and 'ry' at position (x0, y0). rx*ry must be lower than 512 in 8 Bit mode of u8g2.Depending on opt, it is possible to draw only some sections of the disc.

        Possible values for options are:

        • U8G2_DRAW_UPPER_RIGHT
        • U8G2_DRAW_UPPER_LEFT
        • U8G2_DRAW_LOWER_LEFT
        • U8G2_DRAW_LOWER_RIGHT
        • U8G2_DRAW_ALL

        These values can be combined with the | operator.

        Specified by:
        drawFilledEllipse in interface GlcdDisplayDriver
        Parameters:
        x - X-Position of the center of the filled circle.
        y - Y-Position of the center of the filled circle.
        rx - X-the size of the ellipse.
        ry - Y- the size of the ellipse.
        options - Selects some or all sections of the ellipse.
      • drawFrame

        public void drawFrame​(int width,
                              int height)
        Description copied from interface: GlcdDisplayDriver

        Draw a frame (empty box), starting at x/y position (upper left edge). The box has width w and height h. Parts of the frame can be outside of the display boundaries. This procedure will use the current color (setDrawColor) to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawFrame in interface GlcdDisplayDriver
        Parameters:
        width - Width of the frame.
        height - Height of the frame.
      • drawFrame

        public void drawFrame​(int x,
                              int y,
                              int width,
                              int height)
        Description copied from interface: GlcdDisplayDriver

        Draw a frame (empty box), starting at x/y position (upper left edge). The box has width w and height h. Parts of the frame can be outside of the display boundaries. This procedure will use the current color (setDrawColor) to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawFrame in interface GlcdDisplayDriver
        Parameters:
        x - X-position of upper left edge.
        y - Y-position of upper left edge.
        width - Width of the frame.
        height - Height of the frame.
      • drawGlyph

        public void drawGlyph​(short encoding)
        Description copied from interface: GlcdDisplayDriver

        Draw a single character. The character is placed at the specified pixel posion x and y. U8g2 supports the lower 16 bit of the unicode character range (plane 0/Basic Multilingual Plane): The encoding can be any value from 0 to 65535. The glyph can be drawn only, if the encoding exists in the active font.

        Specified by:
        drawGlyph in interface GlcdDisplayDriver
        Parameters:
        encoding - Unicode value of the character.
        See Also:
        GlcdDisplayDriver.setFont(byte[])
      • drawGlyph

        public void drawGlyph​(int x,
                              int y,
                              short encoding)
        Description copied from interface: GlcdDisplayDriver

        Draw a single character. The character is placed at the specified pixel posion x and y. U8g2 supports the lower 16 bit of the unicode character range (plane 0/Basic Multilingual Plane): The encoding can be any value from 0 to 65535. The glyph can be drawn only, if the encoding exists in the active font.

        Specified by:
        drawGlyph in interface GlcdDisplayDriver
        Parameters:
        x - X-Position of the character on the display.
        y - Y-Position of the character on the display.
        encoding - Unicode value of the character.
        See Also:
        GlcdDisplayDriver.setFont(byte[])
      • drawHLine

        public void drawHLine​(int width)
        Description copied from interface: GlcdDisplayDriver

        Draw a horizontal line, starting at x/y position (left edge). The width (length) of the line is w pixel. Parts of the line can be outside of the display boundaries. This procedure uses the current color index to draw the line. Color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawHLine in interface GlcdDisplayDriver
        Parameters:
        width - Length of the horizontal line
      • drawHLine

        public void drawHLine​(int x,
                              int y,
                              int width)
        Description copied from interface: GlcdDisplayDriver

        Draw a horizontal line, starting at x/y position (left edge). The width (length) of the line is w pixel. Parts of the line can be outside of the display boundaries. This procedure uses the current color index to draw the line. Color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawHLine in interface GlcdDisplayDriver
        Parameters:
        x - X-Position
        y - Y-Position
        width - Length of the horizontal line
      • drawVLine

        public void drawVLine​(int length)
        Description copied from interface: GlcdDisplayDriver

        Draw a vertical line, starting at x/y position (upper end). The height (length) of the line is h pixel. Parts of the line can be outside of the display boundaries. This procedure uses the current color index to draw the line. Color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawVLine in interface GlcdDisplayDriver
        Parameters:
        length - Length of the vertical line.
      • drawVLine

        public void drawVLine​(int x,
                              int y,
                              int length)
        Description copied from interface: GlcdDisplayDriver

        Draw a vertical line, starting at x/y position (upper end). The height (length) of the line is h pixel. Parts of the line can be outside of the display boundaries. This procedure uses the current color index to draw the line. Color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawVLine in interface GlcdDisplayDriver
        Parameters:
        x - X-position.
        y - Y-position.
        length - Length of the vertical line.
      • drawLine

        public void drawLine​(int x1,
                             int y1)
        Description copied from interface: GlcdDisplayDriver
        Draw a line between two points. This procedure will use the current color (setDrawColor).
        Specified by:
        drawLine in interface GlcdDisplayDriver
        Parameters:
        x1 - X-position of the second point.
        y1 - Y-position of the second point.
      • drawLine

        public void drawLine​(int x,
                             int y,
                             int x1,
                             int y1)
        Description copied from interface: GlcdDisplayDriver
        Draw a line between two points. This procedure will use the current color (setDrawColor).
        Specified by:
        drawLine in interface GlcdDisplayDriver
        Parameters:
        x - X-position of the first point.
        y - Y-position of the first point.
        x1 - X-position of the second point.
        y1 - Y-position of the second point.
      • drawPixel

        public void drawPixel()
        Description copied from interface: GlcdDisplayDriver

        Draw a pixel at the specified x/y position. Position (0,0) is at the upper left corner of the display. The position may be outside the display boundaries.This procedure uses the current color index to draw the pixel. The color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawPixel in interface GlcdDisplayDriver
      • drawPixel

        public void drawPixel​(int x,
                              int y)
        Description copied from interface: GlcdDisplayDriver

        Draw a pixel at the specified x/y position. Position (0,0) is at the upper left corner of the display. The position may be outside the display boundaries.This procedure uses the current color index to draw the pixel. The color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawPixel in interface GlcdDisplayDriver
        Parameters:
        x - X-position.
        y - Y-position.
      • drawRoundedBox

        public void drawRoundedBox​(int width,
                                   int height,
                                   int radius)
        Description copied from interface: GlcdDisplayDriver

        Draw a box with round edges, starting at x/y position (upper left edge). The box/frame has width w and height h. Parts of the box can be outside of the display boundaries. Edges have radius r. It is required that w >= 2*(r+1) and h >= 2*(r+1). This condition is not checked. Behavior is undefined if w or h is smaller than 2*(r+1). This procedure uses the current color index to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawRoundedBox in interface GlcdDisplayDriver
        Parameters:
        width - Width of the box.
        height - Height of the box.
        radius - Radius for the four edges.
      • drawRoundedBox

        public void drawRoundedBox​(int x,
                                   int y,
                                   int width,
                                   int height,
                                   int radius)
        Description copied from interface: GlcdDisplayDriver

        Draw a box with round edges, starting at x/y position (upper left edge). The box/frame has width w and height h. Parts of the box can be outside of the display boundaries. Edges have radius r. It is required that w >= 2*(r+1) and h >= 2*(r+1). This condition is not checked. Behavior is undefined if w or h is smaller than 2*(r+1). This procedure uses the current color index to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawRoundedBox in interface GlcdDisplayDriver
        Parameters:
        x - X-position of upper left edge.
        y - Y-position of upper left edge.
        width - Width of the box.
        height - Height of the box.
        radius - Radius for the four edges.
      • drawRoundedFrame

        public void drawRoundedFrame​(int width,
                                     int height,
                                     int radius)
        Description copied from interface: GlcdDisplayDriver

        Draw a frame with round edges, starting at x/y position (upper left edge). The box/frame has width w and height h. Parts of the box can be outside of the display boundaries. Edges have radius r. It is required that w >= 2*(r+1) and h >= 2*(r+1). This condition is not checked. Behavior is undefined if w or h is smaller than 2*(r+1). This procedure uses the current color index to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawRoundedFrame in interface GlcdDisplayDriver
        Parameters:
        width - Width of the box.
        height - Height of the box.
        radius - Radius for the four edges.
      • drawRoundedFrame

        public void drawRoundedFrame​(int x,
                                     int y,
                                     int width,
                                     int height,
                                     int radius)
        Description copied from interface: GlcdDisplayDriver

        Draw a frame with round edges, starting at x/y position (upper left edge). The box/frame has width w and height h. Parts of the box can be outside of the display boundaries. Edges have radius r. It is required that w >= 2*(r+1) and h >= 2*(r+1). This condition is not checked. Behavior is undefined if w or h is smaller than 2*(r+1). This procedure uses the current color index to draw the box. For a monochrome display, the color index 0 will clear a pixel and the color index 1 will set a pixel.

        Specified by:
        drawRoundedFrame in interface GlcdDisplayDriver
        Parameters:
        x - X-position of upper left edge.
        y - Y-position of upper left edge.
        width - Width of the box.
        height - Height of the box.
        radius - Radius for the four edges.
      • drawString

        public void drawString​(java.lang.String value)
        Description copied from interface: GlcdDisplayDriver

        Draw a string. The first character is placed at position x andy. Use setFont to assign a font before drawing a string on the display. To draw a character with encoding 127 to 255, use the C/C++/Arduino escape sequence "\xab" (hex value ab) or "\xyz" (octal value xyz). This function can not draw any glyph with encoding greater or equal to 256. Use drawUTF8 or drawGlyph to access glyphs with encoding greater or equal to 256.

        Specified by:
        drawString in interface GlcdDisplayDriver
        Parameters:
        value - The text to draw on the display
      • drawString

        public void drawString​(int x,
                               int y,
                               java.lang.String value)
        Description copied from interface: GlcdDisplayDriver

        Draw a string. The first character is placed at position x andy. Use setFont to assign a font before drawing a string on the display. To draw a character with encoding 127 to 255, use the C/C++/Arduino escape sequence "\xab" (hex value ab) or "\xyz" (octal value xyz). This function can not draw any glyph with encoding greater or equal to 256. Use drawUTF8 or drawGlyph to access glyphs with encoding greater or equal to 256.

        Specified by:
        drawString in interface GlcdDisplayDriver
        Parameters:
        x - X-Position of the first character on the display.
        y - Y-Position of the first character on the display.
        value - The text to draw on the display
      • drawTriangle

        public void drawTriangle​(int x1,
                                 int y1,
                                 int x2,
                                 int y2)
        Description copied from interface: GlcdDisplayDriver

        Draw a triangle (filled polygon). Arguments are 16 bit and the polygon is clipped to the size of the display. Multiple polygons are drawn so that they exactly match without overlap:The left side of a polygon is drawn, the right side is not draw. The upper side is only draw if it is flat.

        Specified by:
        drawTriangle in interface GlcdDisplayDriver
        Parameters:
        x1 - X-position point 1.
        y1 - Y-position point 1.
        x2 - X-position point 2.
        y2 - Y-position point 2.
      • drawTriangle

        public void drawTriangle​(int x0,
                                 int y0,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2)
        Description copied from interface: GlcdDisplayDriver

        Draw a triangle (filled polygon). Arguments are 16 bit and the polygon is clipped to the size of the display. Multiple polygons are drawn so that they exactly match without overlap:The left side of a polygon is drawn, the right side is not draw. The upper side is only draw if it is flat.

        Specified by:
        drawTriangle in interface GlcdDisplayDriver
        Parameters:
        x0 - X-position point 0.
        y0 - Y-position point 0.
        x1 - X-position point 1.
        y1 - Y-position point 1.
        x2 - X-position point 2.
        y2 - Y-position point 2.
      • drawXBM

        public void drawXBM​(int width,
                            int height,
                            java.io.File file)
        Description copied from interface: GlcdDisplayDriver

        Draw a XBM Bitmap. Position (x,y) is the upper left corner of the bitmap. XBM contains monochrome, 1-bit bitmaps.

        The current color index is used for drawing (see setColorIndex) pixel values 1. By default, drawXBM will draw solid bitmaps, use GlcdDisplayDriver.setBitmapMode(GlcdBitmapMode) to switch between modes (solid or transparent). The XBMP version of this procedure expects the bitmap to be in PROGMEM area (AVR only). Many tools (including GIMP) can save a bitmap as XBM. A nice step by step instruction is here (external link). The result will look like this:

        Specified by:
        drawXBM in interface GlcdDisplayDriver
        Parameters:
        width - Width of the bitmap.
        height - Height of the bitmap.
        file - File containing bitmap data
        See Also:
        GlcdDisplayDriver.setBitmapMode(com.ibasco.ucgdisplay.drivers.glcd.enums.GlcdBitmapMode)
      • drawXBM

        public void drawXBM​(int x,
                            int y,
                            int width,
                            int height,
                            java.io.File file)
        Description copied from interface: GlcdDisplayDriver

        Draw a XBM Bitmap. Position (x,y) is the upper left corner of the bitmap. XBM contains monochrome, 1-bit bitmaps.

        The current color index is used for drawing (see setColorIndex) pixel values 1. By default, drawXBM will draw solid bitmaps, use GlcdDisplayDriver.setBitmapMode(GlcdBitmapMode) to switch between modes (solid or transparent). The XBMP version of this procedure expects the bitmap to be in PROGMEM area (AVR only). Many tools (including GIMP) can save a bitmap as XBM. A nice step by step instruction is here (external link). The result will look like this:

        Specified by:
        drawXBM in interface GlcdDisplayDriver
        Parameters:
        x - X-position.
        y - Y-position.
        width - Width of the bitmap.
        height - Height of the bitmap.
        file - File containing bitmap data
        See Also:
        GlcdDisplayDriver.setBitmapMode(com.ibasco.ucgdisplay.drivers.glcd.enums.GlcdBitmapMode)
      • drawXBM

        public void drawXBM​(int width,
                            int height,
                            byte[] data)
        Description copied from interface: GlcdDisplayDriver

        Draw a XBM Bitmap. Position (x,y) is the upper left corner of the bitmap. XBM contains monochrome, 1-bit bitmaps.

        The current color index is used for drawing (see setColorIndex) pixel values 1. By default, drawXBM will draw solid bitmaps, use GlcdDisplayDriver.setBitmapMode(GlcdBitmapMode) to switch between modes (solid or transparent). The XBMP version of this procedure expects the bitmap to be in PROGMEM area (AVR only). Many tools (including GIMP) can save a bitmap as XBM. A nice step by step instruction is here (external link). The result will look like this:

        Specified by:
        drawXBM in interface GlcdDisplayDriver
        Parameters:
        width - Width of the bitmap.
        height - Height of the bitmap.
        data - Byte array containing bitmap data
        See Also:
        GlcdDisplayDriver.setBitmapMode(com.ibasco.ucgdisplay.drivers.glcd.enums.GlcdBitmapMode)
      • drawXBM

        public void drawXBM​(int x,
                            int y,
                            int width,
                            int height,
                            byte[] data)
        Description copied from interface: GlcdDisplayDriver

        Draw a XBM Bitmap. Position (x,y) is the upper left corner of the bitmap. XBM contains monochrome, 1-bit bitmaps.

        The current color index is used for drawing (see setColorIndex) pixel values 1. By default, drawXBM will draw solid bitmaps, use GlcdDisplayDriver.setBitmapMode(GlcdBitmapMode) to switch between modes (solid or transparent). The XBMP version of this procedure expects the bitmap to be in PROGMEM area (AVR only). Many tools (including GIMP) can save a bitmap as XBM. A nice step by step instruction is here (external link). The result will look like this:

        Specified by:
        drawXBM in interface GlcdDisplayDriver
        Parameters:
        x - X-position.
        y - Y-position.
        width - Width of the bitmap.
        height - Height of the bitmap.
        data - Bitmap data
        See Also:
        GlcdDisplayDriver.setBitmapMode(com.ibasco.ucgdisplay.drivers.glcd.enums.GlcdBitmapMode)
      • drawUTF8

        public int drawUTF8​(java.lang.String value)
        Description copied from interface: GlcdDisplayDriver

        Draw a string which is encoded as UTF-8. There are two preconditions for the use of this function: (A) the C/C++/Arduino compiler must support UTF-8 encoding (this is default for the gnu compiler, which is also used for most Arduino boards) and (B) the code editor/IDE must support and store the C/C++/Arduino code as UTF-8 (true for the Arduino IDE). If these conditions are met, you can use the character with code value greater than 127 directly in the string (of course the character must exist in the font file, see also setFont). Advantage: No escape codes are required and the source code is more readable. The glyph can be copied and paste into the editor from a "char set" tool. Disadvantage: The code is less portable and the strlen function will not return the number of visible characters.

        Specified by:
        drawUTF8 in interface GlcdDisplayDriver
        Parameters:
        value - UTF-8 encoded text
        Returns:
        Width of the string.
        See Also:
        GlcdDisplayDriver.getUTF8Width(String), GlcdDisplayDriver.setFont(byte[]), GlcdDisplayDriver.drawString(int, int, String)
      • drawUTF8

        public int drawUTF8​(int x,
                            int y,
                            java.lang.String value)
        Description copied from interface: GlcdDisplayDriver

        Draw a string which is encoded as UTF-8. There are two preconditions for the use of this function: (A) the C/C++/Arduino compiler must support UTF-8 encoding (this is default for the gnu compiler, which is also used for most Arduino boards) and (B) the code editor/IDE must support and store the C/C++/Arduino code as UTF-8 (true for the Arduino IDE). If these conditions are met, you can use the character with code value greater than 127 directly in the string (of course the character must exist in the font file, see also setFont). Advantage: No escape codes are required and the source code is more readable. The glyph can be copied and paste into the editor from a "char set" tool. Disadvantage: The code is less portable and the strlen function will not return the number of visible characters.

        Specified by:
        drawUTF8 in interface GlcdDisplayDriver
        Parameters:
        x - X-Position of the first character on the display.
        y - Y-Position of the first character on the display.
        value - UTF-8 encoded text
        Returns:
        Width of the string.
        See Also:
        GlcdDisplayDriver.getUTF8Width(String), GlcdDisplayDriver.setFont(byte[]), GlcdDisplayDriver.drawString(int, int, String)
      • getUTF8Width

        public int getUTF8Width​(java.lang.String text)
        Description copied from interface: GlcdDisplayDriver

        Return the pixel width of an UTF-8 encoded string.

        Specified by:
        getUTF8Width in interface GlcdDisplayDriver
        Parameters:
        text - UTF-8 encoded text.
        Returns:
        Width of the string if drawn with the current font
      • setFont

        public void setFont​(byte[] data)
        Description copied from interface: GlcdDisplayDriver

        Define a u8g2 font for the glyph and string drawing functions. Note: u8x8 font can NOT be used. Available fonts are listed here here. The last two characters of the font name define the type and character set for the font:

        Specified by:
        setFont in interface GlcdDisplayDriver
        Parameters:
        data - Font data
        See Also:
        List of available fonts
      • setFont

        public void setFont​(GlcdFont font)
        Description copied from interface: GlcdDisplayDriver

        Define a u8g2 font for the glyph and string drawing functions. Note: u8x8 font can NOT be used. Available fonts are listed here here. The last two characters of the font name define the type and character set for the font:

        Specified by:
        setFont in interface GlcdDisplayDriver
        Parameters:
        font - A GlcdFont instance
        See Also:
        List of available fonts
      • setFontMode

        public void setFontMode​(GlcdFontMode mode)
        Description copied from interface: GlcdDisplayDriver

        Defines, whether the glyph and string drawing functions will write the background color (mode 0/solid, mode = 0) or not (mode 1/transparent, mode = 1). Default mode is 1 (background color of the characters is not changed).

        Note: Always choose a suitable font, depending on the font mode:

        Font Name Font Type Suitable for...
        FONT_xxx_TX Transparent gylphs with variable width mode = 1, XOR Mode
        FONT_xxx_MX Monospace/fixed width glyphs mode = 0
        FONT_xxx_HX Glyphs with variable width and common height mode = 0
        FONT_xxx_8X Monospace/fixed width glyphs in a 8x8 box mode = 0
        Specified by:
        setFontMode in interface GlcdDisplayDriver
        Parameters:
        mode - Enable (1) or disable (0) transparent mode.
        See Also:
        GlcdDisplayDriver.setDrawColor(com.ibasco.ucgdisplay.drivers.glcd.enums.GlcdDrawColor), GlcdDisplayDriver.setFont(byte[])
      • setFontPosBaseline

        public void setFontPosBaseline()
        Description copied from interface: GlcdDisplayDriver

        Change the reference position for the glyph and string draw functions. By default the reference position is "Baseline".

        Specified by:
        setFontPosBaseline in interface GlcdDisplayDriver
      • setFontPosBottom

        public void setFontPosBottom()
        Description copied from interface: GlcdDisplayDriver

        Change the reference position for the glyph and string draw functions. By default the reference position is "Baseline".

        Specified by:
        setFontPosBottom in interface GlcdDisplayDriver
      • setFontPosTop

        public void setFontPosTop()
        Description copied from interface: GlcdDisplayDriver

        Change the reference position for the glyph and string draw functions. By default the reference position is "Baseline".

        Specified by:
        setFontPosTop in interface GlcdDisplayDriver
      • setFontPosCenter

        public void setFontPosCenter()
        Description copied from interface: GlcdDisplayDriver

        Change the reference position for the glyph and string draw functions. By default the reference position is "Baseline".

        Specified by:
        setFontPosCenter in interface GlcdDisplayDriver
      • setFlipMode

        public void setFlipMode​(boolean enable)
        Description copied from interface: GlcdDisplayDriver

        Some displays support a 180 degree rotation of the internal frame buffer. This hardware feature can be controlled with this procedure. Important: Redraw the complete display after changing the flip mode. Best is to clear the display first, then change the flip mode and finally redraw the content. Results will be undefined for any existing content on the screen.

        Specified by:
        setFlipMode in interface GlcdDisplayDriver
        Parameters:
        enable - Enable (true) or disable (false) 180 degree rotation of the display content
      • setPowerSave

        public void setPowerSave​(boolean enable)
        Description copied from interface: GlcdDisplayDriver

        Activates (enable = true) or disables (enable = false) the power save mode of the display. With activated power save mode, nothing will be visible on the display. The content of the RAM of the display is not changed. This procedure is also called from begin.

        Specified by:
        setPowerSave in interface GlcdDisplayDriver
        Parameters:
        enable - Enable (true) or disable (false) power save mode for the display.
        See Also:
        GlcdDisplayDriver.begin()
      • setDrawColor

        public void setDrawColor​(GlcdDrawColor color)
        Description copied from interface: GlcdDisplayDriver

        Defines the bit value (color index) for all drawing functions. All drawing function will change the display memory to this bit value. Default value is 1. For example the GlcdDisplayDriver.drawBox(int, int, int, int) procedure will set all pixels for the defined area to the bit value, provided here. The color value 2 will activate the XOR mode. Exceptions:

        Both functions will always set the buffer to the pixel value 0. The color argument of setDrawColor is ignored.


        Note: Not all graphics procedures will support XOR mode. Especially XOR mode is not supported by drawCircle, drawDisc, drawEllipse and drawFilledEllipse.


        Exceptions:

        • GlcdDisplayDriver.clear(), GlcdDisplayDriver.clearBuffer(): Both functions will always set the buffer to the pixel value 0. The color argument of setDrawColor is ignored.
        • drawGlyph: All font drawing procedures will use this color argument as foreground color. In none-transparent (solid) mode (setFontMode) the complement of the color value will be the background color and is set to 0 for color value 2 (However, suggestion is not to use solid and XOR mode together):
        Font Mode Draw Color Glyph Foreground Color Glyph Background Color
        0: solid 0 0 1
        0: solid 1 1 0
        0: solid 2 XOR 0
        1: transparent 0 0 -
        1: transparent 1 1 -
        1: transparent 2 XOR -
        Specified by:
        setDrawColor in interface GlcdDisplayDriver
        Parameters:
        color - The GlcdDrawColor value
        See Also:
        GlcdDisplayDriver.drawBox(int, int, int, int), GlcdDisplayDriver.drawGlyph(int, int, short), GlcdDisplayDriver.setFontMode(GlcdFontMode)
      • initDisplay

        public void initDisplay()
        Description copied from interface: GlcdDisplayDriver

        Reset and configure the display. This procedure must be called before any other procedures draw something on the display. This procedure leaves the display in a power save mode. In order to see something on the screen, disable power save mode first (setPowerSave). This procedure is called by the begin procedure. Either begin or initDisplay must be called initially.

        Specified by:
        initDisplay in interface GlcdDisplayDriver
      • firstPage

        public void firstPage()
        Description copied from interface: GlcdDisplayDriver

        This command is part of the (picture) loop which renders the content of the display. This command must be used together with nextPage. There are some restrictions: Do not change the content when executing this loop. Always redraw everything. It is not possible to redraw only parts of the content. The advantage is lesser RAM consumption compared to a full frame buffer in RAM, see sendBuffer.

        Specified by:
        firstPage in interface GlcdDisplayDriver
        See Also:
        GlcdDisplayDriver.nextPage()
      • nextPage

        public int nextPage()
        Description copied from interface: GlcdDisplayDriver

        This command is part of the (picture) loop which renders the content of the display. This command must be used together with firstPage. There are some restrictions: Do not change the content when executing this loop. Always redraw everything. It is not possible to redraw only parts oft the content. The advantage is lesser RAM consumption compared to a full frame buffer in RAM, see sendBuffer. This procedure will send a refresh message (refreshDisplay) to an e-Paper/e-Ink device after completion of the loop (just before returning 0).

        Specified by:
        nextPage in interface GlcdDisplayDriver
        Returns:
        0, once the loop is completed (all data transfered to the display).
        See Also:
        GlcdDisplayDriver.firstPage()
      • sendBuffer

        public void sendBuffer()
        Description copied from interface: GlcdDisplayDriver

        Send the content of the memory frame buffer to the display. Use GlcdDisplayDriver.clearBuffer() to clear the buffer and the draw functions to draw something into the frame buffer. This procedure is useful only with a full frame buffer in the RAM of the microcontroller (Constructor with buffer option "f", see here). This procedure will also send a refresh message (refreshDisplay) to an e-Paper/e-Ink device.

        Specified by:
        sendBuffer in interface GlcdDisplayDriver
        See Also:
        GlcdDisplayDriver.clearBuffer()
      • clearBuffer

        public void clearBuffer()
        Description copied from interface: GlcdDisplayDriver

        Clears all pixel in the memory frame buffer. Use sendBuffer to transfer the cleared frame buffer to the display. In most cases, this procedure is useful only with a full frame buffer in the RAM of the microcontroller (Constructor with buffer option "f", see here). This procedure will also send a refresh message (refreshDisplay) to an e-Paper/e-Ink device.

        Specified by:
        clearBuffer in interface GlcdDisplayDriver
        See Also:
        GlcdDisplayDriver.sendBuffer()
      • getHeight

        public int getHeight()
        Specified by:
        getHeight in interface com.ibasco.ucgdisplay.common.drivers.DisplayDriver
      • getWidth

        public int getWidth()
        Specified by:
        getWidth in interface com.ibasco.ucgdisplay.common.drivers.DisplayDriver
      • setCursor

        public void setCursor​(int x,
                              int y)
        Specified by:
        setCursor in interface com.ibasco.ucgdisplay.common.drivers.DisplayDriver
      • setAutoPageClear

        public int setAutoPageClear​(boolean clear)
        Description copied from interface: GlcdDisplayDriver

        Enables (mode=1) or disables (mode=0) automatic clearing of the pixel buffer by the GlcdDisplayDriver.firstPage() and GlcdDisplayDriver.nextPage() procedures. By default this is enabled and in most situation it is not required to disable this. If disabled, the user is responsible to set ALL pixel of the current pixel buffer to some suitable state. The buffer can be erased manually with the clearBuffer procedure. One application for using this function are situation where the background is rendered manually through a direct manipulation of the pixel buffer (see DirectAccess.ino example).

        Specified by:
        setAutoPageClear in interface GlcdDisplayDriver
        Parameters:
        clear - Set to false to turn off automatic clearing of the internal pixel buffer. Default value is true.
        Returns:
        The width of the buffer in tiles.
        See Also:
        GlcdDisplayDriver.getBuffer()
      • setContrast

        public void setContrast​(int value)
        Description copied from interface: GlcdDisplayDriver

        Set the contrast or brightness for the display (if supported). Range for 'value': 0 (no contrast) to 255 (maximum contrast or brightness).

        Specified by:
        setContrast in interface GlcdDisplayDriver
        Parameters:
        value - Contrast or brightness from 0 to 255.
      • setDisplayRotation

        public void setDisplayRotation​(int rotation)
        Description copied from interface: GlcdDisplayDriver

        Changes the display rotation. Usually the rotation is defined as part of the constructor. The argment can be one of the following values:

        Constant Description
        ROTATION_R0 No rotation, landscape
        ROTATION_R1 90 degree clockwise rotation
        ROTATION_R2 180 degree clockwise rotation
        ROTATION_R3 270 degree clockwise rotation
        ROTATION_MIRROR No rotation, landscape, display content is mirrored
        Specified by:
        setDisplayRotation in interface GlcdDisplayDriver
        Parameters:
        rotation - Display rotation argument.
      • getNativeBuffer

        public java.nio.ByteBuffer getNativeBuffer()
        Description copied from interface: GlcdDisplayDriver
        Returns the pixel buffer that is shared with the native library
        Specified by:
        getNativeBuffer in interface GlcdDisplayDriver
        Returns:
        A direct ByteBuffer
      • setClipWindow

        public void setClipWindow​(int x0,
                                  int y0,
                                  int x1,
                                  int y1)
        Description copied from interface: GlcdDisplayDriver

        Restricts all graphics output to the specified range. The range is defined from x0 (included) to x1 (excluded) and y0 (included) to y1 (excluded). Use setMaxClipWindow to restore writing to the complete window.

        Specified by:
        setClipWindow in interface GlcdDisplayDriver
        Parameters:
        x0 - Left edge of the visible area.
        y0 - Upper edge of the visible area.
        x1 - Right edge +1 of the visible area.
        y1 - Lower edge +1 of the visible area.
        See Also:
        GlcdDisplayDriver.setMaxClipWindow()
      • updateDisplay

        public void updateDisplay​(int x,
                                  int y,
                                  int width,
                                  int height)
        Description copied from interface: GlcdDisplayDriver

        Updates the specified rectangle areaof the display. This is almost identical to GlcdDisplayDriver.sendBuffer(). The area has to be specified in tiles. One tile is a 8x8 pixel area. To get the pixel value, multiply the tile value with 8 (for ROTATION_R0).

        The tile coordinates are independent from the applied rotation in the U8g2 constructor but have the same orientation as ROTATION_R0. For other rotations the calculation between pixel value tile position is more complicated. The three member functions GlcdDisplayDriver.sendBuffer(), GlcdDisplayDriver.updateDisplay() and GlcdDisplayDriver.updateDisplay(int, int, int, int) are designed for the full buffer mode (constructor with _F_ in the name). However GlcdDisplayDriver.sendBuffer() and GlcdDisplayDriver.updateDisplay() can be used in page mode also. If updateDisplay is used together with ePaper displays, ensure that a proper refresh sequence is send to the display.

        Differences between sendBuffer, updateDisplay and updateDisplayArea

        Behavior/Feature sendBuffer updateDisplay updateDisplayArea
        Sends a refreshDisplay message yes no no
        Works in full buffer mode yes yes yes
        Works in page buffer mode yes yes no
        Specified by:
        updateDisplay in interface GlcdDisplayDriver
        Parameters:
        x - The starting x-coordinate of the rectangular region
        y - The starting y-coordinate of the rectangular region
        width - The width of the rectangular region
        height - The height of the rectangular region
      • exportToXBM

        public java.lang.String exportToXBM()
        Description copied from interface: GlcdDisplayDriver
        Exports an XBM formatted ASCII string representati0on of the current display buffer
        Specified by:
        exportToXBM in interface GlcdDisplayDriver
        Returns:
        The XBM formatted ASCII representation of the display buffer
      • exportToPBM

        public java.lang.String exportToPBM()
        Description copied from interface: GlcdDisplayDriver
        Exports a PBM formatted ASCII string representation of the current display buffer
        Specified by:
        exportToPBM in interface GlcdDisplayDriver
        Returns:
        The PBM formatted ASCII representation of the display buffer
      • exportToXBM2

        public java.lang.String exportToXBM2()
        Description copied from interface: GlcdDisplayDriver

        Exports an XBM formatted ASCII string representati0on of the current display buffer.

        Display controllers: SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0xx

        Specified by:
        exportToXBM2 in interface GlcdDisplayDriver
        Returns:
        The XBM formatted ASCII representation of the display buffer
      • exportToPBM2

        public java.lang.String exportToPBM2()
        Description copied from interface: GlcdDisplayDriver

        Exports a PBM formatted ASCII string representation of the current display buffer

        Display controllers: SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0xx

        Specified by:
        exportToPBM2 in interface GlcdDisplayDriver
        Returns:
        The PBM formatted ASCII representation of the display buffer
      • sendCommand

        public void sendCommand​(java.lang.String format,
                                byte... args)
        Description copied from interface: GlcdDisplayDriver

        Send special commands to the display controller. These commands are specified in the datasheet of the display controller. U8g2 just provides an interface (There is no support on the functionality for these commands). The information is transfered as a sequence of bytes. Each byte has a special meaning:

        • Command byte (c): Commands for the controller. Usually this byte will activate or deactivate a feature in the display controller.
        • Argument (a): Some commands require extra information. A command byte then requires a certain number or arguments.
        • Pixel data (d): Instructs the display controller to interpret the byte as pixel data, which has to be written to the display memory. In some cases, pixel data require a special command also.

        Example

        Send multiple commands with arguments: Activate hardware scroll to the left on a SSD1306 display

             sendCommand("caaaaaac", 0x027, 0, 3, 0, 7, 0, 255, 0x2f);
         
        Specified by:
        sendCommand in interface GlcdDisplayDriver
        Parameters:
        format - A sequence (string) of c, a or d
        args - A sequence of bytes, separated by comma, one byte per char in the fmt string. The byte will be interpreted accordingly to the char at the same position of the fmt string.
      • setPrimaryColor

        public void setPrimaryColor​(int color)
        Description copied from interface: GlcdDisplayDriver
        Set the primary color (set bit) for the pixel data on the BGRA buffer.
        Specified by:
        setPrimaryColor in interface GlcdDisplayDriver
        Parameters:
        color - A 32-bit color value in BGRA format
      • setSecondaryColor

        public void setSecondaryColor​(int color)
        Description copied from interface: GlcdDisplayDriver
        Set the secondary color (unset bit) for the pixel data on the BGRA buffer.
        Specified by:
        setSecondaryColor in interface GlcdDisplayDriver
        Parameters:
        color - A 32-bit color value in BGRA format
      • drawPixels

        public void drawPixels​(int x,
                               int y,
                               int width,
                               int height,
                               byte[] buffer)
        Description copied from interface: GlcdDisplayDriver

        Draws pixels on the screen based on the provided pixel buffer. The size of the buffer can be determined by the following formula width * height

        Specified by:
        drawPixels in interface GlcdDisplayDriver
        buffer - The pixel buffer
      • drawPixelsBgra

        public void drawPixelsBgra​(int x,
                                   int y,
                                   int width,
                                   int height,
                                   byte[] buffer)
        Description copied from interface: GlcdDisplayDriver

        Draws pixels on the screen based on the provided pixel buffer. This buffer is using the BGRA format. The size of the buffer is determined by the following formulat: width * height * 4

        Specified by:
        drawPixelsBgra in interface GlcdDisplayDriver
        Parameters:
        x - The x-coordinate
        y - The y-coordinate
        width - The width of the pixels to be drawn
        height - The height of the pixels to be drawn
        buffer - The bgra pixel buffer
      • getId

        public final long getId()
        Specified by:
        getId in interface com.ibasco.ucgdisplay.common.drivers.DisplayDriver
      • write

        public void write​(byte... data)
        Specified by:
        write in interface com.ibasco.ucgdisplay.common.drivers.DisplayDriver
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object