STONE TFT Screen ventilator Project: HMI Design, Control Creation, Hardware Connection and Command Testing

  Introduction: This sleep ventilator screen interface uses a 5.6-inch STONE serial screen, with its own backlight, rich colors, a serial port to facilitate communication with the main control board, touch input also eliminates the keyboard, the appearance of the entire ventilator is more simple and generous. The adjustable pressure value and delay time are sliding options, which makes the operation more convenient.

  Remember “Meet the Woofers”? As shown in picture (1), in this long story, the author Roku Mu Xue writes about the lonely old man Li Keng Chen and his daughter Dabao and the dog Dumbao. Li Keng Chen first did not like the dog Dumbao, his daughter left home to work in the north, it is the dog Dumbao has been with him; but the dog always woke him up in the middle of the night, and later learned that the old man Li Keng Chen suffered from paroxysmal sleep apnea syndrome, the dog Dumbao woke up to save his life!
Meet the WoofersMeet the Woofers

  If you don’t have that smart a DOG, then you can get an Angel sleep ventilator, Figure (2). It can help you prevent apnea by opening your blocked airway during sleep with a continuous positive pressure —-CPAP mode with different weight pressure adjustment values see figure (3). You can also set a 15-60 minute delayed pressure boost (you can use sec instead of min for visualizing the effect during the demo) to bring the air pressure up gradually only after you fall asleep to avoid starting with high air pressure that will affect your sleep.
Figure (2) Main interface of sleep ventilatorFigure (2) Main interface of sleep ventilator
Figure (3) CPAP mode air pressure adjustment reference valuesFigure (3) CPAP mode air pressure adjustment reference values

  The display interface of this sleep ventilator uses a 5.6″ STONE serial touch screen with a backlight, rich colors, and a serial port for easy communication with the main control board, and the touch input also eliminates the keyboard, making the whole ventilator more simple and generous in appearance. Adjustable pressure value and delay time are sliding options – Figure (4), more convenient operation. In addition, the delay time countdown and the pressure gauge display value are shown in a special interface — Figure (5), which is intuitive and clear. The development process is recorded as follows.
Figure (4) Parameter adjustment interfaceFigure (4) Parameter adjustment interface
Figure (5) Pressure and countdown ramp-up display screenFigure (5) Pressure and countdown ramp-up display screen

  Description

  HMI and control creation instructions
Interface Download
Hardware connection and command testing
debugging code

  1、ventilator screen design and control creation instructions

  As in figure (2), enter the ventilator parameter adjustment interface through the enter button, slide up and down to adjust the air pressure value on the left, and also slide up and down to adjust the delayed boost time on the right. Click “Start” to start boosting, or delay boosting, with a red “STOP” button to leave or other needs to stop boosting at any time. Press the “Pressure gauge” button to enter the pressure display and time delay countdown display.

  You can adjust the parameter: round_rsdius: 50 on the button property page to achieve round and arc-shaped buttons. Figure (6) shows a screenshot of the properties of the “STOP” button.
Figure (6) Parameter design of the circular buttonFigure (6) Parameter design of the circular button

  The font will appear lowercase in the STONE display and larger in the PC, so design the font size as large as possible in the PC so that it doesn’t feel too small when downloaded to the screen, resulting in multiple version adjustments for font size.

  Text_selector selector design middle highlighted font than the two sides of the font is larger, the color red more conspicuous, such as ts11 property parameters see Figure (7). The actual effect is shown in Figure (4).
