This library provides a Microsoft Makecode package for the TomatoCube MakeCode Arcade Shield. LCD Portion adapted from RB-TFT1.8. See https://tomatocube.com for more details.
All graphical objects (e.g. pixels, lines, rectangles) can be drawn in different colors. The following color options are available:
- Black
- Navy
- Dark Green
- Dark Cyan
- Maroon
- Purple
- Olive
- Light Grey
- Dark Grey
- Blue
- Green
- Cyan
- Red
- Magenta
- Yellow
- White
- Orange
- Green Yellow
- Pink
The TFT display needs to be initialized before it is ready to use. All necessary TFT-Commands will be transfered via SPI here.
// Initialize TFT Display
TCMKCD.init()
Single pixels can be shown on the screen. The function takes three values. The x and y coordinates as well as the color for the pixel.
// Draw a single red pixel
TCMKCD.drawPixel(10, 10, Color.Red)
Straight lines can be drawn across the screen (horizontal, vertical and diagonal). The function takes five values: The x and y coordinates of the starting point, the x and y coordinates of the ending point and the color for the line.
// Draw a straight blue line
TCMKCD.drawLine(0, 0, 100, 100, Color.Blue)
Rectangles can be drawn on the screen. The function takes four five values: The x and y coordinate of the rectangles origin, the width of the rectangle, the height of the rectangle and the color for the rectangle.
// Draw a yellow rectangle
TCMKCD.drawRectangle(0, 0, 100, 120, Color.Yellow)
Circles can be drawn on the screen as well. Depending on the size of the circle, the drawing process can take a little more time than drawing straight lines or rectangles. The function takes four values: The x and y coordinate (center point) of the circle, the radius and the color of the circle.
// Draw a green circle
TCMKCD.drawCircle(50, 50, 50, Color.Green)
You can also show text on the display. The font size can be set in 5 different zoom levels (1-5). You can specify the font color as well as the background color. The function takes six arguments: The string, the x and y coordinates of the starting point, the zoom level, the text color and the background color.
// Show white text with black background
TCMKCD.showString("I am your RB-TFT1.8!", 10, 10, 1, Color.White, Color.Black)
New objects never replace already drawn objects on the screen. Instead, they are drawn in front of them. The clearScreen()-function will draw a black rectangle across the whole screen dimensions. The function does not expect any parameters.
// Clear screen - replaces whole screen with a black rectangle
TCMKCD.clearScreen()
You can turn off the display. In this mode, the frame memory is disabled and a blank (white) page will be shown. The function does not expect any parameters.
// Turn off display
TCMKCD.turnOff()
You turn the display on again and enable the output from the frame memory. The function does not expect any parameters.
// Turn on display
TCMKCD.turnOn()
- for PXT/microbit
MIT