1974 views|2 replies

1w

Posts

25

Resources
The OP
 

"Playing with the Board" + Replaying MicroPython on the STM32F7DISC (3) [Copy link]

 
This post was last edited by dcexpert on 2020-2-17 22:19

Layer

The STM32F7DISC development board has rich graphics functions. One of the most distinctive functions is layer. The concept of layer is similar to that of layer in Photoshop. There are many uses for layer. For example, you can use layer as buffer, draw in one layer first, and then display it quickly at one time; you can also set the transparency of the layer (set_transparency), or set the position and size of the display window of the layer. Due to RAM limitations, only 2 layers are currently supported. 0 is the background layer, and 1 is the foreground layer. When drawing in layer 1, if the alpha channel is set in the color, transparent color can be displayed and superimposed with layer 0.

The main function of the layer:

  • layer_default_init(), initialization
  • select_layer(n), select the current layer.
  • set_layer_window(n, x, y, width, height), sets the size of a layer window position
  • set_layer_visible(n, show), n represents the layer, show represents display or hide
  • set_transparency(n, tr), n represents the layer, tr is the transparency (0 represents completely transparent, 255 represents opaque)
  • set_layer_address(), set the layer address, usage is not clear yet

  • Due to the lack of documentation, some functions have been explored through continuous testing. There may be errors or inaccuracies. You are welcome to point them out.

For specific usage methods, please refer to the demo on the second floor, and pay special attention to the effects of using alpha channels to open windows and transparency.


This content is originally created by dcexpert , a user of EEWORLD forum. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

 
 

1w

Posts

25

Resources
2
 

Testing Procedure

from time import sleep_ms
import lcdF7D as lcd
import tchF7D as ts

MAX_X = 480
MAX_Y = 272

lcd.init()

lcd.select_layer(0)
lcd.set_text_color(0xFF)
lcd.fill_rect(50, 50, 200, 100)
lcd.set_text_color(0xFF00)
lcd.fill_rect(200, 80, 200, 100)
lcd.set_text_color(0xFF0000)
lcd.fill_rect(100, 100, 200, 100)
lcd.set_text_color(0xFF00)
lcd.set_font(20)
lcd.display_string_at(0, 0, 'rect show on the screen', 0)

lcd.select_layer(1)
lcd.set_text_color(0xFF0000)
lcd.set_font(24)
lcd.display_string_at(0, 60, 'no rect show on the screen', 0)
lcd.set_text_color(0x80, 0)
lcd.fill_rect(180, 90, 30, 30)
sleep_ms(2000)

lcd.set_layer_visible(1, 0)
sleep_ms(2000)

lcd.set_layer_visible(1, 1)

for i in range(255):
    lcd.set_transparency(1, 255 - i)
    sleep_ms(10)

for i in range(220):
    lcd.set_transparency(1, i)
    sleep_ms(10)

First select layer 0, then draw three rectangles of different colors. At this time, the rectangles will not be displayed on the screen. Then set layer 1 to invisible, and you can see the rectangles of layer 0. Then set layer 1 to visible, and gradually adjust the transparency of layer 1.

 
 
 

1w

Posts

25

Resources
3
 
This post was last edited by dcexpert on 2020-2-20 12:32

Another small program to test the layer display, printing numbers on two layers in turn.

  • layer_print.py (869 Bytes, downloads: 0)
  • LCDF7D_PRINT.py (1.49 KB, downloads: 0)
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list