- java.lang.Object
-
- com.ibasco.ucgdisplay.drivers.glcd.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
-
-
Constructor Summary
Constructors Modifier Constructor Description GlcdBaseDriver(GlcdConfig config)
Create new instance based on the config provided.protected
GlcdBaseDriver(GlcdConfig config, boolean virtual)
Create new instance based on the config provided.protected
GlcdBaseDriver(GlcdConfig config, boolean virtual, GlcdDriverEventHandler handler)
protected
GlcdBaseDriver(GlcdConfig config, boolean virtual, GlcdDriverEventHandler handler, GlcdDriverAdapter driverAdapter)
Creates a new instance based on the config provided.
-
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 instancevoid
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 bufferjava.lang.String
exportToPBM2()
Exports a PBM formatted ASCII string representation of the current display bufferjava.lang.String
exportToXBM()
Exports an XBM formatted ASCII string representati0on of the current display bufferjava.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 underlyingGlcdConfig
used by this instanceint
getDescent()
Returns the reference height of the glyphs below the baseline (descent).<T extends GlcdDriverEventHandler>
TgetDriverEventHandler()
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 toGlcdDisplayDriver.getNativeBuffer()
but this returns a buffer in bgra pixel format.java.nio.ByteBuffer
getNativeBuffer()
Returns the pixel buffer that is shared with the native libraryint
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 eventsprotected void
onGpioEvent(U8g2GpioEvent event)
Called when a gpio event has occuredvoid
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 theGlcdDisplayDriver.firstPage()
andGlcdDisplayDriver.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()
Removes the effect ofGlcdDisplayDriver.setClipWindow(int, int, int, int)
.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
-
Methods inherited from interface com.ibasco.ucgdisplay.drivers.glcd.GlcdDisplayDriver
getBufferSize
-
-
-
-
Constructor Detail
-
GlcdBaseDriver
public GlcdBaseDriver(GlcdConfig config)
Create new instance based on the config provided.- Parameters:
config
- TheGlcdConfig
associated with this instance
-
GlcdBaseDriver
protected GlcdBaseDriver(GlcdConfig config, boolean virtual)
Create new instance based on the config provided.- Parameters:
config
- TheGlcdConfig
associated with this instancevirtual
- Set totrue
to enable virtual mode.
-
GlcdBaseDriver
protected GlcdBaseDriver(GlcdConfig config, boolean virtual, GlcdDriverEventHandler handler)
-
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
- TheGlcdConfig
associated with this instancevirtual
- Set totrue
to enable virtual mode. If virtual mode is enabled, all instruction/data events are routed toGlcdDriverEventHandler
for further processing.handler
- TheGlcdDriverEventHandler
instance that will handle the data and instruction events thrown by the native display driver. If a null value is provided, theU8g2DriverAdapter
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()
-
getDriverEventHandler
public final <T extends GlcdDriverEventHandler> T getDriverEventHandler()
-
setDriverEventHandler
protected final void setDriverEventHandler(GlcdDriverEventHandler driverEventHandler)
-
getConfig
public final GlcdConfig getConfig()
Get the underlyingGlcdConfig
used by this instance- Returns:
- The
GlcdConfig
-
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
-
createDefaultEventHandler
protected GlcdDriverEventHandler createDefaultEventHandler()
-
checkConfig
protected void checkConfig(GlcdConfig config) throws GlcdConfigException
Validates the provided configuration instance- Parameters:
config
- TheGlcdConfig
instance- Throws:
GlcdConfigException
- Throws when a validation error occurs
-
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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- Parameters:
radius
- Defines the size of the circle: Radus = radoptions
- 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 interfaceGlcdDisplayDriver
- 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 = radoptions
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- Parameters:
x
- X-Positiony
- Y-Positionwidth
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
-
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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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, useGlcdDisplayDriver.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 interfaceGlcdDisplayDriver
- 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, useGlcdDisplayDriver.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 interfaceGlcdDisplayDriver
- 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, useGlcdDisplayDriver.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 interfaceGlcdDisplayDriver
- 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, useGlcdDisplayDriver.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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- Parameters:
font
- AGlcdFont
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 ModeFONT_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 interfaceGlcdDisplayDriver
- Parameters:
mode
- Enable (1) or disable (0) transparent mode.- See Also:
GlcdDisplayDriver.setDrawColor(com.ibasco.ucgdisplay.drivers.glcd.enums.GlcdDrawColor)
,GlcdDisplayDriver.setFont(byte[])
-
setFontDirection
public void setFontDirection(GlcdFontDirection direction)
Description copied from interface:GlcdDisplayDriver
The arguments defines the drawing direction of all strings or glyphs.
Argument String Rotation Description 0 0 degree Left to right 1 90 degree Top to down 2 180 degree Right to left 3 270 degree Down to top - Specified by:
setFontDirection
in interfaceGlcdDisplayDriver
- Parameters:
direction
- Writing direction/string rotation.- See Also:
GlcdDisplayDriver.drawString(int, int, String)
-
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 interfaceGlcdDisplayDriver
-
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 interfaceGlcdDisplayDriver
-
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 interfaceGlcdDisplayDriver
-
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 interfaceGlcdDisplayDriver
-
setFontRefHeightAll
public void setFontRefHeightAll()
Description copied from interface:GlcdDisplayDriver
A call to this procedure will define the calculation method for the ascent and descent of the current font. This method will be used for the current and all other fonts, which will be set with
GlcdDisplayDriver.setFont(byte[])
. Changing this calculation method has an effect onGlcdDisplayDriver.getAscent()
andGlcdDisplayDriver.getDescent()
. Default isGlcdDisplayDriver.setFontRefHeightText()
.Ascent will be the highest ascent of all glyphs of the current font. Descent will be the highest descent of all glyphs of the current font.
- Specified by:
setFontRefHeightAll
in interfaceGlcdDisplayDriver
- See Also:
GlcdDisplayDriver.getAscent()
,GlcdDisplayDriver.getDescent()
-
setFontRefHeightExtendedText
public void setFontRefHeightExtendedText()
Description copied from interface:GlcdDisplayDriver
A call to this procedure will define the calculation method for the ascent and descent of the current font. This method will be used for the current and all other fonts, which will be set with
GlcdDisplayDriver.setFont(byte[])
. Changing this calculation method has an effect onGlcdDisplayDriver.getAscent()
andGlcdDisplayDriver.getDescent()
.Ascent will be the largest ascent of "A", "1" or "(" of the current font. Descent will be the descent of "g" or "(" of the current font.
- Specified by:
setFontRefHeightExtendedText
in interfaceGlcdDisplayDriver
- See Also:
GlcdDisplayDriver.getAscent()
,GlcdDisplayDriver.getDescent()
-
setFontRefHeightText
public void setFontRefHeightText()
Description copied from interface:GlcdDisplayDriver
A call to this procedure will define the calculation method for the ascent and descent of the current font. This method will be used for the current and all other fonts, which will be set with
GlcdDisplayDriver.setFont(byte[])
. Changing this calculation method has an effect onGlcdDisplayDriver.getAscent()
andGlcdDisplayDriver.getDescent()
.Ascent will be the ascent of "A" or "1" of the current font. Descent will be the descent "g" of the current font (this is the default after startup).
- Specified by:
setFontRefHeightText
in interfaceGlcdDisplayDriver
- See Also:
GlcdDisplayDriver.getAscent()
,GlcdDisplayDriver.getDescent()
-
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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- Parameters:
color
- TheGlcdDrawColor
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 interfaceGlcdDisplayDriver
-
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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- Returns:
- 0, once the loop is completed (all data transfered to the display).
- See Also:
GlcdDisplayDriver.firstPage()
-
getAscent
public int getAscent()
Description copied from interface:GlcdDisplayDriver
Returns the reference height of the glyphs above the baseline (ascent). This value depends on the current reference height (see setFontRefHeightAll).
- Specified by:
getAscent
in interfaceGlcdDisplayDriver
- Returns:
- The ascent of the current font.
- See Also:
GlcdDisplayDriver.setFont(byte[])
,GlcdDisplayDriver.getDescent()
,GlcdDisplayDriver.setFontRefHeightAll()
-
getDescent
public int getDescent()
Description copied from interface:GlcdDisplayDriver
Returns the reference height of the glyphs below the baseline (descent). For most fonts, this value will be negative. This value depends on the current reference height (see
GlcdDisplayDriver.setFontRefHeightAll()
).- Specified by:
getDescent
in interfaceGlcdDisplayDriver
- Returns:
- The descent of the current font.
- See Also:
GlcdDisplayDriver.setFont(byte[])
,GlcdDisplayDriver.getDescent()
,GlcdDisplayDriver.setFontRefHeightAll()
-
getMaxCharWidth
public int getMaxCharWidth()
Description copied from interface:GlcdDisplayDriver
Each glyph is stored as a bitmap. This returns the width of the largest bitmap in the font.
- Specified by:
getMaxCharWidth
in interfaceGlcdDisplayDriver
- Returns:
- The largest width of any glyph in the font.
- See Also:
GlcdDisplayDriver.getMaxCharHeight()
-
getMaxCharHeight
public int getMaxCharHeight()
Description copied from interface:GlcdDisplayDriver
Each glyph is stored as a bitmap. This returns the height of the largest bitmap in the font.
- Specified by:
getMaxCharHeight
in interfaceGlcdDisplayDriver
- Returns:
- The largest height of any glyph in the font.
- See Also:
GlcdDisplayDriver.getMaxCharWidth()
-
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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- See Also:
GlcdDisplayDriver.sendBuffer()
-
clearDisplay
public void clearDisplay()
Description copied from interface:GlcdDisplayDriver
Clears all pixel on the connected display. This procedure is also called from begin. Usually there is no need to call this function except for the init procedure. Other procedures like
GlcdDisplayDriver.sendBuffer()
andGlcdDisplayDriver.nextPage()
will also overwrite (and clear) the display.- Specified by:
clearDisplay
in interfaceGlcdDisplayDriver
-
begin
public void begin()
Description copied from interface:GlcdDisplayDriver
Simplified setup procedure of the display for the Arduino enviornment. See the setup guide for the selection of a suitable U8g2 constructor. This function will reset, configure, clear and disable power save mode of the display. U8g2 can also detect key press events. Up to six buttons can be observed. The Arduino pin number can be assigned here. Use U8X8_PIN_NONE if there is no switch connected to the pin. The switch has to connect the GPIO pin with GND (low active button). Use getMenuEvent to check for any key press event. Select, next and prev pins are also required for the user interface procedures (for example userInterfaceMessage ).
begin will call:
- Specified by:
begin
in interfaceGlcdDisplayDriver
- See Also:
GlcdDisplayDriver.initDisplay()
,GlcdDisplayDriver.setPowerSave(boolean)
,GlcdDisplayDriver.clearDisplay()
-
getHeight
public int getHeight()
- Specified by:
getHeight
in interfacecom.ibasco.ucgdisplay.common.drivers.DisplayDriver
-
getWidth
public int getWidth()
- Specified by:
getWidth
in interfacecom.ibasco.ucgdisplay.common.drivers.DisplayDriver
-
clear
public void clear()
Description copied from interface:GlcdDisplayDriver
Clears all pixel on the display and the buffer. Puts the cursor for the print function into the upper left corner.
clear will call:
- Specified by:
clear
in interfacecom.ibasco.ucgdisplay.common.drivers.DisplayDriver
- Specified by:
clear
in interfaceGlcdDisplayDriver
- See Also:
GlcdDisplayDriver.clearBuffer()
-
setCursor
public void setCursor(int x, int y)
- Specified by:
setCursor
in interfacecom.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()
andGlcdDisplayDriver.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 interfaceGlcdDisplayDriver
- Parameters:
clear
- Set tofalse
to turn off automatic clearing of the internal pixel buffer. Default value istrue
.- Returns:
- The width of the buffer in tiles.
- See Also:
GlcdDisplayDriver.getBuffer()
-
setBitmapMode
public void setBitmapMode(GlcdBitmapMode mode)
Description copied from interface:GlcdDisplayDriver
Defines, whether the bitmap functions will write the background color to solid or transparent. Default mode is
GlcdBitmapMode.SOLID
.- Specified by:
setBitmapMode
in interfaceGlcdDisplayDriver
- Parameters:
mode
- UseGlcdBitmapMode.SOLID
for a solid bitmap background orGlcdBitmapMode.TRANSPARENT
for transparent.- See Also:
GlcdDisplayDriver.drawXBM(int, int, java.io.File)
, U8g2 - setBitmapMode
-
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 interfaceGlcdDisplayDriver
- Parameters:
value
- Contrast or brightness from 0 to 255.
-
setDisplayRotation
public void setDisplayRotation(GlcdRotation 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 GlcdRotation.ROTATION_NONE
No rotation, landscape GlcdRotation.ROTATION_90
90 degree clockwise rotation GlcdRotation.ROTATION_180
180 degree clockwise rotation GlcdRotation.ROTATION_270
270 degree clockwise rotation GlcdRotation.ROTATION_MIRROR
No rotation, landscape, display content is mirrored - Specified by:
setDisplayRotation
in interfaceGlcdDisplayDriver
- Parameters:
rotation
- Display rotation argument.
-
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 interfaceGlcdDisplayDriver
- Parameters:
rotation
- Display rotation argument.
-
getBuffer
public byte[] getBuffer()
Description copied from interface:GlcdDisplayDriver
Return the contents of the display buffer. The total memory size of the buffer is 8 * (
GlcdDisplayDriver.getBufferTileHeight()
*GlcdDisplayDriver.getBufferTileWidth()
). The buffer can be erased withGlcdDisplayDriver.clearBuffer()
.- Specified by:
getBuffer
in interfaceGlcdDisplayDriver
- Returns:
- The contents of th
- See Also:
GlcdDisplayDriver.getBufferTileHeight()
,GlcdDisplayDriver.getBufferTileWidth()
,GlcdDisplayDriver.clearBuffer()
-
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 interfaceGlcdDisplayDriver
- Returns:
- A direct
ByteBuffer
-
getNativeBgraBuffer
public java.nio.ByteBuffer getNativeBgraBuffer()
Description copied from interface:GlcdDisplayDriver
Similar toGlcdDisplayDriver.getNativeBuffer()
but this returns a buffer in bgra pixel format.- Specified by:
getNativeBgraBuffer
in interfaceGlcdDisplayDriver
- Returns:
- A direct
ByteBuffer
. Null if virtual mode is false.
-
getBufferTileWidth
public int getBufferTileWidth()
Description copied from interface:GlcdDisplayDriver
Return the width of the page buffer in tiles (One tile has a width of 8 pixel).
- Specified by:
getBufferTileWidth
in interfaceGlcdDisplayDriver
- Returns:
- The width of the buffer in tiles.
- See Also:
GlcdDisplayDriver.getBuffer()
,GlcdDisplayDriver.getBufferTileHeight()
-
getBufferTileHeight
public int getBufferTileHeight()
Description copied from interface:GlcdDisplayDriver
Return the height of the page buffer in tiles. The height of one tile is 8 pixel.
- Specified by:
getBufferTileHeight
in interfaceGlcdDisplayDriver
- Returns:
- The height of the buffer in tiles.
- See Also:
GlcdDisplayDriver.getBuffer()
,GlcdDisplayDriver.getBufferTileWidth()
-
getBufferCurrTileRow
public int getBufferCurrTileRow()
Description copied from interface:GlcdDisplayDriver
Return the intended position for the content of the pixel buffer (page) on the target display. If it is assumed, that the buffer will be placed at the top of the display, then this value is zero. This value is modified by
GlcdDisplayDriver.firstPage()
/GlcdDisplayDriver.nextPage()
and used byGlcdDisplayDriver.sendBuffer()
to place the content of the pixel buffer at the target position.- Specified by:
getBufferCurrTileRow
in interfaceGlcdDisplayDriver
- Returns:
- The current page position in tiles (one tile has a height of 8 pixel)
- See Also:
GlcdDisplayDriver.getBuffer()
-
setBufferCurrTileRow
public void setBufferCurrTileRow(int row)
Description copied from interface:GlcdDisplayDriver
Set the position of the pixel buffer for the sendBuffer command.
- Specified by:
setBufferCurrTileRow
in interfaceGlcdDisplayDriver
- Parameters:
row
- Location for the pixel buffer on the display. row is the "tile" position and must be multiplied with 8 to get the pixel position.- See Also:
GlcdDisplayDriver.getBuffer()
,GlcdDisplayDriver.sendBuffer()
-
getStrWidth
public int getStrWidth(java.lang.String text)
Description copied from interface:GlcdDisplayDriver
Return the pixel width of string.
- Specified by:
getStrWidth
in interfaceGlcdDisplayDriver
- Parameters:
text
- Text string to be measured- Returns:
- Width of the string if drawn with the current font (setFont).
- See Also:
GlcdDisplayDriver.setFont(GlcdFont)
,GlcdDisplayDriver.setFont(byte[])
,GlcdDisplayDriver.drawString(int, int, String)
-
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 interfaceGlcdDisplayDriver
- 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()
-
setMaxClipWindow
public void setMaxClipWindow()
Description copied from interface:GlcdDisplayDriver
Removes the effect of
GlcdDisplayDriver.setClipWindow(int, int, int, int)
. Graphics is written to the complete display.- Specified by:
setMaxClipWindow
in interfaceGlcdDisplayDriver
- See Also:
GlcdDisplayDriver.setClipWindow(int, int, int, int)
-
updateDisplay
public void updateDisplay()
Description copied from interface:GlcdDisplayDriver
Updates all area of 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()
andGlcdDisplayDriver.updateDisplay(int, int, int, int)
are designed for the full buffer mode (constructor with _F_ in the name). HoweverGlcdDisplayDriver.sendBuffer()
andGlcdDisplayDriver.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
GlcdDisplayDriver.sendBuffer()
,GlcdDisplayDriver.updateDisplay()
andGlcdDisplayDriver.updateDisplay(int, int, int, int)
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 interfaceGlcdDisplayDriver
-
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()
andGlcdDisplayDriver.updateDisplay(int, int, int, int)
are designed for the full buffer mode (constructor with _F_ in the name). HoweverGlcdDisplayDriver.sendBuffer()
andGlcdDisplayDriver.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 interfaceGlcdDisplayDriver
- Parameters:
x
- The starting x-coordinate of the rectangular regiony
- The starting y-coordinate of the rectangular regionwidth
- The width of the rectangular regionheight
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- Parameters:
format
- A sequence (string) of c, a or dargs
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
- 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 interfaceGlcdDisplayDriver
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 interfaceGlcdDisplayDriver
- Parameters:
x
- The x-coordinatey
- The y-coordinatewidth
- The width of the pixels to be drawnheight
- The height of the pixels to be drawnbuffer
- The bgra pixel buffer
-
getId
public final long getId()
- Specified by:
getId
in interfacecom.ibasco.ucgdisplay.common.drivers.DisplayDriver
-
write
public void write(byte... data)
- Specified by:
write
in interfacecom.ibasco.ucgdisplay.common.drivers.DisplayDriver
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-