
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
Hallo Oskar, ich habe Dein Programm für mBasic angepasst: Alle Gotos, Table, usw.. beseitigt. Der mBasic erzeugt im Vergleich zum C-Control DOS Compiler 200kb weniger, obwohl ich nur kommentierten Quellcode gelöscht habe. Ich konnte es aber nur auf dem Emulator testen, da keine App.Board Hardware. Grüße, Jörg Dim Relais1 As Boolean Port[1,1] Dim Relais2 As Boolean Port[1,2] Dim Relais3 As Boolean Port[1,3] Dim Relais4 As Boolean Port[1,4] Dim Relais5 As Boolean Port[1,5] Dim Relais6 As Boolean Port[1,6] Dim Relais7 As Boolean Port[1,7] Dim Relais8 As Boolean Port[1,8] Dim relais As Byte Port[1], Temp As Byte AD[1], Tastatur As Byte AD[8] Dim value, output, vario As Integer Dim LCD_buf, LCD_param, lastsec, key_nr, key_rel, compare, xy, i As Byte Dim LCD_port As Byte Port[2] Dim LCD_rs As Boolean Port[2,6], LCD_rw As Boolean Port[2,5], LCD_e As Boolean Port[2,7] Beep = 625: Pause 12:Beep = 425: Pause 12:Beep = 312: Pause 24: Const Grad[256] = Array{-27, -27, -26, -25, -24, -24, -23, -22, -22, -21, -20, -20, -19, -18, -18, -17, -17, -16, -15, -15, -14, -13, -13, -12, -11, -11, -10, -9, -9, -8, -8, -7, -6, -6, -5, -5, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 68, 69, 69, 70, 70, 71, 71, 71, 72, 72, 73, 73, 74, 74, 74, 75, 75, 76, 76, 77, 77, 77, 78, 78, 79, 79, 80, 80, 80, 81, 81, 82, 82, 82, 83, 83, 84, 84, 85, 85, 85, 86, 86, 87, 87, 87, 88, 88, 89, 89, 89, 90, 90, 91, 91, 91, 92, 92, 93, 93, 93, 94, 94, 95, 95, 95, 96, 96, 97, 97, 97, 98, 98, 99, 99, 99, 100} Const NULL = &h30, MINUS = &h2D, LEERZ = &H20, C_ = 67, DOPPELPUNKT = &H3A Const Aus = 0, Ein = not Aus '*************************************** Programmoperationen ************************************************ Call LCD_Init Do Select Case Second Case 0: Call WriteMinute Case Is <> lastSec: Call WriteSecond Call Schalten lastsec = second End Select Loop Sub WriteMinute '------------------------------------------------ xy=28:Call Cursor '1te Zeile 1 Position LCD_param = NULL + Hour / 10 : Call LCD_WriteChar LCD_param = NULL + Hour Mod 10 : Call LCD_WriteChar LCD_param = DOPPELPUNKT : Call LCD_WriteChar LCD_param = NULL + minute / 10 : Call LCD_WriteChar LCD_param = NULL + minute Mod 10 : Call LCD_WriteChar LCD_param = DOPPELPUNKT : Call LCD_WriteChar Call WriteSecond End Sub Sub WriteSecond '------------------------------------------------- xy=34:Call Cursor '1te Zeile 7te Position LCD_param = NULL + second / 10 : Call LCD_WriteChar LCD_param = NULL + second Mod 10 : Call LCD_WriteChar 'schreibt TIME auf das Display in die 2. Zeile xy=20:Call Cursor LCD_param = &H54: Call LCD_WriteChar xy=21:Call Cursor LCD_param = &H49: Call LCD_WriteChar xy=22:Call cursor LCD_param = &H4D: Call LCD_WriteChar xy=23:Call cursor LCD_param = &H45: Call LCD_WriteChar xy=24:Call cursor LCD_param = &H3A: Call LCD_WriteChar Call WriteTemp End Sub Sub WriteTemp '---------------------------------------------------------------- xy=49:GoSub Cursor ' Aktualisieren der Temperatur vario = Grad[Temp] output = Abs(vario) If vario < 0 Then LCD_param = MINUS Else LCD_param = LEERZ: End If Call LCD_WriteChar ' Tausender-Dezimalstelle oder Leerzeichen If (Abs(vario)) >= 1000 Then LCD_param = NULL + output/1000 Else LCD_param = LEERZ: End If Call LCD_WriteChar output = output Mod 1000 ' Hunderter-Dezimalstelle oder Leerzeichen If (Abs(vario)) >= 100 Then LCD_param = NULL + output/100 Else LCD_param = LEERZ: End If Call LCD_WRITECHAR output = output Mod 100 ' Zehner-Dezimalstelle oder Leerzeichen If (Abs(vario)) >= 10 Then LCD_param = NULL + output/10 Else LCD_param = LEERZ: End If Call LCD_WriteChar ' einer Dezimalstelle oder Leerzeichen LCD_param = NULL + output Mod 10 Call LCD_WriteChar LCD_param = LEERZ : Call LCD_WriteChar LCD_param = &Hdf : Call LCD_WriteChar LCD_param = C_ : Call LCD_Writechar xy=40:Call cursor ' schreibt Lichtsteuerung auf das Display in der 1. Zeile xy=0:Call Cursor LCD_param = &H20: Call LCD_WRITECHAR xy=1:GoSub cursor LCD_param = &H4C: GoSub LCD_WRITECHAR xy=2:GoSub cursor LCD_param = &H49: GoSub LCD_WRITECHAR xy=3:GoSub Cursor LCD_param = &H43: GoSub LCD_WRITECHAR xy=4:GoSub cursor LCD_param = &H48: GoSub LCD_WRITECHAR xy=5:GoSub cursor LCD_param = &H54: GoSub LCD_WRITECHAR xy=6:GoSub cursor LCD_param = &H53: GoSub LCD_WRITECHAR xy=7:GoSub cursor LCD_param = &H54: GoSub LCD_WRITECHAR xy=8:GoSub cursor LCD_param = &H45: GoSub LCD_WRITECHAR xy=9:GoSub cursor LCD_param = &H55: GoSub LCD_WRITECHAR xy=10:GoSub cursor LCD_param = &H45: GoSub LCD_WRITECHAR xy=11:GoSub cursor LCD_param = &H52: GoSub LCD_WRITECHAR xy=12:GoSub cursor LCD_param = &H55: GoSub LCD_WRITECHAR xy=13:GoSub cursor LCD_param = &H4E: GoSub LCD_WRITECHAR xy=14:GoSub Cursor LCD_param = &H47: GoSub LCD_WRITECHAR xy=15:GoSub cursor LCD_param = &H20: GoSub LCD_WRITECHAR End Sub '*************************************** LCD_Interface *********************************************************** '( muss in jedes Programm mit LCD-Ausgabe eingefuegt werden) 'die Zahl XY ermittelt die nächste Position am LCD. '(0+ 1.zeile , 20+ 2.zeile, 40+ 3.ziele, 60+ 4.zeile. 'Also 44 ist daher 3.Zeile Postition 5. Sub Cursor lcd_param=xy If xy>=20 Then lcd_param=xy+44: End if If xy>=40 Then lcd_param=xy-24: End if If xy>=60 Then lcd_param=xy+20: End if lcd_param=lcd_param+128 Call LCD_WriteCmd End Sub 'Blinkender cursor am LCD ein (on) oder aus (off) schalten. Sub CurOn lcd_param=15:Call LCD_WriteCmd End Sub Sub CurOff lcd_param=12:Call LCD_WriteCmd End Sub Sub LCD_Init ' alle ports 0 LCD_port = Aus ' 8-Bit-Modus aktivieren lcd_param=&H38 : Call LCD_WriteCmd ' mit 8-Bit-Command in 4-Bit-Modus umschalten lcd_port=&B00000010 Switch LCD_e Switch LCD_e ' ab jetzt 4-Bit-Modus LCD_param = &H28 : Call LCD_WriteCmd LCD_param = &H0C : Call LCD_WriteCmd Call LCD_CLS End Sub ' Display loeschen ---------------------------------- Sub LCD_CLS LCD_param = &H02 : Call LCD_WriteCmd LCD_param = &H01 : Call LCD_WriteCmd End Sub ' LCD-Kommando -------------------------------------- Sub LCD_WriteCmd LCD_buf = Aus Call LCD_Write End Sub ' Zeichenausgabe ------------------------------------ Sub LCD_WriteChar LCD_buf = &B00100000 Call LCD_Write End Sub ' Kommando oder Zeichen an Display senden ---------------- Sub LCD_Write LCD_port = LCD_buf Or (LCD_param ShR 4) ' Hi-Nibble Switch LCD_e Switch LCD_e LCD_port = LCD_buf Or (LCD_param And &H0F) ' Lo-Nibble Switch LCD_e Switch LCD_e End Sub 'tastatur routine Sub WaitKey Const ASCIICodes[] = Array{11, 7, 4, 1, 10, 8, 5, 2, 12, 9, 6, 3} key_nr=0 compare=tastatur If compare>238 Then key_nr=0 key_rel=99 Else compare=compare/21 xy = ASCIICodes[compare] If Not (key_rel = xy) Then key_nr=xy key_rel=key_nr End If End If End Sub Sub Schalten '---------------------------------------------------- Call WaitKey If key_nr=11 Then relais=0: End If If key_nr=12 Then Call LCD_CLS: End If If key_nr=1 Then Call meldung: End If xy=1 For i=1 To 8 If i=key_nr Then relais=(relais xor xy): End If xy=xy ShL 1 Next Call Steuerung End Sub Sub Steuerung Const Montag = 1, Freitag = 5, Sonntag = 7 '+++++++++++++++++++++++++++++++++++++++++++ DOW Abfrage ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 'Montag = 1, Dienstag = 2, Mittwoch = 3, Donnerstag = 4 Freitag = 5, Samstag = 6, Sonntag = 7 '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ If (hour = 23) And (minute = 59) Then Call Reset: End If ' Reset aller Relais um 23.59 Uhr '-------------------------------------------------------------------------------------------------------------- '********************** Tastaturabfrage ************************************************************************** If (dow => Montag) And (dow =< Freitag) Then If (hour = 20) And (minute = 35) Then Relais1 = Ein: End If If (hour = 20) And (minute = 36) Then Relais1 = Aus: End If '*************************************************************************************** If (hour = 05) And (minute = 45) Then Relais1 = Ein: End If If (hour = 05) And (minute = 46) Then Relais1 = Aus: End If '*************************************************************************************** If (hour = 07) And (minute = 00) Then Relais2 = Ein: End If If (hour = 07) And (minute = 01) Then Relais2 = Aus: End If '*************************************************************************************** If (hour = 05) And (minute = 47) Then Relais3 = Ein: End If If (hour = 05) And (minute = 48) Then Relais3 = Aus: End If '*************************************************************************************** If (hour = 07) And (minute = 03) Then Relais4 = Ein: End If If (hour = 07) And (minute = 04) Then Relais4 = Aus: End If End If If (dow => Montag And dow =< Sonntag) Then If (hour = 22) And (minute = 55) Then Relais2 = Ein: End If If (hour = 22) And (minute = 56) Then Relais2 = Aus: End If '*************************************************************************************** If (hour = 20) And (minute = 30) Then Relais3 = Ein: End If If (hour = 20) And (minute = 31) Then Relais3 = Aus: End If '*************************************************************************************** If (hour = 23) And (minute = 00) Then Relais4 = Ein: End If If (hour = 23) And (minute = 01) Then Relais4 = Aus: End If '*************************************************************************************** If (hour = 23) And (minute = 10) Then Relais6 = Ein: End If If (hour = 23) And (minute = 11) Then Relais6 = Aus: End If '*************************************************************************************** If (hour = 20) And (minute = 00) Then Relais7 = Ein: End If If (hour = 20) And (minute = 01) Then Relais7 = Aus: End If '*************************************************************************************** If (hour = 23) And (minute = 16) Then Relais8 = Ein: End If If (hour = 23) And (minute = 17) Then Relais8 = Aus: End If '*************************************************************************************** End If End Sub Sub Reset Relais1=Aus Relais2=Aus Relais3=Aus Relais4=Aus Relais5=Aus Relais6=Aus Relais7=Aus Relais8=Aus End Sub Sub Meldung '... End Sub |
| Antwort schreiben |