3.3. Inkplate MicroPython

3.3.1. .begin() method

Before calling any display method you must call .begin() like this:
display.begin()
  • Description:

    If you forget to do this most method calls will result in core panick and esp32 resetting. After you’ve called this you can proceed calling all other methods described below.

3.3.2. .drawPixel()

  • Method prototype (as seen in Inkplate.h):
.drawPixel(x, y, color)
  • Arguments and return value:
    x0 - x coordinate of pixel, [0, 799] in rotations 2, 4 and [0, 599] in 1, 3
    y0 - y coordinate of pixel, [0, 599] in rotations 2, 4 and [0, 799] in 1, 3
    color - pixel color, in 3 bit mode in range [0, 7]

    Returns nothing.

  • Description:
    Most basic drawing command in the library is .drawPixel()
    Draws one pixel at x0, y0 in desired color.
    Requires .display() to be called afterwards to update the screen,
    See below.
  • Example:
    display.drawPixel(100, 50, display.BLACK)
    
  • Result:
    Here is what the code above produces:
    Quite small, isn’t it.
    _images/IMG_4345.jpg

3.3.3. .clearDisplay()

  • Method prototype (as seen in Inkplate.h):
.clearDisplay()
  • Arguments and return value:
    No Arguments

    Returns nothing.

  • Description:
    Clears all data in buffer.
  • Example:
    display.clearDisplay()
    

3.3.4. .display()

  • Method prototype (as seen in Inkplate.h):
.display()
  • Arguments and return value:
    No Arguments

    Returns nothing.

  • Description:
    Displays all data in frame buffer to screen.
  • Example:
    # Any drawing code
    display.drawPixel(10, 100, display.BLACK)
    
    display.display()
    

3.3.5. .partialUpdate()

  • Method prototype (as seen in Inkplate.h):
.partialUpdate()
  • Arguments and return value:
    No Arguments

    Returns nothing.

  • Description:
    Updates only the changed parts of the screen.
    After a few updates creates blurry parts of the screen.
    Fixed by calling .clean()
  • Example:
    display.drawPixel(100, 50, display.BLACK)
    
    display.partialUpdate()
    
    display.drawPixel(100, 100, display.BLACK)
    

3.3.6. .setRotation()

  • Method prototype (as seen in Inkplate.h):
.setRotation(r)
  • Arguments and return value:
    r - screen rotation.

    Returns nothing.

  • Description:
    Rotates the screen to be used in different orientations.
    Default is 2, to fip 180 input 4
    1 and 3 are for portait mode.
    Once flipped coordinate space remains to have the origin in the top left corner.
  • Example:
    display.setRotation(3)
    
    display.setCursor(100, 100)
    display.print("INKPLATE6")
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4347.jpg

3.3.7. .selectDisplayMode()

  • Method prototype (as seen in Inkplate.h):
.selectDisplayMode(_mode)
  • Arguments and return value:
    _mode - New display mode, display.Inkplate.INKPLATE_1BIT or display.Inkplate.INKPLATE_2BIT.

    Returns nothing.

  • Description:
    Changes the screen mode to from monochrome to 3 bit grayscale or vice versa.
  • Example:
    display.selectDisplayMode(Inkplate.INKPLATE_2BIT)
    

3.3.8. .getDisplayMode()

  • Method prototype (as seen in Inkplate.h):
.getDisplayMode()
  • Arguments and return value:
    No arguments.

    Returns currently set display mode.

  • Description:
    Used to determine which display mode is currently used.
    Returns Inkplate.INKPLATE_1BIT or Inkplate.INKPLATE_2BIT.
  • Example:
    if display.getDisplayMode() == Inkplate.INKPLATE_2BIT:
        print("I'm in grayscale mode!")
    

3.3.9. .clean()

  • Method prototype (as seen in Inkplate.h):
clean()
  • Arguments and return value:
    No arguments.

    Returns nothing.

  • Description:
    Cleans the actual screen of any possible burn in.
    Should not be used in intervals less than 5 seconds.
  • Example:
    display.clean()
    

3.3.10. .drawFastVLine()

  • Method prototype:
