• Author
    Posts
  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    UI Interface Design
    Today we are doing a simple home control. Through PS, I have designed this simple interface as follows.

    Function: When the light button is pressed, the page jumps to the next picture, showing the switching status of the three lights. When the light switch button is pressed, the serial port of the screen module sends out the switch signal protocol. The external MCU can send data directly to the screen module via the serial port.
    This allows the screen to display the on/off status of the lights directly.

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    A new project with TOOL 2019
    The latest version of STONE TOOL 2019 is available for download on the STONE website and allows you to work on UI projects.

    STONE TOOL 2019 is a no-installation design tool that can be opened and run directly after downloading and unzipping. The details are as follows.

    Double click on the software icon to open the STONE TOOL software.
    Then click on the “file” button in the top left corner to create a new project.

    As I am using STVC050WT-01, the resolution is 480*272, the default Flash space size is 128Mbyte (expandable to 1024MByte), so I choose 128Mbyte here.
    Set the project name and storage path, then click “OK” to finish.

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    Adding UI pictures
    Add the two UI icons we have prepared for the project by right-clicking on the “picture” directory.

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    Adding a button
    We want to add a function to the “Light” button on the first UI screen in the STONE TOOL software: when you click on the “Light” button, it will jump to a second page.

    Click on the “Button” icon and draw the area of the button.

    The yellow part indicates the area of the button drawn by the user. The properties of the button are listed in the properties section on the right-hand side of the STONE TOOL software.
    Simply set the “pages witch” option to 1 to switch to a second page when the button is pressed.

    Once this is done we click on “Tool” inside the “Generating configuration file”, then on “Virtual serial port screen” and we can see the virtual runtime effect.

    We then proceed to change the arrow in the top left corner of page 2 to a button.

    When the user presses this button, it returns to the first page.

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    Adding text to the display
    Using the Text variable control, circle the blank space behind “light1”.

    Then click on the Text Variable you have just added, and the properties screen will appear on the right of the STONE TOOL software, changing the following parameters.

    Among them, “Variable memory address” means the memory address where the display content is stored, an address can store two Bytes, our default display content is “OFF”, which requires three Bytes of Our default display is “OFF”, which requires three bytes of memory space, so we change “Word Length” to 4, which takes up two memory addresses. This means that we are storing “OFF” at addresses 0020 and 0021.

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    Buttons with return values
    The control we used above is “Button”, which has no return value, meaning that the serial port of the display module does not send data to the MCU when the user presses the button.
    If we want the display module to return data to the MCU when the user presses the button, we can use the “return pressed key value” control.

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    Serial communication
    Return of button values
    After downloading the program to the display module, switch on the computer and connect the serial port via USB-TTL, press the light-on button of Light1, the serial data returns: A5 5A 06 83 00 26 01 00 A8

    Press the button to switch off the light
    Serial data return: A5 5A 06 83 00 26 01 00 A9

    Description: A5 5A: Frame header
    06: instruction byte length, 83 00 26 01 00 A9 6 bytes in total (without data frame header)
    83: Read variable memory instruction
    00 26: variable memory address
    01: Data word length, 00 A9, 1 word length (2 bytes)
    00 A9: user data content, depending on the set key value
    Write register data
    The following instruction indicates that the two data 55 aa are written to address 0x0020 in the data storage area.
    0xA5 0x5A 0x05 0x82 0x00 0x20 0x55 0xaa
    As we have already set the text display storage address of Light1 to 0x0020, writing data to this address using the serial port is equivalent to changing the contents of the Light1 text display box.
    Reading register data
    The serial port sends the following command to the display module.
    0xA5 0x5A 0x03 0x83 0x00 0x20
    This means that the value of the address 0x0020 is read, which in this case means that the switch status of the light is read.

You must be logged in to reply to this topic.