'Controller D15G14E_14_030526 - Nokia 3510i Display
'Temperaturanzeige mit min und max temperatur
'Dirk Milewski- http://www.comwebnet.de
'Atmega 16L
'Hwstack = 256
'Swstack = 256
'Framesize = 128
'-------------------------------------------------------------------------------
'Display Pin 1 Reset => AVR Pin a0
' 2 CS a1
' 3 GND GND
' 4 Sdata a2
' 5 Sclk a3
' 6 Vdigital Vdd (3 Volt)
' 7 Vbooster Vdd
' 8 Vlcd uber Elko (10uF/10V) an GND
'-------------------------------------------------------------------------------
$regfile = "m16def.dat"
$crystal = 8000000
$baud = 19200
Declare Sub Lcd_init
Declare Sub Lcd_cls(byval Bcolor As Byte)
Declare Sub Lcd_setcolor(byval Forecolor As Byte , Byval Backcolor As Byte)
Declare Sub Lcd_setdoublesize(byval Size As Byte)
Declare Sub Lcd_setframe(byval Lcd_left As Byte , Byval Lcd_top As Byte , Byval Lcd_width As Byte , Byval Lcd_height As Byte)
Declare Sub Lcd_sendbyte(byval Lcd_command As Byte , Byval Lcd_data As Byte)
Declare Sub Lcd_locate(byval Lcd_x As Byte , Byval Lcd_y As Byte)
Declare Sub Lcd_plot(byval Plotx As Byte , Byval Ploty As Byte , Byval Fcolor As Byte)
Declare Sub Lcd_command(byval Lcommand As Byte)
Declare Sub Lcd_parameter(byval Lparameter As Byte)
Declare Sub Lcd_print(byval Xpo As Byte , Byval Ypo As Byte , Byval Fco As Byte , Byval Bco As Byte , Byval Gross As Byte , Byval Lcd_text As String)
Declare Sub Getline(s As String)
Declare Sub Flushbuf()
Declare Sub Read1820
Declare Sub Crcit
Declare Sub Temperature
Dim Bd(9) As Byte
Dim I As Byte , Tmp As Byte
Dim Crc As Byte
Dim T As Integer , T1 As Integer
Dim V As Byte
Dim Min As Integer
Dim Max As Integer
'Config Watchdog = 2048
Config Spi = Soft , Din = Pinb.3 , Dout = Porta.2 , Ss = None , Clock = Porta.3
Config 1wire = Portd.7
Config Pinb.0 = Input
Portb.0 = 1
Kontakt01 Alias Pinb.0
Config Pinb.1 = Input
Portb.1 = 1
Enter Alias Pinb.1
Config Pinb.2 = Input
Portb.2 = 1
Hoch Alias Pinb.2
Config Pinb.3 = Input
Portb.3 = 1
Up Alias Pinb.3
Dim Rr As Integer
Dim Ll As Integer
Dim Ff As Byte
Dim Aa As Byte
Dim Fcol As Byte
Dim Bcol As Byte
Dim Lcd_doublesize As Byte
Dim Lcd_posx As Byte
Dim Lcd_posy As Byte
Dim Lcd_fcolor As Byte
Dim Lcd_bcolor As Byte
Dim Feld As Byte
Dim Gx1 As Byte
Dim Gy1 As Byte
Dim Gx2 As Byte
Dim Gy2 As Byte
Dim P As Integer
Dim Dx As Integer
Dim Dy As Integer
Dim Xp As Byte
Dim Yp As Byte
Dim Color As Byte
Dim Schleife As Byte
Dim Dfg As String * 25
Dim Wert As Single
Dim Delta As Long
Dim Wert2 As Long
Dim Mm As Long
Dim Lcount As Long At &H100
Dim Wcountlo As Word At &H100 Overlay
Dim Wcounthi As Word At &H102 Overlay
Ddra = &B11111111
Const P_io = &B11111111
Dim Sret As String * 66 , Stemp As String * 6
Dim I2c_buffer(4) As Byte
'Dim I As String * 2 ,
Dim M As Byte
Dim Key As Byte
Dim Q As Byte
Dim Y As Byte
'Config Porta = Output
P_ddr Alias Ddra
P_out Alias Porta
Config Pinb.0 = Input
Portd.0 = 1
Taste0 Alias Pinb.0
Config Pinb.1 = Input
Portb.1 = 1
Taste1 Alias Pinb.1
Config Pinb.2 = Input
Portb.2 = 1
Taste2 Alias Pinb.1
Config Pinb.3 = Input
Portb.3 = 1
Taste3 Alias Pinb.3
Config Pinb.4 = Input
Portb.4 = 1
Taste4 Alias Pinb.4
Config Pinb.5 = Input
Portb.5 = 1
Taste5 Alias Pinb.5
Config Pinb.6 = Input
Portb.6 = 1
Taste6 Alias Pinb.6
Config Porta = Output
Lcd_io Alias Porta
Const Lcd_rs = 0
Const Lcd_cs = 1
Const Lcd_sdata = 2
Const Lcd_sclk = 3
Const Blau = &B11111100
Const Weis = 0
Const Schwarz = 255
Const Magenta = &B00011100
Const Rot = 22
Const Gruen = 99
Const Lcd_cmd = 0
Const Lcd_prm = 1
P_ddr = P_io
$eeprom
Data &H00 , &H00 , &H00 , &H00 , &H00 ' "(space)"
Data &H00 , &H06 , &H5F , &H06 , &H00 ' "!"
Data &H07 , &H03 , &H00 , &H07 , &H03 ' """
Data &H24 , &H7E , &H24 , &H7E , &H24 ' "#"
Data &H24 , &H2B , &H6A , &H12 , &H00 ' "$"
Data &H63 , &H13 , &H08 , &H64 , &H63 ' "%"
Data &H36 , &H49 , &H56 , &H20 , &H50 ' "&"
Data &H00 , &H07 , &H03 , &H00 , &H00 ' "'"
'40
Data &H00 , &H3E , &H41 , &H00 , &H00 ' "("
Data &H00 , &H41 , &H3E , &H00 , &H00 ' ")"
Data &H08 , &H3E , &H1C , &H3E , &H08 ' "*"
Data &H08 , &H08 , &H3E , &H08 , &H08 ' "+"
Data &H00 , &HE0 , &H60 , &H00 , &H00 ' ","
Data &H08 , &H08 , &H08 , &H08 , &H08 ' "-"
Data &H00 , &H60 , &H60 , &H00 , &H00 ' "."
Data &H20 , &H10 , &H08 , &H04 , &H02 ' "/"
Data &H3E , &H51 , &H49 , &H45 , &H3E ' "0"
Data &H00 , &H42 , &H7F , &H40 , &H00 ' "1"
'50
Data &H62 , &H51 , &H49 , &H49 , &H46 ' "2"
Data &H22 , &H49 , &H49 , &H49 , &H36 ' "3"
Data &H18 , &H14 , &H12 , &H7F , &H10 ' "4"
Data &H2F , &H49 , &H49 , &H49 , &H31 ' "5"
Data &H3C , &H4A , &H49 , &H49 , &H30 ' "6"
Data &H01 , &H71 , &H09 , &H05 , &H03 ' "7"
Data &H36 , &H49 , &H49 , &H49 , &H36 ' "8"
Data &H06 , &H49 , &H49 , &H29 , &H1E ' "9"
Data &H00 , &H6C , &H6C , &H00 , &H00 ' ":"
Data &H00 , &HEC , &H6C , &H00 , &H00 ' ";"
'60
Data &H08 , &H14 , &H22 , &H41 , &H00 ' "<"
Data &H24 , &H24 , &H24 , &H24 , &H24 ' "="
Data &H00 , &H41 , &H22 , &H14 , &H08 ' ">"
Data &H02 , &H01 , &H59 , &H09 , &H06 ' "?"
Data &H3E , &H41 , &H5D , &H55 , &H1E ' "@"
Data &H7E , &H09 , &H09 , &H09 , &H7E ' "A"
Data &H7F , &H49 , &H49 , &H49 , &H36 ' "B"
Data &H3E , &H41 , &H41 , &H41 , &H22 ' "C"
Data &H7F , &H41 , &H41 , &H41 , &H3E ' "D"
Data &H7F , &H49 , &H49 , &H49 , &H41 ' "E"
'70
Data &H7F , &H09 , &H09 , &H09 , &H01 ' "F"
Data &H3E , &H41 , &H49 , &H49 , &H7A ' "G"
Data &H7F , &H08 , &H08 , &H08 , &H7F ' "H"
Data &H00 , &H41 , &H7F , &H41 , &H00 ' "I"
Data &H30 , &H40 , &H40 , &H40 , &H3F ' "J"
Data &H7F , &H08 , &H14 , &H22 , &H41 ' "K"
Data &H7F , &H40 , &H40 , &H40 , &H40 ' "L"
Data &H7F , &H02 , &H04 , &H02 , &H7F ' "M"
Data &H7F , &H02 , &H04 , &H08 , &H7F ' "N"
Data &H3E , &H41 , &H41 , &H41 , &H3E ' "O"
Data &H7F , &H09 , &H09 , &H09 , &H06 ' "P"
'80
Data &H3E , &H41 , &H51 , &H21 , &H5E ' "Q"
Data &H7F , &H09 , &H09 , &H19 , &H66 ' "R"
Data &H26 , &H49 , &H49 , &H49 , &H32 ' "S"
Data &H01 , &H01 , &H7F , &H01 , &H01 ' "T"
Data &H3F , &H40 , &H40 , &H40 , &H3F ' "U"
Data &H1F , &H20 , &H40 , &H20 , &H1F ' "V"
Data &H3F , &H40 , &H3C , &H40 , &H3F ' "W"
Data &H63 , &H14 , &H08 , &H14 , &H63 ' "X"
Data &H07 , &H08 , &H70 , &H08 , &H07 ' "Y"
Data &H71 , &H49 , &H45 , &H43 , &H00 ' "Z"
Data &H00 , &H7F , &H41 , &H41 , &H00 ' "["
'90
Data &H02 , &H04 , &H08 , &H10 , &H20 ' "\"
Data &H00 , &H41 , &H41 , &H7F , &H00 ' "]"
Data &H04 , &H02 , &H01 , &H02 , &H04 ' "^"
Data &H80 , &H80 , &H80 , &H80 , &H80 ' "_" ' "`"
Data &H0C , &H12 , &H12 , &H0C , &H00 ' neu "°" statt "`"
'Data &H00 , &H03 , &H07 , &H00 , &H00
Data &H20 , &H54 , &H54 , &H54 , &H78 ' "a"
Data &H7F , &H44 , &H44 , &H44 , &H38 ' "b"
Data &H38 , &H44 , &H44 , &H44 , &H28 ' "c"
Data &H38 , &H44 , &H44 , &H44 , &H7F ' "d"
Data &H38 , &H54 , &H54 , &H54 , &H18 ' "e"
Data &H08 , &H7E , &H09 , &H09 , &H00 ' "f"
'100
Data &H18 , &HA4 , &HA4 , &HA4 , &H7C ' "g"
Data &H7F , &H04 , &H04 , &H78 , &H00 ' "h"
Data &H00 , &H00 , &H7D , &H00 , &H00 ' "i"
Data &H40 , &H80 , &H84 , &H7D , &H00 ' "j"
Data &H7F , &H10 , &H28 , &H44 , &H00 ' "k"
Data &H00 , &H00 , &H7F , &H40 , &H00 ' "l"
Data &H7C , &H04 , &H18 , &H04 , &H78 ' "m"
Data &H7C , &H04 , &H04 , &H78 , &H00 ' "n"
Data &H38 , &H44 , &H44 , &H44 , &H38 ' "o"
Data &HFC , &H44 , &H44 , &H44 , &H38 ' "p"
Data &H38 , &H44 , &H44 , &H44 , &HFC ' "q"
'110
Data &H44 , &H78 , &H44 , &H04 , &H08 ' "r"
Data &H08 , &H54 , &H54 , &H54 , &H20 ' "s"
Data &H04 , &H3E , &H44 , &H24 , &H00 ' "t"
Data &H3C , &H40 , &H20 , &H7C , &H00 ' "u"
Data &H1C , &H20 , &H40 , &H20 , &H1C ' "v"
Data &H3C , &H60 , &H30 , &H60 , &H3C ' "w"
Data &H6C , &H10 , &H10 , &H6C , &H00 ' "x"
Data &H9C , &HA0 , &H60 , &H3C , &H00 ' "y"
Data &H64 , &H54 , &H54 , &H4C , &H00 ' "z"
Data &H08 , &H3E , &H41 , &H41 , &H00 ' "{"
'120
Data &H00 , &H00 , &H7F , &H00 , &H00 ' "|"
Data &H00 , &H41 , &H41 , &H3E , &H08 ' "}"
Data &H02 , &H01 , &H02 , &H01 , &H00 ' "~"
Data &H3F , &H21 , &H21 , &H21 , &H21 ' "["
Data &H21 , &H21 , &H21 , &H21 , &H21
Data &H21 , &H21 , &H21 , &H21 . &H3F ' "]"
Data &H3F , &H3F , &H3F , &H3F , &H3F
Data &H3F , &H00 , &H00 , &H00 , &H00
$data
' Haupprogramm
Dfg = " Alarm! "
' Enable Icp1
'Enable Ovf1
Enable Interrupts
'Start Watchdog
Print "by Dirk Milewski!"
Call Lcd_init
Call Lcd_cls(blau)
Temperature
Waitms 250
Min = T
' Print "Nr,;Temp Card;MIN;Max"
Schleife:
Do
Temperature
Waitms 250
Incr Wcountlo
Call Lcd_print(1 , 1 , 0 , 50 , 0 , " * Temperatur * ")
Wert = T / 10
Wert = Wert + 0.001
Dfg = Str(wert)
Dfg = Mid(dfg , 1 , 4)
Dfg = Dfg + "`C"
If T < Min Then Min = T
If T > Max Then Max = T
Print Wcountlo ; ";" ; T ; ";" ; Min ; ";" ; Max
Call Lcd_print(2 , 2 , 0 , 255 , 1 , Dfg)
Wert = Max / 10
Wert = Wert + 0.001
Dfg = Str(wert)
Dfg = Mid(dfg , 1 , 4)
Dfg = Dfg + "`C max"
Call Lcd_print(2 , 6 , 0 , 255 , 0 , Dfg)
Wert = Min / 10
Wert = Wert + 0.001
Dfg = Str(wert)
Dfg = Mid(dfg , 1 , 4)
Dfg = Dfg + "`C min"
Call Lcd_print(2 , 7 , 0 , 255 , 0 , Dfg)
Y = Portb
Y = Hex(y)
Dfg = Str(y)
Call Lcd_print(1 , 5 , 0 , 255 , 0 , Dfg)
'Wert = 1 / Wert
'Dfg = Str(wert)
'Dfg = Dfg + " ms"
'Call Lcd_print(1 , 5 , 0 , Blau , 0 , Dfg)
Wait 1
If Taste0 = 0 Then
Key = 1
Gosub Graf
End If
'Reset Watchdog
Loop
End 'end program
Graf:
Call Lcd_cls(0)
For Q = 4 To 60
Call Lcd_plot(15 , Q , 255)
Next Q
For Q = 4 To 67 Step 8
For Y = 13 To 17
Call Lcd_plot(y , Q , 255)
Next Y
Next Q
For Q = 0 To 8
Y = Q * 10
Y = 80 - Y
Dfg = Str(y)
Call Lcd_print(1 , Q , 255 , 0 , 0 , Dfg)
Next Q
Wait 1
Q = 16
Bu:
Temperature
Waitms 250
If Taste0 = 0 Then
Key = 0
Call Lcd_cls(blau)
Return
End If
Incr Q
Wert = T / 10
Wert = Wert + 0.00001
Y = Round(wert)
Y = 65 - Y
Dfg = Str(wert)
Dfg = Mid(dfg , 1 , 5)
Dfg = Dfg + "`C"
Call Lcd_print(5 , 1 , 255 , 0 , 0 , Dfg)
Call Lcd_plot(q , Y , Rot)
If Q = 97 Then Goto Graf
Wait 30
Goto Bu
'-------------------------------------------------------------------------------
'Zeichenausgabe
'-------------------------------------------------------------------------------
'Sub Lcd_pr(byval Lcd_text As String)
Sub Lcd_print(byval Xpo As Byte , Byval Ypo As Byte , Byval Fco As Byte , Byval Bco As Byte , Byval Gross As Byte , Byval Lcd_text As String)
Local R As Integer
Local A As Byte
Local B As Byte
Local C As Long
Local D As Byte
Local E As Byte
Local F As Byte
Local G As Long
Local Zeichen As String
'Reset Watchdog
Call Lcd_setcolor(fco , Bco)
Call Lcd_setdoublesize(gross)
Call Lcd_locate(xpo , Ypo)
Call Lcd_sendbyte(lcd_cmd , &H36) 'von oben nach unten zeichnen
Call Lcd_sendbyte(lcd_prm , &B00100000)
Call Lcd_sendbyte(lcd_cmd , &H2C) 'Und wieder Daten
For R = 1 To Len(lcd_text)
Zeichen = Mid(lcd_text , R , 1) 'Hole char
G = Asc(zeichen) 'Bestimme Pos in Tabelle
G = G - 32
G = G * 5
Readeeprom B , G
Call Lcd_locate(lcd_posx , Lcd_posy)
A = 8 '1.linie frei
If Lcd_doublesize = 1 Then A = 32
If Lcd_doublesize = 2 Then A = 16
While A > 0
Call Lcd_sendbyte(lcd_prm , Lcd_bcolor)
Decr A
Wend
'Reset Watchdog
'linie 2-6
For F = 1 To 5
C = 1
If Lcd_doublesize = 1 Then C = C + 1 '2x ??
While C > 0
D = B 'Byte darf nicht verandert werden fur 2. durchlauf
For E = 1 To 8
A = D And 1
If A = 1 Then
Call Lcd_sendbyte(lcd_prm , Lcd_fcolor)
If Lcd_doublesize > 0 Then Call Lcd_sendbyte(lcd_prm , Lcd_fcolor)
Else
Call Lcd_sendbyte(lcd_prm , Lcd_bcolor)
If Lcd_doublesize > 0 Then Call Lcd_sendbyte(lcd_prm , Lcd_bcolor)
End If
Shift D , Right , 1
Next
Decr C
Wend
G = G + 1
Readeeprom B , G
Next
'Reset Watchdog
Incr Lcd_posx
If Lcd_doublesize = 1 Then
If Lcd_posx > 8 Then
Lcd_posx = 1
Incr Lcd_posy
If Lcd_posy > 4 Then Lcd_posy = 1
End If
Else
If Lcd_posx > 16 Then
Lcd_posx = 1
Incr Lcd_posy
If Lcd_posy > 8 Then Lcd_posy = 1
End If
End If
Next
Call Lcd_sendbyte(lcd_cmd , &H36) 'und wieder von links nach rechts
Call Lcd_sendbyte(lcd_prm , 0)
Call Lcd_sendbyte(lcd_cmd , &H2C) 'Und wieder Daten
End Sub
'-------------------------------------------------------------------------------
'Koordinatenfenster
'-------------------------------------------------------------------------------
Sub Lcd_locate(byval Lcd_x As Byte , Byval Lcd_y As Byte)
Local A As Byte
Local B As Byte
Local C As Byte
Local D As Byte
'Reset Watchdog
Lcd_posx = Lcd_x
Lcd_posy = Lcd_y
If Lcd_doublesize = 1 Then
A = Lcd_x - 1
A = A * 12
C = A + 11
B = Lcd_y - 1
B = B * 16
B = B + 2
D = B + 15
Elseif Lcd_doublesize = 2 Then
A = Lcd_x - 1
A = A * 6
C = A + 5
B = Lcd_y - 1
B = B * 16
B = B + 2
D = B + 15
Else
A = Lcd_x - 1
A = A * 6
C = A + 5
B = Lcd_y - 1
B = B * 8
B = B + 2
D = B + 7
End If
Call Lcd_setframe(a , B , C , D)
End Sub
'-------------------------------------------------------------------------------
'Frame
'-------------------------------------------------------------------------------
Sub Lcd_setframe(byval Lcd_left As Byte , Byval Lcd_top As Byte , Byval Lcd_width As Byte , Byval Lcd_height As Byte)
'Reset Watchdog
Call Lcd_sendbyte(lcd_cmd , &H2A)
Call Lcd_sendbyte(lcd_prm , Lcd_left)
Call Lcd_sendbyte(lcd_prm , Lcd_width)
'Set Lcd_out.lcd_cs 'Cs auf 1 Ende der Sequenz
Call Lcd_sendbyte(lcd_cmd , &H2B)
Call Lcd_sendbyte(lcd_prm , Lcd_top)
Call Lcd_sendbyte(lcd_prm , Lcd_height)
'Set Lcd_out.lcd_cs 'Cs auf 1 Ende der Sequenz
Call Lcd_sendbyte(lcd_cmd , &H2C) 'Und wieder Daten
End Sub
'-------------------------------------------------------------------------------
'Color
'-------------------------------------------------------------------------------
Sub Lcd_setcolor(byval Forecolor As Byte , Byval Backcolor As Byte)
Lcd_fcolor = Forecolor
Lcd_bcolor = Backcolor
End Sub
'-------------------------------------------------------------------------------
'Initialisierung (8bit-Modus)
'-------------------------------------------------------------------------------
Sub Lcd_setdoublesize(byval Size As Byte)
Lcd_doublesize = Size
End Sub
'-------------------------------------------------------------------------------
'Ubertragen eines Commandos oder eines Parameters / Datenbytes
'-------------------------------------------------------------------------------
Sub Lcd_sendbyte(byval Lcd_command As Byte , Byval Lcd_data As Byte)
Local R As Integer
Local A As Byte
Reset Watchdog
Reset P_out.lcd_cs 'Cs auf 0 Start der Sequenz
If Lcd_command = Lcd_cmd Then
Reset P_out.lcd_sclk
Reset P_out.lcd_sdata '0 fur Command
Set P_out.lcd_sclk
Else
Reset P_out.lcd_sclk
Set P_out.lcd_sdata '1 fur Data
Set P_out.lcd_sclk
End If
Shiftout P_out.lcd_sdata , P_out.lcd_sclk , Lcd_data , Msbl
Set P_out.lcd_cs 'Cs auf 1 Ende der Sequenz
End Sub
'-------------------------------------------------------------------------------
' meine routinen
'-------------------------------------------------------------------------------
Sub Lcd_command(lcommand As Byte)
'Reset Watchdog
'Cs auf 0 Start der Sequenz
Reset Lcd_io.lcd_cs
'0 fur Command
Reset Lcd_io.lcd_sclk 'Porta.3 = 0
Reset Lcd_io.lcd_sdata 'Porta.2 = 0
Set Lcd_io.lcd_sclk 'Porta.3 = 1
Spiinit
Spiout Lcommand , 1
End Sub
'-------------------------------------------
'Senden eines Wertes
'-------------------------------------------
Sub Lcd_parameter(lparameter As Byte)
'Reset Watchdog
'Cs auf 0 Start der Sequenz
Reset Lcd_io.lcd_cs 'Porta.1 = 0
'1 fur Parameter
Reset Lcd_io.lcd_sclk 'Porta.3 = 0
Set Lcd_io.lcd_sdata 'Porta.2 = 1
Set Lcd_io.lcd_sclk 'Porta.3 = 1
Spiinit
Spiout Lparameter , 1
End Sub
'-----------------------------------------------
Sub Lcd_init
'Reset Watchdog
'Initialisierung Reset
Reset Lcd_io.lcd_rs
Waitms 5
Set Lcd_io.lcd_rs
Set Lcd_io.lcd_cs
Set Lcd_io.lcd_cs
Set Lcd_io.lcd_sclk 'Porta.3 = 1
'Software Reset
Call Lcd_command(&H01)
Set Lcd_io.lcd_cs
Waitms 5
'Sleep out
Call Lcd_command(&H11)
Set Lcd_io.lcd_cs
'Voltage control
Call Lcd_command(&Hba) 'Voltage 127 - 63
Call Lcd_parameter(127)
Call Lcd_parameter(3)
'Gosub Cs
'Contrast
Call Lcd_command(&H25) 'Voltage
Call Lcd_parameter(63) '63
'Gosub Cs
'Display ON
Call Lcd_command(&H29)
Set Lcd_io.lcd_cs
'Booster voltage ON
Call Lcd_command(&H03)
Set Lcd_io.lcd_cs
Waitms 40
Call Lcd_command(&H3a)
Call Lcd_parameter(&H02)
'Booster voltage stabilizing
'**************************************************************************
' <Display setup2>
'Inversion control 'Off, normal
Call Lcd_command(&H20)
Set Lcd_io.lcd_cs
End Sub
'--------------------------------------------------------
Sub Lcd_cls(bcolor As Byte)
'Local Lr As Integer
'Reset Watchdog
Call Lcd_command(&H3a)
Call Lcd_parameter(2)
Set Lcd_io.lcd_cs
'Colour set
'nur fur 8 bit relevant
Call Lcd_command(&H2d)
'rot
Call Lcd_parameter(&H0)
Call Lcd_parameter(&H2)
Call Lcd_parameter(&H3)
Call Lcd_parameter(&H4)
Call Lcd_parameter(&H5)
Call Lcd_parameter(&H6)
Call Lcd_parameter(&H8)
Call Lcd_parameter(&Hf)
'grun
Call Lcd_parameter(&H0)
Call Lcd_parameter(&H2)
Call Lcd_parameter(&H3)
Call Lcd_parameter(&H4)
Call Lcd_parameter(&H5)
Call Lcd_parameter(&H6)
Call Lcd_parameter(&H8)
Call Lcd_parameter(&Hf)
'Blau
Call Lcd_parameter(&H0)
Call Lcd_parameter(&H3)
Call Lcd_parameter(&H6)
Call Lcd_parameter(&Hf)
Call Lcd_setframe(0 , 0 , 97 , 67)
Set Lcd_io.lcd_cs
Call Lcd_command(&H2c)
Bcol = Bcolor
For Rr = 0 To 6566
'Reset Watchdog
Call Lcd_parameter(bcolor)
Next Rr
End Sub
'------------------------------------------------------------
Sub Lcd_plot(byval Plotx As Byte , Byval Ploty As Byte , Byval Fcolor As Byte)
Local Lx1 As Byte
Local Ly1 As Byte
Local Ly2 As Byte
Local Lx2 As Byte
'Reset Watchdog
Lx1 = Plotx
Ly1 = Ploty
Ly2 = Plotx
Lx2 = Ploty
Call Lcd_setframe(lx1 , Ly1 , Lx2 , Ly2 )
Call Lcd_command(&H2c)
P = 1
Call Lcd_parameter(fcolor)
End Sub
'------------------------------
Sub Getline(s As String)
S = ""
Reset Watchdog
Do
M = Inkey()
Select Case M
Case 0 'nothing
Case 13 ' we do not need this one
Case 10 : If S <> "" Then Exit Do ' if we have received something
Case Else
S = S + Chr(m)
' Call Lcd_print(1 , 4 , 0 , Blau , 0 , S)
If S = "> " Then Exit Do
If Right(s , 2) = "OK" Then Exit Do
If S = "OK" Then Exit Do
' build string
End Select
Loop
End Sub
'flush input buffer
Sub Flushbuf()
Waitms 100 'give some time to get data if it is there
Do
M = Inkey() ' flush buffer
Loop Until M = 0
End Sub
'------------------------------------------
' Frequenzmessung
'------------------------------------------
Oncapture:
Disable Icp1
Wcountlo = Timer1
'Delta = Lcount - Wcountlo
Timer1 = 0
'Dfg = Str(lcount)
'Call Lcd_print(1 , 5 , 0 , 255 , 0 , Dfg)
Wcounthi = 0
Enable Icp1
Return
Onoverflow:
Incr Wcounthi
Return
Sub Temperature ' actual measuring
1wwrite &HCC : 1wwrite &H44 ' start measure
Waitms 300 ' wait for end of conversion
Read1820 ' read 9 bytes
If Err = 1 Then ' if there is no sensor
Locate 2 , 4 : Lcd "-- " ' we put "-- " on LCD
Else
If Crc = 0 Then ' sensor present, check CRC
Locate 2 , 4 : Lcd T ' CRC OK, print T*10 on LCD
Else
Locate 2 , 4 : Lcd "** " ' CRC NOT OK, "** " on LCD
End If
End If
End Sub
'//////////////////////////////////////////////////////////////////////////////
Sub Read1820 ' reads sensor ans calculate
' T for 0.1 C
1wreset ' reset the bus
1wwrite &HCC ' read internal RAM
1wwrite &HBE ' read 9 data bytest
Bd(1) = 1wread(9) ' read bytes in array
1wreset ' reset the bus
Crcit ' ckeck CRC
If Crc = 0 Then ' if is OK, calculate for
Tmp = Bd(1) And 1 ' 0.1C precision
If Tmp = 1 Then Decr Bd(1)
T = Makeint(bd(1) , Bd(2))
T = T * 50 : T = T - 25 : T1 = Bd(8) - Bd(7) : T1 = T1 * 100
T1 = T1 / Bd(8) : T = T + T1 : T = T / 10
End If
End Sub
'//////////////////////////////////////////////////////////////////////////////
Sub Crcit ' calculate 8 bit CRC
' bigger but faster
Crc = 0 ' needs a 256 elements table
For I = 1 To 9
Tmp = Crc Xor Bd(i)
Crc = Lookup(tmp , Crc8)
Next
End Sub
'//////////////////////////////////////////////////////////////////////////////
Crc8:
Data 0 , 94 , 188 , 226 , 97 , 63 , 221 , 131 , 194 , 156
Data 126 , 32 , 163 , 253 , 31 , 65 , 157 , 195 , 33 , 127
Data 252 , 162 , 64 , 30 , 95 , 1 , 227 , 189 , 62 , 96
Data 130 , 220 , 35 , 125 , 159 , 193 , 66 , 28 , 254 , 160
Data 225 , 191 , 93 , 3 , 128 , 222 , 60 , 98 , 190 , 224
Data 2 , 92 , 223 , 129 , 99 , 61 , 124 , 34 , 192 , 158
Data 29 , 67 , 161 , 255 , 70 , 24 , 250 , 164 , 39 , 121
Data 155 , 197 , 132 , 218 , 56 , 102 , 229 , 187 , 89 , 7
Data 219 , 133 , 103 , 57 , 186 , 228 , 6 , 88 , 25 , 71
Data 165 , 251 , 120 , 38 , 196 , 154 , 101 , 59 , 217 , 135
Data 4 , 90 , 184 , 230 , 167 , 249 , 27 , 69 , 198 , 152
Data 122 , 36 , 248 , 166 , 68 , 26 , 153 , 199 , 37 , 123
Data 58 , 100 , 134 , 216 , 91 , 5 , 231 , 185 , 140 , 210
Data 48 , 110 , 237 , 179 , 81 , 15 , 78 , 16 , 242 , 172
Data 47 , 113 , 147 , 205 , 17 , 79 , 173 , 243 , 112 , 46
Data 204 , 146 , 211 , 141 , 111 , 49 , 178 , 236 , 14 , 80
Data 175 , 241 , 19 , 77 , 206 , 144 , 114 , 44 , 109 , 51
Data 209 , 143 , 12 , 82 , 176 , 238 , 50 , 108 , 142 , 208
Data 83 , 13 , 239 , 177 , 240 , 174 , 76 , 18 , 145 , 207
Data 45 , 115 , 202 , 148 , 118 , 40 , 171 , 245 , 23 , 73
Data 8 , 86 , 180 , 234 , 105 , 55 , 213 , 139 , 87 , 9
Data 235 , 181 , 54 , 104 , 138 , 212 , 149 , 203 , 41 , 119
Data 244 , 170 , 72 , 22 , 233 , 183 , 85 , 11 , 136 , 214
Data 52 , 106 , 43 , 117 , 151 , 201 , 74 , 20 , 246 , 168
Data 116 , 42 , 200 , 150 , 21 , 75 , 169 , 247 , 182 , 232
Data 10 , 84 , 215 , 137 , 107 , 53