drawFastVLine(x, y, h, color)
  • Arguments and return value:
    x - x coordinate of the line start point
    y - y coordinate of the line start point
    h - line height
    color - line color

    Returns nothing.

  • Description:
    Draw a perfectly vertical line.
    Garantees to be faster than regular line draw.
  • Example:
    display.drawFastVLine(100, 100, 400, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4354.jpg

3.3.11. .drawFastHLine()

  • Method prototype:
drawFastHLine(x, y, w, color)
  • Arguments and return value:
    x - x coordinate of the line start point
    y - y coordinate of the line start point
    w - line width
    color - line color

    Returns nothing.

  • Description:
    Draw a perfectly horizontal line.
    Garantees to be faster than regular line draw.
  • Example:
    display.drawFastHLine(100, 100, 600, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4355.jpg

3.3.12. .fillRect()

  • Method prototype:
fillRect(x, y, w, h, color)
  • Arguments and return value:
    x - x coordinate of the rectangle
    y - y coordinate of the rectangle
    w - rectangle width
    h - rectangle height
    color - rectanle color, in range [0, 6]

    Returns nothing.

  • Description:
    Draws a filled rectangle on the screen.
  • Example:
    display.fillRect(random(0, 799), random(0, 599), 30, 30, random(0, 7))
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4356.jpg

3.3.13. .fillScreen()

  • Method prototype:
fillScreen(color)
  • Arguments and return value:
    color - color of the screen after filling.

    Returns nothing.

  • Description:
    Fills the whole screen to a solid color.
  • Example:
    display.fillScreen(0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4357.jpg

3.3.14. .drawLine()

  • Method prototype:
drawLine(x0, y0, x1, y1, color)
  • Arguments and return value:
    x0 - Start point x coordinate.
    y0 - Start point y coordinate.
    x1 - End point x coordinate.
    y1 - End point y coordinate.
    color - Line color.

    Returns nothing.

  • Description:
    General purpose line drawing function.
    If the line is vertical or horizontal it is recommended to use drawFastHLine or drawFastVLine,
    although drawLine automatically checks and uses faster drawing function if needed.
  • Example:
    #Diagonal lines
    display.drawLine(0, 0, 799, 599, 0)
    display.drawLine(799, 0, 0, 599, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4358.jpg

3.3.15. .drawRect()

  • Method prototype:
drawRect(x, y, w, h, color)
  • Arguments and return value:
    x - Rectangle x coordinate.
    y - Rectangle y coordinate.
    w - Rectangle width.
    h - Rectangle height.
    color - Rectangle color (edges only, see fillRect for fully filled one).

    Returns nothing.

  • Description:
    Draws and empty (not filled) rectangle.
  • Example:
    display.drawRect(200, 200, 400, 300, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4359.jpg

3.3.16. .drawCircle()

  • Method prototype:
drawCircle(x0, y0, r, color)
  • Arguments and return value:
    x0 - Circle center x coordinte.
    y0 - Circle center y coordinate.
    r - Circle radius.
    color - Circle color (just the edge, see fillCircle for fully filled).

    Returns nothing.

  • Description:
    Draws an empty(not filled) circle.
  • Example:
    display.drawCircle(400, 300, 75, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4360.jpg

3.3.17. .fillCircle()

  • Method prototype:
fillCircle(x0, y0, r, color)
  • Arguments and return value:
    x0 - Circle center x coordinte.
    y0 - Circle center y coordinate.
    r - Circle radius.
    color - Circle color (fully filled).

    Returns nothing.

  • Description:
    Draws a filled circle to screen in a supplied color.
  • Example:
    display.fillCircle(random(0, 799), random(0, 599), 15, random(0, 7))
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4361.jpg

3.3.18. .drawTriangle()

  • Method prototype:
drawTriangle(x0, y0, x1, y1,
  x2, y2, color)
  • Arguments and return value:
    x0 - First point x coordinate.
    y0 - First point y coordinate.
    x1 - Second point x coordinate.
    y1 - Second point y coordinate.
    x2 - Third point x coordinate.
    y2 - Third point y coordinate.
    color - Triangle edge color(see fillTriangle for a fully filled one).

    Returns nothing.

  • Description:
    Draw an empty rectangle to screen.
  • Example:
    display.drawTriangle(250, 400, 550, 400, 400, 100, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4362.jpg

3.3.19. .fillTriangle()

  • Method prototype:
fillTriangle(x0, y0, x1, y1,
  x2, y2, color)
  • Arguments and return value:
    x0 - First point x coordinate.
    y0 - First point y coordinate.
    x1 - Second point x coordinate.
    y1 - Second point y coordinate.
    x2 - Third point x coordinate.
    y2 - Third point y coordinate.
    color - Triangle fill color.

    Returns nothing.

  • Description:
    Draw a rectangle filled with a certain color.
  • Example:
    display.fillTriangle(300, 350, 500, 350, 400, 150, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4363.jpg

3.3.20. .drawRoundRect()

  • Method prototype:
drawRoundRect(x0, y0, w, h,
  radius, color)
  • Arguments and return value:
    x0 - Rectangle x coordinate.
    y0 - Rectangle y coordinate.
    w - Rectangle width.
    h - Rectangle height.
    radius - Curvature radius of the edges.
    color - Rectangle edges color (for a fully filled one see fillRoundRect).

    Returns nothing.

  • Description:
    Draws an empty (not filled) rectangle with round edges to screen.
  • Example:
    display.drawRoundRect(200, 200, 400, 300, 10, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4364.jpg

3.3.21. .fillRoundRect()

  • Method prototype:
fillRoundRect(x0, y0, w, h,
  radius, color)
  • Arguments and return value:
    x0 - Rectangle x coordinate.
    y0 - Rectangle y coordinate.
    w - Rectangle width.
    h - Rectangle height.
    radius - Curvature radius of the edges.
    color - Rectangle fill color.

    Returns nothing.

  • Description:
    Draws a fully filled rectangle with rounded corners to screen.
  • Example:
    display.fillRoundRect(200, 200, 400, 300, 10, 0)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4365.jpg

3.3.22. .drawBitmap()

  • Method prototype:
drawBitmap(x, y, b, w, h)
  • Arguments and return value:
    x - Bitmap x coordinate.
    y - Bitmap y coordinate.
    b - Bytearray to draw from.
    w - Bitmap width.
    h - Bitmap height.

    Returns nothing.

  • Description:
    Draws a monochrome bitmap to screen.
    To get image data, use LCD image Converter.
  • Example:
    display.drawBitmap(100, 250, logo, 576, 100)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4366.jpg

3.3.23. .drawImageFile()

  • Method prototype:
drawBitmap(x, y, path, invert=False)
  • Arguments and return value:
    x - Bitmap x coordinate.
    y - Bitmap y coordinate.
    path - File path e.g. “sd/file.bmp”
    w - Bitmap width.
    h - Bitmap height.
    invert - Inverts color.

    Returns nothing.

  • Description:
    Draws a bitmap file to screen.
  • Example:
    display.drawBitmap(100, 250, "sd/file.bmp", 576, 100)
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4366.jpg

3.3.24. .setTextSize()

  • Method prototype:
setTextSize(s)
  • Arguments and return value:
    s - font scale

    Returns nothing.

  • Description:
    Scales the font to some value.
  • Example:
    display.setTextSize(4)
    

3.3.25. .setFont()

  • Method prototype:
setFont(f)
  • Arguments and return value:
    f - font dictionary

    Returns nothing.

  • Description:
    Used to change the text font.
    Fonts can be found in the supplied Fonts folder or made using tools.
  • Example:
    # Font has to be included
    display.setFont(font)
    display.println("Inkplate 6")
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4371.jpg

3.3.26. .printText()

  • Method prototype:
print(x, y, s)
  • Arguments and return value:
    x - x coordinate to write text
    y - y coordinate to write text
    s - String to be printed.

    Returns nothing.

  • Description:
    Puts the text on screen.
  • Example:
    display.printText(100, 100, "Some text")
    
  • Result:
    Here is what the code above produces:
    _images/IMG_4373.jpg

3.3.27. .width()

  • Method prototype:
width()
  • Arguments and return value:
    No arguments.

    Returns nothing.

  • Description:
    Returns screen width.
  • Example:
    display.width()
    

3.3.28. .height()

  • Method prototype:
height()
  • Arguments and return value:
    No arguments.

    Returns nothing.

  • Description:
    Returns screen height.
  • Example:
    display.height()
    

3.3.29. .getRotation()

  • Method prototype:
getRotation()
  • Arguments and return value:
    No arguments.

    Returns nothing.

  • Description:
    Returns screen rotation, in range [0,3], 2 is default.
  • Example:
    if display.getRotation() == 4:
        print("I'm upside down!")