{"id":606,"date":"2013-09-19T10:23:00","date_gmt":"2013-09-19T07:23:00","guid":{"rendered":"http:\/\/blog.iridi.com\/en\/2013\/09\/19\/how-to-create-analogue-clocks-in-iridium-gui-editor\/"},"modified":"2018-07-18T13:26:21","modified_gmt":"2018-07-18T10:26:21","slug":"how-to-create-analogue-clocks-in-iridium-gui-editor","status":"publish","type":"post","link":"https:\/\/blog.iridi.com\/en\/how-to-create-analogue-clocks-in-iridium-gui-editor\/","title":{"rendered":"How to Create Analogue Clocks in iRidium GUI Editor"},"content":{"rendered":"<p><i>Sergey Smirnov<\/i><\/p>\n<p><i>Script programmer at iRidium mobile<\/i><\/p>\n<p>The article presents step-by-step instructions on how to create an analogue clock in <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/IRidium_GUI_Editor\" target=\"_blank\" rel=\"noopener\">iRidium GUI Editor<\/a>. To do it you need the installed <a href=\"https:\/\/s3.amazonaws.com\/iridium2_downloads\/environment\/iRidium_SETUP_2.1.exe\" target=\"_blank\" rel=\"noopener\">iRidium Environment<\/a>, some basic knowledge of <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/IRidium_GUI_Editor\" target=\"_blank\" rel=\"noopener\">iRidium GUI Editor <\/a> and <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/IRidium_Script_API\" target=\"_blank\" rel=\"noopener\">iRidium Script<\/a> scenes. There are<b> 6 steps<\/b> on the whole:<\/p>\n<ol>\n<li><a href=\"#one\">Creation of the clock face<\/a><\/li>\n<li><a href=\"#two\">Creation of the second hand<\/a><\/li>\n<li><a href=\"#three\">Creation of the minute hand<\/a><\/li>\n<li><a href=\"#four\">Creation of the hour hand<\/a><\/li>\n<li><a href=\"#five\">Fixing the hands together<\/a><\/li>\n<li><a href=\"#six\">Starting the clock<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>At the end of this article you can find a <a href=\"#seven\">list of used Editor items <\/a>and the archive with the <a href=\"https:\/\/s3.amazonaws.com\/iRidiumWiki2.0\/i2Scripts\/Lessons\/Clock+iRidium.zip\" target=\"_blank\" rel=\"noopener\">ready-for-work project.<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4 style=\"text-align: center;\"><a name=\"one\"><\/a>Creation of the clock face<\/h4>\n<p>1. <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Creating_Graphic_Items_.28Draw_Item.29\" target=\"_blank\" rel=\"noopener\">Create an item <\/a> \u2013 the clock face &#8211; with the following properties:<\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/9f2\/9f2d742347b01e0b38342a97261e901b.png\" width=\"300\" height=\"170\" \/> <b>Name:<\/b> Dial<br \/>\n<b>Left:<\/b> 0<br \/>\n<b>Top:<\/b> 0<br \/>\n<b>Width:<\/b> 363<br \/>\n<b>Height:<\/b> 363<\/p>\n<p>The rest <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#General_Properties_of_Graphic_Items\" target=\"_blank\" rel=\"noopener\">properties <\/a> are by default.<\/p>\n<p>&nbsp;<\/p>\n<p>2. Set up <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#States\" target=\"_blank\" rel=\"noopener\">the item appearance:<\/a><\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/71a\/71af8c18237242d6c7878aee7595520a.png\" width=\"199\" height=\"317\" \/> <b>Color Alpha Channel:<\/b><\/p>\n<p>The property regulates the transparency of the item background. Make the background transparent, indicate <b>0<\/b>.<br \/>\n<b><\/b><\/p>\n<p><b>Image:<\/b><\/p>\n<p><a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Graphic_and_Sound_Galleries\" target=\"_blank\" rel=\"noopener\">Set<\/a> the clock face image <b>dial.png<\/b> on the graphic item.<br \/>\nThe image can be taken from <a href=\"https:\/\/s3.amazonaws.com\/iRidiumWiki2.0\/i2Scripts\/Lessons\/Clock+iRidium.zip\" target=\"_blank\" rel=\"noopener\">the archive with the ready project:<\/a>.<\/p>\n<p><b>States:<\/b><br \/>\nRemove the second item state.<\/p>\n<p>&nbsp;<\/p>\n<h4 style=\"text-align: center;\"><a name=\"two\"><\/a>Creation of the second hand:<\/h4>\n<p>1. <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Creating_Graphic_Items_.28Draw_Item.29\" target=\"_blank\" rel=\"noopener\">Create an item <\/a> \u2013 the second hand &#8211; with the following properties:<\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/17c\/17c79d403d66273bb31a46b99b1dd29f.png\" width=\"287\" height=\"165\" \/> <b>Name:<\/b> Seconds<br \/>\n<b>Left:<\/b> 179<br \/>\n<b>Top:<\/b> 45<br \/>\n<b>Width:<\/b> 5<br \/>\n<b>Height:<\/b> 272<br \/>\nThe rest <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#General_Properties_of_Graphic_Items\" target=\"_blank\" rel=\"noopener\">properties <\/a> are by default.<\/p>\n<p>&nbsp;<\/p>\n<p>2. Theory:<\/p>\n<p>At any moment the clock hand has a position defined as an angle of turning inside the clock face. Each item has an <b>Angle<\/b> property which enables turning of the item.<\/p>\n<p><b>Problem: <\/b> The characteristic feature of the <b>Angle<\/b> property is a fixed point of turning located in the item center. For the clock hand the point of turning is its lower part.<\/p>\n<p><img class=\"aligncenter\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/11a\/11ab0e2fdef64050cf3dd88d24ace88e.png\" width=\"446px\" \/><\/p>\n<p><b>on the left <\/b> &#8211; the point of turning for the clock hand, <b>on the right <\/b> &#8211; the point of turning for the item<\/p>\n<p><b>Solution: <\/b> The background of the hand item will be transparent and the image set on this item will be equal to half the item height. As a result, only half the item will be seen and the lower part of the hand will be in the item center. That will create the correct turning angle.<\/p>\n<p>3. Set up <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#States\" target=\"_blank\" rel=\"noopener\">the item appearance:<\/a><br \/>\n<img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/e92\/e9228ed3361d299e7636c1e66b046159.png\" width=\"270\" height=\"366\" \/> <b>Color Alpha Channel:<\/b>The property regulates the transparency of the item background. Make the background transparent, indicate <b>0<\/b>.<br \/>\n<b><\/b><\/p>\n<p><b>Image:<\/b><br \/>\n<a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Graphic_and_Sound_Galleries\" target=\"_blank\" rel=\"noopener\"> Set the clock face image <\/a> <b>Seconds.png<\/b> for the graphic item.<br \/>\nThe image can be got from the archive with <a href=\"https:\/\/s3.amazonaws.com\/iRidiumWiki2.0\/i2Scripts\/Lessons\/Clock+iRidium.zip\" target=\"_blank\" rel=\"noopener\">the ready project.<\/a><br \/>\n<b>Image Align:<\/b><\/p>\n<p>The image <b>Seconds.png<\/b> has smaller height than the item. In order to attach the image to the upper part of the item indicate <b>top-middle<\/b>.<\/p>\n<p><b><\/b><b>States:<\/b>Remove the second item state.<\/p>\n<p>&nbsp;<\/p>\n<p>4. Calculations:<\/p>\n<p>Each minute has <b>60 seconds.<\/b> Therefore the second hand has <b>60 positions <\/b>on the clock face. In one minute the second hand turns <b>360 degrees<\/b>. Hereof, <b>the number of positions is less than the number of degrees.<\/b> It means the second hand moves from one position to another with a particular <b>step<\/b>.<\/p>\n<p>To calculate <b>the step <\/b>it is required to know the ratio of the number of degrees to the number of positions in one full turning: <b>360 \/ 60 = 6. <\/b>The second hand moves with <b>step 6.<\/b><\/p>\n<p><b>The Seconds <\/b>system variable returns the value from <b>0<\/b> to <b>59<\/b>, where each of the values corresponds to one of the <b>60 positions<\/b> of the hand.<\/p>\n<p>The turning angle for<b>for the second hand<\/b> is <b>Seconds * 6<\/b><\/p>\n<p>To turn the second hand, write the turning angle in the <b>Angle <\/b>property of the item.<\/p>\n<p>5. Write a script to turn the second hand:<\/p>\n<p><img class=\"herta\" src=\"http:\/\/www.iridiummobile.net\/new_include_areas\/img\/herta.png\" \/><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Clock type, as the value instead of <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">item<\/span><span style=\"font-size: 10pt; color: green;\">_<\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Seconds<\/span><span style=\"font-size: 10pt; color: green;\"> the identifier <\/span><\/p>\n<p class=\"1\"><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">\/\/ <\/span><span style=\"font-size: 10pt; color: green;\">of the second<\/span> <span style=\"font-size: 10pt; color: green;\">hand item <\/span> <span style=\"font-size: 10pt; color: green;\">is used<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">function<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> iRidium_Clock(item_Seconds)<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">{<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Function of turning the second hand<\/span><\/p>\n<p class=\"1\"><b><span style=\"font-size: 10pt; color: navy;\"> function<\/span><\/b><span style=\"font-size: 10pt;\"> CurrentTime()<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> {<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Writing the value of the current number of seconds in the <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Seconds variable<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> Seconds =<b> IR.GetVariable<\/b>(&#8220;System.Time.Seconds&#8221;);<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Calculating the turning angle for the second hand Seconds * 6<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ and writing this value in the Angle property of the item<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> item_Seconds.Angle = Seconds * 6;<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> } <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Turning of the second hand each 1000 ms <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> <b>IR.SetInterval<\/b>(1000, CurrentTime); <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">}; <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Create the clock instance where <\/span><span style=\"color: #008000; font-size: 13px;\">instead of <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">item<\/span><span style=\"font-size: 10pt; color: green;\">_<\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Seconds we receive <\/span><span style=\"color: green; font-size: 10pt;\">the item identifier<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; line-height: 115%; font-family: Calibri, sans-serif; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt; line-height: 115%; font-family: Calibri, sans-serif;\"> iRidium_Clock_1 = <b><span style=\"color: navy;\">new<\/span><\/b> iRidium_Clock(<b>IR.GetItem<\/b>(&#8220;Page 1&#8221;)<b>.GetItem<\/b>(&#8220;Seconds&#8221;));<\/span><\/p>\n<p><img class=\"herta\" src=\"http:\/\/www.iridiummobile.ru\/new_include_areas\/img\/herta.png\" \/><\/p>\n<p><b>Note that<\/b> in the last string the receipt of the item identifier consists <b>of two parts: <\/b><\/p>\n<ul>\n<li><b>&#8220;Page 1&#8221;<\/b> \u2013 name of the page with the second hand item. <b>Check<\/b> if you have <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Project_Pages_and_Popup_Pages\">the same page name.<\/a> If you have a different page name you should write it instead of <b>&#8220;Page 1&#8221;<\/b>.<\/li>\n<li><b>&#8220;Seconds&#8221;<\/b> \u2013 the name of the second hand item<\/li>\n<\/ul>\n<h4 style=\"text-align: center;\">Creation of the minute hand:<\/h4>\n<p>&nbsp;<\/p>\n<p>1. <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Creating_Graphic_Items_.28Draw_Item.29\" target=\"_blank\" rel=\"noopener\">Create an item <\/a> &#8211; the minute hand &#8211; with the following properties:<\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/512\/512cd6bcd7705d24a2960c11d69af024.png\" width=\"264\" height=\"151\" \/> <b>Name:<\/b> Minutes<br \/>\n<b>Left:<\/b> 177<br \/>\n<b>Top:<\/b> 45<br \/>\n<b>Width:<\/b> 8<br \/>\n<b>Height:<\/b> 272<br \/>\nThe rest <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#General_Properties_of_Graphic_Items\" target=\"_blank\" rel=\"noopener\">properties<\/a> are by default.<\/p>\n<p>&nbsp;<\/p>\n<p>2. 2. Set up <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#States\" target=\"_blank\" rel=\"noopener\">the item appearance:<\/a><\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/5d0\/5d0368b3733bc93e1116035e07e441da.png\" width=\"236\" height=\"320\" \/><b><\/b><\/p>\n<p><b>Color Alpha Channel:\u00a0<\/b>The property regulates the transparency of the item background. Make the background transparent, indicate <b>0<\/b>.<br \/>\n<b><\/b><\/p>\n<p><b>Image:\u00a0<\/b><a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Graphic_and_Sound_Galleries\" target=\"_blank\" rel=\"noopener\">Set the clock face<\/a> image <b>Minutes.png <\/b> on the graphic item.<br \/>\n<b>The image<\/b> can be taken from the archive with the ready <a href=\"https:\/\/s3.amazonaws.com\/iRidiumWiki2.0\/i2Scripts\/Lessons\/Clock+iRidium.zip\" target=\"_blank\" rel=\"noopener\">project.<\/a><br \/>\n<b>Image Align:<\/b><\/p>\n<p>The image <b>Minutes.png<\/b> has smaller height than the item. In order to attach the image to the upper part of the item indicate <b>top-middle<\/b><br \/>\n<b><\/b><\/p>\n<p><b>States:\u00a0<\/b>Remove the second item state.<br \/>\n3. Calculations:<\/p>\n<p>The turning of <b>the minute <\/b> hand is calculated similarly to the one of the second hand. <b>The minute<\/b> hand has <b>60<\/b> positions and moves with the step <b>6<\/b>. The <b>Minutes<\/b> system variable returns the value from <b>\u043e\u0442 0 to 59<\/b>, where each of the values corresponds to one of the <b>60<\/b> positions of the hand.<\/p>\n<p><b>Minutes * 6<\/b><\/p>\n<p>But every second the minute hand makes a small step to the new position. So each position of the minute hand has <b>60 smaller positions <\/b> in it. And in one second the minute hand moves to one smaller position.<\/p>\n<p>As it was mentioned before, the <b>Seconds<\/b> system variable returns the position of the second hand. But to make it smaller we have to mark it down:<\/p>\n<p><b>Seconds \/ 10<\/b><\/p>\n<p><img class=\"aligncenter\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/1ad\/1ade5556e1802839871589a1941c0d61.png\" width=\"320px\" \/><\/p>\n<div class=\"clear\"><\/div>\n<p>The turning angle for the minute hand is<b>Minutes * 6 + Seconds \/ 10;<\/b><\/p>\n<p>To turn the minute hand, write the turning angle in the <b>Angle<\/b> property of the item.<\/p>\n<p>4. Write a script to turn the minute hand:<\/p>\n<p><img class=\"herta\" src=\"http:\/\/www.iridiummobile.net\/new_include_areas\/img\/herta.png\" \/><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Clock type, as the values, instead of <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">item<\/span><span style=\"font-size: 10pt; color: green;\">_<\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Seconds<\/span><span style=\"font-size: 10pt; color: green;\"> and <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">item<\/span><span style=\"font-size: 10pt; color: green;\">_<\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Minutes<\/span><span style=\"font-size: 10pt; color: green;\"> the identifiers<\/span><\/p>\n<p class=\"1\"><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">\/\/ <\/span><span style=\"font-size: 10pt; color: green;\">of the<\/span> <span style=\"font-size: 10pt; color: green;\">second<\/span> <span style=\"font-size: 10pt; color: green;\">and<\/span> <span style=\"font-size: 10pt; color: green;\">minute<\/span> <span style=\"font-size: 10pt; color: green;\">hand items are used<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">function<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> iRidium_Clock(item_Seconds, item_Minutes)<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">{<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Function of turning the second and minute hands<\/span><\/p>\n<p class=\"1\"><b><span style=\"font-size: 10pt; color: navy;\">function<\/span><\/b><span style=\"font-size: 10pt;\"> CurrentTime()<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> {<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Writing the value of the current number of seconds in the Seconds variable <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Seconds<\/span><\/p>\n<p class=\"1\"><b> <\/b><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> Seconds =<b> IR.GetVariable<\/b>(&#8220;System.Time.Seconds&#8221;);<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Writing the value of the current number of minutes in the Minutes variable <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Minutes<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> Minutes =<b> IR.GetVariable<\/b>(&#8220;System.Time.Minutes&#8221;);<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Calculating the angle of turning the second hand Seconds * 6<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ and writing this value in the Angle property of the item<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> item_Seconds.Angle = Seconds * 6;<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Calculating the turning angle for the minute hand Minutes * 6 + Seconds \/ 10 <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Minutes<\/span><span style=\"font-size: 10pt; color: green;\"> * 6 + <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Seconds<\/span><span style=\"font-size: 10pt; color: green;\"> \/ 10<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ and writing this value in the Angle property of the item<\/span><\/p>\n<p class=\"1\"><span lang=\"EN-US\" style=\"font-size: 10pt;\">item_Minutes.Angle = Minutes * 6 + Seconds \/ 10<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">} <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Turn the second and minute hand each 1000 ms <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> <b> IR.SetInterval<\/b>(1000, CurrentTime); <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">}; <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Create the clock instance and receive identifiers of the Seconds and Minutes items <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Seconds<\/span><span style=\"font-size: 10pt; color: green;\"> \u0438 <\/span><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">Minutes<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; line-height: 115%; font-family: Calibri, sans-serif; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt; line-height: 115%; font-family: Calibri, sans-serif;\"> iRidium_Clock_1 = <b><span style=\"color: navy;\">new<\/span><\/b> iRidium_Clock(<b>IR.GetItem<\/b>(&#8220;Page 1&#8221;)<b>.GetItem<\/b>(&#8220;Seconds&#8221;),<b>IR.GetItem<\/b>(&#8220;Page 1&#8221;)<b>.GetItem<\/b>(&#8220;Minutes&#8221;));<\/span><\/p>\n<p><img class=\"herta\" src=\"http:\/\/www.iridiummobile.net\/new_include_areas\/img\/herta.png\" \/><\/p>\n<p><b>Note that<\/b> that in the last string the receipt of the item identifiers consists of <b>two parts:<\/b><\/p>\n<ul>\n<li><b>&#8220;Page 1&#8221;<\/b> \u2013 the name of the page with the second hand item. <b>Check<\/b> if you have the same <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Project_Pages_and_Popup_Pages\">page name<\/a> If you have a different page name you should write it instead of <b>&#8220;Page 1&#8221;<\/b>.<\/li>\n<li><b>&#8220;Seconds&#8221;<\/b> \u2013 the name of the second hand item<\/li>\n<li><b>&#8220;Minutes&#8221;<\/b> \u2013 the name of the minute hand item<\/li>\n<\/ul>\n<h4 style=\"text-align: center;\">Creation of the hour hand:<\/h4>\n<p>1. <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Creating_Graphic_Items_.28Draw_Item.29\" target=\"_blank\" rel=\"noopener\">Create an item <\/a> &#8211; the hour hand &#8211; with the following properties:<\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/d48\/d480bf0c83f24e2df8f91f77daeee95c.png\" width=\"287\" height=\"153\" \/> <b>Name:<\/b> Hour<br \/>\n<b>Left:<\/b> 176<br \/>\n<b>Top:<\/b> 85<br \/>\n<b>Width:<\/b> 11<br \/>\n<b>Height:<\/b> 189<br \/>\nThe rest <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#General_Properties_of_Graphic_Items\" target=\"_blank\" rel=\"noopener\">properties<\/a> are by default.<\/p>\n<p>2. Set up <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#States\" target=\"_blank\" rel=\"noopener\">the item appearance:<\/a><\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/d88\/d8838406482e0fbe382b2e68e32363d3.png\" width=\"292\" height=\"388\" \/><b>Color Alpha Channel:<\/b><br \/>\nThe property regulates the transparency of the item background. Make the background transparent, indicate <b>0<\/b>.<br \/>\n<b>Image:<\/b><br \/>\n<a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Graphic_and_Sound_Galleries\" target=\"_blank\" rel=\"noopener\">Set the clock face image <\/a><b>Hour.png <\/b> on the graphic item.<br \/>\n<b>The image <\/b> can be taken from the archive <a href=\"https:\/\/s3.amazonaws.com\/iRidiumWiki2.0\/i2Scripts\/Lessons\/Clock+iRidium.zip\" target=\"_blank\" rel=\"noopener\">with the ready project.<\/a><\/p>\n<p><b>Image Align:<\/b><br \/>\nThe image <b>Hour.png<\/b> has smaller height than the item. In order to attach the image to the upper part of the item indicate <b>top-middle.<\/b><br \/>\n<b>States:<\/b><br \/>\nRemove the second item state.<\/p>\n<p>3. Calculations:<\/p>\n<p>The <b>Hour<\/b> system variable returns a value in the range from <b>0 to 11<\/b>. Each value corresponds to one of the <b>12 positions <\/b>of the hour hand. Another number of positions means another step of moving.<\/p>\n<p><b>360 \/ 12 = 30<\/b>, the hour hand moves <b>with step 30<\/b>.<\/p>\n<p><b>Hour * 30<\/b><\/p>\n<p>All other calculations are performed <b>similarly<\/b> to the ones for <b>the minute hand<\/b>.<\/p>\n<p><b>Minutes \/ 10<\/b><\/p>\n<p><img class=\"aligncenter\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/5d1\/5d1d8d3775dac198753c33233dfb4a10.png\" width=\"320px\" \/><\/p>\n<div class=\"clear\"><\/div>\n<p>The turning angle for the minute hand is <b>Hour * 30 + Minutes \/ 10;<\/b><\/p>\n<p>To turn the hour hand, write the received value in the <b>Angle <\/b>property of the item.<\/p>\n<p>4. Write a script to turn the hour hand:<\/p>\n<p><img class=\"herta\" src=\"http:\/\/www.iridiummobile.net\/new_include_areas\/img\/herta.png\" \/><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Clock type, as values, instead of item_Seconds, item_Minutes, item_Hour identifiers <\/span><\/p>\n<p class=\"1\"><span lang=\"EN-US\" style=\"font-size: 10pt; color: green;\">\/\/ <\/span><span style=\"font-size: 10pt; color: green;\">of the second, minute and hour<\/span> <span style=\"font-size: 10pt; color: green;\">hand items are used<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">function<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> iRidium_Clock(item_Seconds, item_Minutes, item_Hour)<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">{<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Function of turning all hands<\/span><\/p>\n<p class=\"1\"><b><span style=\"font-size: 10pt; color: navy;\"> function<\/span><\/b><span style=\"font-size: 10pt;\"> CurrentTime()<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> {<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Writing the value of the current number of seconds in the Seconds variable<\/span><\/p>\n<p class=\"1\"><b> <\/b><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> Seconds = <b>IR.GetVariable<\/b>(&#8220;System.Time.Seconds&#8221;);<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Writing the value of the current number of minutes in the Minutes variable<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt;\"> Minutes = <b>IR.GetVariable<\/b>(&#8220;System.Time.Minutes&#8221;);<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Writing the value of the current number of hours in the Hour variable<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; color: navy;\">var<\/span><\/b> <span lang=\"EN-US\" style=\"font-size: 10pt;\">Hour =<b> IR.GetVariable<\/b>(&#8220;System.Time.Hour&#8221;);<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Calculating the turning angle for the second hand Seconds * 6<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ and writing this value in the Angle property of the item<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> item_Seconds.Angle = Seconds * 6;<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Calculating the turning angle for the minute hand Minutes * 6 + Seconds \/ 10<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ and writing this value in the Angle property of the item<\/span><\/p>\n<p class=\"1\"><span lang=\"EN-US\" style=\"font-size: 10pt;\">item_Minutes.Angle = Minutes * 6 + Seconds \/ 10;<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Calculating the turning angle for the hour hand Hour * 30 + Minutes \/ 10<\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ and writing this value in the Angle property of the item<\/span><\/p>\n<p class=\"1\"><span lang=\"EN-US\" style=\"font-size: 10pt;\">item_Hour.Angle = Hour * 30 + Minutes \/ 10; <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">} <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\"> \/\/ Turning all hands each 1000 ms <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\"> <b> IR.SetInterval<\/b>(1000, CurrentTime); <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt;\">}; <\/span><\/p>\n<p class=\"1\"><span style=\"font-size: 10pt; color: green;\">\/\/ Create the clock instance and receive identifiers of all hands<\/span><\/p>\n<p class=\"1\"><b><span lang=\"EN-US\" style=\"font-size: 10pt; line-height: 115%; font-family: Calibri, sans-serif; color: navy;\">var<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10pt; line-height: 115%; font-family: Calibri, sans-serif;\"> iRidium_Clock_1 = <b><span style=\"color: navy;\">new<\/span><\/b> iRidium_Clock(<b>IR.GetItem<\/b>(&#8220;Page 1&#8221;)<b>.GetItem<\/b>(&#8220;Seconds&#8221;),<b>IR.GetItem<\/b>(&#8220;Page 1&#8221;)<b>.GetItem<\/b>(&#8220;Minutes&#8221;),<b>IR.GetItem<\/b>(&#8220;Page 1&#8221;)<b>.GetItem<\/b>(&#8220;Hour&#8221;));<\/span><\/p>\n<p><img class=\"herta\" src=\"http:\/\/www.iridiummobile.net\/new_include_areas\/img\/herta.png\" \/><\/p>\n<div class=\"clear\"><\/div>\n<p><b>Note that <\/b> in the last string the receipt of each item identifier consists of <b>two parts:<\/b><\/p>\n<ul>\n<li><b>&#8220;Page 1&#8221;<\/b> \u2013 the name of the page with the second hand item. <b>Check<\/b> if you have the same <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Project_Pages_and_Popup_Pages\">page name<\/a>. If you have a different page name you should write it instead of <b>&#8220;Page 1&#8221;<\/b>.<\/li>\n<li><b>&#8220;Seconds&#8221;<\/b> \u2013 the name of the second hand item<\/li>\n<li><b>&#8220;Minutes&#8221;<\/b> \u2013 the name of the minute hand item<\/li>\n<li><b>&#8221; Hour&#8221;<\/b> \u2013 the name of the hour hand item<\/li>\n<\/ul>\n<h4 style=\"text-align: center;\">Fixing the hands together:<\/h4>\n<p>1. <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Creating_Graphic_Items_.28Draw_Item.29\" target=\"_blank\" rel=\"noopener\">Create an item<\/a> &#8211; the mount for the hands &#8211; with the following properties:<\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/587\/5875b8dabaeda7777dd365e1b7f136fc.png\" width=\"303\" height=\"171\" \/> <b>Name:<\/b> Mount<br \/>\n<b>Left:<\/b> 164<br \/>\n<b>Top:<\/b> 163<br \/>\n<b>Width:<\/b> 35<br \/>\n<b>Height:<\/b> 35<br \/>\nThe rest <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#General_Properties_of_Graphic_Items\" target=\"_blank\" rel=\"noopener\">properties<\/a> are by default.<\/p>\n<p>&nbsp;<\/p>\n<p>2. Set up <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#States\" target=\"_blank\" rel=\"noopener\">the item appearance:<\/a><\/p>\n<p><img loading=\"lazy\" class=\"alignleft\" style=\"float: left;\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/6d4\/6d4a0a67201e9faf4354b8144305b75e.png\" width=\"245\" height=\"341\" \/> <b>Color:<\/b> Set up the item color <b>#FF3A3A3A <\/b><\/p>\n<p>(<span style=\"color: #ff0000;\">R<\/span>: 58 <span style=\"color: #37b44a;\">G<\/span>:58<span style=\"color: #0000ff;\"> B<\/span>:58)<\/p>\n<p><b>Color Alpha Channel:<\/b><\/p>\n<p>The property regulates the transparency of the item background. Now we need non-transparent background, indicate <b>255<\/b>.<\/p>\n<p><b>Border:<\/b> The item should be round, so indicate <b>Circle 35<\/b><\/p>\n<h3><\/h3>\n<h4 style=\"text-align: center;\"><a name=\"six\"><\/a>Starting the clock:<\/h4>\n<p>Everything is ready and you can start the clock. Press <b>F5<\/b> or button.<\/p>\n<p><img class=\"aligncenter\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/997\/9976f39aeb51cac3fc91bd78be3f7a54.png\" width=\"100px\" \/><\/p>\n<p><img class=\"aligncenter\" src=\"https:\/\/iridiummobile.net\/upload\/medialibrary\/840\/8404ae687554514692964ceff10136bb.png\" width=\"300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4 style=\"text-align: center;\"><a name=\"seven\"><\/a>Used items:<\/h4>\n<ul>\n<li><a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/System_Tokens\" target=\"_blank\" rel=\"noopener\">system variables <\/a> System Tokens \/ Time: Hour, Minutes, Seconds<\/li>\n<li>the function for reading variables <a href=\"http:\/\/wiki2.iridiummobile.ru\/index.php\/Tokens_API#.D0.9F.D0.BE.D0.BB.D1.83.D1.87.D0.B8.D1.82.D1.8C_.D0.B4.D0.B0.D1.82.D1.83\" target=\"_blank\" rel=\"noopener\">IR.GetVariable<\/a><\/li>\n<li>the <b>Angle<\/b> property of the item<\/li>\n<li>the function of performing commands with interval <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Systems_API#IR.SetInterval\" target=\"_blank\" rel=\"noopener\">IR.SetInterval<\/a><\/li>\n<li>the function for receiving the item identifier <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/GUI_API#IR.GetItem\" target=\"_blank\" rel=\"noopener\">IR.GetItem<\/a><\/li>\n<li>5 <a href=\"http:\/\/wiki2.iridiummobile.net\/index.php\/Creating_the_Graphic_Part_of_iRidium_Projects#Types_of_Graphic_Items\" target=\"_blank\" rel=\"noopener\">graphic items<\/a><\/li>\n<li>4 images: a clock face and 3 hands<\/li>\n<\/ul>\n<p><a class=\"detail\" href=\"https:\/\/s3.amazonaws.com\/iRidiumWiki2.0\/i2Scripts\/Lessons\/Clock+iRidium.zip\">Download: Analogue clock (project) <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sergey Smirnov Script programmer at iRidium mobile The article presents step-by-step instructions on how to create an analogue clock in iRidium GUI Editor. To do<\/p>\n","protected":false},"author":2,"featured_media":1002,"comment_status":"open","ping_status":"open","sticky":false,"template":"template-centered.php","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/posts\/606"}],"collection":[{"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/comments?post=606"}],"version-history":[{"count":3,"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":1201,"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/posts\/606\/revisions\/1201"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/media\/1002"}],"wp:attachment":[{"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/media?parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/categories?post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iridi.com\/en\/wp-json\/wp\/v2\/tags?post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}