Getting Started with TinyScreen Programming

Let’s look at some of the basics of O Watch programming using TinyScreen.

The Screen

The TinyScreen resolution is 96 pixels wide by 64 pixels high (96×64) as shown.
OWatchScreen

When you display any item on the screen you need to tell the O Watch where to print it. e.g. if you draw something on the screen like a rectangle, you need to specifiy the starting position or the x,y co-ordinates. Note that the starting point is the left top and the first pixel starts at (0,0) meaning (95,63) is the right-bottom corner the highest values for x & y respectively.

TinyScreen Functions

Let’s refer to the Hello World example again.

Here you see a number of commands start with the prefix display. All the commands that start with display. prefix are TinyScreen functions included in the TinyScreen library.

Following are the TinyScreen functions used in this example:

  • display.begin() – This initializes the TinyScreen board. It is required at the start of all O Watch programs.
  • display.setFlip(1) – Flips the display right-side up. By default TinyScreen prints everything upside down from O Watch perspective. So we need this for all O Watch programs as well. If you wish to flip the display back then you can set this to 0 or remove this.
  • display.on() – This switches on the display. You can use display.off() to switch off the display and save power. This can be in the setup or it could be in the loop as well if you wish to switch the screen on and off based on certain events.
  • display.setFont(liberationSansNarrow_12ptFontInfo) – sets the font type in which text will be printed on screen. You can change this to other available fonts.
  • display.fontColor(TS_8b_Blue,TS_8b_Black) – Sets the color and background for text printed on screen.
  • display.setBrightness(10) – Sets the display brightness (and the amount of power used). Values are from 0-15.
  • display.setCursor(15,25) – Sets the x,y position on the screen where the next print comman will begin.
  • display.print("Hello World!") – This is the TinyScreen print command.
  • display.clearScreen() – Clears the whole screen.

Exercises

  1. Change the code so that the text is on for 100 milliseconds and off for 1000.
  2. Change the code so that the text turns on when the sketch starts and stays on.
  3. Change the code to display text 5 times in different positions before clearing screen

<< Back: Arduino Programming   |   Next: TinyScreen Demo >>