{"id":819,"date":"2012-09-09T20:26:11","date_gmt":"2012-09-09T18:26:11","guid":{"rendered":"http:\/\/ubik75.com\/?p=819"},"modified":"2012-09-09T20:26:11","modified_gmt":"2012-09-09T18:26:11","slug":"robotc-afficher-un-texte","status":"publish","type":"post","link":"http:\/\/ubik75.com\/?p=819","title":{"rendered":"RobotC, afficher un texte"},"content":{"rendered":"<p>Pouvoir afficher un texte sur l&rsquo;\u00e9cran du Nxt permet \u00e0 l&rsquo;utilisateur de voir certaines valeurs de variables lors de l&rsquo;ex\u00e9cution d&rsquo;un programme, afficher un menu afin de piloter diff\u00e9rents moteurs. Plusieurs fonctions existent dans RobotC, je vais vous les pr\u00e9senter.<\/p>\n<p><!--more--><\/p>\n<p><span style=\"text-decoration: underline;\">Organisation de l&rsquo;\u00e9cran d&rsquo;affichage du Nxt:<\/span><\/p>\n<p><a href=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/08\/DisplayNXT.jpg\" rel=\"lightbox\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"844\" data-permalink=\"http:\/\/ubik75.com\/?attachment_id=844\" data-orig-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/08\/DisplayNXT.jpg\" data-orig-size=\"261,369\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;ubik&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1347191520&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"DisplayNXT\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/08\/DisplayNXT-212x300.jpg\" data-large-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/08\/DisplayNXT.jpg\" class=\"aligncenter size-medium wp-image-844\" title=\"DisplayNXT\" src=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/08\/DisplayNXT-212x300.jpg\" alt=\"\" width=\"212\" height=\"300\" srcset=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/08\/DisplayNXT-212x300.jpg 212w, http:\/\/ubik75.com\/wp-content\/uploads\/2012\/08\/DisplayNXT.jpg 261w\" sizes=\"auto, (max-width: 212px) 85vw, 212px\" \/><\/a>L&rsquo;\u00e9cran poss\u00e8de 8 lignes de 0 \u00e0 7, les coordonn\u00e9es de d\u00e9part (0,0) se trouvent en bas \u00e0 gauche pour se terminer en haut \u00e0 droite (99,63).<\/p>\n<p><span style=\"text-decoration: underline;\">Les diff\u00e9rentes fonctions:<\/span><\/p>\n<ul>\n<li><strong>eraseDisplay<\/strong>();<\/li>\n<li><strong>nxtDisplayTextLine<\/strong>(&#8230;.);<\/li>\n<li><strong>nxtDisplayString<\/strong>(&#8230;);<\/li>\n<li><strong>nxtDisplayStringAt<\/strong>(&#8230;..);<\/li>\n<li><strong>nxtDisplayClearTextLine<\/strong>(..);<\/li>\n<li><strong>nxtDisplayCenteredTextLine(&#8230;);<\/strong><\/li>\n<\/ul>\n<p>La fonction <strong>eraseDisplay()<\/strong> permet d&rsquo;effacer l&rsquo;\u00e9cran.<\/p>\n<p>La fonction <strong>nxtDisplayTextLine<\/strong>(<strong><span style=\"color: #3366ff;\"> l<\/span><\/strong>, <span style=\"color: #ff6600;\">&lsquo; \u00a0 %tag&rsquo;<\/span>,<span style=\"color: #808080;\"> var<\/span>) affiche une variable<span style=\"color: #808080;\"> var<\/span> \u00e0 la ligne<strong><span style=\"color: #3366ff;\"> l<\/span><\/strong> avec une valeur de <span style=\"color: #ff9900;\">tag<\/span> en fonction du type de la variable.<\/p>\n<p><span style=\"text-decoration: underline;\">Les diff\u00e9rents types existants:<\/span><\/p>\n<ul>\n<li><strong>%d<\/strong> affiche un nombre entier, <strong>%08d<\/strong> affiche un nombre entier sur 8 d\u00e9cimales.<\/li>\n<li><strong>%f<\/strong> affiche un nombre d\u00e9cimal, <strong>%1.2f<\/strong> affiche un nombre d\u00e9cimal avec deux chiffres apr\u00e8s la virgule, <strong>%4.3f<\/strong> affiche un nombre d\u00e9cimal avec 3 chiffres apr\u00e8s la virgule et 4 chiffres avant la virgule.<\/li>\n<li><strong>%s<\/strong> affiche une chaine de caract\u00e8res.<\/li>\n<li><strong>%x<\/strong> affiche une variable en valeur hexad\u00e9cimale, <strong>%X<\/strong> la m\u00eame chose en\u00a0 grand caract\u00e8re.<\/li>\n<\/ul>\n<p>La fonction <strong>nxtDisplayString<\/strong>(<strong> l<\/strong>, &lsquo; \u00a0 %tag&rsquo;, var) est identique \u00e0 la fonction <strong>nxtDisplayTextLine<\/strong>(<strong> l<\/strong>, \u00a0\u00bb\u00a0\u00a0 %tag\u00a0\u00bb, var).<\/p>\n<p>La fonction <strong>nxtDisplayStringAt<\/strong>( <strong><span style=\"color: #3366ff;\">x, y<\/span><\/strong>,<span style=\"color: #ff9900;\"> &lsquo; \u00a0 %tag&rsquo;<\/span>, <span style=\"color: #888888;\">var<\/span>) affiche une variable <span style=\"color: #888888;\">var<\/span> aux coordonn\u00e9es (<strong><span style=\"color: #3366ff;\">x,y<\/span><\/strong>) avec une valeur de<span style=\"color: #ff9900;\"> tag<\/span> en fonction du type de la variable.<\/p>\n<p>La fonction <strong>nxtDisplayClearTextLine<\/strong>(<strong><span style=\"color: #3366ff;\"> l<\/span><\/strong> ) efface une ligne <strong><span style=\"color: #3366ff;\">l, l <\/span><\/strong><span style=\"color: #3366ff;\"><span style=\"color: #000000;\">de 0 \u00e0 7<\/span><\/span><span style=\"color: #000000;\">.<\/span><\/p>\n<p>La fonction <strong>nxtDisplayCenteredTextLine<\/strong>(&#8230;.) est identique \u00e0 la fonction <strong>nxtDisplayTextLine<\/strong>(&#8230;), le texte affich\u00e9 \u00e0 l&rsquo;\u00e9cran est centr\u00e9.<\/p>\n<p><span style=\"text-decoration: underline;\">Un programme utilisant toutes les commandes vues pr\u00e9c\u00e9demment:<br \/>\n<\/span><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nint i=11;\r\nfloat x=3.141592;\r\nchar tab&#x5B;]={'R','O','B','O','T'};\r\nstring str= &quot;Bonjour Ubik75&quot;;\r\n\r\ntask main()\r\n\r\n{\r\n\/\/ effacer l'ecran NXT\r\neraseDisplay();\r\n\r\nnxtDisplayTextLine(7,&quot;entier i:%d&quot;, i); \/\/ nbre de ligne de 0 a 7\r\n\r\nnxtDisplayString(0,&quot;%s&quot;, str);\r\nnxtDisplayCenteredTextLine(1,&quot;%s&quot;, str);\r\n\r\n\/\/ Affichage en HEXA de i=10\r\nnxtDisplayString(2,&quot;HEXA i:%x&quot;, i);\r\nnxtDisplayString(3,&quot;HEXA i:%X&quot;, i);\r\nnxtDisplayStringAt(60, 47, &quot;%d&quot;, i);\r\n\r\nnxtDisplayStringAt(20, 20, &quot;%f&quot;, x);\r\nnxtDisplayStringAt(30, 30, &quot;%1.2f&quot;, x);\r\nnxtDisplayStringAt(75, 7, &quot;%d&quot;, i);\r\n\r\nwait1Msec(5000);\r\n\/\/ effacer la ligne 0\r\nnxtDisplayClearTextLine(0);\r\n\r\nwait1Msec(10000);\r\n}\r\n<\/pre>\n<p><span style=\"text-decoration: underline;\">Photos de l&rsquo;ex\u00e9cution du programme:<\/span><a href=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01.jpg\" rel=\"lightbox\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"867\" data-permalink=\"http:\/\/ubik75.com\/?attachment_id=867\" data-orig-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01.jpg\" data-orig-size=\"800,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;3.3&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-TZ30&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1347211360&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.3&quot;,&quot;iso&quot;:&quot;400&quot;,&quot;shutter_speed&quot;:&quot;0.04&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"DisplayNXT01\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01-300x225.jpg\" data-large-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01.jpg\" class=\"aligncenter size-medium wp-image-867\" title=\"DisplayNXT01\" src=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01-300x225.jpg 300w, http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01-400x300.jpg 400w, http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT01.jpg 800w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><\/p>\n<ul>\n<li>La ligne 0 de l&rsquo;\u00e9cran correspond \u00e0 la ligne 14 du programme.<\/li>\n<li>La ligne 1 de l&rsquo;\u00e9cran correspond \u00e0 la ligne 15 du programme.<\/li>\n<li>La ligne 2 de l&rsquo;\u00e9cran correspond aux lignes 18 et 20 du programme.<\/li>\n<li>La ligne 3 de l&rsquo;\u00e9cran correspond \u00e0 la ligne 19 du programme.<\/li>\n<li>La ligne 4 de l&rsquo;\u00e9cran correspond \u00e0 la ligne 23 du programme.<\/li>\n<li>La ligne 5 de l&rsquo;\u00e9cran correspond \u00e0 la ligne 22 du programme.<\/li>\n<li>La ligne 7 de l&rsquo;\u00e9cran correspond aux lignes 12 et 24 du programme.<\/li>\n<\/ul>\n<p><a href=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02.jpg\" rel=\"lightbox\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"870\" data-permalink=\"http:\/\/ubik75.com\/?attachment_id=870\" data-orig-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02.jpg\" data-orig-size=\"800,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;3.3&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;DMC-TZ30&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1347211384&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.3&quot;,&quot;iso&quot;:&quot;400&quot;,&quot;shutter_speed&quot;:&quot;0.066666666666667&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"DisplayNXT02\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02-300x225.jpg\" data-large-file=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02.jpg\" class=\"aligncenter size-medium wp-image-870\" title=\"DisplayNXT02\" src=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02-300x225.jpg 300w, http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02-400x300.jpg 400w, http:\/\/ubik75.com\/wp-content\/uploads\/2012\/09\/DisplayNXT02.jpg 800w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><\/p>\n<ul>\n<li>La ligne 0 de l&rsquo;\u00e9cran est effac\u00e9e et correspond \u00e0 la ligne 28 du programme.<\/li>\n<\/ul>\n<p>Avec ses diff\u00e9rentes fa\u00e7ons d&rsquo;afficher une variable, vous pouvez utiliser l&rsquo;\u00e9cran du NXT afin de d\u00e9boguer vos programmes ou cr\u00e9er des menus.<\/p>\n","protected":false},"excerpt":{"rendered":"<img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"http:\/\/ubik75.com\/wp-content\/plugins\/thumbnail-for-excerpts\/tfe_no_thumb.png\" class=\"alignleft wp-post-image tfe\" alt=\"\" title=\"\" \/><p>Pouvoir afficher un texte sur l&rsquo;\u00e9cran du Nxt permet \u00e0 l&rsquo;utilisateur de voir certaines valeurs de variables lors de l&rsquo;ex\u00e9cution d&rsquo;un programme, afficher un menu afin de piloter diff\u00e9rents moteurs. Plusieurs fonctions existent dans RobotC, je vais vous les pr\u00e9senter.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6,84],"tags":[],"class_list":["post-819","post","type-post","status-publish","format-standard","hentry","category-logiciel","category-robotc"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2eCSX-dd","jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/ubik75.com\/index.php?rest_route=\/wp\/v2\/posts\/819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ubik75.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ubik75.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ubik75.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ubik75.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=819"}],"version-history":[{"count":40,"href":"http:\/\/ubik75.com\/index.php?rest_route=\/wp\/v2\/posts\/819\/revisions"}],"predecessor-version":[{"id":1034,"href":"http:\/\/ubik75.com\/index.php?rest_route=\/wp\/v2\/posts\/819\/revisions\/1034"}],"wp:attachment":[{"href":"http:\/\/ubik75.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ubik75.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ubik75.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}