Getting started with TouchGFX || STM32F750

Started by tha, May 10, 2023, 07:32:38 AM

Previous topic - Next topic

tha

เราจะใช้ the MVP design pattern เพื่อส่ง the data ไปยัง the UI. The design ถูกแสดงข้างล่าง.



•   The model อย่างใดอย่างหนึง สุ่มตัวอย่าง the data จาก the backend module, หรือรับ data นี้ผ่านทาง task อื่น.
•   The model ส่ง the data ไปยัง the presenter.
•   The presenter ส่ง data นี้ต่อไปไปยัง the view.
•   The view อัฟเดต the data บน the UI.

tha

ข้างล่างคือ the presenter source file, ซึ่งจะรับ the data จาก the model.



ที่นี่ the functions setLight และ setADC ถูกเรียกโดย the modelListener. The presenter เรียก the same functions ใน the view และส่งผ่าน the data ที่รับจาก the model ไปยัง the view.

โปรดทราบว่าฟังชั่นเหล่านี้ต้องถูกกำหนดใน the presenter header files ด้วย.

tha

ข้างล่างคือ the view source file.



•   The setLight function จะเซ็ต the visibility ของ the lightON image. The visibility จะเปลี่ยนขึ้นอยู่กับ the data ที่รับจาก
     the presenter.
•   หลังจากการเปลี่ยน the visibility, เราต้อง invalidate the image เพื่อให้การเปลี่ยนมีผล.
•   ก่อนอื่น The setADC function จะแปลงค่า, ที่รับจาก the presenter, ไปเป็น the characters.
•   เราจะ invalidate the textArea อีกครั้งเพื่อให้ค่าเหล่านี้ถูกแสดงบน the UI.

โปรดทราบว่าฟังชั่นเหล่านี้ต้องถูกกำหนดไว้ก่อนแล้วใน the Screen1View header file.


tha

                                                                                 Result

ข้างล่างคือ the gifs ที่แสดง the results.



คุณจะเห็น the UI แสดง the Light ถูก turned on เมื่อไรก็ตามที่ the button ถูกกด.



นอกจากนี้ the ADC values กำลังอัฟเดตเมื่อ the potentiometer ถูกหมุน.


tha

https://controllerstech.com/touchgfx4-sending-data-from-another-task-gauge-animation/

                              TouchGFX#4. Sending data from another task ||
                                                               Gauge || Animation

นี่เป็นบทช่วยสอนที่ 4 ใน the STM32 Touch GFX series, และวันนี้เราจะมาดูวิธีการส่ง the data จาก the MCU ไปยัง the UI อีกครั้ง. ในบทช่วยสอนก่อนหน้านี้ ฉันได้กล่าวถึงวิธีการสุ่มตัวอย่างจาก the GUI task และแสดงผล the data บน the UI.
ในบทช่วยสอนนี้ เราจะดูวิธีการสุ่มตัวอย่างจาก tasks อื่น, และจากนั้นส่ง the data ไปยัง the GUI task โดยใช้ the inter messaging system, ซึ่งจะถูกแสดงผลบน the UI ต่อไป.

ฉันจะใช้ the Gauge เพื่อแสดง the ADC value, และ the animated image ซึ่งการเคลื่อนไหวของมันสามารถถูกควบคุมโดย the button.

มาดู the touchGFX setup ก่อน.

tha

                                                                                    TouchGFX Setup

Guage Setup



•   ฉันได้เพิ่ม the gauge ให้กับ the Screen.
•   ชื่อของ the Gauge คือ "gauge1".
•   ย่านถูกเซ็ตจาก 0 ถึง 100 และค่าต่ำสุดถูกเซ็ตเป็น 0.
•   ส่วนที่เหลือของ the configuration ถูกเก็บเป็นค่าเริ่มต้น.

tha

Animated Image



•   ชื่อของ the animated image คือ "animatedImage1".
•   ฉันได้คัดลอก 60 images จาก a gif file, ดังนั้น the first image คือ frame_00 และ the last image ถูกเซ็ตเป็น frame_59.
•   ฉันได้ปิดใช้งาน the "Start on Load" ด้วย, เพื่อให้ the animation ไม่สตาร์ทโดยตัวของมันเอง.
          •   แต่ฉันจะควบคุม the start และ stop โดยใช้ the button.