{"id":1402,"date":"2025-04-10T11:58:08","date_gmt":"2025-04-10T11:58:08","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=1402"},"modified":"2025-04-28T08:18:58","modified_gmt":"2025-04-28T08:18:58","slug":"ui_utils-spt","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/","title":{"rendered":"ui_utils.spt"},"content":{"rendered":"\n<p>The ui_utils.spt file contains a collection of useful subroutines relating to the HMI430.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-horizontal is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-499968f5 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-text-align-center wp-element-button\" href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/ui_utils.spt\">Download ui_utils.spt<\/a><\/div>\n<\/div>\n\n\n\n<p>You&#8217;ll also need the utils.spt file<\/p>\n\n\n\n<div class=\"wp-block-buttons is-horizontal is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-499968f5 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-text-align-center wp-element-button\" href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/utils.spt\">Download utils.spt<\/a><\/div>\n<\/div>\n\n\n\n<h6 class=\"wp-block-heading\">UIsubInitialise<\/h6>\n\n\n\n<p>This subroutine should be called once at power on.\u00a0 It will register the\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/connectevent\/\">ConnectEvent<\/a>\u00a0handler.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">UIsubGetButton<\/h6>\n\n\n\n<p>This is probably the most important subroutine.&nbsp; It should be just once within a button even subroutine.&nbsp; It will return a bunch of information about the button press:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>W: x coordinate of the press<\/li>\n\n\n\n<li>Q: y coordinate of the press<\/li>\n\n\n\n<li>Y: button ID<\/li>\n\n\n\n<li>X: button pressed state<br>&nbsp;&nbsp;&nbsp; &#8211; released = 0<br>&nbsp;&nbsp;&nbsp; &#8211; pressed&nbsp; = 1<br>&nbsp;&nbsp;&nbsp; &#8211; error occurred = 4 (should never happen)<br>&nbsp; For &#8220;repeating&#8221; buttons, state may also be:<br>&nbsp;&nbsp;&nbsp; &#8211; long release = 2<br>&nbsp; &nbsp; &#8211; held&nbsp; = 3 (continues to be reported at the repeat rate while the button is being held).<br>&nbsp; Helpful hint regarding state value:<br>&nbsp;&nbsp; &#8211;&nbsp; bit 0 is the pressed\/release state<br>&nbsp;&nbsp; &#8211;&nbsp; bit 1 is true if &#8220;held&#8221;<\/li>\n<\/ul>\n\n\n\n<p>Calling this function is optional.&nbsp; If your button subroutine only responds to one specific button and only when the button is pressed, then you don&#8217;t need UIsubGetButton.<\/p>\n\n\n\n<p>However, if you are performing number entry, then each number on your keypad can be given an ID 0 thru 9.&nbsp; All these buttons can call the same subroutine as it will call UIsubGetButton to get the ID of the button.<\/p>\n\n\n\n<p>Perhaps you are controlling a water pump.&nbsp; On your LCD you may have a picture of the tank.&nbsp; In fact, the tank is a button, pressing it halfway up can set the new fill level to 50%.&nbsp; Call UIsubGetButton to determine where the user pressed the tank.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Callbacks<\/h6>\n\n\n\n<p>ui_utils.spt expects your application will have the following subroutines.&nbsp; If you don&#8217;t need them, then simply have them as stub routines, eg:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">UIsubBacklightEvent:<br>   Return<br><br>UIsubRedrawAfterCal:<br>   Return<\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">UIsubBacklightEvent<\/h6>\n\n\n\n<p>This routine will be called whenever the backlight changes state, eg from high to medium, or medium to off, or off to high.&nbsp; The parameters passed to this routine are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>x = UIBLkOff\/UIBLkMedium\/UIBLkHigh representing the backlight at off\/medium\/high levels<\/li>\n\n\n\n<li>w = backlight level (as specified in #SetBacklight().<\/li>\n<\/ul>\n\n\n\n<h6 class=\"wp-block-heading\">UIsubRedrawAfterCal<\/h6>\n\n\n\n<p>If you press on the LCD when turning it on and keep it pressed for a few more seconds, the controller will automatically start the touch screen calibration function.&nbsp; Once you have finished calibrating the touch screen, this routine will be called, allowing you to redraw your UI.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Example<\/h6>\n\n\n\n<p>Here&#8217;s an example using the&nbsp;ui_utils.spt module:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">   &lt;POWER ON&gt;<br>   ...<br>   GoSub          UIsubInitialise      ;place this at the start of your code<br>   ...<br>   ...<br><br>UIsubBacklightEvent:<br>   LoadX          UIBLkHigh             ;is the backlight..<br>   Compare                              ;..at the high level?  0 = yes, otherwise no<br>   Output         oSwDisplayLED         ;light the display button if backlight is medium or off<br>   Return<br><br>UIsubRedrawAfterCal:<br>   ;(your code to redraw your screen)<br>   Return<br><br><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">   #Include File( \"ui_utils.spt\" )              ;place this somewhere near the end of your code (or use a build script)<br><\/pre>\n\n\n\n<p>Note this function differs from its cousin in the Android world in that the &#8220;Connect&#8221; event is never sent (there&#8217;s no point, the touch screen is always connected).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ui_utils.spt file contains a collection of useful subroutines relating to the HMI430. You&#8217;ll also need the utils.spt file UIsubInitialise This subroutine should be called&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1401,"menu_order":0,"template":"","class_list":["post-1402","spl_knowledgebase","type-spl_knowledgebase","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ui_utils.spt - SPLat Controls<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ui_utils.spt - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"The ui_utils.spt file contains a collection of useful subroutines relating to the HMI430. You&#8217;ll also need the utils.spt file UIsubInitialise This subroutine should be called...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-28T08:18:58+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/\",\"name\":\"ui_utils.spt - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-10T11:58:08+00:00\",\"dateModified\":\"2025-04-28T08:18:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Product documentation\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Product documentation: Controllers\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"HMI430\/700 product documentation\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Utilities\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"ui_utils.spt\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"name\":\"SPLat Controls\",\"description\":\"OEM Embedded Machine Controllers\",\"publisher\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\",\"name\":\"SPLat Controls\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"contentUrl\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"caption\":\"SPLat Controls\"},\"image\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ui_utils.spt - SPLat Controls","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"ui_utils.spt - SPLat Controls","og_description":"The ui_utils.spt file contains a collection of useful subroutines relating to the HMI430. You&#8217;ll also need the utils.spt file UIsubInitialise This subroutine should be called...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/","og_site_name":"SPLat Controls","article_modified_time":"2025-04-28T08:18:58+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/","name":"ui_utils.spt - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-10T11:58:08+00:00","dateModified":"2025-04-28T08:18:58+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/ui_utils-spt\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Product documentation","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/"},{"@type":"ListItem","position":3,"name":"Product documentation: Controllers","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/"},{"@type":"ListItem","position":4,"name":"HMI430\/700 product documentation","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/"},{"@type":"ListItem","position":5,"name":"Utilities","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-controllers\/hmi430-700-product-documentation\/utilities\/"},{"@type":"ListItem","position":6,"name":"ui_utils.spt"}]},{"@type":"WebSite","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","name":"SPLat Controls","description":"OEM Embedded Machine Controllers","publisher":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization","name":"SPLat Controls","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","contentUrl":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","caption":"SPLat Controls"},"image":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/1402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase"}],"about":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/types\/spl_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/users\/1"}],"up":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/1401"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=1402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}