Lcd screen display driver

1. function

1.1. lcd.init(type=1, freq=15000000, color=lcd.BLACK)

Initialize the LCD screen to display

Parameters

  • type: type of LCD (reserved for future use):

    • 0: None
    • 1: lcd shield (default)

      type is a key-value parameter that must be explicitly called by writing type= in the function call

  • freq: frequency of lcd ( actually maybe SPI )

  • colorLCD initialized color, 16 bits RGB565 color, e.g. 0xFFFF; or RGB888 tuple, e.g. (236, 36, 36), default lcd.BLACK

1.2. lcd.deinit()

Unregister the LCD driver to release the I/O pins

1.3. lcd.width()

Returns the width of the LCD (horizontal resolution)

1.4. lcd.height()

Returns the height of the LCD (vertical resolution).

1.5. lcd.type()

Returns the type of LCD (reserved for future use):

0: None 1: lcd Shield

1.6. lcd.freq(freq)

Set or get frequency of LCD (SPI)

Paremeters

  • freq: frequency of LCD (SPI)

Return

frequency of LCD

1.7. lcd.set_backlight(state)

Setting the backlight status of LCD, turning off the backlight will greatly reduce the energy consumption of the LCD expansion board.

//TODO: Not implemented

Parameters

  • state: backlight brightness, value [0,100]

1.8. lcd.get_backlight()

Return to backlight status

return value

Backlight brightness, value [0,100]

1.9. lcd.display(image, roi=Auto)

Display a image (GRAYSCALE or RGB565) on the LCD.

Roi is a rectangular tuple (x, y, w, h) of a region of interest. If not specified, it is an image rectangle

If the roi width is less than the lcd width, the vertical black border is used to make roi at the center of the screen (that is, fill the unoccupied area with black).

If the roi width is greater than the lcd width, roi is at the center of the screen, and the unmatched pixels are not displayed (ie, the LCD displays the center of roi in window form).

If the roi height is less than the lcd height, use a vertical black border to center roi in the center of the screen (ie fill the unoccupied area with black).

If the roi height is greater than the lcd height, roi is at the center of the screen, and the unmatched pixels are not displayed (ie, the LCD displays the center of roi in window form).

roi is a key-value parameter that must be explicitly called by writing roi= in a function call.

1.10. lcd.clear()

Empty the LCD screen to black or other color.

Parameters

  • colorLCD initialized color, 16 bits RGB565 color, e.g. 0xFFFF; or RGB888 tuple, e.g. (236, 36, 36)

1.11. lcd.direction(dir)

Set LCD direction and mirror

parameters maybe change in the future

Parameters

  • dir: nomally lcd.YX_LRUD or lcd.YX_RLDU, other values just exchange XY or LR or DU

2. Routine

2.1. Routine 1: Display English

import lcd

lcd.init()
lcd.draw_string(100, 100, "hello maixpy", lcd.RED, lcd.BLACK)

2.2. Routine 2: Displaying pictures

import lcd
import image

img = image.Image("/sd/pic.bmp")
lcd.display(img)

2.3. Routine 3: Display English in the form of displaying pictures

import lcd
import image

img = image.Image()
img.draw_string(60, 100, "hello maixpy", scale=2)
lcd.display(img)

2.4. Routine 4: Real-time display of images captured by the camera

import sensor, lcd

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
sensor.skip_frames()
lcd.init()

while(True):
    lcd.display(sensor.snapshot())
powered by GitbookFile Modify: 2020-08-26 15:56:59

results matching ""

    No results matching ""