2486 views|6 replies

26

Posts

0

Resources
The OP
 

【TOPWAY 5-inch smart TFT module】Smart curtains [Copy link]

1. UI material preparation
and material organization. According to the function implementation, process the UI of the operation interface and organize the materials. The materials can allow you to design your own UI, mainly the theme of the operation interface.

① Import a background image of 800x480 according to the screen resolution. Determine the theme of the entire operation interface. The image here is mainly used to display the page background image.

② The operation interface of the screen, first you need to control the power supply of the bedroom, and then turn on the power supply of the bedroom. In the development tool SGTools, you can import ICON to create a variable icon to identify the switch status of the bedroom power supply. As shown in the figure below, it is the icon indication of the control switch. As shown in the figure below

③ Visually display the movement of the curtains. The dynamic opening and closing of the curtains can be realized through the animation control in SGTools. Since the resolution of the GIF image is 480*272, which exceeds 1/4 of the screen resolution, I found a small software on the Internet to crop the GIF file to 360*230 size;

2. Create a project through SGTools
① Open SGTools and create a project. You can find the steps in my previous post. The resolution of the project is 800x480;
import the background image, switch icon and animation file, and rename them for easy calling, as shown below;

② Create a page, create animation resources (you can directly import GIF to achieve this), and set the background image for the associated display. The operation here is relatively simple, so the operation process is omitted;

③ Edit the functions of each page, such as adding control buttons and variable icon controls that display icon status;
in the living room socket page, add the switch ICON icon and configure the associated variable to 0x080008, bit 0: =0 for off; =1 for on; as shown in the figure below

, add the corresponding touch keys, and use the touch keys to switch the switch status, using the VP XOR function "*VP := *VP XOP Value" to achieve this;

Then associate the same VP address "0x080008" as the variable icon.

④ Bedroom curtain page settings, add window opening animation and window closing animation;
overlap the two animations and set the corresponding enable variables;
the window opening animation enable is: 0x080004-window opening enable;
the window closing animation enable is: 0x080006-window closing enable; as shown below

Add touch keys to control curtain status variable 0x08000A using vp=value function - curtain status: = 0 no animation; = 1 window opening animation; = 2 window closing animation;

As shown below:

3. Simple Lua script program logic design
To realize the function of touch key control animation, certain logical judgment is required, and some logical processing needs to be done by the lower computer, and then realized through the serial port. I learned from the technical support staff of Topway that the intelligent module I have also supports LUA script function, which can do some simple logical processing;


--  主循环 调用一次等待10ms
luamain = function (void)
    local windows = 0
    -- 读 窗帘状态变量值
    windows = hmt.readvp16(0x08000A)
    -- 判断 窗帘状态值是否为 0,是写开/关窗帘都不使能
    if (windows == 0) then
        hmt.writevp16(0x080004,0x00)
        hmt.writevp16(0x080006,0x00)
    -- 判断 窗帘状态值是否为 1,开窗帘使能,关窗帘不使能
    elseif (windows == 1) then
        hmt.writevp16(0x080004,0x01)
        hmt.writevp16(0x080006,0x00)
    -- 判断 窗帘状态值是否为 2,关窗帘使能,开窗帘不使能
    elseif (windows == 2) then
        hmt.writevp16(0x080004,0x00)
        hmt.writevp16(0x080006,0x01)
    end
end

--  触摸键事件,回调函数
tpkhook = function (page,id,state)

    return 0
end

-- 页面切换时,回调函数
pagechangehook = function (page)

  return 0
end

After editing the above projects and programs, you can directly use the data cable to download them to the screen through SGTools.

4. Functional Testing

V. Summary
1. The interactive interface is easy to develop. You just need to find relevant materials on the Internet and use tools to process them.
2. LUA can do basic logic processing and does not require high requirements for the microcontroller of the lower computer.

This post is from Analog electronics

Latest reply

I hope there will be more exciting works   Details Published on 2022-4-6 19:04

1w

Posts

25

Resources
2
 

Good results

This post is from Analog electronics

Comments

Yes, the icons switched and the animation played smoothly during testing.  Details Published on 2022-3-31 12:31
 
 

26

Posts

0

Resources
3
 

Yes, the icons switched and the animation played smoothly during testing.

This post is from Analog electronics
 
 
 
 

76

Posts

2

Resources
4
 

The interface looks very advanced. I didn’t expect that the serial port screen can also be applied to smart home control.

This post is from Analog electronics

Comments

The development tools are quite convenient, and the application of scripts is indeed very convenient.  Details Published on 2022-4-2 16:06
 
 
 
 

26

Posts

0

Resources
5
 
Cijian dare not be the first to publish on 2022-4-1 10:03 The interface looks very high-end, I didn’t expect that the serial port screen can also be applied to smart home control

The development tools are quite convenient, and the application of scripts is indeed very convenient.

This post is from Analog electronics

Comments

I hope there will be more exciting works  Details Published on 2022-4-6 19:04
 
 
 
 

76

Posts

2

Resources
6
 
echo_xpout posted on 2022-4-2 16:06 The development tools are quite convenient, and the application of scripts is indeed very convenient.

I hope there will be more exciting works

This post is from Analog electronics

Comments

This screen still has many functions that have not been explored in depth. Personally, I feel that there are many functions that can be explored in the field of smart home.  Details Published on 2022-4-7 08:50
 
 
 
 

26

Posts

0

Resources
7
 
Cijian dare not be the first to publish on 2022-4-6 19:04 I hope there will be more wonderful works

This screen still has many functions that have not been explored in depth. Personally, I feel that there are many functions that can be explored in the field of smart home.

This post is from Analog electronics
 
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

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