{"id":151,"date":"2016-01-07T09:24:25","date_gmt":"2016-01-07T09:24:25","guid":{"rendered":"http:\/\/iict-space.heig-vd.ch\/ape\/?page_id=151"},"modified":"2016-01-14T08:43:11","modified_gmt":"2016-01-14T08:43:11","slug":"fsm_colors_example","status":"publish","type":"page","link":"http:\/\/iict-space.heig-vd.ch\/ape\/teaching\/aro1\/fsm_colors_example\/","title":{"rendered":"FSM_colors_example"},"content":{"rendered":"<p>Ce fichier doit s&#8217;appeler par exemple: <strong>FSM_colors.aesl<\/strong><\/p>\n<pre>\r\n#d\u00e9claration des variables \u00e9tat\r\nvar state[2] = [0,0]\r\nvar new_state[2] = [0,0]\r\n\r\n#initialisation \u00e0 0 des capteurs et des leds\r\ncall sound.system(-1)\r\ncall leds.top(0,0,0)\r\ncall leds.bottom.left(0,0,0)\r\ncall leds.bottom.right(0,0,0)\r\ncall leds.circle(0,0,0,0,0,0,0,0)\r\n\r\n#si un bouton est press\u00e9\r\nonevent buttons\r\nif button.center == 1 then #et qu'il s'agit de celui de centre\r\n  call leds.top(32,32,32)\r\n\r\n  new_state[0] = 1\r\n  new_state[1] = 0\r\nend\r\n\r\ncall math.copy(state, new_state)#mettre \u00e0 jour les \u00e9tats\r\n\r\n#si une secousse est ressentie\r\nonevent tap\r\n# si etat = 1\r\nif state[0] == 1 and\r\n  state[1] == 0 then\r\n  call leds.top(32,0,0)\r\n  new_state[0] = 0\r\n  new_state[1] = 1\r\nend\r\n\r\n# si etat = 2\r\nif state[0] == 0 and\r\n  state[1] == 1 then\r\n  call leds.top(0,32,0)\r\n  new_state[0] = 1\r\n  new_state[1] = 1\r\nend\r\n\r\n# si etat = 3\r\nif state[0] == 1 and\r\n  state[1] == 1 then\r\n  call leds.top(0,0,32)\r\n  new_state[0] = 1\r\n  new_state[1] = 0\r\nend\r\n\r\ncall math.copy(state, new_state)#mettre \u00e0 jour les \u00e9tats\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ce fichier doit s&#8217;appeler par exemple: FSM_colors.aesl #d\u00e9claration des variables \u00e9tat var state[2] = [0,0] var new_state[2] = [0,0] #initialisation \u00e0 0 des capteurs et des leds call sound.system(-1) call leds.top(0,0,0) call leds.bottom.left(0,0,0) call leds.bottom.right(0,0,0) call leds.circle(0,0,0,0,0,0,0,0) #si un bouton <a class=\"more-link\" href=\"http:\/\/iict-space.heig-vd.ch\/ape\/teaching\/aro1\/fsm_colors_example\/\">Continue reading <span class=\"screen-reader-text\">  FSM_colors_example<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"parent":140,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/pages\/151"}],"collection":[{"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":8,"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/pages\/151\/revisions"}],"predecessor-version":[{"id":183,"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/pages\/151\/revisions\/183"}],"up":[{"embeddable":true,"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/pages\/140"}],"wp:attachment":[{"href":"http:\/\/iict-space.heig-vd.ch\/ape\/wp-json\/wp\/v2\/media?parent=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}