The line method draws the line up to a second set of coordinates whereas the hline and vline methods draw horizontal and vertical lines respectively up to a given length.ĭraw a rectangle at the given location, size and colour. Pc = lcd.pixel(45, 50) # Gets the colour of the pixel at (45, 50)ĭraw a line from a set of coordinates using the given colour and a thickness of 1 pixel. If c is given, set the specified pixel to the given colour.įor example: lcd.pixel(25, 30, colour(0,255,0)) # Colours pixel (25, 30) green If c is not given, get the colour value of the specified pixel – useful for collision detection in a game. The following is from the Micropython documentation:įill the entire display with the specified colour. They only become visible to the user once the lcd.show() instruction is executed. The following methods draw shapes ( such as those above) onto the FrameBuffer. Two horizontal and two vertical lines will outline a rectangle. Tip: If we draw a series of lines of the same length, touching, one below the other, we get a solid rectangle. and we can draw a horizontal red line like this: The line below places the 16-bit colour code into the buffer at the position of the pixel(x, y). Let's start with a few simple examples of the code that follows this import block. The garbage collection library, gc, has also been imported so that we can check how much memory is available. The third line here imports the Framebuffer library which includes several very useful routines to draw objects on the display. ImportsĪt the top of our driver program we will always import a minimal set of libraries using this block at the top of our MicroPython script (we add even more later when we want to do advanced programs): from machine import Pin,SPI,PWM Display manufacturers usually supply some of these procedures/methods but leave the rest up to the end user to construct. We are going to use the Waveshare 1.44” 128x128 Pico display but any of the others will also work in the same way.Ī simple instruction to illuminate an identified pixel (x, y) with a specific colour is all that is needed to build a graphics system.Īll the other graphical and text objects we would like to display can be built from this single pixel instruction such as lines, circles, rectangles, triangles and text strings at different sizes. Optional: 10K ohm potentiometers, breadboard, jumper wires, Pico Decker/Duo and tactile buttons.The ability to enter, edit, save and execute MicroPython code on your Pico using Thonny. A Waveshare Pico LCD Display and driver software.Micro-USB cable – for power and programming the Pico.This can be really handy for making your own interfaces, data displays and other fun projects with many of our Waveshare Pico LCDs. In this tutorial Tony Goodhew explains how to use the basic graphics procedures which are included in the display driver, and for the ambitious makers out there he also provides examples for advanced shapes and graphics! In one of our previous tutorials we explained how to control colour on Waveshare Raspberry Pi Pico LCD displays.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |