home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / FOXPRO / GAGEDE / GAGEDEMO.PRG next >
Text File  |  1993-12-14  |  22KB  |  816 lines

  1. ****************************************************************************
  2. *                              GAGEDEMO.PRG                                *
  3. *                                                                          *
  4. *                     LED Gauge Demonstration Program                      *
  5. *                                                                          *
  6. *  Author: Ed Duchesne CIS [70720,1423]                                    *
  7. *  Date: December 17, 1993                                                 *
  8. *  Requires: files - LOADFONT.EXE, LEDGAUGE.FON, NORMAL.FON                *
  9. *            FoxPro - DOS version only.  Hardware - VGA Monitor.           *
  10. ****************************************************************************
  11. ****************************************************************************
  12. *
  13. * Notes: The included files loadfont.exe, ledgauge.fon and normal.fon must
  14. * be in the current foxpro default directory or on the current path. The 
  15. * loadfont program reads the font files and replaces the character set on 
  16. * your VGA card. You must include the entire file name for the font you 
  17. * wish to use. Loadfont.exe can be used from the DOS commmand line or while 
  18. * in FoxPro: e.g. - From inside FoxPro - RUN LOADFONT LEDGAUGE.FON
  19. * From DOS Prompt - LOADFONT LEDGAUGE.FON
  20. * The Gagedemo program automatically runs loadfont at startup and shutdown.
  21. * To get a better idea of what this does scroll this file down to the
  22. * LEDStr Function (last function in this listing) and have a good look at it,
  23. * then from the Command window in FoxPro type   RUN LOADFONT LEDGAUGE.FON 
  24. * and then view the LEDStr Function again. To return to a regular font
  25. * type RUN LOADFONT NORMAL.FON or use the DOS Command MODE CO80.
  26. * Note - this only works in VGA25 mode, if you change to VGA50 for a moment
  27. * the LEDGAUGE.FON will be replaced with your regular font.
  28. * To see which characters have been changed after loading the LEDGAUGE font
  29. * file view the ASCII Chart under the 'System' menu option in FoxPro.
  30. * If you want to expand on the ideas included in this program I recommend
  31. * you download a copy of Michael J. Mefford's FONTED.COM from Compuserve.
  32. * Fonted.com allows you to create your own VGA fonts and similar to the
  33. * one used for this demo. The Fonted zip file also has a DOC file with good 
  34. * details on replacing VGA fonts.
  35. * LOADFONT.EXE was created with Borland Pascal 7.
  36. * The LOADFONT.EXE and .FON files as well as this program file may be
  37. * distributed as public domain.
  38. *
  39. * If you find any of the ideas included in this demo useful in you own
  40. * applications or have any questions about these techniques please
  41. * drop me a line or give me a call.
  42. * Ed Duchesne
  43. * 3960-76st
  44. * Edmonton,Alberta (Canada)
  45. * T6K-1V6
  46. *
  47. * CIS [70720,1423]
  48. * Phone - Day: (403) 468-1133, Evening: (403) 463-0008.
  49. ****************************************************************************
  50.  
  51.  
  52. IF Initialize()
  53.   DO Main
  54.   DO ShutDown
  55. ENDIF
  56.  
  57.  
  58. FUNCTION Initialize
  59.   SET DISPLAY TO VGA25
  60.   IF FILE('LOADFONT.EXE') AND FILE('LEDGAUGE.FON')
  61.     RUN LOADFONT.EXE LEDGAUGE.FON
  62.   ELSE
  63.     WAIT "Required File(s) LOADFONT.EXE and/or LEDGAUGE.FON not available" WINDOW
  64.     WAIT "LOADFONT.EXE,LEDGAUGE.FON and NORMAL.FON must be in default directory" WINDOW
  65.     RETURN .F.
  66.   ENDIF  
  67.   PUSH KEY CLEAR
  68.   
  69.   PUBLIC TalkSave,ColorSave,BlinkSave,EscapeSave
  70.  
  71.   
  72.   IF SET('TALK') = 'ON'
  73.     SET TALK OFF       
  74.     TalkSave = 'ON'
  75.   ELSE
  76.     TalkSave = 'OFF'
  77.   ENDIF
  78.   IF SET('BLINK') = 'OFF'
  79.     SET BLINK ON       
  80.     BlinkSave = 'OFF'
  81.   ELSE
  82.     BlinkSave = 'ON'
  83.   ENDIF
  84.   IF SET('ESCAPE') = 'ON'
  85.     SET ESCAPE OFF       
  86.     EscapeSave = 'ON'
  87.   ELSE
  88.     EscapeSave = 'OFF'
  89.   ENDIF
  90.  
  91.   ColorSave = SET('COLOR')
  92.  
  93.   SET COLOR TO W+/B
  94.   SET CURSOR OFF
  95.   CLEAR
  96. RETURN .T.
  97.  
  98. PROCEDURE Main
  99.   DO DrawMenu  && Paint menu on screen
  100.   ON KEY LABEL LEFTMOUSE DO MouseReport
  101.   * Simple event loop
  102.   DO WHILE .T.
  103.     CurrKey = INKEY(0,'M')
  104.     DO CASE
  105.       CASE CurrKey = 151
  106.         IF NOT MouseReport()
  107.           EXIT
  108.         ENDIF
  109.       CASE CurrKey = -1
  110.         DO F2Button
  111.       CASE CurrKey = -2
  112.         DO F3Button
  113.       CASE CurrKey = -3
  114.         DO F4Button            
  115.       CASE CurrKey = 27
  116.         DO QuitButton
  117.         EXIT
  118.     ENDCASE  
  119.   ENDDO
  120. RETURN
  121.  
  122. PROCEDURE Shutdown
  123.   SET TALK &TalkSave
  124.   SET COLOR TO &ColorSave
  125.   SET BLINK &BlinkSave
  126.   SET ESCAPE &EscapeSave
  127.   SET CURSOR ON
  128.   RELEASE TalkSave,ColorSave,BlinkSave,EscapeSave  
  129.   CLEAR
  130.     
  131.   POP KEY
  132.   
  133.   IF FILE('LOADFONT.EXE') AND FILE('NORMAL.FON')
  134.     RUN LOADFONT.EXE NORMAL.FON
  135.   ELSE
  136.     WAIT "Required File(s) LOADFONT.EXE and/or NORMAL.FON not available." WINDOW
  137.     WAIT "You can restore regular font with DOS Command: MODE CO80" WINDOW
  138.   ENDIF  
  139. RETURN
  140.  
  141. PROCEDURE DrawMenu
  142.   * Menu Bar
  143.   =FillArea(2,3,3,74,' ','N/W')
  144.   =DrawFrame(1,2,3,74,'W+/B','N+/B',.F.)
  145.  
  146.   * Button outlines
  147.   =DrawFrame(2,4,1,16,'W+/W','N+/W',.F.)  && F2 Button
  148.   =DrawFrame(2,22,1,16,'W+/W','N+/W',.F.)  && F3 Button
  149.   =DrawFrame(2,40,1,21,'W+/W','N+/W',.F.)  && F4 Button
  150.   =DrawFrame(2,63,1,11,'W+/W','N+/W',.F.)  && Quit Button
  151.  
  152.   * Button text
  153.   @ 3,6 SAY 'LED Gauges' COLOR N/W
  154.   @ 3,18 SAY 'F2' COLOR W+/W
  155.   @ 3,24 SAY 'Bar Gauges' COLOR N/W
  156.   @ 3,36 SAY 'F3' COLOR W+/W
  157.   @ 3,42 SAY 'Gauges Combined' COLOR N/W
  158.   @ 3,59 SAY 'F4' COLOR W+/W
  159.   @ 3,65 SAY 'Quit' COLOR N/W
  160.   @ 3,71 SAY 'ESC' COLOR W+/W
  161. RETURN
  162.  
  163. * Called when left mouse button pressed
  164. * Checks to see if mouse pointer is located over a button
  165. FUNCTION MouseReport
  166.   PRIVATE Row,Col,Trash
  167.   Row = MROW("")
  168.   Col = MCOL("")
  169.   IF Row = 3
  170.     Trash = INKEY('M') && Throw away character in buffer
  171.     IF Col > 4 AND Col < 21  && F2
  172.       DO F2Button
  173.       RETURN .T.
  174.     ENDIF
  175.     IF Col > 22 AND Col < 39  && F3
  176.       DO F3Button
  177.       RETURN .T.
  178.     ENDIF
  179.     IF Col > 40 AND Col < 62  && F4
  180.       DO F4Button
  181.       RETURN .T.
  182.     ENDIF
  183.     IF Col > 63 AND Col < 75  && Quit
  184.       DO QuitButton
  185.       RETURN .F.
  186.     ENDIF
  187.   ENDIF
  188. RETURN .T.
  189.  
  190. PROCEDURE F2Button
  191.   * Animate the button
  192.   =DrawFrame(2,4,1,16,'W+/W','N+/W',.T.)
  193.   WAIT "" TIMEOUT 0.01
  194.   =DrawFrame(2,4,1,16,'W+/W','N+/W',.F.)
  195.   DO LEDGauges 
  196. RETURN
  197.  
  198. PROCEDURE F3Button
  199.   =DrawFrame(2,22,1,16,'W+/W','N+/W',.T.)
  200.   WAIT "" TIMEOUT 0.01
  201.   =DrawFrame(2,22,1,16,'W+/W','N+/W',.F.)
  202.   DO BarGauges
  203. RETURN
  204.  
  205. PROCEDURE F4Button
  206.   =DrawFrame(2,40,1,21,'W+/W','N+/W',.T.)
  207.   WAIT "" TIMEOUT 0.01
  208.   =DrawFrame(2,40,1,21,'W+/W','N+/W',.F.)
  209.   DO BothGauges
  210. RETURN
  211.  
  212. PROCEDURE QuitButton
  213.   =DrawFrame(2,63,1,11,'W+/W','N+/W',.T.)
  214.   WAIT "" TIMEOUT 0.01
  215.   =DrawFrame(2,63,1,11,'W+/W','N+/W',.F.)
  216. RETURN
  217.  
  218.  
  219. * Display and animate a window with LED & LCD type digits
  220. PROCEDURE LEDGauges
  221.   =FillArea(7,3,16,74,' ','N/W')
  222.   =DrawFrame(6,2,16,74,'W+/B','N+/B',.F.)
  223.   @ 7,25 SAY "Press any key to stop display" COLOR N/W
  224.   =DrawFrame(8,4,8,70,'W+/W','N+/W',.T.)
  225.   
  226.   =DrawFrame(10,7,4,18,'W+/W','N+/W',.F.)
  227.   
  228.   @ 11,9 SAY "Date" COLOR N/W
  229.     
  230.   =DrawFrame(10,30,4,16,'W+/W','N+/W',.F.)
  231.   @ 11,32 SAY "Time" COLOR N/W
  232.     
  233.   =DrawFrame(10,51,4,19,'W+/W','N+/W',.F.)
  234.   @ 11,53 SAY "SSM" COLOR N/W
  235.   
  236.   
  237.   @ 19,36 SAY "Counters" COLOR N/W
  238.   =DrawFrame(18,18,2,10,'W+/W','N+/W',.T.)
  239.   =DrawFrame(18,50,2,10,'W+/W','N+/W',.T.)
  240.    
  241.   Counter1 = 0
  242.   Counter2 = -9999  
  243.   LEDRun = .T.
  244.   
  245.   SET COLOR TO G+/N
  246.   =LEDStr(12,9,DTOC(DATE()))
  247.   
  248.   ON KEY LEDRun = .F.  && Stop on any key press
  249.  
  250.   DO WHILE LEDRun
  251.     * Set Values for counters
  252.     Counter1 = Counter1 + 1
  253.     IF Counter1 > 9999
  254.       Counter1 = -9999
  255.     ENDIF
  256.     Counter2 = Counter2 + 1  
  257.     IF Counter2 > 9999
  258.       Counter2 = -9999
  259.     ENDIF
  260.     
  261.     SET COLOR TO G+/N
  262.     =LEDStr(12,32,TIME())  && Display current time
  263.     =LEDStr(12,53,STR(SECONDS(),9,2))  && Display Seconds Since Midnight 
  264.     
  265.     SET COLOR TO N/W
  266.     =LEDStr(19,19,STR(Counter1,5,0))  && Display LCD Counter 1
  267.     =LEDStr(19,51,STR(Counter2,5,0))  && Display LCD Counter 2
  268.   ENDDO
  269.   Trash = INKEY() && Throw away last keystroke
  270.   ON KEY
  271.   =FillArea(6,2,18,76,' ','W+/B')  && Erase window
  272. RETURN
  273.  
  274. * Display and animate 3 horizontal bar gauges
  275. PROCEDURE BarGauges
  276.   =FillArea(7,13,15,54,' ','N/W')
  277.   =DrawFrame(6,12,15,54,'W+/B','N+/B',.F.)
  278.   @ 7,21 SAY "Press any key or mouse to stop display" COLOR N/W
  279.   =DrawFrame(8,14,11,50,'W+/W','N+/W',.T.)
  280.   
  281.   =DrawFrame(9,22,9,33,'W+/W','N+/W',.F.)
  282.   
  283.   =DrawFrame(11,29,5,23,'W+/W','N+/W',.T.)
  284.   
  285.   @ 12,24 SAY "Red" COLOR W+/W
  286.   @ 13,24 SAY "Green" COLOR W+/W
  287.   @ 14,24 SAY "Blue" COLOR W+/W
  288.   
  289.   @ 15,30 SAY '╫' COLOR N/W
  290.   @ 15,40 SAY '│' COLOR N/W
  291.   @ 15,50 SAY '╫' COLOR N/W
  292.   @ 16,30 SAY '0%' COLOR W+/W
  293.   @ 16,39 SAY '50%' COLOR W+/W
  294.   @ 16,49 SAY '100%' COLOR W+/W
  295.   
  296.   * Variable Starting Values
  297.   Bar1Value = 0
  298.   Bar2Value = -20
  299.   Bar3Value = -50
  300.   Bar1CountUp = .T. && direction of bar movement .F. = reverse
  301.   Bar2CountUp = .T.
  302.   Bar3CountUp = .T.
  303.   BarRun = .T.
  304.   
  305.   
  306.   DO WHILE BarRun  && Run until key or mouse press
  307.     IF Bar1CountUp
  308.       Bar1Value = Bar1Value + 1
  309.       IF Bar1Value > 85
  310.         Bar1CountUp = .F.
  311.       ENDIF
  312.     ELSE
  313.       Bar1Value = Bar1Value - 1
  314.       IF Bar1Value < (-20)
  315.         Bar1CountUp = .T.    
  316.       ENDIF  
  317.     ENDIF
  318.   
  319.     * Set values for the bars  
  320.     IF Bar2CountUp
  321.       Bar2Value = Bar2Value + 1
  322.       IF Bar2Value > 110
  323.         Bar2CountUp = .F.
  324.       ENDIF
  325.     ELSE
  326.       Bar2Value = Bar2Value - 1
  327.       IF Bar2Value < (-17)
  328.         Bar2CountUp = .T.    
  329.       ENDIF  
  330.     ENDIF
  331.     
  332.     IF Bar3CountUp
  333.       Bar3Value = Bar3Value + 1
  334.       IF Bar3Value > 102
  335.         Bar3CountUp = .F.
  336.       ENDIF
  337.     ELSE
  338.       Bar3Value = Bar3Value - 1
  339.       IF Bar3Value < 21
  340.         Bar3CountUp = .T.    
  341.       ENDIF  
  342.     ENDIF
  343.   
  344.     * Draw the bars
  345.     SET COLOR TO R/W  
  346.     =DrawBar(12,31,Bar1Value)
  347.     SET COLOR TO G/W
  348.     =DrawBar(13,31,Bar2Value)
  349.     SET COLOR TO B/W
  350.     =DrawBar(14,31,Bar3Value)
  351.     
  352.     IF INKEY(0.01,'M') <> 0  && If key or mouse pressed
  353.       BarRun = .F.
  354.     ENDIF    
  355.   ENDDO 
  356.   
  357.   =FillArea(6,12,17,56,' ','W+/B')  && Erase the window
  358.   
  359. RETURN
  360.  
  361. * Display and animate LED gauges, bars and annunciator lights
  362. PROCEDURE BothGauges
  363.   =FillArea(7,3,16,74,' ','N/W')
  364.   =DrawFrame(6,2,16,74,'W+/B','N+/B',.F.)
  365.   @ 7,25 SAY "Press any key to stop display" COLOR N/W
  366.   =DrawFrame(8,4,13,70,'W+/W','N+/W',.T.)
  367.   
  368.   * RPM Frames
  369.   =DrawFrame(10,13,2,8,'W+/W','N+/W',.T.)
  370.   =DrawFrame(14,13,2,8,'W+/W','N+/W',.T.)
  371.   =DrawFrame(18,13,2,8,'W+/W','N+/W',.T.)
  372.   
  373.   * Bar gauge frames
  374.   =DrawFrame(10,25,2,20,'W+/W','N+/W',.T.)
  375.   =DrawFrame(14,25,2,20,'W+/W','N+/W',.T.)
  376.   =DrawFrame(18,25,2,20,'W+/W','N+/W',.T.)
  377.  
  378.   * Percentage display frames
  379.   =DrawFrame(10,49,2,9,'W+/W','N+/W',.T.)
  380.   =DrawFrame(14,49,2,9,'W+/W','N+/W',.T.)
  381.   =DrawFrame(18,49,2,9,'W+/W','N+/W',.T.)
  382.   
  383.   * Annunciator light bezels
  384.   =DrawFrame(10,63,2,8,'W+/W','N+/W',.F.)
  385.   =DrawFrame(14,63,2,8,'W+/W','N+/W',.F.)
  386.   =DrawFrame(18,63,2,8,'W+/W','N+/W',.F.)
  387.   
  388.   @ 9,14 SAY "R.P.M." COLOR N/W 
  389.   @ 9,26 SAY "Relative" COLOR N/W
  390.   @ 9,50 SAY "Percent" COLOR N/W
  391.   @ 9,64 SAY "Status" COLOR N/W
  392.   @ 11,6 SAY "Motor 1" COLOR N/W
  393.   @ 15,6 SAY "Motor 2" COLOR N/W
  394.   @ 19,6 SAY "Motor 3" COLOR N/W
  395.   
  396.   * Display empty values in LED gauge positions
  397.   SET COLOR TO BG+/N
  398.   =LEDStr(11,14,'   0')
  399.   =LEDStr(15,14,'   0')
  400.   =LEDStr(19,14,'   0')
  401.   SET COLOR TO G+/N
  402.   =LEDStr(11,50,'  0.0')
  403.   =LEDStr(15,50,'  0.0')
  404.   =LEDStr(19,50,'  0.0')
  405.   
  406.   * Initialize variables 
  407.   M1Up = .T.
  408.   M2Up = .T.
  409.   M3Up = .T.
  410.   M1Value = 0
  411.   M2Value = -175
  412.   M3Value = -360
  413.   M1Percent = 0.0
  414.   M2Percent = 0.0
  415.   M3Percent = 0.0
  416.   
  417.   RunMotor = .T.
  418.   
  419.   ON KEY RunMotor = .F.
  420.   
  421.   DO WHILE RunMotor
  422.     DO DisplayM1  && Display top set of gauges
  423.     DO DisplayM2  && Display middle set of gauges
  424.     DO DisplayM3  && Display bottom set of gauges
  425.   ENDDO
  426.   
  427.   ON KEY
  428.   Trash = INKEY()  && Throw away last keystroke
  429.   =FillArea(6,2,18,76,' ','W+/B')  && Erase window
  430. RETURN
  431.  
  432. PROCEDURE DisplayM1
  433.   IF M1Up    
  434.     M1Value = M1Value + 1
  435.     IF M1Value > 0       
  436.       M1Percent = (M1Value / 1000) * 100
  437.     ELSE 
  438.       M1Percent = 0.0
  439.     ENDIF  
  440.     IF M1Value > 1075
  441.       M1Up = .F.
  442.     ENDIF
  443.   ELSE
  444.     M1Value = M1Value - 1
  445.     IF M1Value > 0       
  446.       M1Percent = (M1Value / 1000) * 100
  447.     ELSE 
  448.       M1Percent = 0.0
  449.     ENDIF  
  450.     IF M1Value < -61
  451.       M1Up = .T.
  452.     ENDIF    
  453.   ENDIF
  454.   
  455.   IF M1Value >= 0 
  456.     SET COLOR TO BG+/N
  457.     =LEDStr(11,14,STR(M1Value,4,0))
  458.   ENDIF
  459.     
  460.   SET COLOR TO B/W
  461.   IF M1Value > 0
  462.     =DrawDoubleBar(11,26,INT(M1Percent))
  463.   ELSE
  464.     =DrawDoubleBar(11,26,0)
  465.   ENDIF
  466.   
  467.   IF M1Percent < 75.1 
  468.     SET COLOR TO G+/N
  469.   ELSE
  470.     IF M1Percent > 90
  471.       SET COLOR TO R+/N
  472.     ELSE
  473.       SET COLOR TO GR+/N  
  474.     ENDIF  
  475.   ENDIF  
  476.   =LEDStr(11,50,STR(M1Percent,5,1))
  477.   
  478.   IF M1Percent <= 100
  479.     SET COLOR TO W+/G
  480.     @ 11,64 SAY " Cond.  "
  481.     @ 12,64 SAY " Normal "
  482.   ELSE
  483.     SET COLOR TO W+/R*
  484.     @ 11,64 SAY " OVER-  "
  485.     @ 12,64 SAY " SPEED  "  
  486.   ENDIF  
  487. RETURN
  488.  
  489. PROCEDURE DisplayM2
  490.   IF M2Up    
  491.     M2Value = M2Value + 1
  492.     IF M2Value > 0       
  493.       M2Percent = (M2Value / 1000) * 100
  494.     ELSE 
  495.       M2Percent = 0.0
  496.     ENDIF  
  497.     IF M2Value > 1150
  498.       M2Up = .F.
  499.     ENDIF
  500.   ELSE
  501.     M2Value = M2Value - 1
  502.     IF M2Value > 0       
  503.       M2Percent = (M2Value / 1000) * 100
  504.     ELSE 
  505.       M2Percent = 0.0
  506.     ENDIF  
  507.     IF M2Value < -7
  508.       M2Up = .T.
  509.     ENDIF    
  510.   ENDIF
  511.   
  512.   IF M2Value >= 0 
  513.     SET COLOR TO BG+/N
  514.     =LEDStr(15,14,STR(M2Value,4,0))
  515.   ENDIF
  516.     
  517.   SET COLOR TO B/W
  518.   IF M2Value > 0
  519.     =DrawDoubleBar(15,26,INT(M2Percent))
  520.   ELSE
  521.     =DrawDoubleBar(15,26,0)
  522.   ENDIF
  523.   
  524.   IF M2Percent < 75.1 
  525.     SET COLOR TO G+/N
  526.   ELSE
  527.     IF M2Percent > 90
  528.       SET COLOR TO R+/N
  529.     ELSE
  530.       SET COLOR TO GR+/N  
  531.     ENDIF  
  532.   ENDIF  
  533.   =LEDStr(15,50,STR(M2Percent,5,1))
  534.   
  535.   IF M2Percent <= 100
  536.     SET COLOR TO W+/G
  537.     @ 15,64 SAY " Cond.  "
  538.     @ 16,64 SAY " Normal "
  539.   ELSE
  540.     SET COLOR TO W+/R*
  541.     @ 15,64 SAY " OVER-  "
  542.     @ 16,64 SAY " SPEED  "  
  543.   ENDIF    
  544. RETURN
  545.  
  546.  
  547. PROCEDURE DisplayM3
  548.   IF M3Up    
  549.     M3Value = M3Value + 1
  550.     IF M3Value > 0       
  551.       M3Percent = (M3Value / 1000) * 100
  552.     ELSE 
  553.       M3Percent = 0.0
  554.     ENDIF  
  555.     IF M3Value > 1010
  556.       M3Up = .F.
  557.     ENDIF
  558.   ELSE
  559.     M3Value = M3Value - 1
  560.     IF M3Value > 0       
  561.       M3Percent = (M3Value / 1000) * 100
  562.     ELSE 
  563.       M3Percent = 0.0
  564.     ENDIF  
  565.     IF M3Value < -33
  566.       M3Up = .T.
  567.     ENDIF    
  568.   ENDIF
  569.   
  570.   IF M3Value >= 0 
  571.     SET COLOR TO BG+/N
  572.     =LEDStr(19,14,STR(M3Value,4,0))
  573.   ENDIF
  574.     
  575.   SET COLOR TO B/W
  576.   IF M3Value > 0
  577.     =DrawDoubleBar(19,26,INT(M3Percent))
  578.   ELSE
  579.     =DrawDoubleBar(19,26,0)
  580.   ENDIF
  581.   
  582.   IF M3Percent < 75.1 
  583.     SET COLOR TO G+/N
  584.   ELSE
  585.     IF M3Percent > 90
  586.       SET COLOR TO R+/N
  587.     ELSE
  588.       SET COLOR TO GR+/N  
  589.     ENDIF  
  590.   ENDIF  
  591.   =LEDStr(19,50,STR(M3Percent,5,1))
  592.   
  593.   IF M3Percent <= 100
  594.     SET COLOR TO W+/G
  595.     @ 19,64 SAY " Cond.  "
  596.     @ 20,64 SAY " Normal "
  597.   ELSE
  598.     SET COLOR TO W+/R*
  599.     @ 19,64 SAY " OVER-  "
  600.     @ 20,64 SAY " SPEED  "  
  601.   ENDIF    
  602. RETURN
  603.  
  604.  
  605. *  Function DrawBar : Draw a single height bar **************************** 
  606. *  Parameters 
  607. *     - BRow = Row the bar is to appear on
  608. *     - BCol = Column the bar will grow from
  609. *     - BNum = Value for bar. Range in this implementation 0 to 100 
  610. *  Note: The color of the bar depends on the current SET COLOR TO color
  611. *  e.g.: =DrawBar(10,10,68)
  612. ****************************************************************************
  613.  
  614. FUNCTION DrawBar
  615. PARAMETERS BRow,BCol,BNum
  616.   IF BNum < 0 OR BNum > 100
  617.     RETURN .F.
  618.   ENDIF
  619.   FChars = INT(BNum / 5)
  620.   BRem = MOD(BNum,5)
  621.   IF BRem > 0
  622.     EndChar = CHR(142+BRem)
  623.     @ BRow,BCol SAY REPLICATE('█',FChars)+EndChar+REPLICATE(' ',19 - FChars)
  624.   ELSE
  625.     @ BRow,BCol SAY REPLICATE('█',FChars)+REPLICATE(' ',20 - FChars)
  626.   ENDIF
  627. RETURN .T.
  628.  
  629.  
  630. *  Function DrawFrame : Draw a 3D style frame ****************************** 
  631. *  Parameters 
  632. *     - FRow = Row for the top of the frame
  633. *     - FCol = Column left edge of frame
  634. *     - FHeight = The vertical space "between" the top and bottom edges
  635. *     - FWidth = The number of columns "between" the right and left edges
  636. *     - SunColor = Color of the sunlit part of the frame
  637. *     - ShadeColor = Color of the shaded areas of the frame
  638. *     - Inset = .T. For concave frame, .F. For convex frame          
  639. *  Note: The background color for SunColor & ShadeColor should be the same
  640. *  e.g.: =DrawFrame(10,10,1,20,'W+/W','N+/W',.T.)
  641. ****************************************************************************
  642.  
  643. FUNCTION DrawFrame
  644. PARAMETERS FRow,FCol,FHeight,FWidth,SunColor,ShadeColor,Inset
  645.   IF FHeight < 1 OR FWidth < 1
  646.     RETURN .F.
  647.   ENDIF
  648.   IF Inset
  649.     LTColor = ShadeColor  && Left & Top
  650.     RBColor = SunColor    && Right & Botom
  651.   ELSE
  652.     LTColor = SunColor
  653.     RBColor = ShadeColor
  654.   ENDIF
  655.   
  656.   SET COLOR TO <Color
  657.   @ FRow,FCol SAY '╟'+REPLICATE('╞',FWidth) 
  658.   FOR LineCount = 1 to FHeight
  659.     @ FRow+LineCount,FCol SAY '╫'
  660.   ENDFOR
  661.   SET COLOR TO &RBColor
  662.   FOR LineCount = 1 to FHeight
  663.     @ FRow+LineCount,FCol+FWidth+1 SAY 'Å'
  664.   ENDFOR
  665.   @ FRow+FHeight+1,FCol+1 SAY REPLICATE('╪',FWidth)+'ô'
  666. RETURN .T.
  667.  
  668.  
  669. *  Function FillArea : Fill an area of screen with ************************* 
  670. *  Parameters 
  671. *     - FillRow = First row to fill
  672. *     - FillCol = First column to fill
  673. *     - FillHeight = Number of rows to fill
  674. *     - FillWidth = Number of columns to fill
  675. *     - FillChar = Character to fill the area with
  676. *     - FillColor = Color of the characters used to fill area        
  677. *  e.g.: =FillColor(10,10,5,70,'░','W+/B') 
  678. ****************************************************************************
  679.  
  680. FUNCTION FillArea
  681. PARAMETERS FillRow,FillCol,FillHeight,FillWidth,FillChar,FillColor
  682.   SET COLOR TO &FillColor
  683.   FOR LineCount = 0 to FillHeight-1
  684.     @ FillRow+LineCount,FillCol SAY REPLICATE(FillChar,FillWidth)
  685.   ENDFOR
  686. RETURN
  687.  
  688.  
  689. * Draw a double height bar - same usage as DrawBar
  690. FUNCTION DrawDoubleBar
  691. PARAMETERS BRow,BCol,BNum
  692.   IF BNum < 0 OR BNum > 100
  693.     RETURN .F.
  694.   ENDIF
  695.   FChars = INT(BNum / 5)
  696.   BRem = MOD(BNum,5)
  697.   IF BRem > 0
  698.     EndChar = CHR(142+BRem)
  699.     @ BRow,BCol SAY REPLICATE('█',FChars)+EndChar+REPLICATE(' ',19 - FChars)
  700.     @ BRow+1,BCol SAY REPLICATE('█',FChars)+EndChar+REPLICATE(' ',19 - FChars)
  701.   ELSE
  702.     @ BRow,BCol SAY REPLICATE('█',FChars)+REPLICATE(' ',20 - FChars)
  703.     @ BRow+1,BCol SAY REPLICATE('█',FChars)+REPLICATE(' ',20 - FChars)
  704.   ENDIF
  705. RETURN .T.
  706.  
  707.  
  708. *  Function LEDStr : Draw a double height & width digital string *********** 
  709. *  Parameters 
  710. *     - LEDRow = First of two rows to be occupied by the characters
  711. *     - LEDCol = First column for sting to appear 
  712. *     - LEDString = Sting to display
  713. *  Note: The color of the digits depend on the current SET COLOR TO color
  714. *        Function will ignore all characters except the following:
  715. *        0123456789,' '(space), '-', ':','.',',','/' 
  716. *  e.g.: =LEDStr(10,10,STR(MyNumericVariable,5,3))
  717. *  Also: Punctuation characters use 1 column each, all others use 2 columns
  718. ****************************************************************************
  719.  
  720. FUNCTION LEDStr
  721.   PARAMETERS LEDRow,LEDCol,LEDString
  722.   PRIVATE CC,MCount,MRow,MRow2,MCol,ShowChar
  723.   CC = LEN(LEDString)
  724.   MRow = LEDRow
  725.   MRow2 = MRow+1
  726.   MCol = LEDCol
  727.   
  728.   FOR MCount = 1 TO CC 
  729.     ShowChar = SUBSTR(LEDString,MCount,1)
  730.   DO CASE
  731.     CASE ShowChar = ' '
  732.       @ MRow, MCol SAY '  '
  733.       @ MRow2,MCol SAY '  '
  734.       MCol = MCol+2
  735.       LOOP
  736.     CASE ShowChar = '0'
  737.       @ MRow, MCol SAY '╙ç'
  738.       @ MRow2,MCol SAY '╬ä'
  739.       MCol = MCol+2
  740.       LOOP
  741.     CASE ShowChar = '1'
  742.       @ MRow, MCol SAY ' Ç'
  743.       @ MRow2,MCol SAY ' ü'
  744.       MCol = MCol+2
  745.       LOOP
  746.     CASE ShowChar = '2'
  747.       @ MRow, MCol SAY '╠é'
  748.       @ MRow2,MCol SAY '╬â'
  749.       MCol = MCol+2
  750.       LOOP
  751.     CASE ShowChar = '3'
  752.       @ MRow, MCol SAY '╠é'
  753.       @ MRow2,MCol SAY '╧ä'
  754.       MCol = MCol+2
  755.       LOOP
  756.     CASE ShowChar = '4'
  757.       @ MRow, MCol SAY '╨à'
  758.       @ MRow2,MCol SAY ' ü'
  759.       MCol = MCol+2
  760.       LOOP
  761.     CASE ShowChar = '5'
  762.       @ MRow, MCol SAY '╤å'
  763.       @ MRow2,MCol SAY '╧ä'
  764.       MCol = MCol+2
  765.       LOOP
  766.     CASE ShowChar = '6'
  767.       @ MRow, MCol SAY '╤å'
  768.       @ MRow2,MCol SAY '╬ä'
  769.       MCol = MCol+2
  770.       LOOP
  771.     CASE ShowChar = '7'
  772.       @ MRow, MCol SAY '╥ç'
  773.       @ MRow2,MCol SAY ' ü'
  774.       MCol = MCol+2
  775.       LOOP
  776.     CASE ShowChar = '8'
  777.       @ MRow, MCol SAY '╤é'
  778.       @ MRow2,MCol SAY '╬ä'
  779.       MCol = MCol+2
  780.       LOOP
  781.     CASE ShowChar = '9'
  782.       @ MRow, MCol SAY '╤é'
  783.       @ MRow2,MCol SAY ' ü'
  784.       MCol = MCol+2
  785.       LOOP
  786.     CASE ShowChar = '-'
  787.       @ MRow, MCol SAY '╒ë'
  788.       @ MRow2,MCol SAY '  '
  789.       MCol = MCol+2
  790.       LOOP
  791.     CASE ShowChar = '.'
  792.       @ MRow, MCol SAY ' ' 
  793.       @ MRow2,MCol SAY 'Ä' 
  794.       MCol = MCol+1
  795.       LOOP
  796.     CASE ShowChar = ':'
  797.       @ MRow, MCol SAY ''
  798.       @ MRow2,MCol SAY ''
  799.       MCol = MCol+1
  800.       LOOP
  801.     CASE ShowChar = '/'
  802.       @ MRow, MCol SAY ' è'
  803.       @ MRow2,MCol SAY '╓ '
  804.       MCol = MCol+2
  805.       LOOP      
  806.     CASE ShowChar = ','
  807.       @ MRow, MCol SAY ' '
  808.       @ MRow2,MCol SAY 'ì'
  809.       MCol = MCol+1
  810.       LOOP
  811.   ENDCASE
  812.   ENDFOR
  813. RETURN  
  814.  
  815.