10 REM K8055_7-seg
20 REM Multiplex two 7-segment displays
30 REM Jochen Lueg
40 REM http://roevalley.com
50 REM Limavady, February 2012
60 REM Version 1.2
70
80
90 ON ERROR PROCerror
100 PROCK8055_init
110 PROCinit
120 SYS K8055_CloseDevice%,Board%
130 SYS K8055_OpenDevice%,Board%
140 PROCscreen(480,250)
150 OFF
160 PRINT
170 PRINT " Select from the following:"
180 PRINT
190 PRINT " 1 . . . . . . . . Display 1 counts from 0 to 9"
200 PRINT " 2 . . . . . . . . Display 2 counts from 0 to 9"
210 PRINT " 3 . . . . . . . . Walking segment"
220 PRINT " 4 . . . . . . . . Count from 0 to 99 on both displays"
230 PRINT
240 PRINT " R . . . . . . . . Return to this menu"
250 PRINT " Q . . . . . . . . Leave this program"
260 PRINT
270 REPEAT
280 REPEAT
290 Key$=INKEY$(0)
300 UNTIL Key$="1" OR Key$="2" OR Key$="3" OR Key$="4" OR Key$="Q" OR Key$="q"
310 IF Key$="1" PROCcount_display(2)
320 IF Key$="2" PROCcount_display(1)
330 IF Key$="3" PROCwalking_segment
340 IF Key$="4" PROCmultiplex
350 UNTIL Key$="Q" OR Key$="q"
360
370 SYS K8055_ClearAllDigital%,1
380 SYS K8055_ClearAllAnalog%,1
390 SYS K8055_CloseDevice%,1
400 SYS "FreeLibrary",K8055_Board%
410 REPEAT UNTIL INKEY(0)=-1
420 *QUIT
430 END
440
450
460 DEFPROCscreen(ScreenWidth%,ScreenHeight%)
470 SYS "SetWindowPos",@hwnd%,0,0,0,ScreenWidth%,ScreenHeight%,6
480 VDU 26
490 COLOUR 128
500 CLS
510 COLOUR 15
520 ENDPROC
530
540
550 DEFPROCcount_display(d%)
560 SYS K8055_ClearAllDigital%,1
570 SYS K8055_ClearAllAnalog%,1
580 SYS K8055_OutputAnalogChannel%,d%,255
590 REPEAT
600 FOR J%=0 TO 9
610 SYS K8055_WriteAllDigital%,N%(J%)
620 TIME=0
630 REPEAT
640 Key$=INKEY$(0)
650 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q" OR TIME >50
660 NEXT
670 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"
680 SYS K8055_ClearAllAnalog%,1
690 SYS K8055_ClearAllDigital%,1
700 ENDPROC
710
720
730 DEFPROCwalking_segment
740 SYS K8055_ClearAllAnalog%
750 SYS K8055_ClearAllDigital%
760 REPEAT
770 SYS K8055_ClearAllAnalog%
780 SYS K8055_OutputAnalogChannel%,2,255
790
800 FOR J%=1 TO 4
810 SYS K8055_WriteAllDigital%,W%(J%)
820 TIME=0
830 REPEAT
840 Key$=INKEY$(0)
850 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q" OR TIME >2
860 NEXT
870
880 SYS K8055_ClearAllAnalog%
890 SYS K8055_OutputAnalogChannel%,1,255
900 FOR J%=5 TO 8
910 SYS K8055_WriteAllDigital%,W%(J%)
920 TIME=0
930 REPEAT
940 Key$=INKEY$(0)
950 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q" OR TIME >2
960 NEXT
970 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"
980 SYS K8055_ClearAllAnalog%
990 SYS K8055_ClearAllDigital%
1000 ENDPROC
1010
1020
1030 DEFPROCmultiplex
1040 LOCAL N1%,N2%
1050 N1%=0: N2%=0
1060 SYS K8055_ClearAllAnalog%
1070 SYS K8055_ClearAllDigital%
1080 REPEAT
1090 FOR J%= 0 TO 9
1100 FOR I%=0 TO 9
1110 FOR Waste%=1 TO 8
1120 SYS K8055_WriteAllDigital%,N%(J%)
1130 SYS K8055_OutputAnalogChannel%,1,255
1140 TIME=0:REPEAT UNTIL TIME>2
1150 SYS K8055_ClearAnalogChannel%,1
1160 SYS K8055_WriteAllDigital%,N%(I%)
1170 SYS K8055_OutputAnalogChannel%,2,255
1180 TIME=0:REPEAT UNTIL TIME>2
1190 SYS K8055_ClearAnalogChannel%,2
1200 Key$=INKEY$(0)
1210 IF Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q" ENDPROC
1220 NEXT
1230 NEXT
1240 NEXT
1250 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"
1260 ENDPROC
1270
1280
1290 DEFPROCerror
1300 PRINT REPORT$;" at line ";ERL :
1310 SYS K8055_ClearAllDigital%,1
1320 SYS K8055_ClearAllAnalog%,1
1330 SYS K8055_CloseDevice%,1
1340 SYS "FreeLibrary",K8055_Board%
1350 END
1360 ENDPROC
1370
1380
1390 DEFPROCinit
1400 Board%=0
1410 T%=-3
1420
1430 DIM N%(9) : REM Pattern for numerals
1440 N%(0)=%11101110
1450 N%(1)=%01000010
1460 N%(2)=%11011100
1470 N%(3)=%11011010
1480 N%(4)=%01110010
1490 N%(5)=%10111010
1500 N%(6)=%10111110
1510 N%(7)=%11100010
1520 N%(8)=%11111110
1530 N%(9)=%11111010
1540
1550 DIM W%(8) : REM Pattern for walking segment
1560 W%(1)=%10000000
1570 W%(2)=%01000000
1580 W%(3)=%00000010
1590 W%(4)=%00001000
1600 W%(5)=%00001000
1610 W%(6)=%00000100
1620 W%(7)=%00100000
1630 W%(8)=%10000000
1640 ENDPROC
1650
1660
1670 DEFPROCK8055_init
1680 REM Typing errors in routine name do not generate an error message - they just hang up the program.
1690 REM These are all the system calls in the order found in the manual
1700 SYS"LoadLibrary","K8055D.dll" TO K8055_Board%
1710 SYS"GetProcAddress",K8055_Board%,"OpenDevice" TO K8055_OpenDevice%
1720 SYS"GetProcAddress",K8055_Board%,"CloseDevice" TO K8055_CloseDevice%
1730 SYS"GetProcAddress",K8055_Board%,"ReadAnalogChannel" TO K8055_ReadAnalogChannel%
1740 SYS"GetProcAddress",K8055_Board%,"ReadAllAnalog" TO K8055_ReadAllAnalog%
1750 SYS"GetProcAddress",K8055_Board%,"OutputAnalogChannel" TO K8055_OutputAnalogChannel%
1760 SYS"GetProcAddress",K8055_Board%,"OutputAllAnalog" TO K8055_OutputAllAnalog%
1770 SYS"GetProcAddress",K8055_Board%,"ClearAnalogChannel" TO K8055_ClearAnalogChannel%
1780 SYS"GetProcAddress",K8055_Board%,"ClearAllAnalog" TO K8055_ClearAllAnalog%
1790 SYS"GetProcAddress",K8055_Board%,"SetAnalogChannel" TO K8055_SetAnalogChannel%
1800 SYS"GetProcAddress",K8055_Board%,"SetAllAnalog" TO K8055_SetAllAnalog%
1810 SYS"GetProcAddress",K8055_Board%,"WriteAllDigital" TO K8055_WriteAllDigital%
1820 SYS"GetProcAddress",K8055_Board%,"ClearDigitalChannel" TO K8055_ClearDigitalChannel%
1830 SYS"GetProcAddress",K8055_Board%,"ClearAllDigital" TO K8055_ClearAllDigital%
1840 SYS"GetProcAddress",K8055_Board%,"SetDigitalChannel" TO K8055_SetDigitalChannel%
1850 SYS"GetProcAddress",K8055_Board%,"SetAllDigital" TO K8055_SetAllDigital%
1860 SYS"GetProcAddress",K8055_Board%,"ReadDigitalChannel" TO K8055_ReadDigitalChannel%
1870 SYS"GetProcAddress",K8055_Board%,"ReadAllDigital" TO K8055_ReadAllDigital%
1880 SYS"GetProcAddress",K8055_Board%,"ResetCounter" TO K8055_ResetCounter%
1890 SYS"GetProcAddress",K8055_Board%,"ReadCounter" TO K8055_ReadCounter%
1900 SYS"GetProcAddress",K8055_Board%,"SedtCounterDebouceTime" TO K8055_SetCounterDebounceTime%
1910 ENDPROC
|
|