//--------------------------------------------------------------------- // // Reach SLCD+/6/43 macro demo file, WQVGA landscape // 01-14-2010 // //--------------------------------------------------------------------- /* single line comments can be 'C' style or C++ style */ // blank lines are allowed //--------------------------------------------------------------------- // The BMPload program generates a macros.h file that provides // the index number for each named macro //--------------------------------------------------------------------- // MACRO #1 (first one in the file) // This is the macro that invokes the self-running demo. // It is the default value for the *DEMOMAC command, so it starts // if the SLCD is powered on with its serial port looped back to itself. //--------------------------------------------------------------------- #define power_on_loopback_demo xbbs 255 // Max bright for demo m optional_calibration // check for touch calibration m clear // set black and white colors, clear screen m splash_logos // initial splash screen and button to next #end //--------------------------------------------------------------------- // MACROS #2 - #6 // These macros implement a number pad at relative (0,0) // It assumes button BMP 10, 11 are loaded // NOTE: Button #1 is reserved ("Next") //--------------------------------------------------------------------- #define number_pad //move entire keyboard to parameter location o `0` `1` //Key output area xi 40 50 0 // set font 24 for buttons f 24 // define button text using "simple math" with argument bdc 12 0 32 1 "`(`2`+1)`" 10 11 bdc 2 48 32 1 "`(`2`+2)`" 10 11 bdc 3 96 32 1 "`(`2`+3)`" 10 11 bdc 4 0 80 1 "`(`2`+4)`" 10 11 bdc 5 48 80 1 "`(`2`+5)`" 10 11 bdc 6 96 80 1 "`(`2`+6)`" 10 11 bdc 7 0 128 1 "`(`2`+7)`" 10 11 bdc 8 48 128 1 "`(`2`+8)`" 10 11 bdc 9 96 128 1 "`(`2`+9)`" 10 11 bdc 10 0 176 1 "*" 10 11 bdc 0 48 176 1 "`2`" 10 11 bdc 11 96 176 1 "#" 10 11 #end //--------------------------------------------------------------------- // Macro to set font and color for input box display. Foregorund color // is XOR of background color to match the buttons //--------------------------------------------------------------------- #define grey24 S 333 CCC f 24 #end //--------------------------------------------------------------------- // Write text to the screen (also includes macro parameter simple math) //--------------------------------------------------------------------- #define button_text m grey24 t "`0` " `(`1`+60)` `(`2`+3)` //uses output area location + offset #end //--------------------------------------------------------------------- // This macro enables the buttons specified in number_pad macro // to write text to the screen inside a bitmap // NOTE: Button #1 is reserved ("Next") //--------------------------------------------------------------------- #define attach_buttons xa 0 p button_text 0 `0` `1` xa 12 p button_text 1 `0` `1` xa 2 p button_text 2 `0` `1` xa 3 p button_text 3 `0` `1` xa 4 p button_text 4 `0` `1` xa 5 p button_text 5 `0` `1` xa 6 p button_text 6 `0` `1` xa 7 p button_text 7 `0` `1` xa 8 p button_text 8 `0` `1` xa 9 p button_text 9 `0` `1` xa 11 p button_text # `0` `1` xa 10 p button_text * `0` `1` #end //--------------------------------------------------------------------- // This macro creates a keypad and displays the key // using previous macros //--------------------------------------------------------------------- #define keypad_demo m clear f 24BC t "Macro Parameter Simple Math Demo" 50 10 t "Key button text" 290 60 t "utilizes" 290 90 t "Simple Math" 290 120 //The third parameter is used with simple math to create button text m number_pad 130 50 0 //parms: x offset, y offset, first button number m attach_buttons 130 50 //parms are x-y offset m next_button splash_keyboard #end #define rand_draw p `R1:5` m rand_color tr `R80:399` `R15:204` `R80:399` `R15:204` `R80:399` `R15:204` m rand_color c `R80:399` `R15:174` `R10:40` :repeat #end #define rand_color s `R0:16` 1 #end #define demo_end m clear #end #define clear o 0 0 ta LT s 0 1 z #end #define next_button o 0 0 f 13B bd 1 407 227 1 "Next" 16 11 1 2 xm 1 `0` #end #define splash_logos xi 5 0 0 m next_button splash_panel #end #define splash_panel xi 6 0 0 m next_button splash_fonts #end #define splash_slcd m clear // clear screen xi 7 80 15 // show next buttton now because macro will stop on error // if CH16 font was not downloaded m next_button splash_drawing // show chinese font f 13 t "(Error - CH16 font not downloaded!!)" 133 208 utf8 on // enable UTF8 test f CH16 // select downloaded font t "Downloadable fonts: \xe4\xb8\x9c \xe4\xb8\x9a" 133 208 anic f 24B S 0f0 fff tf 0 "FLASHING TEXT" 125 125 T f 8x8 ani 1 wvr 188 ani 1 xi 27 230 145 ani 1 y 50 ani 1 wvr 188 ani 1 xi 26 230 145 ani 1 wvr 188 ani 1 xi 27 290 145 ani 1 y 50 ani 1 wvr 188 ani 1 xi 26 290 145 ani 1 wvr 188 ani 1 xi 27 350 145 ani 1 y 50 ani 1 wvr 188 ani 1 xi 26 350 145 ani 1 y 50 anie 1 ani 2 k 306 85 380 115 1 L ani 2 y 50 anie 2 k 180 75 260 125 10 u ani 3 s 0 1 ani 3 k 180 75 260 125 1 d ani 3 y 50 ani 4 s 0 1 ani 4 k 180 75 260 125 1 u ani 4 y 50 ani 5 anie 3 ani 5 y 500 ani 5 anid 3 0 ani 5 anie 4 ani 5 y 500 ani 5 anid 4 0 anie 5 S 000 fff #end #define splash_fonts m clear // clear screen f 24BC t "On-board Proportional Fonts" 90 20 sc 0 0 o 100 55 f 8 t "8 point font: quick brown fox 0123" f 16B t "\n" f 10 t "10 point: quick brown fox 0123" f 16B t "\n" f 13 t "13 point: quick brown fox 0123" f 16B t "\n" f 13B t "13 point bold: quick brown fox 0123" f 16B t "\n" f 16 t "16 point: quick brown fox 0123" f 16B t "\n" f 16B t "16 point bold: quick brown fox 0123" f 18BC t "\n18 point bold comic: quick fox 0123" t "\n" f 24 t "24 point: quick fox 0123" f 24B t "\n24 point bold: quick 01\n" f 32 t "32 point & " f 32B t "32 bold" m next_button splash_fixed_fonts #end #define splash_keyboard m clear // clear screen // clear string memory mpop -1 f 24BC t "Easy to use buttons" 54 0 f 13B // set up stateful button with macro callback m keyboard_button_display "Off" bd 2 50 24 2 "" "" 0 0 0 0 3 4 xa 2 p keyboard_button_display "On " xa 2 r keyboard_button_display "Off" // setup demo instant button bd 3 200 20 1 "Hold" 16 11 1 2 // adjust origin for keyboard o 0 72 // set font for buttons f24 // keyboard row one m drawKey 10 0 0 1 m drawKey 11 48 0 2 m drawKey 12 96 0 3 m drawKey 13 144 0 4 m drawKey 14 192 0 5 m drawKey 15 240 0 6 m drawKey 16 288 0 7 m drawKey 17 336 0 8 m drawKey 18 384 0 9 m drawKey 19 432 0 0 // keyboard row two m drawKey 20 0 48 Q m drawKey 21 48 48 W m drawKey 22 96 48 E m drawKey 23 144 48 R m drawKey 24 192 48 T m drawKey 25 240 48 Y m drawKey 26 288 48 U m drawKey 27 336 48 I m drawKey 28 384 48 O m drawKey 29 432 48 P // keyboard row three m drawKey 30 0 96 A m drawKey 31 48 96 S m drawKey 32 96 96 D m drawKey 33 144 96 F m drawKey 34 192 96 G m drawKey 35 240 96 H m drawKey 36 288 96 J m drawKey 37 336 96 K m drawKey 38 384 96 L m drawKey 39 432 96 " " // keyboard row four m drawKey 40 0 144 Z m drawKey 41 48 144 X m drawKey 42 96 144 C m drawKey 43 144 144 V m drawKey 44 192 144 B m drawKey 45 240 144 N m drawKey 46 288 144 M m drawKey 47 336 144 , m drawKey 48 432 144 - // special erase key - typematic f 16 bd 49 384 144 3 "rub" 15 16 10 11 xm 49 keyboard_erase // reset origin o 0 0 f 13B // draw cursor m keyboard_press "" // link to next screen m upper_next_button state_save_restore_demo #end #define keyboard_button_display f 13B t "`0`" 85 34 #end // drawKey // args: index x y letter #define drawKey bd `0` `1` `2` 1 "`3`" 11 9 10 11 xa `0` p keyboard_press "`3`" #end // keyboard_press // arg letter #define keyboard_press mpush "`0`" t "`M`_ " 0 57 #end #define keyboard_erase mpop 1 m keyboard_press "" #end #define splash_charts m clear // clear screen f 24BC t "Data visualization charts" 108 15 // 5 levelbars o 123 55 m levelbar_init 0 o 176 55 m levelbar_init 1 o 229 55 m levelbar_init 2 o 282 55 m levelbar_init 3 o 335 55 m levelbar_init 4 // 1 long chart o 90 155 cd 0 0 0 301 49 1 3 1 100 008 2 F00 2 0F0 2 FFF p 2 l 302 0 302 50 l 0 50 302 50 o 0 0 // link to next screen m next_button demo_strip_chart m master_flopper #end #define levelbar_init ld `0` 0 0 20 80 0 0 1 888 100 F00 65 FF0 50 0F0 p 2 l 21 0 21 81 l 0 81 21 81 lv `0` 0 #end #define master_flopper // cycle through a prime (to slide on chart) number of relative randoms. // this thing updates REALLY fast so we need to slow it down a little. // 1 w 100 lv 0 `R10:50` lv 1 `R20:60` lv 2 `R20:60` lv 3 `R20:60` lv 4 `R10:50` cv 0 `R10:20` `R40:60` `R80:100` // 2 w 100 lv 0 `R10:50` lv 1 `R40:80` lv 2 `R40:90` lv 3 `R20:80` lv 4 `R10:50` cv 0 `R10:30` `R30:50` `R60:90` // 3 w 100 lv 0 `R20:70` lv 1 `R40:60` lv 2 `R60:100` lv 3 `R20:60` lv 4 `R20:50` cv 0 `R20:40` `R40:60` `R60:80` // 4 w 100 lv 0 `R20:50` lv 1 `R20:60` lv 2 `R60:80` lv 3 `R20:60` lv 4 `R20:50` cv 0 `R20:30` `R30:60` `R70:80` // 5 w 100 lv 0 `R30:50` lv 1 `R20:100` lv 2 `R40:100` lv 3 `R20:100` lv 4 `R30:50` cv 0 `R10:30` `R50:80` `R70:100` // 6 w 100 lv 0 `R40:80` lv 1 `R20:100` lv 2 `R40:100` lv 3 `R20:100` lv 4 `R40:80` cv 0 `R10:30` `R60:90` `R60:100` // 7 w 100 lv 0 `R20:50` lv 1 `R30:60` lv 2 `R60:80` lv 3 `R30:60` lv 4 `R20:50` cv 0 `R10:30` `R30:70` `R60:100` :repeat #end #define splash_drawing xbbs 255 // make sure we are on full m clear // clear screen f 18BC t "Fast colorful drawing primitives!" 90 225 m next_button splash_info m rand_draw #end #define splash_info z xi 8 0 0 s 0 1 // change this to "m next_button demo_end" to exit the demo instead of restarting it m next_button panel_pattern m logo_bounce #end #define logo_bounce // to the right and down s 1 0 m showAt 0 0 m showAt 1 2 m showAt 2 4 m showAt 3 6 m showAt 4 8 m showAt 5 10 m showAt 6 12 m showAt 7 14 m showAt 8 16 m showAt 9 18 m showAt 10 20 m showAt 11 22 m showAt 12 24 m showAt 13 26 m showAt 14 28 m showAt 15 30 m showAt 16 32 m showAt 17 34 m showAt 18 36 m showAt 19 38 m showAt 20 40 m showAt 21 42 m showAt 22 44 m showAt 23 46 m showAt 24 48 m showAt 25 50 m showAt 26 52 m showAt 27 54 m showAt 28 56 m showAt 29 58 m showAt 30 60 m showAt 31 62 m showAt 32 64 m showAt 33 66 // to the right and up m showAt 34 64 m showAt 35 62 m showAt 36 60 m showAt 37 58 m showAt 38 56 m showAt 39 54 m showAt 40 52 m showAt 41 50 m showAt 42 48 m showAt 43 46 m showAt 44 44 m showAt 45 42 m showAt 46 40 m showAt 47 38 m showAt 48 36 m showAt 49 34 m showAt 50 32 m showAt 51 30 m showAt 52 28 m showAt 53 26 m showAt 54 24 m showAt 55 22 m showAt 56 20 m showAt 57 18 m showAt 58 16 m showAt 59 14 m showAt 60 12 m showAt 61 10 m showAt 62 8 m showAt 63 6 m showAt 64 4 m showAt 65 2 m showAt 66 0 // to the left and down m showAt 65 2 m showAt 64 4 m showAt 63 6 m showAt 62 8 m showAt 61 10 m showAt 60 12 m showAt 59 14 m showAt 58 16 m showAt 57 18 m showAt 56 20 m showAt 55 22 m showAt 54 24 m showAt 53 26 m showAt 52 28 m showAt 51 30 m showAt 50 32 m showAt 49 34 m showAt 48 36 m showAt 47 38 m showAt 46 40 m showAt 45 42 m showAt 44 44 m showAt 43 46 m showAt 42 48 m showAt 41 50 m showAt 40 52 m showAt 39 54 m showAt 38 56 m showAt 37 58 m showAt 36 60 m showAt 35 62 m showAt 34 64 m showAt 33 66 // to the left and up m showAt 32 64 m showAt 31 62 m showAt 30 60 m showAt 29 58 m showAt 28 56 m showAt 27 54 m showAt 26 52 m showAt 25 50 m showAt 24 48 m showAt 23 46 m showAt 22 44 m showAt 21 42 m showAt 20 40 m showAt 19 38 m showAt 18 36 m showAt 17 34 m showAt 16 32 m showAt 15 30 m showAt 14 28 m showAt 13 26 m showAt 12 24 m showAt 11 22 m showAt 10 20 m showAt 9 18 m showAt 8 16 m showAt 7 14 m showAt 6 12 m showAt 5 10 m showAt 4 8 m showAt 3 6 m showAt 2 4 m showAt 1 2 :repeat #end #define showAt o `0` `1` // set location wvr `1` 43 // wait for retrace xi 9 0 0 // display bitmap #end // to debug the mpush/mpop buffer #define display_memory t "`M`" #end // to debug poweron macros #define pontest beep 100 w 500 :repeat #end // startup calibration option #define optional_calibration s 0 1 z f24B // whole screen touch area xs 128 0 0 479 271 // if touched, execute macro 30 xm 128 touch_calibrate t "Touch screen to calibrate." 20 100 w 1000 t "." w 1000 t "." w 1000 t "." w 1000 xc 128 m rand_color #end // calibrate then run demo #define touch_calibrate tc m clear m splash_logos #end #define splash_fixed_fonts m clear // clear screen f 24BC t "Fixed Width Fonts Include:" 100 20 sc 0 0 o 105 55 f 4x6 t "4x6 font: quick brown fox 0123" f 8x10 t "\n" f 6x8 t "6x8 font: quick brown fox 0123" f 8x12 t "\n" f 8x8 t "8x8 font: quick brown fox 0123" f 8x12 t "\n" f 8x10 t "8x10 font: quick brown fox 0123" f 8x12 t "\n" f 8x13 t "8x13 font: quick brown fox 0123" f 8x16 t "\n" f 8x16 t "8x16 font: quick brown fox 0123" f 8x16 t "\n" f 12x24 t "12x24 font: quick 0123" f 12x24 t "\n" f 16x32i t "16x32 font: 0123" f 8x16 t "\n\n" f 32x64 t "32X64\xB0C" m next_button macro_parms #end // run demo without calibrate #define demo_nocalib m clear m splash_logos #end // demo the slider control #define demo_slider m clear // clear screen *debounce 10 // fast response for sliders f 24BC t "Slider Control Demo" 130 20 // display left slider sl 128 42 120 110 43 0 0 1 1 50 0 m slider128_update // display its value // when slider is touched, update the displayed value xm 128 slider128_update // display right slider and text sl 129 44 200 65 45 5 0 1 1 255 0 f 16 t "Move\nto\nchange\npanel\nbacklight" 300 95 // set to max sv 129 255 // implement setting m slider129_update // when slider is touched, use it to change brightness xm 129 slider129_update // link to next screen m next_button demo_sliding_compass #end // demo the sliding compass #define demo_sliding_compass m clear // clear screen f 24BC t "Sliding Compass Demo" 129 20 // compass pointer indicator tr 240 115 220 60 260 60 F00 // display initial compass slide xio 46 140 115 1 200 0 m next_button demo_meter1 m compass_slide_action #end #define compass_slide_action xbbs 255 // make sure we are on full bright from last screen //move the compass around m compass_slide_offset 5 75 m compass_slide_offset 7 75 m compass_slide_offset 9 75 m compass_slide_offset 11 75 m compass_slide_offset 13 75 m compass_slide_offset 15 75 m compass_slide_offset 17 75 m compass_slide_offset 19 75 m compass_slide_offset 21 75 m compass_slide_offset 23 75 m compass_slide_offset 25 75 m compass_slide_offset 27 75 m compass_slide_offset 29 75 m compass_slide_offset 31 75 m compass_slide_offset 33 75 m compass_slide_offset 35 75 m compass_slide_offset 37 75 m compass_slide_offset 39 75 m compass_slide_offset 41 75 m compass_slide_offset 43 75 m compass_slide_offset 45 75 m compass_slide_offset 44 75 m compass_slide_offset 45 75 m compass_slide_offset 46 75 m compass_slide_offset 47 75 m compass_slide_offset 48 75 m compass_slide_offset 49 75 m compass_slide_offset 50 75 m compass_slide_offset 51 100 m compass_slide_offset 50 75 m compass_slide_offset 49 75 m compass_slide_offset 48 75 m compass_slide_offset 47 75 m compass_slide_offset 45 75 m compass_slide_offset 43 75 m compass_slide_offset 41 75 m compass_slide_offset 39 75 m compass_slide_offset 37 75 m compass_slide_offset 35 75 m compass_slide_offset 33 75 m compass_slide_offset 31 75 m compass_slide_offset 29 75 m compass_slide_offset 27 75 m compass_slide_offset 25 75 m compass_slide_offset 23 75 m compass_slide_offset 21 75 m compass_slide_offset 19 75 m compass_slide_offset 17 75 m compass_slide_offset 15 75 m compass_slide_offset 13 75 m compass_slide_offset 11 75 m compass_slide_offset 9 75 m compass_slide_offset 7 75 m compass_slide_offset 5 75 m compass_slide_offset 3 75 m compass_slide_offset 2 75 m compass_slide_offset 1 75 m compass_slide_offset 0 75 :repeat #end #define compass_slide_offset xio 46 140 115 1 200 `0` w `1` #end #define slider128_update f 24 ta CT // text align align center top t " `L128` " 132 85 #end #define slider129_update xbbs `L129` #end // demo meter 1 #define demo_meter1 m clear // clear screen f 24BC t "Gauge Meter Demo" 130 20 m next_button demo_meter2 //Display and move meter m create_meter1 m meter_move1 #end #define create_meter1 S FF0000 FFFFFF // red needle o 160 85 // md .. needle polygon points ... md 0 47 0 0 1 10 150 50 58 234 77 75 -3 36 0 75 3 36 #end #define meter_move1 mv 0 10 mv 0 11 mv 0 12 mv 0 13 mv 0 14 mv 0 15 mv 0 16 mv 0 17 mv 0 18 mv 0 19 mv 0 20 mv 0 21 mv 0 22 mv 0 23 mv 0 24 mv 0 25 mv 0 26 mv 0 27 mv 0 28 mv 0 29 mv 0 30 mv 0 31 mv 0 32 mv 0 33 mv 0 34 mv 0 35 mv 0 36 mv 0 37 mv 0 38 mv 0 39 mv 0 40 mv 0 41 mv 0 42 mv 0 43 mv 0 44 mv 0 45 mv 0 46 mv 0 47 mv 0 48 mv 0 49 mv 0 50 mv 0 51 mv 0 52 mv 0 53 mv 0 54 mv 0 55 mv 0 56 mv 0 57 mv 0 58 mv 0 59 mv 0 60 mv 0 59 mv 0 58 mv 0 57 mv 0 56 mv 0 55 mv 0 54 mv 0 53 mv 0 52 mv 0 51 mv 0 50 :repeat #end // demo meter 2 #define demo_meter2 m clear // clear screen f 24BC t "Framed Gauge Meter Demo" 100 17 m next_button splash_slcd //Display and move meter m create_meter2 m meter_move2 #end #define create_meter2 S CC0000 000000 // dark red needle o 115 40 // md .. needle polygon points ... md 1 48 0 0 1 475 515 495 90 270 126 120 -4 0 0 78 4 0 #end #define meter_move2 mv 1 475 mv 1 476 mv 1 477 mv 1 478 mv 1 479 mv 1 480 mv 1 481 mv 1 482 mv 1 483 mv 1 484 mv 1 485 mv 1 486 mv 1 487 mv 1 488 mv 1 489 mv 1 490 mv 1 491 mv 1 492 mv 1 493 mv 1 494 mv 1 495 mv 1 496 mv 1 497 mv 1 498 mv 1 499 mv 1 500 mv 1 501 mv 1 502 mv 1 503 mv 1 504 mv 1 505 mv 1 506 mv 1 507 mv 1 508 mv 1 509 mv 1 510 mv 1 511 mv 1 512 mv 1 513 mv 1 514 mv 1 515 mv 1 514 mv 1 513 mv 1 512 mv 1 511 mv 1 510 mv 1 509 mv 1 508 mv 1 507 mv 1 506 mv 1 505 mv 1 504 mv 1 503 mv 1 502 mv 1 501 mv 1 500 mv 1 499 mv 1 498 mv 1 497 mv 1 496 mv 1 495 :repeat #end #define upper_next_button o 0 0 f 13B bd 99 407 15 1 "Next" 16 11 1 2 xm 99 `0` #end // This macro demonstrates the use macro parameters. // Refer to Software reference section, // "Macro Parameters (Arguments)". #define macro_parms m clear // clear screen f 24BC t "Macro Parameter Demo" 130 20 f 24 t "Macros can accept up to ten parameters!" 50 50 m display_parms Reach products allow you to always touch every single customer. m next_button macro_labels #end #define display_parms t "Below is the macro list:" 140 80 f 16 t "#1:`0` #2:`1` #3:`2` #4:`3` #5:`4`" 130 110 t "#6:`5` #7:`6` #8:`7` #9:`8` #10:`9`" 130 130 f 24 t "Parameters combined with text command:" 40 160 f 16 tf 0 500 "`0` `1` `2` `3` `4` `5` `6` `7` `8` `9`" 50 200 #end // This macro demonstrates the use of Labels. // Refer to Software reference section, // "Special macro arguments and commands". #define macro_labels //Common Code Area m clear // clear screen f 24BC t "Macro Label Demo" 125 20 f 24 t "Macros can contain control \":labels\"!" 70 50 bdc 0 180 100 2 "ON" "OFF" 30 31 //This line assigns a macro (with a pre-defined label) to a button state xm 0 execute_labels:s0_1 execute_labels:s0_0 m next_button keypad_demo #end #define execute_labels //Predefined labels are used when assigning a macro label to a button :s0_1 t "Macro label \"execute_labels:s0_1\" executed. " 60 200 :s0_0 t "Macro label \"execute_labels:s0_0\" executed. " 60 200 #end //--------------------------------------------------------------------- // STRIP CHART with 8 PENS //--------------------------------------------------------------------- #define demo_strip_chart m clear o 0 0 f 24B m center_cursor_horiz 12 ta CT t "New Chart Features:" f 13B m center_cursor_horiz 40 ta CT t "--Up to 8 pens--\n--Stripchart mode--" // define a strip chart with 8 pens, each with a pen width of 2: // -- index is 1 // -- corners are 70,85 and 410,214 // -- type is STRIP starting at RIGHT EDGE (3) // -- data width is 5 pixels // -- min/max data values are 0/160 // -- chart background color is a dark blue (RGB of 048) // -- pen colors are: // -- orange (F80) // -- red (F00) // -- green (0F0) // -- blue (00F) // -- purple (F0F) // -- yellow (FF0) // -- cyan (0FF) // -- white (FFF) cd 1 70 85 410 214 3 5 0 160 048 2 F80 2 F00 2 0F0 2 00F 2 F0F 2 FF0 2 0FF 2 FFF // put a black border around it, 2 pixels wide: S 000 FFF p2 r 68 83 411 215 // link to next screen m next_button demo_slider // loop on updating values until user presses Next button: m update_strip_chart #end #define update_strip_chart cv 1 `R00:20` `R20:40` `R40:60` `R60:80` `R80:100` `R100:120` `R120:140` `R140:160` w 100 :repeat #end //--------------------------------------------------------------------- // HORIZONTALLY CENTER CURSOR at given Y value //--------------------------------------------------------------------- #define center_cursor_horiz sc 240 `0` #end //--------------------------------------------------------------------- // STATE SAVE/RESTORE DEMO //--------------------------------------------------------------------- #define state_save_restore_demo m clear m center_cursor_horiz 12 f 24BC ta CT t "Drawing State\nSave/Restore Demo\n\n" f 24 ta CT t "Normal State\n" w 1000 m red_state w 1000 ta CT t "Normal Again" // link to next screen: m next_button dynamic_label_demo w 3000 :repeat #end #define red_state ss S FFF F00 f 24B ta CT t "\n\n White on Red State \n" sr #end //--------------------------------------------------------------------- // WINDOW SAVE/RESTORE DEMO not available for WQVGA, so not here :-) //--------------------------------------------------------------------- //--------------------------------------------------------------------- // This macro simply creates a pattern to check the pixel alignment. //--------------------------------------------------------------------- #define panel_pattern m clear f 24BC m center_cursor_horiz 20 ta CT t "Panel Alignment\nPattern" f 18BC m center_cursor_horiz 80 ta CT t "Make sure that lines meet\nat panel corners." m center_cursor_horiz 120 ta CT t "Supports: 480 X 272" p 1 // big X l 0 0 479 271 l 479 0 0 271 // ^ l 0 136 240 0 l 240 0 480 136 // v l 0 136 240 271 l 240 271 479 136 m next_button demo_nocalib #end //--------------------------------------------------------------------- // DEMO DYNAMIC MACRO LABELS //--------------------------------------------------------------------- #define dynamic_label_demo m clear m center_cursor_horiz 12 f 24BC ta CT t "Dynamic Labels Demo" m set_corner_points 240 100 // horiz, vert center of square m next_button text_in_box_demo m cycle_squares #end #define set_corner_points set i0 `(`0`-40)` set i1 `(`1`-40)` set i2 `(`0`+40)` set i3 `(`1`+40)` #end #define color_sqr :lbl_red r `i0` `i1` `i2` `i3` 1 F00 :lbl_yellow r `i0` `i1` `i2` `i3` 1 FF0 :lbl_green r `i0` `i1` `i2` `i3` 1 0F0 :lbl_blue r `i0` `i1` `i2` `i3` 1 00F #end #define show_cycle f 13B m center_cursor_horiz 160 // i1 + offset + 20 ta CT t " set s0 `0` \nm color_sqr:lbl_``s0``" #end #define do_cycle set s0 `0` m color_sqr:lbl_`s0` w 1000 #end #define cycle_squares m show_cycle red m do_cycle red m show_cycle yellow m do_cycle yellow m show_cycle green m do_cycle green m show_cycle blue m do_cycle blue :repeat #end //--------------------------------------------------------------------- // TEXT IN A BOX DEMO //--------------------------------------------------------------------- #define text_in_box_demo m clear m center_cursor_horiz 12 f 24BC ta CT t "Text In a Box Demo" // define corners of bounding box: m set_box_tlc:wqvga_l m set_box_brc `i0` `i1` // show the bounding box using a red, filled rectangle: r `i0` `i1` `i2` `i3` 1 F00 // draw a black border around bounding box: S 000 F00 m draw_box_border `i0` `i1` `i2` `i3` // set foreground (text) to white and background to red: S FFF F00 // set font and alignment f13B ta CT // show a message centered along each edge of the box: t "Text can be aligned," `i0` `i1` `i2` `i3` w 1000 t "rotated, or wrapped" `i0` `i1` `i2` `i3` CW w 1000 t "within a bounding" `i0` `i1` `i2` `i3` I w 1000 t "rectangle (like this)." `i0` `i1` `i2` `i3` CCW w 1000 // and show a message centered in a smaller bounding box: m make_box_smaller `i0` `i1` `i2` `i3` r `i0` `i1` `i2` `i3` 1 FFF S 000 FFF m draw_box_border `i0` `i1` `i2` `i3` S F00 FFF // red foreground (text), white background ta CC t "It can also be word wrapped and centered." `i0` `i1` `i2` `i3` WW // map next button to next demo S 000 FFF // black foreground (text), white background m next_button relative_touch_demo #end #define set_box_tlc // box is 160x160 :wqvga_l // 480x272 set i0 160 // (480-160)/2 set i1 56 // (272-160)/2 :wqvga_p // 272x480 set i0 56 // (272-160)/2 set i1 160 // (480-160)/2 :qvga_l // 320x240 set i0 80 // (320-160)/2 set i1 40 // (240-160)/2 :qvga_p // 240x320 set i0 40 // (240-160)/2 set i1 80 // (320-160)/2 #end #define set_box_brc set i2 `(`0`+159)` // x1 = x0 + width - 1 set i3 `(`1`+159)` // y1 = y0 + height - 1 #end #define draw_box_border p2 r `(`0`-2)` `(`1`-2)` `(`2`+1)` `(`3`+1)` #end #define make_box_smaller set i0 `(`0`+40)` set i1 `(`1`+40)` set i2 `(`2`-40)` set i3 `(`3`-40)` #end //--------------------------------------------------------------------- // RELATIVE TOUCH DEMO //--------------------------------------------------------------------- #define relative_touch_demo m clear m center_cursor_horiz 12 f 24BC ta CT t "Relative Touch Demo" // define corners of bounding box: m set_box_tlc:wqvga_l m set_box_brc `i0` `i1` // show the map image (160x160 bmp): xi 49 `i0` `i1` // draw a red border around the image // and label the corners in red: S F00 FFF m draw_box_border `i0` `i1` `i2` `i3` m label_corners `i0` `i1` `i2` `i3` // setup the special hotspot: S 000 FFF m setup_xxy `i0` `i1` `i2` `i3` // map next button to next demo m next_button splash_charts #end #define label_corners f 8 sc `0` `(`1`-4)` ta CB t "0,0" sc `2` `(`1`-4)` ta CB t "159,0" sc `0` `(`3`+4)` ta CT t "0,159" sc `2` `(`3`+4)` ta CT t "159,159" #end #define show_xxy m center_cursor_horiz `(`0`+16)` ta CT t " Touched: `%3 Xr`,`%-3 Yr` " #end #define setup_xxy xxy 128 `0` `1` `2` `3` xa 128 p show_xxy `3` f 13B m center_cursor_horiz `(`3`+16)` ta CT t " Touch the map " #end