Figure (7) Air pressure selector parameter designFigure (7) Air pressure selector parameter design
Figure (8) Pressure gauge pointer propertiesFigure (8) Pressure gauge pointer properties

  The icon style of the pointer gauge_pointer control is selected in the image in Figure (8), the anchor point of the pointer is set by anchor_x, anchor_y, range 0.0 – 1.0. angle setting, currently set in PC -140 is pointing to air pressure 0, in the screen, the original position is in the middle 0 degrees, need program command to re-specify.

  Figure (2) and Figure (3) interface involving the name and range of controls and content needed for programming are displayed together in a unified manner for easy access during programming.

  Programming control name

  Figure (2) Parameter adjustment interface:

  Start button name = b11

  Stop button name = b12

  Pressure gauge button name = b13

  Delayed pressure boost selector button name = cb1

  Pressure selector name = ts11 range 1-20

  Delay time selector name = ts12 range 1-60
Figure (3) Pressure and countdown display screen:

  Pressure gauge pointer name = gp1 Pressure value 0: -140, 20: -110

  Min countdown name = l21

  Sec countdown name = l22

  2、Interface Download

  By clicking debug — “download” under the main menu, select the respirator folder, and a subfolder with the same name as the project will be generated (the last generated folder should be renamed before each download. Otherwise, it will return an error);

  check the dial switch on the back of the STONE serial screen to the “device” position above, and use the USB communication cable to directly connect the PC and the USB interface of the display, the PC will pop up the new disk folder, copy the subfolder of the same name of the project just generated /default/ to the “raw” folder of the display storage directory.

  3、Hardware connection and command testing

  Verify the commands to be used before programming. Connect as shown in Figure (9), check the feedback from STONE, and verify the validity of the commands through the serial assistant.

  This project involves five types of controls:

button
label
text_selector
gauge_pointer
checkbox

  We will test and verify them one by one.
Figure (9) Serial Assistant test adapter board jumper diagramFigure (9) Serial Assistant test adapter board jumper diagram

  button related:

  0x1001  button key-value actively sent down

  Key-value (last byte of the data section):

  0x01  press down button pressed

  0x02  press up button release (button complete trigger click event)

  Example:

  The parameter screen Start button (name = b11 ) is pressed to actively issue the command.

  ST<0x10 0x01 0x00 0x04 b11 0x01>ET

  The serial assistant returns hexadecimal data:     Verify OK

  53 54 3C 10 01 00 04 62 31 31 01 3E 45 54 5C 0B

  Button release (completion of button click action) active command —- as a way to 62 31 31 02 decode feasible!

  ST<0x10 0x01 0x00 0x04 b11 0x02>ET

  The serial assistant returns hexadecimal data:  Verify OK

  53 54 3C 10 01 00 04 62 31 31 02 3E 45 54 18 0B

  Note: Button b11 (ASCII code 0x62 0x31 0x31).

  Label Related:

  set_text  Set the text displayed by the label

  Example:

  Set text: (min countdown name = l21)

  ST<{“cmd_code”: “set_text”, “type”: “label”, “widget”: “l21”, “text”: “29”}>ET Verify the top screen OK

  text selector related:

  0x1081  text selector value is sent  (int type Active posting: posted as soon as the selector is adjusted)

  Data format:

  value: the last four bytes of the data section

  Example: (delayed boost time min selector control name = ts12, options: 1-60, current 16, reselect when 20)

  The hexadecimal data received by the serial assistant is.

  53 54 3C 10 81 00 08 74 73 31 32 00 00 00 14 3E 45 54 F8 4E OK

  The screen actively gives instructions viz.

  ST<0x10 0x81 0x00 0x08 ts12 0x00 0x00 0x00 0x00 0x14 >ET   ts11 current value:20 = 0x14

  gauge_pointer related:

  set_angle  Sets the rotation angle of the pointer (int type)

  Example: (barometer pointer name = gp1)

  Set the pointer angle parameter: the following are verified OK

  ST<{“cmd_code”: “set_angle”, “type”: “gauge_pointer”, “widget”: “gp1”, “angle”:-140}>ET

  ST<{“cmd_code”: “set_angle”, “type”: “gauge_pointer”, “widget”: “gp1”, “angle”:30}>ET

  ST<{“cmd_code”: “set_angle”, “type”: “gauge_pointer”, “widget”: “gp1”, “angle”:30}>ET

  ST<{“cmd_code”: “set_angle”, “type”: “gauge_pointer”, “widget”: “gp1”, “angle”:130}>ET pointer”, “widget”: “gp1”, “angle”:130}>ET

  ST<{“cmd_code”: “set_angle”, “type”: “gauge_pointer”, “widget”: “gp1”, “angle”:-110}>ET

  ST<{“cmd_code”: “set_angle”, “type”: “gauge_pointer”, “widget”: “gp1”, “angle”:0}>ET

  ST<{“cmd_code”: “set_angle”, “type”: “gauge_pointer”, “widget”: “gp1”, “angle”:270}>ET

  Checkbox related:

  The multi-select button is actively sent down when the status changes.

  0x1020  Active posting after check button value change

  Example: (delayed boost selector knob name = cb1)

  The “unchecked” serial assistant received when the value changed.

  53 54 3C 10 20 00 04 63 62 31 00 3E 45 54 AC 46

  Equivalent to a directive:

  ST<0x10 0x20 0x00 0x0D cb1 0x00 >ET  Unchecked

  When the value is changed, the “selected” serial assistant receives.

  53 54 3C 10 20 00 04 63 62 31 01 3E 45 54 50 47

  Equivalent to a directive:

  ST<0x10 0x20 0x00 0x0D cb1 0x01 >ET  selected

  With the above command tested, the next step is to program the function with confidence. Of course, the first thing is still the hardware connection. We are using the ESP32 development board to implement the communication with the STONE serial screen.

  As in Figure (10), the NodeMCU-32S development board TX0, RX0, and GND is required to connect with the STONE screen adapter board corresponding to complete the HMI information interaction.

  STONE screen interface is 232 signals, through the adapter board into the MCU interface needs TX, and RX signals, in order to level the match.

  Figure (10) on the left is the NodeMCU-32S board, blue (TX0), red (RX0) wire connected to the adapter board jumper position (next to the blue jumper removed), black even GND.
