'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''moja konfiguracja sprzetowa $regfile = "m128def.dat" $crystal = 14745600 $hwstack = 255 $swstack = 255 $framesize = 255 $baud = 9600 '**************************** Definicje związane z lcd i inne************************ '************************************************************************************* Config Adc = Single , Prescaler = Auto , Reference = Avcc 'adc Enable Adc Start Adc Config Timer1 = Pwm , Pwm = 8 , Compare B Pwm = Clear Up , Prescale = 8 'pwm Enable Timer1 Start Timer1 Config Timer3 = Timer , Prescale = 64 On Timer3 Sekunda Enable Timer3 Start Timer3 Enable Interrupts 'Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , 'Polarity = Low , Phase = 1 , Clockrate = 4 Config Graphlcd = 240 * 64 , Dataport = Portc , Controlport = Porta , Ce = 3 , Cd = 2 , Wr = 1 , Rd = 0 , Reset = 4 , Fs = 5 , Mode = 6 'lcd graficzny Cls Cursor Off Config Sda = Portf.3 'BMP085 podlaczenie Config Scl = Portf.4 'BMP085 podlaczenie ' Config Portf.1 = Output 'poswietlenia sw+led Ledsw Alias Portf.1 'masa diod ' 1-1 czerw, 0-1 niebieska, 1-0 czerwona Config Portd.0 = Output 'led 1 sw 1 Led1 Alias Portd.0 Config Portd.1 = Output 'led 2 sw 2 Led2 Alias Portd.1 Config Portd.2 = Output 'led 3 sw 3 Led3 Alias Portd.2 Config Portd.3 = Output 'led 4 sw 4 Led4 Alias Portd.3 Config Portf.2 = Output 'led 5 sw 5 Led5 Alias Portf.2 Config Portf.2 = Output 'rtc enable Rtc_cs Alias Portb.5 Config Pind.4 = Input 'sw 1 Sw1 Alias Pind.4 Config Pind.5 = Input 'sw 2 Sw2 Alias Pind.5 Config Pind.6 = Input 'sw 3 Sw3 Alias Pind.6 Config Pind.7 = Input 'sw 4 Sw4 Alias Pind.7 Config Pinf.0 = Input 'sw 5 Sw5 Alias Pinf.0 Declare Sub Program1 'podprogramy Declare Sub Program2 'podprogramy Declare Sub Program3 'podprogramy Declare Sub Program4 'podprogramy Declare Sub Program5 'podprogramy Declare Sub Main Declare Sub Disp 'podprogram lcd Declare Sub Rs 'dane rs Declare Sub Clslcd Declare Sub Logmaxmin Dim Programn As Byte 'zmienna programowa Programn = 2 'zmienna do licznika Dim Licznikn As Byte Dim Menu As Byte ' zmienna menu Dim Zmiany As Bit ' zmiana ustawien daty i godziny Config Debounce = 30 Dim Y As Byte Dim X As Byte Dim Move As Byte Move = 0 Y = 0 X = 0 Dim Wyniki As Byte 'przelaczanie odczytow Wyniki = 1 Dim Minmax As Bit Minmax = 0 Dim Minmaxstart As Bit Minmaxstart = 0 Dim Cl As Bit Cl = 0 'zmienna czyszczaca ekran Declare Sub Cisnienie_duze Dim Cis_tys As Long Dim Cis_set As Long Dim Cis_dzie As Long Dim Cis_dzie1 As Long Dim Cis_jed As Long Dim Cis_jed1 As Long Dim Tempds As Long Dim Tempbmp As Long Dim Tempds_jed As Long Dim Tempds_dzie As Long Dim Tempds_set As Long Dim Tempbmp_jed As Long Dim Tempbmp_dzie As Long Dim Tempbmp_tys As Long Dim Tempbmp_set As Long Dim Wilg_dzie As Long Dim Wilg_jed As Long Declare Sub Odczyt Declare Sub Temp_duze Declare Sub Temp_duze_bmp Declare Sub Wilg_duze Config Pinf.6 = Input ' adc Dim Osw As Word Dim Osw1 As Byte Osw = 1 Dim Podswnoc As Byte Dim Podsw As Byte 'podswietlenie Config Portb.6 = Output '**************************** Definicje związane z ds18b20 *************************** '************************************************************************************* Declare Sub Rtemp Dim Temp As Integer Dim Temp1 As Integer Dim Temp2 As Integer 'znienna do min max Dim Napis As String * 6 Dim Z As Long Dim Z1 As Long Dim Z2 As Long Dim B As Byte Dim Led As Byte Dim Tempdsmin As Integer Dim Tempdsmax As Integer Dim Dthe As Bit Dim Dthes As Bit Dim Bmpe As Bit Dim Dse As Bit Config 1wire = Portb.0 'podlaczenie 1wire Tempdsmin = 100 Tempdsmax = 1 Dim Licznik As Byte 'licznik w przerwaniu Licznik = 1 Dthe = 0 Dthes = 0 Bmpe = 0 Dse = 0 '**************************** Definicje związane z DTH11 *************************** '************************************************************************************* Dht_put Alias Portb.0 'podlaczenie 1wire Dht_get Alias Pinb.0 'podlaczenie 1wire Dht_io_set Alias Ddrb.0 'podlaczenie 1wire Declare Sub Get_th(th As Byte , Hh As Byte) Dim Th As Byte Dim Hh As Byte Dim Hh1 As Byte Dim Hh2 As Byte 'znienna do min max Dim Hmin As Byte Dim Hmax As Byte Dim Crc As Byte Dim Mybyte As Byte Dim Sensor_data As String * 40 Dim Tmp_str8 As String * 8 Dim Count As Byte Hmin = 99 '**************************** Definicje związane z BMP085 *************************** '************************************************************************************* Dim Tempbmmin As Single Dim Tempbmmax As Single Dim Cismin As Single Dim Cismax As Single Dim Ac1 As Integer Dim Ac1a As Long Dim Ac2 As Integer Dim Ac3 As Integer Dim Ac4 As Word Dim Ac5 As Word Dim Ac5a As Single Dim Ac6 As Word Dim B1 As Integer Dim B2 As Integer Dim B3 As Long Dim B3a As Long Dim B4 As Long Dim B5 As Long Dim B6 As Integer Dim B6a As Long Dim B7 As Long Dim Mb As Integer Dim Mc As Integer Dim Mc2 As Long Dim Md As Integer Dim Adres As Byte Dim Wert As Byte Dim Ut As Long Dim X1 As Long Dim X1t As Single Dim X2 As Long Dim X3 As Long Dim Tbmp As Single Dim Tbmp1 As Long Dim Tbmp2 As Single Dim Tbmp3 As Single 'zmienna max min Dim T2 As Long Dim Temperatur As String * 6 Dim Temperatur1 As String * 6 Dim Luftdruck As String * 8 Dim Luftdruck1 As String * 8 Dim Druck As Single Dim Druck1 As Single Dim Druck2 As Single Dim Cis_duze As Long Dim P As Long Dim P2 As Long Dim 2potenz15 As Long Dim 2potenz11 As Integer Dim 2potenz13 As Integer Dim 2potenz8 As Integer Dim 2potenz4 As Integer Dim 2potenz2 As Integer Dim 2potenz16 As Long Dim 2potenz12 As Integer Dim Msb As Long Dim Lsb As Long Dim Up As Long Dim Druckvar As Byte Declare Sub Berechne_temp Declare Sub Berechne_druck Declare Sub Schreibe_bmp085(byval Adres As Byte , Byval Wert As Byte) Declare Sub Lese_bmp085(byval Adres As Byte , Wert As Byte) Declare Sub Lese_roh_daten Declare Sub Messen Declare Sub Lese_kalib_data Declare Sub Lese Const Addr_schreiben = &B11101110 Const Addr_lesen = &B11101111 Dim Lese_start As Bit Cismin = 1200 '**************************** Definicje związane z PCF8583 *************************** '************************************************************************************* Declare Sub Gettime Dim Sek As Byte 'zmienna porownawcza Dim Sk As Byte Dim Mk As Byte Dim Hk As Byte Dim S As Byte Dim S_string As String * 8 Dim M As Byte Dim H As Byte Dim Yd As Byte Dim Wm As Byte Dim Day As Byte Dim Weekdays As Byte Dim Month As Byte Dim Year As Byte Dim S_bcd As Byte Dim M_bcd As Byte Dim H_bcd As Byte Dim Yd_bcd As Byte Dim Wm_bcd As Byte Dim Day_bcd As Byte Dim Weekdays_bcd As Byte Dim Month_bcd As Byte Dim Year_bcd As Byte ' Dim Czas_pcf As String * 8 ' wyswietlanie czasu Dim Data_pcf As String * 8 ' wyswietlanie daty Dim Ss As String * 8 Declare Sub Ustaw_zegar Dim Ust_zeg As Byte Declare Sub Ustawianie Dim Zmienna_ust As Byte Zmienna_ust = 0 Dim Gd As String * 8 Dim Mda As String * 8 Dim Sd As String * 8 Dim Ydd As String * 8 Dim Wmd As String * 8 Dim Yeard As String * 8 Declare Sub Zegar_duze '**************************** Glowny program ***************************************** '************************************************************************************* Call Lese_kalib_data Readeeprom Podsw , 1 Readeeprom Podswnoc , 2 Do Call Main Loop '**************************** Program Main ***************************************** '************************************************************************************* Main: Do Osw = Getadc(6) If Osw1 = 1 Then Ocr1b = Podsw Else Ocr1b = 0 End If If Osw <= 8 And Osw1 = 0 Then Ocr1b = Podswnoc End If If Osw > 9 And Osw <= 13 And Osw1 = 0 Then Ocr1b = 0 End If If Osw > 13 And Osw1 = 0 Then Ocr1b = 0 End If '############################################### 'wejscie w programowanie zegara If Sw1 = 0 And Sw5 = 1 Then Waitms 20 End If If Sw1 = 0 And Sw5 = 1 Then Programn = 1 Licznik = 1 Osw1 = 1 Reset Ledsw Set Led1 Reset Led2 Reset Led3 Reset Led4 Reset Led5 Cls End If If Sw5 = 0 And Sw1 = 0 Then Waitms 20 End If If Sw5 = 0 And Sw1 = 0 Then Osw1 = 1 Set Ledsw Set Led1 Reset Led2 Reset Led3 Reset Led4 Set Led5 Wait 1 Call Ustaw_zegar End If '############################################### If Sw2 = 0 Then Waitms 20 End If If Sw2 = 0 Then Osw1 = 1 Programn = 2 Reset Ledsw Reset Led1 Set Led2 Reset Led3 Reset Led4 Reset Led5 Cls End If If Sw3 = 0 Then Waitms 20 End If If Sw3 = 0 Then Osw1 = 1 Programn = 3 Reset Ledsw Reset Led1 Reset Led2 Set Led3 Reset Led4 Reset Led5 Cls End If If Sw4 = 0 Then Waitms 20 End If If Sw4 = 0 Then Osw1 = 1 Programn = 4 Reset Ledsw Reset Led1 Reset Led2 Reset Led3 Reset Led5 Set Led4 Cls End If If Sw5 = 0 Then Waitms 20 End If If Sw5 = 0 Then Osw1 = 1 Programn = 6 Reset Ledsw Reset Led1 Reset Led2 Reset Led3 Reset Led4 Set Led5 Cls End If If Sw1 = 0 And Sw2 = 0 Then Waitms 500 End If If Sw1 = 0 And Sw2 = 0 Then Programn = 5 End If If Licznik = 1 Then Dthe = 0 Dthes = 0 Bmpe = 0 Dse = 0 End If Select Case Programn Case 1 : Program1 Case 2 Program2 Case 3 : Program3 Case 4 : Program4 Case 5 Ustaw_zegar Case 6: Program5 End Select Loop '**************************** Program 1 ********************************************** '************************************************************************************* Program1: Call Odczyt Call Gettime 'odczyt zegara Call Disp 'procedura wyswietlenia na lcd Call Logmaxmin Call Rs Return '**************************** Program 2********************************************** '************************************************************************************* Program2: Programn = 2 If Licznik = 0 Or Licznik = 19 Or Licznik = 39 Then Call Clslcd End If Call Odczyt Call Gettime Call Logmaxmin Call Rs If Wyniki = 1 Then Call Zegar_duze End If If Wyniki = 2 Then Call Cisnienie_duze End If If Wyniki = 3 Then Call Temp_duze End If If Wyniki = 4 Then Call Temp_duze_bmp End If If Wyniki = 5 Then Call Wilg_duze End If Return '**************************** Program 3 ********************************************** '************************************************************************************* Program3: Programn = 3 Call Odczyt Call Gettime If Wyniki = 2 Then Call Temp_duze_bmp End If Call Rs Return '**************************** Program 4 ********************************************** '************************************************************************************* Program4: Programn = 4 Return '**************************** Program 5 ********************************************** '************************************************************************************* Program5: Line(0 , 0) -(240 , 0) , 255 ' horizontal linia Line(0 , 32) -(160 , 32) , 255 'LINE(X0,Y0) - (X1,Y1), on/off Line(0 , 63) -(240 , 63) , 255 ' vertical linia Line(0 , 0) -(0 , 63) , 255 Line(80 , 0) -(80 , 63) , 255 Line(160 , 0) -(160 , 63) , 255 Line(239 , 0) -(239 , 63) , 255 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Bmpe = 1 Then Call Messen 'odczyt cisnienia i temp Tbmp = Tbmp / 10 Temperatur = Fusing(tbmp , "###.##") Druck = P Druck = Druck / 100 Druck = Druck + 16 Luftdruck = Fusing(druck , "####.##") End If If Dse = 1 Then Call Rtemp 'odczyt temp ds-a End If If Dthe = 1 And Dthes = 0 Then Call Get_th(th , Hh) 'odczyt wilgotnosc End If '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Locate 2 , 2 Lcd "Temp.dom" Locate 2 , 15 Lcd "Cisnienie" Locate 4 , 2 Lcd Temperatur ; " C" ; " " Locate 4 , 15 Lcd Luftdruck ; " hPa" Locate 6 , 2 Lcd "Temp.zew" Locate 6 , 15 Lcd "Wilgotnosc" Locate 8 , 2 Lcd ; Napis ; " C " ; " " Locate 8 , 15 Lcd ; Hh ; "%" ; " " If Temp > 260 Then Showpic 181 , 1 , Hot End If If Temp < 260 And Temp > 0 Then Showpic 175 , 1 , Cloudy End If If Temp < 0 Then Showpic 175 , 1 , Snow End If If Hh > 45 Or Druck < 1005 Then Showpic 175 , 1 , Rain End If If H = 1 Or Temp = 0 Then Showpic 175 , 1 , Error End If Return '**************************** kasowanie wyswietlacza *********************************** '************************************************************************************* Clslcd: For X = 0 To 240 For Y = 0 To 64 Pset X , Y , 0 ' set the pixel Next X Next Y Return '**************************** Wyswietlanie wynikow *********************************** '************************************************************************************* Disp: Disable Interrupts Locate 1 , 1 Lcd "Temperatura w domu: " ; Temperatur ; " C" ; Spc(10) Locate 2 , 1 Lcd "Cisnienie : " ; Luftdruck ; " hPa" If Temp = 0 And Hh = 1 Then Locate 3 , 1 Lcd "Temperatura na dworze: " ; "Error" ; " C " ; Spc(10) Locate 4 , 1 Lcd "Wilgotnosc powietrza: " ; "Error" ; "%" ; Spc(10) Else Locate 3 , 1 Lcd "Temperatura na dworze: " ; Napis ; " C " ; Spc(10) Locate 4 , 1 Lcd "Wilgotnosc powietrza: " ; Hh ; "%" ; Spc(10) End If 'Cismin 'Cismax 'Tempbmmin 'Tempbmmax 'Tempdsmin 'Tempdsmax 'hmin 'hmax '********************************************'zegar na lcd Locate 8 , 1 Lcd Czas_pcf ; " " ; Data_pcf ; " " Locate 8 , 22 Select Case Weekdays Case 0 : Lcd "Poniedzialek" Case 1 : Lcd "Wtorek" Case 2 : Lcd "Sroda" Case 3 : Lcd "Czwartek" Case 4 : Lcd "Piatek" Case 5 : Lcd "Sobota" Case 6 : Lcd "Niedziela" End Select '********************************************'pomocnicze na lcd 'Locate 7 , 1 'Lcd "program " ; Programn ; " " ; "licznik= " ; Licznik ; " " 'Locate 7 , 25 'Lcd Bmpe ; " " ; Dse ; " " ; Dthe ; " " ; Dthes ; " " ; Ocr1b 'Locate 7 , 1 'Lcd "adc= " ; Osw ; " " ; "Podswietlenie= " ; Podsw ; " " ; Podswnoc; " " '******************************************** grafika If Temp > 260 Then Showpic 185 , 0 , Hot End If If Temp < 260 And Temp > 0 And Hh < 45 Then Showpic 185 , 0 , Cloudy End If If Temp < 0 Then Showpic 185 , 0 , Snow End If If Hh > 45 Or Druck < 1005 Then Showpic 185 , 0 , Rain End If If H = 1 Or Temp = 0 Then Showpic 185 , 0 , Error End If Enable Interrupts Return '**************************** Dane do rs-a ************************************** '************************************************************************************* Rs: If Licznik = 1 Or Licznik = 20 Or Licznik = 40 Then Print "***************************************" Select Case Wyniki Case 1 : Print "zegar" Case 2 : Print "cisnienie" Case 3 : Print "temperatura dwor" Case 4 : Print "temperatuda dom" Case 5 : Print "wilgotnosc" End Select Print "-----------------------------------------" Print "Temperatura w domu = " ; Temperatur ; " C" Print "Temperatura w domu min = " ; Tempbmmin Print "Temperatura w domu max = " ; Tempbmmax Print "-----------------------------------------" Print "Cisnienie =" ; Luftdruck ; " hPa" Print "Cisnienie min = " ; Cismin Print "Cisnienie max = " ; Cismax Print "-----------------------------------------" Print "Temperatura na dworze =" ; Napis ; " C " Print "Temperatura na dworze min = " ; Tempdsmin Print "Temperatura na dworze max = " ; Tempdsmax Print "-----------------------------------------" Print "Wilgotnosc powietrza =" ; Hh ; "%" Print "Wilgotnosc min = " ; Hmin Print "Wilgotnosc max = " ; Hmax Print "-----------------------------------------" Print "-----------------------------------------" Print "minmax = " ; Minmax Print "-----------------------------------------" Print Czas_pcf ; " " ; Data_pcf ; " " Print "***************************************" Print " " Print " " Print " " End If Return '**************************** Ustawianie zegara ************************************** '************************************************************************************* Ustaw_zegar: Programn = 5 Cls Menu = 1 Do If Menu > 4 Then Menu = 1 Debounce Sw1 , 0 , Menu_incr , Sub Select Case Menu Case 1 : Locate 1 , 1 Lcd "MENU > Ustawianie czasu " Waitms 150 Toggle Ledsw Set Led1 Set Led2 Reset Led3 Reset Led4 Set Led5 Debounce Sw5 , 0 , Main : Debounce Sw2 , 0 , Menu_dt , Sub Case 2 : Locate 1 , 1 Lcd "MENU > Ustawianie podswietlenia dzien" ; Spc(10) Waitms 150 Toggle Ledsw Set Led1 Reset Led2 Set Led3 Set Led4 Reset Led5 Debounce Sw5 , 0 , Main : Debounce Sw3 , 0 , Menu_pods , Sub Case 3 : Locate 1 , 1 Lcd "MENU > Ustawianie podswietlenia noc" ; Spc(10) Waitms 150 Set Ledsw Reset Led1 Reset Led2 Reset Led3 Reset Led4 Reset Led5 Debounce Sw5 , 0 , Main : Debounce Sw4 , 0 , Menu_pods_noc , Sub Case 4 : Locate 1 , 1 Lcd "MENU > Ustawianie loggera" ; Spc(10) Waitms 150 Set Ledsw Reset Led1 Reset Led2 Reset Led3 Reset Led4 Reset Led5 Debounce Sw5 , 0 , Main : Debounce Sw3 , 0 , Menu_dt , Sub End Select Loop Return Menu_incr: Incr Menu Return '**************************** Ustawianie zegara Menu_dt******************************* '************************************************************************************* Menu_dt: Menu = 1 Zmiany = 0 Do Debounce Sw1 , 0 , Menu_incr , Sub Toggle Ledsw Set Led1 Reset Led2 Set Led3 Set Led4 Reset Led5 Select Case Menu Case 1 : Locate 1 , 1 Lcd "MENU > Ustaw godzine" ; Spc(10) Gosub Czas_menu Locate 3 , 1 Lcd Czas_pcf ; " " ; Data_pcf Locate 4 , 1 Lcd "==" ; Spc(18) If Sw4 = 0 Then Incr H If H > 23 Then H = 0 Waitms 300 End If If Sw3 = 0 Then Decr H If H = 255 Then H = 23 Waitms 300 End If Case 2 : Locate 1 , 1 Lcd "MENU > Ustaw minuty" ; Spc(10) Gosub Czas_menu Locate 3 , 1 Lcd Czas_pcf ; " " ; Data_pcf Locate 4 , 1 Lcd Spc(3) ; "==" ; Spc(15) If Sw4 = 0 Then Incr M If M > 59 Then M = 0 Waitms 300 End If If Sw3 = 0 Then Decr M If M = 255 Then M = 59 Waitms 300 End If Case 3 : Locate 1 , 1 Lcd "MENU > Ustaw sekundy" ; Spc(10) Gosub Czas_menu Locate 3 , 1 Lcd Czas_pcf ; " " ; Data_pcf Locate 4 , 1 Lcd Spc(6) ; "==" ; Spc(12) If Sw4 = 0 Then Incr S If S > 59 Then S = 0 Waitms 300 End If If Sw3 = 0 Then Decr S If S = 255 Then S = 59 Waitms 300 End If Case 4 : Locate 1 , 1 Lcd "MENU > Ustaw dzien" ; Spc(10) Gosub Czas_menu Locate 3 , 1 Lcd Czas_pcf ; " " ; Data_pcf Locate 4 , 1 Lcd Spc(10) ; "==" ; Spc(8) If Sw4 = 0 Then Incr Day If Day > 31 Then Day = 1 Waitms 300 End If If Sw3 = 0 Then Decr Day If Day = 0 Then Day = 31 Waitms 300 End If Case 5 : Locate 1 , 1 Lcd "MENU > Ustaw miesiac" ; Spc(10) Gosub Czas_menu Locate 3 , 1 Lcd Czas_pcf ; " " ; Data_pcf Locate 4 , 1 Lcd Spc(13) ; "==" ; Spc(5) If Sw4 = 0 Then Incr Month If Month > 12 Then Month = 1 Waitms 300 End If If Sw3 = 0 Then Decr Month If Month = 0 Then Month = 12 Waitms 300 End If Case 6 : Locate 1 , 1 Lcd "MENU > Ustaw rok" ; Spc(10) Gosub Czas_menu Locate 3 , 1 Lcd Czas_pcf ; " " ; Data_pcf Locate 4 , 1 Lcd Spc(16) ; "====" If Sw4 = 0 Then Incr Year If Year > 14 Then Year = 12 Waitms 300 End If If Sw3 = 0 Then Decr Year If Year = 11 Then Year = 14 Waitms 300 End If Case 7 : Locate 1 , 1 Lcd "MENU > Ustaw dzien tygodnia" ; Spc(10) Locate 4 , 1 Lcd Spc(15) ; " " Locate 3 , 1 Select Case Weekdays Case 0 : Lcd "Poniedzialek" ; Spc(8) Case 1 : Lcd "Wtorek" ; Spc(14) Case 2 : Lcd "Sroda" ; Spc(15) Case 3 : Lcd "Czwartek" ; Spc(12) Case 4 : Lcd "Piatek" ; Spc(14) Case 5 : Lcd "Sobota" ; Spc(14) Case 6 : Lcd "Niedziela" ; Spc(11) End Select If Sw4 = 0 Then Incr Weekdays If Weekdays > 6 Then Weekdays = 0 Waitms 300 End If If Sw3 = 0 Then Decr Weekdays If Weekdays = 255 Then Weekdays = 6 Waitms 300 End If Case 8 : Locate 1 , 1 Lcd "Zapisac czas? " ; Spc(4) Locate 3 , 1 Lcd Spc(3) ; "Tak Nie" ; Spc(9) Locate 4 , 1 If Zmiany = 1 Then Lcd Spc(3) ; "===" ; Spc(14) Else Lcd Spc(8) ; "===" ; Spc(9) End If If Sw3 = 0 Or Sw4 = 0 Then Toggle Zmiany Waitms 500 End If Case 9 : If Zmiany = 1 Then Gosub Settime Cls Locate 2 , 1 Lcd " Czas ustawiony " Wait 1 Gosub Main Else Cls Locate 2 , 1 Lcd "Czas nie ustawiony " Wait 1 Gosub Main End If End Select Loop Menu_pods: Do Locate 1 , 1 Lcd "MENU > Ustaw podswietlenie na dzien" ; Spc(10) Locate 2 , 1 Lcd "jasnosc =" ; Podsw ; Spc(10) Set Ledsw Set Led1 Reset Led2 Set Led3 Set Led4 Reset Led5 If Sw4 = 0 Then Incr Podsw Waitms 100 End If If Sw3 = 0 Then Decr Podsw Waitms 100 End If Ocr1b = Podsw If Sw1 = 0 Then Writeeeprom Podsw , 1 Gosub Ustaw_zegar End If Loop Menu_pods_noc: Do Locate 1 , 1 Lcd "MENU > Ustaw podswietlenie na noc" ; Spc(10) Locate 2 , 1 Lcd "jasnosc =" ; Podswnoc ; Spc(10) Set Ledsw Set Led1 Reset Led2 Set Led3 Set Led4 Reset Led5 If Sw4 = 0 Then Incr Podswnoc Waitms 100 End If If Sw3 = 0 Then Decr Podswnoc Waitms 100 End If Ocr1b = Podswnoc If Sw1 = 0 Then Writeeeprom Podswnoc , 2 Gosub Ustaw_zegar End If Loop '**************************** Ustawianie zegara Settime ************************** '************************************************************************************* Settime: S_bcd = Makebcd(s) 'konwertowanie na bcd M_bcd = Makebcd(m) H_bcd = Makebcd(h) Year = Year - 12 Year_bcd = Makebcd(year) Shift Year_bcd , Left , 6 Day_bcd = Makebcd(day) Yd_bcd = Year_bcd Or Day_bcd Weekdays_bcd = Makebcd(weekdays) Shift Weekdays_bcd , Left , 5 Month_bcd = Makebcd(month) Wm_bcd = Weekdays_bcd Or Month_bcd I2cstart ' zapis zmiennych do pcf I2cwbyte 160 I2cwbyte 2 I2cwbyte S_bcd I2cwbyte M_bcd I2cwbyte H_bcd I2cwbyte Yd_bcd I2cwbyte Wm_bcd I2cstop Return '**************************** Ustawianie zegara Czas_menu ************************** '************************************************************************************* Czas_menu: Ss = Str(h) Ss = Format(ss , "00") Czas_pcf = Ss + ":" Ss = Str(m) Ss = Format(ss , "00") Czas_pcf = Czas_pcf + Ss + ":" Ss = Str(s) Ss = Format(ss , "00") Czas_pcf = Czas_pcf + Ss Ss = Str(day) Ss = Format(ss , "00") Data_pcf = Ss + "." Ss = Str(month) Ss = Format(ss , "00") Data_pcf = Data_pcf + Ss + ".20" Ss = Str(year) Ss = Format(ss , "00") Data_pcf = Data_pcf + Ss Return '****************************Odczyt cisnienia i temperatury ************************** '************************************************************************************* Sub Messen Call Schreibe_bmp085(&Hf4 , &H2E) Adres = &HF6 Call Lese_roh_daten Shift Msb , Left , 8 Ut = Msb + Lsb Call Berechne_temp Call Schreibe_bmp085(&Hf4 , &H74 ) Adres = &HF6 Call Lese_roh_daten Shift Msb , Left , 16 Shift Lsb , Left , 8 Up = Msb + Lsb Shift Up , Right , 6 Call Berechne_druck If Minmax = 1 Then Tbmp2 = Tbmp Druck1 = Druck End If End Sub Sub Berechne_temp Ut = Ut - Ac6 2potenz15 = 2 ^ 15 Ac5a = Ac5 / 2potenz15 X1t = Ut * Ac5a 2potenz11 = 2 ^ 11 Mc2 = Mc * 2potenz11 X3 = X1t + Md X2 = Mc2 / X3 B5 = X1t + X2 2potenz4 = 2 ^ 4 T2 = B5 + 8 Tbmp = T2 / 2potenz4 End Sub Sub Berechne_druck 'B6 B6 = B5 - 4000 'X1 2potenz12 = 2 ^ 12 B6a = B6 * B6 B6a = B6a / 2potenz12 X1 = B2 * B6a X1 = X1 / 2potenz11 'X2 X2 = Ac2 * B6 X2 = X2 / 2potenz11 'X3 X3 = X1 + X2 'B3 Ac1a = Ac1 * 4 Ac1a = Ac1a + X3 Shift Ac1a , Left , 2 Ac1a = Ac1a + 2 B3 = Ac1a / 4 'X1 die zweite 2potenz13 = 2 ^ 13 B6a = B6 / 2potenz13 X1 = Ac3 * B6a 'X2 die zweite B6a = B6 * B6 B6a = B6a / 2potenz12 X2 = B1 * B6a 2potenz16 = 2 ^ 16 X2 = X2 / 2potenz16 'X3 die zweite X3 = X1 + X2 X3 = X3 + 2 2potenz2 = 2 ^ 2 X3 = X3 / 2potenz2 'B4 B4 = X3 + 32768 B4 = B4 * Ac4 B4 = B4 / 2potenz15 If B4 <= 0 Then B4 = B4 * -1 'Print B4 'B7 B7 = Up - B3 B3a = 50000 Shift B3a , Right , 2 ' B7 = B7 * B3a If B7 <= 0 Then B7 = B7 * -1 'Print B7 If B7 < &H80000000 Then P = B7 * 2 'Print "p1 " ; P P = P / B4 'Print "p1 " ; P Else P = B7 / B4 'Print "p2 " ; P P = P * 2 'Print "p2 " ; P End If 'Print P 'nochmal X1 2potenz8 = 2 ^ 8 P2 = P / 2potenz8 X1 = P2 * P2 'Print X1 X1 = X1 * 3038 X1 = X1 / 2potenz16 'Print X1 ' nochmal X2 X2 = -7357 * P X2 = X2 / 2potenz16 'Print X2 P2 = P P = X2 + 3791 P = P + X1 P = P / 2potenz4 P = P + P2 End Sub Sub Lese_kalib_data Lese_start = 1 Adres = &HAA 'Ac1 lesen Call Lese Ac1 = Msb + Lsb Adres = Adres + 1 'Ac2 lesen Call Lese Ac2 = Msb + Lsb Adres = Adres + 1 'Ac3 lesen Call Lese Ac3 = Msb + Lsb Adres = Adres + 1 'Ac4 lesen Call Lese Ac4 = Msb + Lsb Adres = Adres + 1 'Ac5 lesen Call Lese Ac5 = Msb + Lsb Adres = Adres + 1 'Ac6 lesen Call Lese Ac6 = Msb + Lsb Adres = Adres + 1 'B1 lesen Call Lese B1 = Msb + Lsb Adres = Adres + 1 'B2 lesen Call Lese B2 = Msb + Lsb Adres = Adres + 1 'MB lesen Call Lese Mb = Msb + Lsb Adres = Adres + 1 'MB lesen Call Lese Mc = Msb + Lsb Adres = Adres + 1 'Md lesen Call Lese Md = Msb + Lsb Adres = Adres + 1 End Sub Sub Lese_roh_daten Call Lese_bmp085(adres , Wert) Msb = Wert Adres = Adres + 1 Call Lese_bmp085(adres , Wert) Lsb = Wert End Sub Sub Schreibe_bmp085(byval Adres As Byte , Byval Wert As Byte) I2cstart I2cwbyte Addr_schreiben I2cwbyte Adres I2cwbyte Wert I2cstop Waitms 10 End Sub Lese: Call Lese_bmp085(adres , Wert) Msb = Wert Adres = Adres + 1 Call Lese_bmp085(adres , Wert) Lsb = Wert Shift Msb , Left , 8 Return Sub Lese_bmp085(byval Adres As Byte , Wert As Byte) I2cstart I2cwbyte Addr_schreiben I2cwbyte Adres I2cstart I2cwbyte Addr_lesen I2crbyte Wert , Nack I2cstop Waitms 10 End Sub 'Return '**************************** Odczyt witgotnosci************************************** '************************************************************************************* Sub Get_th(th As Byte , Hh As Byte) Count = 0 Sensor_data = "" Set Dht_io_set Reset Dht_put Waitms 25 Set Dht_put Waitus 40 Reset Dht_io_set Waitus 40 If Dht_get = 1 Then Hh = 1 Exit Sub End If Waitus 80 If Dht_get = 0 Then Hh = 2 ' Exit Sub End If While Dht_get = 1 : Wend Do While Dht_get = 0 : Wend Waitus 30 If Dht_get = 1 Then Sensor_data = Sensor_data + "1" While Dht_get = 1 : Wend Else Sensor_data = Sensor_data + "0" End If Incr Count Loop Until Count = 40 Set Dht_io_set Set Dht_put Tmp_str8 = Left(sensor_data , 8) Hh = Binval(tmp_str8) Tmp_str8 = Mid(sensor_data , 17 , 8) Th = Binval(tmp_str8) Tmp_str8 = Right(sensor_data , 8) Crc = Binval(tmp_str8) Mybyte = Th + Hh If Mybyte <> Crc Then Hh = 3 End If Dthes = 1 If Minmax = 1 Then Hh1 = Hh End If End Sub Return '**************************** Zegar PCF8583 ****************************************** '************************************************************************************* Sub Gettime I2cstart I2cwbyte 160 ' wysylanie adresu odczytu I2cwbyte 2 I2cstart I2cwbyte 161 I2crbyte S , Ack ' sekundy I2crbyte M , Ack ' minuty I2crbyte H , Ack ' godziny I2crbyte Yd , Ack ' rok/dni I2crbyte Wm , Nack ' tygodnie/miesiace I2cstop Year = Yd ' konwertowanie rok/dni Shift Year , Right , 6 Year = Year + Makebcd(12) Yd.7 = 0 : Yd.6 = 0 Weekdays = Wm 'konwertowanie tygodnie/miesiace Shift Weekdays , Right , 5 Wm.7 = 0 : Wm.6 = 0 : Wm.5 = 0 Czas_pcf = Bcd(h) + ":" + Bcd(m) + ":" + Bcd(s) ' czas jako string Data_pcf = Bcd(yd) + "." + Bcd(wm) + ".20" + Bcd(year) ' data jako string S = Makedec(s) ' konwetrowanie na dziesietne M = Makedec(m) H = Makedec(h) Year = Makedec(year) Day = Makedec(yd) Weekdays = Makedec(weekdays) Month = Makedec(wm) Sek = S If S = 0 Then Toggle Minmax End If End Sub Return '**************************** Odczyrt ds18B20 **************************************** '************************************************************************************* Sub Rtemp: 'Disable Interrupts 1wreset 1wwrite &HCC 1wwrite &H44 Waitms 750 1wreset 1wwrite &HCC 1wwrite &HBE Temp = 1wread(2) Temp = Temp * 10 Temp = Temp / 16 Tempds = Temp Napis = Str(temp) Napis = Format(napis , " 0.0") If Minmax = 1 Then Temp1 = Temp End If End Sub 'Enable Interrupts Return '****************************zegar duze fonty ******************************************** '************************************************************************************* Zegar_duze: If Cl = 0 Then Call Clslcd End If Sk = S Mk = M Hk = H '######################################sekundy If S = 0 Then Showpic 170 , 0 , 0 Showpic 204 , 0 , 0 End If 'dwukropek If S > 0 And S < 10 Then Showpic 170 , 0 , 0 End If If S > 9 And S < 20 Then Showpic 170 , 0 , 1 Sk = S - 10 End If If S > 19 And S < 30 Then Showpic 170 , 0 , 2 Sk = S - 20 End If If S > 29 And S < 40 Then Showpic 170 , 0 , 3 Sk = S - 30 End If If S > 39 And S < 50 Then Showpic 170 , 0 , 4 Sk = S - 40 End If If S > 49 And S < 60 Then Showpic 170 , 0 , 5 Sk = S - 50 End If Select Case Sk Case 0 : Showpic 204 , 0 , 0 Showpic 158 , 17 , Kro Showpic 158 , 32 , Kro Case 1 : Showpic 204 , 0 , 1 Showpic 158 , 17 , Krop Showpic 158 , 32 , Krop Case 2 : Showpic 204 , 0 , 2 Showpic 158 , 17 , Kro Showpic 158 , 32 , Kro Case 3 : Showpic 204 , 0 , 3 Showpic 158 , 17 , Krop Showpic 158 , 32 , Krop Case 4 : Showpic 204 , 0 , 4 Showpic 158 , 17 , Kro Showpic 158 , 32 , Kro Case 5 : Showpic 204 , 0 , 5 Showpic 158 , 17 , Krop Showpic 158 , 32 , Krop Case 6 : Showpic 204 , 0 , 6 Showpic 158 , 17 , Kro Showpic 158 , 32 , Kro Case 7 : Showpic 204 , 0 , 7 Showpic 158 , 17 , Krop Showpic 158 , 32 , Krop Case 8 : Showpic 204 , 0 , 8 Showpic 158 , 17 , Kro Showpic 158 , 32 , Kro Case 9 : Showpic 204 , 0 , 9 Showpic 158 , 17 , Krop Showpic 158 , 32 , Krop End Select '######################################sekundy '######################################minuty If M = 0 Then Showpic 87 , 0 , 0 Showpic 121 , 0 , 0 End If 'Showpic 123 , 0 , Kro 'dwukropek If M > 0 And M < 10 Then Showpic 87 , 0 , 0 End If If M > 9 And M < 20 Then Showpic 87 , 0 , 1 Mk = M - 10 End If If M > 19 And M < 30 Then Showpic 87 , 0 , 2 Mk = M - 20 End If If M > 29 And M < 40 Then Showpic 87 , 0 , 3 Mk = M - 30 End If If M > 39 And M < 50 Then Showpic 87 , 0 , 4 Mk = M - 40 End If If M > 49 And M < 60 Then Showpic 87 , 0 , 5 Mk = M - 50 End If Select Case Mk Case 0 : Showpic 121 , 0 , 0 Case 1 : Showpic 121 , 0 , 1 Case 2 : Showpic 121 , 0 , 2 Case 3 : Showpic 121 , 0 , 3 Case 4 : Showpic 121 , 0 , 4 Case 5 : Showpic 121 , 0 , 5 Case 6 : Showpic 121 , 0 , 6 Case 7 : Showpic 121 , 0 , 7 Case 8 : Showpic 121 , 0 , 8 Case 9 : Showpic 121 , 0 , 9 End Select '######################################minuty '######################################godziny If H = 0 Then Showpic 0 , 0 , 0 Showpic 37 , 0 , 0 End If If H > 0 And H < 10 Then Showpic 0 , 0 , 0 End If If H > 9 And H < 20 Then Showpic 0 , 0 , 1 Hk = H - 10 End If If H > 19 And H < 24 Then Showpic 0 , 0 , 2 Hk = H - 20 End If Select Case Hk Case 0 : Showpic 37 , 0 , 0 Case 1 : Showpic 37 , 0 , 1 Case 2 : Showpic 37 , 0 , 2 Case 3 : Showpic 37 , 0 , 3 Case 4 : Showpic 37 , 0 , 4 Case 5 : Showpic 37 , 0 , 5 Case 6 : Showpic 37 , 0 , 6 Case 7 : Showpic 37 , 0 , 7 Case 8 : Showpic 37 , 0 , 8 Case 9 : Showpic 37 , 0 , 9 End Select Showpic 75 , 17 , Kro Showpic 75 , 32 , Kro 'Showpic 158 , 17 , Kro 'Showpic 158 , 32 , Kro 'dwukropek Locate 8 , 1 Lcd "Data : " ; Data_pcf ; Spc(16) Cl = 1 Return '****************************Cisnienie_duze ****************************************** '************************************************************************************ '************************ Obliczenia dls duzych fontow ************************* Cisnienie_duze: If Cl = 0 Then Call Clslcd End If Cis_duze = Druck Cis_tys = Cis_duze / 1000 Cis_set = Cis_duze Mod 1000 Cis_set = Cis_set / 100 'przeliczenie cisnienie Cis_dzie = Cis_duze Mod 100 Cis_dzie = Cis_dzie / 10 Cis_jed = Cis_duze Mod 10 Select Case Cis_tys 'Case 0 : Showpic 0 , 0 , 0 Case 1 : Showpic 0 , 0 , 1 End Select Select Case Cis_set Case 0 : Showpic 37 , 0 , 0 Case 1 : Showpic 37 , 0 , 1 Case 2 : Showpic 37 , 0 , 2 Case 3 : Showpic 37 , 0 , 3 Case 4 : Showpic 37 , 0 , 4 Case 5 : Showpic 37 , 0 , 5 Case 6 : Showpic 37 , 0 , 6 Case 7 : Showpic 37 , 0 , 7 Case 8 : Showpic 37 , 0 , 8 Case 9 : Showpic 37 , 0 , 9 End Select Select Case Cis_dzie Case 0 : Showpic 74 , 0 , 0 Case 1 : Showpic 74 , 0 , 1 Case 2 : Showpic 74 , 0 , 2 Case 3 : Showpic 74 , 0 , 3 Case 4 : Showpic 74 , 0 , 4 Case 5 : Showpic 74 , 0 , 5 Case 6 : Showpic 74 , 0 , 6 Case 7 : Showpic 74 , 0 , 7 Case 8 : Showpic 74 , 0 , 8 Case 9 : Showpic 74 , 0 , 9 End Select Select Case Cis_jed Case 0 : Showpic 111 , 0 , 0 Case 1 : Showpic 111 , 0 , 1 Case 2 : Showpic 111 , 0 , 2 Case 3 : Showpic 111 , 0 , 3 Case 4 : Showpic 111 , 0 , 4 Case 5 : Showpic 111 , 0 , 5 Case 6 : Showpic 111 , 0 , 6 Case 7 : Showpic 111 , 0 , 7 Case 8 : Showpic 111 , 0 , 8 Case 9 : Showpic 111 , 0 , 9 End Select Showpic 149 , 7 , Hpa Locate 8 , 1 Lcd "Cisnienie atmosferyczne" ; Spc(10) Cl = 1 Return '****************************temperatura ds_duze ****************************************** '************************************************************************************ Temp_duze: If Cl = 0 Then Call Clslcd End If Tempds = Temp Tempds_set = Tempds Mod 1000 Tempds_set = Tempds_set / 100 'przeliczenie ds18b20 Tempds_dzie = Tempds Mod 100 Tempds_dzie = Tempds / 10 Tempds_dzie = Tempds_dzie Mod 10 Tempds_jed = Tempds Mod 10 If Tempds_set < 0 Then Tempds_set = Tempds_set * Tempds_set 'ujemne temp Tempds_set = Tempds_set / Tempds_set End If If Tempds_dzie < 0 Then Tempds_dzie = Tempds_dzie * Tempds_dzie 'ujemne temp Tempds_dzie = Tempds_dzie / Tempds_dzie End If If Tempds_jed < 0 Then Tempds_jed = Tempds_jed * Tempds_jed 'ujemne temp Tempds_jed = Tempds_jed / Tempds_jed End If If Tempds_set = 0 And Temp > 0 Then 'przesuniecie plusa Showpic 37 , 5 , Dodatnia 'gdy jed=0 End If If Tempds_set = 0 And Temp < 0 Then 'przesuniecie minusa Showpic 37 , 5 , Ujemna 'gdy jed=0 End If If Temp = 0 Then 'Showpic 37 , 0 , 0 '0 jako wynik Showpic 74 , 0 , 0 Showpic 123 , 0 , 0 End If If Temp < 0 And Tempds_set <> 0 Then 'znak - Showpic 5 , 5 , Ujemna End If If Temp > 0 And Tempds_set <> 0 Then Showpic 5 , 5 , Dodatnia 'znak + End If Showpic 111 , 40 , Kro Showpic 160 , 0 , Stopien 'kropka Select Case Tempds_set 'Case 0 : Showpic 37 , 0 , 0 Case 1 : Showpic 37 , 0 , 1 Case 2 : Showpic 37 , 0 , 2 Case 3 : Showpic 37 , 0 , 3 Case 4 : Showpic 37 , 0 , 4 Case 5 : Showpic 37 , 0 , 5 Case 6 : Showpic 37 , 0 , 6 Case 7 : Showpic 37 , 0 , 7 Case 8 : Showpic 37 , 0 , 8 Case 9 : Showpic 37 , 0 , 9 End Select Select Case Tempds_dzie Case 0 : Showpic 74 , 0 , 0 Case 1 : Showpic 74 , 0 , 1 Case 2 : Showpic 74 , 0 , 2 Case 3 : Showpic 74 , 0 , 3 Case 4 : Showpic 74 , 0 , 4 Case 5 : Showpic 74 , 0 , 5 Case 6 : Showpic 74 , 0 , 6 Case 7 : Showpic 74 , 0 , 7 Case 8 : Showpic 74 , 0 , 8 Case 9 : Showpic 74 , 0 , 9 End Select Select Case Tempds_jed Case 0 : Showpic 123 , 0 , 0 Case 1 : Showpic 123 , 0 , 1 Case 2 : Showpic 123 , 0 , 2 Case 3 : Showpic 123 , 0 , 3 Case 4 : Showpic 123 , 0 , 4 Case 5 : Showpic 123 , 0 , 5 Case 6 : Showpic 123 , 0 , 6 Case 7 : Showpic 123 , 0 , 7 Case 8 : Showpic 123 , 0 , 8 Case 9 : Showpic 123 , 0 , 9 End Select Locate 8 , 1 Lcd "Temperatura na dworze" ; Spc(10) Cl = 1 Return '****************************temperatura bmp_duze ****************************************** '************************************************************************************ Temp_duze_bmp: If Cl = 0 Then Call Clslcd End If Tbmp1 = Tbmp * 10 Tempbmp_set = Tbmp1 Mod 1000 Tempbmp_set = Tempbmp_set / 100 'przeliczenie cisnienie Tempbmp_dzie = Tbmp1 Mod 100 Tempbmp_dzie = Tbmp1 / 10 Tempbmp_dzie = Tempbmp_dzie Mod 10 Tempbmp_jed = Tbmp1 Mod 10 If Tempbmp_set < 0 Then Tempbmp_set = Tempbmp_set * Tempbmp_set 'ujemne temp Tempbmp_set = Tempbmp_set / Tempbmp_set End If If Tempbmp_dzie < 0 Then Tempbmp_dzie = Tempbmp_dzie * Tempbmp_dzie 'ujemne temp Tempbmp_dzie = Tempbmp_dzie / Tempbmp_dzie End If If Tempbmp_jed < 0 Then Tempbmp_jed = Tempbmp_jed * Tempbmp_jed 'ujemne temp Tempbmp_jed = Tempbmp_jed / Tempbmp_jed End If If Tbmp = 0 Then Showpic 37 , 40 , 0 '0 jako wynik Showpic 74 , 0 , 0 Showpic 123 , 0 , 0 End If If Tbmp < 0 Then 'znak - Showpic 5 , 5 , Ujemna End If If Tbmp > 0 Then Showpic 5 , 5 , Dodatnia 'znak + End If Showpic 111 , 40 , Kro Showpic 160 , 0 , Stopien 'kropka Select Case Tempbmp_set 'Case 0 : Showpic 37 , 0 , 0 Case 1 : Showpic 37 , 0 , 1 Case 2 : Showpic 37 , 0 , 2 Case 3 : Showpic 37 , 0 , 3 Case 4 : Showpic 37 , 0 , 4 Case 5 : Showpic 37 , 0 , 5 Case 6 : Showpic 37 , 0 , 6 Case 7 : Showpic 37 , 0 , 7 Case 8 : Showpic 37 , 0 , 8 Case 9 : Showpic 37 , 0 , 9 End Select Select Case Tempbmp_dzie Case 0 : Showpic 74 , 0 , 0 Case 1 : Showpic 74 , 0 , 1 Case 2 : Showpic 74 , 0 , 2 Case 3 : Showpic 74 , 0 , 3 Case 4 : Showpic 74 , 0 , 4 Case 5 : Showpic 74 , 0 , 5 Case 6 : Showpic 74 , 0 , 6 Case 7 : Showpic 74 , 0 , 7 Case 8 : Showpic 74 , 0 , 8 Case 9 : Showpic 74 , 0 , 9 End Select Select Case Tempbmp_jed Case 0 : Showpic 123 , 0 , 0 Case 1 : Showpic 123 , 0 , 1 Case 2 : Showpic 123 , 0 , 2 Case 3 : Showpic 123 , 0 , 3 Case 4 : Showpic 123 , 0 , 4 Case 5 : Showpic 123 , 0 , 5 Case 6 : Showpic 123 , 0 , 6 Case 7 : Showpic 123 , 0 , 7 Case 8 : Showpic 123 , 0 , 8 Case 9 : Showpic 123 , 0 , 9 End Select Locate 8 , 1 Lcd "Temperatura w domu" ; Spc(10) Cl = 1 Return '****************************wilgotnosc_duze ****************************************** '************************************************************************************ Wilg_duze: If Cl = 0 Then Call Clslcd End If Wilg_dzie = Hh Mod 100 Wilg_dzie = Hh / 10 'przeliczenie wilgotnosc Wilg_jed = Hh Mod 10 Select Case Wilg_dzie 'Case 0 : Showpic 0 , 0 , 0 Case 1 : Showpic 37 , 0 , 1 Case 2 : Showpic 37 , 0 , 2 Case 3 : Showpic 37 , 0 , 3 Case 4 : Showpic 37 , 0 , 4 Case 5 : Showpic 37 , 0 , 5 Case 6 : Showpic 37 , 0 , 6 Case 7 : Showpic 37 , 0 , 7 Case 8 : Showpic 37 , 0 , 8 Case 9 : Showpic 37 , 0 , 9 End Select Select Case Wilg_jed Case 0 : Showpic 74 , 0 , 0 Case 1 : Showpic 74 , 0 , 1 Case 2 : Showpic 74 , 0 , 2 Case 3 : Showpic 74 , 0 , 3 Case 4 : Showpic 74 , 0 , 4 Case 5 : Showpic 74 , 0 , 5 Case 6 : Showpic 74 , 0 , 6 Case 7 : Showpic 74 , 0 , 7 Case 8 : Showpic 74 , 0 , 8 Case 9 : Showpic 74 , 0 , 9 End Select Showpic 111 , 0 , Procent Locate 8 , 1 Lcd "Wilgotnosc powietrza" ; Spc(10) Cl = 1 Return '**************************** odczyt czujnikow, ******************************************** '************************************************************************************* Odczyt: If Bmpe = 1 Then Call Messen 'odczyt cisnienia i temp Tbmp = Tbmp / 10 Temperatur = Fusing(tbmp , "###.##") Druck = P Druck = Druck / 100 Druck = Druck + 16 Luftdruck = Fusing(druck , "####.##") End If If Dse = 1 Then 'odczyt temp ds-a Call Rtemp End If If Dthe = 1 And Dthes = 0 Then 'odczyt wilgotnosc Call Get_th(th , Hh) End If Return '**************************** max min,******************************************** '********************************************************************************** Logmaxmin: If Tempdsmin = 0 And Tempdsmax = 1 Then Tempdsmin = Temp1 End If If Temp1 <= Temp And Temp1 < Tempdsmin Then 'ds min Tempdsmin = Temp1 End If If Temp1 >= Temp And Temp1 > Tempdsmax Then 'ds max Tempdsmax = Temp1 End If If Tempbmmin = 0 And Tempbmmax = 0 Then Tempbmmin = Tbmp2 End If If Tbmp2 <= Tbmp And Tbmp2 < Tempbmmin Then 'bmp min Tempbmmin = Tbmp2 End If If Tbmp2 >= Tbmp And Tbmp2 > Tempbmmax Then 'bmp max Tempbmmax = Tbmp2 End If If Hmin = 99 And Hmax = 0 Then Hmin = Hh1 End If If Hh1 >= Hh And Hh1 > Hmax Then 'h max Hmax = Hh1 End If If Hh1 <= Hh And Hh1 < Hmax And Hh1 < Hmin Then 'h min Hmin = Hh1 End If If Druck1 >= Druck And Druck1 > Cismax Then 'cisnienie max Cismax = Druck1 End If If Druck1 <= Druck And Druck1 < Cismax And Druck1 < Cismin Then 'cisnienie min Cismin = Druck1 End If Return '**************************** Przerwanie,******************************************** '************************************************************************************* Sekunda: Licznik = Licznik + 1 If Licznik = 60 Then Licznik = 0 Dthes = 0 Bmpe = 0 Dse = 0 Dthe = 0 Osw1 = 0 End If If Licznik = 1 Or Licznik = 20 Or Licznik = 40 Then Wyniki = Wyniki + 1 Cl = 0 End If If Wyniki = 6 Then Wyniki = 1 End If If Licznik = 5 Or Licznik = 10 Then Toggle Bmpe End If If Licznik = 15 Or Licznik = 20 Then Toggle Dse End If If Licznik = 25 Or Licznik = 30 Then Toggle Dthe End If If Licznik = 50 Then Reset Led1 Reset Led2 Reset Led3 Reset Led4 Reset Led5 Reset Ledsw End If Return Hot: $bgf "sun.bgf" Snow: $bgf "snow.bgf" Cloudy: $bgf "cloudy.bgf" Rain: $bgf "rain.bgf" Error: $bgf "error.bgf" 1: $bgf "1.bgf" 2: $bgf "2.bgf" 3: $bgf "3.bgf" 4: $bgf "4.bgf" 5: $bgf "5.bgf" 6: $bgf "6.bgf" 7: $bgf "7.bgf" 8: $bgf "8.bgf" 9: $bgf "9.bgf" 0: $bgf "0.bgf" Kro: $bgf "kro.bgf" Krop: $bgf "krop.bgf" Hpa: $bgf "hpa.bgf" Stopien: $bgf "c.bgf" Ujemna: $bgf "ujemna.bgf" Dodatnia: $bgf "dodatnia.bgf" Procent: $bgf "procent.bgf"