Skip to content

Thumby API Documentation

To get started using the entire Thumby API, import the module at the top of your MicroPython program:

import thumby

Constants

  • __version__
    • type: string
    • values: 1.0 ~ limitless (increased for changes to library)

Methods

What are Thumby Submodules?

Thumby Submodule Documentation Page & Methods
thumbyHardware Hardware:

.reset()
thumbyButton Button

.buttonX.pressed()

.buttonX.justPressed()

.inputPressed()

.inputJustPressed()

.dpadPressed()

.dpadJustPressed()

.actionPressed()

.actionJustPressed()
thumbyGraphics Text:

.display.drawText(string, x, y, color)

.display.setFont(fontFilePath, width, height, space)

General:

Constants: .display.width and .display.height

.display.update()

.display.setFPS(FPS)

.display.fill(color)

.display.brightness(brightness)

Pixels:

.display.setPixel(x, y, color)

.display.getPixel(x, y)

Lines:

.display.drawLine(x1, y1, x2, y2, color)

Rectangles:

.display.drawFilledRectangle(x, y, w, h, color)

.display.drawRectangle(x, y, w, h, color)

Blit:

.display.blit(bitmapData, x, y, width, height, key, mirrorX, mirrorY)

.display.blitWithMask(bitmapData, x, y, width, height, key, mirrorX, mirrorY, maskBitmapData)

.display.drawSprite(sprite)

.display.drawSpriteWithMask(sprite, maskSprite)
thumbySprite Sprite

.Sprite(width, height, bitmapData, x, y, key, mirrorX, mirrorY)

.Sprite.getFrame()

.Sprite.setFrame(frame)
thumbyAudio Audio

.audio.play(freq, duration, duty)

.audio.playBlocking(freq, duration, duty)

.audio.stop()

.audio.setEnabled(setting)

audio.set(freq)
thumbyLink Link

.link.send(data)

.link.receive()
thumbySaves Saves

.saveData.setName(subdirectoryName)

.saveData.setItem(key, value)

.saveData.getItem(key)

.saveData.hasItem(key)

.saveData.delItem(key)

.saveData.save()

.saveData.getName()

Submodules

In Thumby API version 1.7, the Thumby API was divided into submodules for those not using the entire API. Using Thumby submodules increases the speed of program load times. You can always import all thumby constants and methods using import thumby. To import submodules and to use their methods in your code, you would import the submodule name instead, and when using methods you would type the submodule name instead of "thumby".

Let's look at the differences in two small examples that show how to import and use methods with the entire Thumby API and with a submodule.

Using the full API:

import thumby

thumby.display.fill(0)
thumby.display.drawText("Hello world", 0, 0, 1)
thumby.display.update()

Using a submodule of the API:

import thumbyGraphics

thumbyGraphics.display.fill(0)
thumbyGraphics.display.drawText("Hello world", 0, 0, 1)
thumbyGraphics.display.update()

These code snippets work the same, but the second runs faster! Check out what methods are available in which submodule in the table below!