Figure (10) NodeMCU-32S development board and adapter board communication connection diagramFigure (10) NodeMCU-32S development board and adapter board communication connection diagram

  4、Debug code

  This project focuses on the decoding of buttons, multi-selector buttons, and text selectors, as well as the algorithm of the barometer pointer drive, countdown timer, and delayed boost.

  Start air pressure delay boost process, ESP32 board blue LED will flash prompt, barometer display interface air pressure pointer will simulate boost evenly turn to the target air pressure position (16cmH2O table with 160 instead), delay countdown will be dynamically displayed per second decreasing (for intuitive set 1min countdown, the actual use of the general set 15min – 60min).

  The program code below the recording has been verified, please refer to the video for the operation effect.

  Decoding Instructions.

  The barometer pointer drive algorithm uses operations between integer and floating-point numbers, and care needs to be taken to use the following operation format specification, otherwise, you will not get the correct result.
Figure (11) Rules for floating-point and integer arithmeticFigure (11) Rules for floating-point and integer arithmetic

  Video of the HMI of the ventilator screen

   

  Related posts:

  Touch Screen for Automated Feeding System
Record Medical Surgery Notes with STONE Serial LCD Screen
Arduino Tutorial: STONE STWI101WT-01 HMI Display and Arduino
Thermal Print Head for a Parking Management System Based on Raspberry Pi Pico and STONE TFT LCD
Tutorial: STONE HMI display for EV charging infrastructure project
Portable Monitor with STONE serial Touch Screen and ESP32
Arduino Tutorial for Beginners LY-F2 of Seven Star Bug +STONE Serial Screen
Control WS2812B_RGB Lamp by STONE Display Module
STONE Touch Screen+ ESP32 for Massage Chair
STONE TFT LCD Module Acceleration Gyroscope Sensor

STONE TFT Screen ventilator Project: HMI Design, Control Creation, Hardware Connection and Command Testing