REM >ytchtest REM tests Yogi's touchscreen boxes REM REM 20 August 99 PROCinit :REM Arachnid init PROCkill_all :REM Arachnid init LIBRARY ".ProgLibs.Arachnid" LIBRARY ".ProgLibs.BoxConst" LIBRARY ".ProgLibs.JP" :REM touchscreen input library LIBRARY ".ProgLibs.YogiLib": PROCyogi_touchscreen_boxes debug%=0 :REM Report characters coming from touchscreen. touch_debug%=0 :REM Internal reports from touchscreen library. superlabels%=1 :REM 0=coordinates, 1=superlabels with two-rectangle mask. stylusreport%=0 :REM 1=report on/off, 0=report on only DIM left_count%(nboxes%), middle_count%(nboxes%), right_count%(nboxes%) DIM central_np_count%(nboxes%),wall_np_count%(nboxes%) DIM floor_panel_count%(nboxes%) REM ================================= REM Initialize screen REM ================================= MODE 8:CLS PRINT "ytchtest - Yogi's touchscreen testing program, by RNC, 22-Aug-99" PRINT "Press Q to quit." PRINT "Debug = ";debug%;", touch_debug = ";touch_debug%;", superlabels = ";superlabels%;", stylus report = ";stylusreport% PRINT PRINT "OUTPUT STATUS:" PRINT " A. Houselight" PRINT " B. Central pellet" PRINT " C. Wall pellet" PRINT PRINT "INPUT COUNT:" PRINT " Central nosepoke" PRINT " Wall nosepoke" PRINT " Right sensor" PRINT " Middle sensor" PRINT " Left sensor" PRINT " Floor panel" PRINT PRINT "To operate, press 1-";nboxes%;" to control a box and A-C to switch an output." PRINT "Currently controlling box ." FOR box%=1 TO nboxes% PRINT TAB(29+7*(box%-1),4) "Box-";box% NEXT REM ========================================== REM Init hardware, assign events and run REM ========================================== PROCpipe_keybd(0,0,0,"FNkeyboard_handler(",0,E%) FOR box%=1 TO nboxes% PROCpipe_switch(floor_panel%(box%),On,1,"FNfloor_panel(",box%,E%) PROCpipe_switch(central_mag_nosepoke%(box%),On,1,"FNcentral_np(",box%,E%) PROCpipe_switch(wall_mag_nosepoke%(box%),On,1,"FNwall_np(",box%,E%) PROCpipe_switch(right_sensor_nosepoke%(box%),On,1,"FNright_sensor(",box%,E%) PROCpipe_switch(middle_sensor_nosepoke%(box%),On,1,"FNmiddle_sensor(",box%,E%) PROCpipe_switch(left_sensor_nosepoke%(box%),On,1,"FNleft_sensor(",box%,E%) NEXT IF superlabels%=1 THEN PROCtwo_rectangle_mask(touchscreen_channel%) IF stylusreport%=1 THEN PROCenable_stylus_status(touchscreen_channel%) PROCregister_coordinate_handler(touchscreen_channel%,"FNtest_coord(") PROCregister_superlabel_handler(touchscreen_channel%,"FNtest_superlabel(") window_x%=0 window_y%=POS PROCswitch_to_window IF debug%=1 THEN PRINT "Debugging... everything coming from the touchscreen will be printed." IF touch_debug%=1 THEN PRINT "Touchscreen internal debugging... loads of crap comes out." dummy%=FNcurrent_box(1) REM PROCwait(E%): *AE PROCignore_serial_error_wait PROCout_of_window PRINT TAB(0,31) END DEF FNtest_coord(x%, y%, on_off%) PRINT "Coordinate report: X=";x%;", Y=";y%;", on/off=";on_off% =0 DEF FNtest_superlabel(label$, on_off%) PRINT "Superlabel report: label=";label$;", on/off=";on_off% =0 REM ============================================ REM ******************************************** REM ============================================ DEF FNkeyboard_handler(P%,R%) IF R%=0 =0 key% = GET IF key%>=ASC("a") AND key%<=ASC("z") THEN key%-=32 IF key%>=ASC("1") AND key%<=ASC("9") =FNcurrent_box(key%-ASC("0")) IF key% = ASC("A") =FNhouselight(current_box%) IF key% = ASC("B") =FNcentral_pellet(current_box%) IF key% = ASC("C") =FNwall_pellet(current_box%) IF key% = ASC("Q") =FNend(P%,R%) =0 DEF FNcurrent_box(box%) IF box%<1 OR box%>nboxes% =0 current_box%=box% PROCout_of_window PRINT TAB(26,18);current_box% PROCswitch_to_window =0 REM -------------------------------------- OUTPUTS DEF FNhouselight(box%) LOCAL i$ PROCswitch_over(houselight%(box%),E%) IF FNswitch(houselight%(box%),E%)=On THEN i$="X" ELSE i$=" " PROCout_of_window PRINT TAB(29+7*(box%-1),5); i$ PROCswitch_to_window =0 DEF FNcentral_pellet(box%) LOCAL i$ PROCswitch_over(central_pellet_dispenser%(box%),E%) IF FNswitch(central_pellet_dispenser%(box%),E%)=On THEN i$="X" ELSE i$=" " PROCout_of_window PRINT TAB(29+7*(box%-1),6); i$ PROCswitch_to_window =0 DEF FNwall_pellet(box%) LOCAL i$ PROCswitch_over(wall_pellet_dispenser%(box%),E%) IF FNswitch(wall_pellet_dispenser%(box%),E%)=On THEN i$="X" ELSE i$=" " PROCout_of_window PRINT TAB(29+7*(box%-1),7); i$ PROCswitch_to_window =0 REM -------------------------------------- INPUTS DEF FNfloor_panel(box%, R%) IF R%=0 =0 floor_panel_count%(box%)+=1 PROCout_of_window PRINT TAB(29+7*(box%-1),15); floor_panel_count%(box%) PROCswitch_to_window =0 DEF FNcentral_np(box%, R%) IF R%=0 =0 central_np_count%(box%)+=1 PROCout_of_window PRINT TAB(29+7*(box%-1),10); central_np_count%(box%) PROCswitch_to_window =0 DEF FNwall_np(box%, R%) IF R%=0 =0 wall_np_count%(box%)+=1 PROCout_of_window PRINT TAB(29+7*(box%-1),11); wall_np_count%(box%) PROCswitch_to_window =0 DEF FNright_sensor(box%, R%) IF R%=0 =0 right_count%(box%)+=1 PROCout_of_window PRINT TAB(29+7*(box%-1),12); right_count%(box%) PROCswitch_to_window =0 DEF FNmiddle_sensor(box%, R%) IF R%=0 =0 middle_count%(box%)+=1 PROCout_of_window PRINT TAB(29+7*(box%-1),13); middle_count%(box%) PROCswitch_to_window =0 DEF FNleft_sensor(box%, R%) IF R%=0 =0 left_count%(box%)+=1 PROCout_of_window PRINT TAB(29+7*(box%-1),14); left_count%(box%) PROCswitch_to_window =0 REM -------------------------------------- DEF FNend(N%,R%) IF R%=0 =0 PROCkill_all =0 REM _____________________________ DEF PROCswitch_to_window screen_x% = POS screen_y% = VPOS VDU 28,0,31,79,21 REM VDU 28,lx,by,rx,ty PRINT TAB(window_x%, window_y%); COLOUR 1 ENDPROC DEF PROCout_of_window window_x% = POS window_y% = VPOS VDU 26 COLOUR 7 PRINT TAB(screen_x%, screen_y%); ENDPROC