Hmt.gettick() function usage: Difference between revisions
From Smart LCD
Created page with "=== background === Smart LCD provide script function, it can enhance the functionality in applications. hmt.gettick() is a MCU tick time function for timing reference. It is necessary to understand its characteristics to prevent to get hidden bug in the Lua script. ==== hmt.gettick() function ==== * provide system tick is close ms. * Using a video clip time count of 51-20=31 second; we can get on screen tick value: 3970754-4000754=30000 File:Gettick-31s.png|400x40..." |
|||
| Line 4: | Line 4: | ||
==== hmt.gettick() function ==== | ==== hmt.gettick() function ==== | ||
* provide system tick | * provide system tick close to ms. | ||
* Using a video clip time count of 51-20=31 second; we can get on screen tick value: 3970754-4000754=30000 | * Using a video clip time count of 51-20=31 second; we can get on screen tick value: 3970754-4000754=30000 | ||
| Line 52: | Line 52: | ||
-- Lua script end | -- Lua script end | ||
* The above Lua script can work | * The above Lua script can work continually over 4hour | ||
* It can do the overflow check and do the "routine process" | * It can do the overflow check and do the "routine process" | ||
* Run and check the above script at about 71minutes by a video | * Run and check the above script at about 71minutes by a video | ||
| Line 65: | Line 65: | ||
* hmt.gettick() value will be overflow | * hmt.gettick() value will be overflow | ||
* hmt.gettick() max value is 4294966 | * hmt.gettick() max value is 4294966 | ||
* As it need long time to expose the overflow it is | * As it need long time to expose the overflow it is necessary to consider the overflow decision logic | ||
=== downloads === | === downloads === | ||
Revision as of 19:27, 22 August 2025
background
Smart LCD provide script function, it can enhance the functionality in applications. hmt.gettick() is a MCU tick time function for timing reference. It is necessary to understand its characteristics to prevent to get hidden bug in the Lua script.
hmt.gettick() function
- provide system tick close to ms.
- Using a video clip time count of 51-20=31 second; we can get on screen tick value: 3970754-4000754=30000
- Using video frame count 97.015 - 44.015 = 53 second; we can get on screen tick value 4137010-4084060=52950
- hmt.gettick() max value is 4294966
hmt.gettick() application (without overflow check)
- Lua script
loop_speed=150 loop_tic=hmt.gettick() luamain = function(void) -- main loop if ((hmt.gettick() - loop_tic) >= loop_speed) then -- looping control -- routine process loop_tic=hmt.gettick() end return 0 end -- Lua script end
- The above Lua script can work normally for about 71minutes
- After then it will not execute the "routine process"
- It is easy to be over looked
hmt.gettick() application (with overflow check)
- Lua script
loop_speed=150 loop_tic=hmt.gettick() temp=0 luamain = function(void) -- main loop temp=hmt.gettick() - loop_tic -- looping control if ( (temp >= loop_speed) or (temp 'smaller_than' 0)) then -- routine process loop_tic=hmt.gettick() end return 0 end -- Lua script end
- The above Lua script can work continually over 4hour
- It can do the overflow check and do the "routine process"
- Run and check the above script at about 71minutes by a video
- The video capture 4294895(dec) and then 7(dec) which corrosed hmt.gettick() max value (4294966)
- hmt.gettick() will be overflow every 71min 35second by calculation
note.
- hmt.gettick() value will be overflow
- hmt.gettick() max value is 4294966
- As it need long time to expose the overflow it is necessary to consider the overflow decision logic
downloads
demo project: SDM-22-0008(unlock_5mode_graph_touch_n_slide)(gettick_fixed).zip
demo video: SDM-22-0008(unlock_5mode_graph_touch_n_slide).mp4

