Introduction to TS Functions, Buttons, Fonts & Colors

Let’s look at another example. This is the demo that comes with the TinyScreen library. You should be able to locate it under Arduino->Library->TinyScreen->Examples. Load that example in your Arduino IDE or copy paste the code below.

Functions in the program

If you look at the main loop(), you see several user written functions being called. hardwareDrawCommands(), drawPixels(), drawBitmap(), writeText() and readInput() are functions written by the author. The code for these functions can be seen below and within each there are several TinyScreen library functions (ones with pre-fix ‘display.’ being used. Let us examine some of those:

  • drawRect(x stary, y start, width, height, fill, 8bitcolor)
  • drawLine(x1, y1, x2, y2, 8bitcolor)
  • drawPixel(x,y,color)

These functions are all mostly self explanatory. You can refer to the TinyScreen Functions list in the next page for details.

Buttons

You can interact with the O Watch using the four buttons on the sides. From the example refer to the following line of code:

This is the primary means of checking if a button has been pressed and based on that input you can then do a set of actions or call a specific function. TSButtonUpperRight, TSButtonUpperLeft, TSButtonLowerRight, TSButtonLowerLeft are the four pre-defined button names. You can also check for multiple buttons at the same time e.g. getButtons(TSButtonUpperLeft|TSButtonUpperRight).

Try changing some of the code to see if you can change colors and fonts.

<< Back: TinyScreen Programming | Next: TinyScreen Functions >>