Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:54 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Solar (hot water) control panel

Author Message
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 09:57am 12 Nov 2017
Copy link to clipboard 
Print this post

I've build this panel for one of my customer, two years ago.
The micro is 44 pin PIC 32MX170 , with MMBasic 4.7 and display ILI9341.
For RTC I use RTC modul DS3231, with build it EEPROM 2432.This EEPROM is my "extended" memory for many variables and graphic routines, because no room in my PIC32. It works perfect with finger or pen and no complain, thanks to Geoff and MMBasic.
Here is the link to youtube and schematic PDF.

www.youtube.com/watch?v=BHLufR2ly_0

2017-11-12_203048_solar_control_fina_2.PDF

and 3D model in PDF. Please download the file and open it in Acrobat Reader to see it in 3D.
https://drive.google.com/open?id=1swmEfAqrKGYgNpXUbY5xEVJOe2RH1feAEdited by ztoti 2017-11-13
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 10:23am 12 Nov 2017
Copy link to clipboard 
Print this post

Neat! I saw the video and like it! Very good job!

Thanks Michael
causality ≠ correlation ≠ coincidence
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 10:37am 12 Nov 2017
Copy link to clipboard 
Print this post

I've updated with 3D file. Check it out again.
Thanks
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 11:53am 12 Nov 2017
Copy link to clipboard 
Print this post

  ztoti said   I've updated with 3D file. Check it out again.
Thanks

??? I only see a pdf with the schematic. No Basic code.

I've no rights to access:
https://drive.google.com/open?id=1swmEfAqrKGYgNpXUbY5xEVJOe2RH1feA

Edited by twofingers 2017-11-13
causality ≠ correlation ≠ coincidence
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 11:59am 12 Nov 2017
Copy link to clipboard 
Print this post

3D PDF file is in my google drive:


https://drive.google.com/a/ztautomation.net/file/d/1swmEfAqrKGYgNpXUbY5xEVJOe2RH1feA/view?usp=sharing

The code it self is useless, because works with .bin file in EEPROM (read and write on EEPROM 2432).
If you try run the program, the error will crack the software.
Here is the link to Dropbox as well.
https://www.dropbox.com/s/fmkfyw1tk44xw3u/PCB.pdf?dl=0Edited by ztoti 2017-11-13
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 12:16pm 12 Nov 2017
Copy link to clipboard 
Print this post

  ztoti said   3D PDF file is in my google drive:


https://drive.google.com/a/ztautomation.net/file/d/1swmEfAqrKGYgNpXUbY5xEVJOe2RH1feA/view?usp=sharing

The code it self is useless, because works with .bin file in EEPROM (read and write on EEPROM 2432).
If you try run the program, the error will crack the software.


hmm ...

... and how do you execute the bin code in the EEPROM?
Maybe you can us tell something about your code.

Still no access to the 3D file (goole drive). Okay, that's not so important to me.

EDIT:
Dropbox works! Thanks! Edited by twofingers 2017-11-13
causality ≠ correlation ≠ coincidence
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9749
Posted: 12:34pm 12 Nov 2017
Copy link to clipboard 
Print this post

Very nice LCD graphics you have going on there. Well done.
That video goes to show just how much you really can cram into a small LCD screen.
Smoke makes things work. When the smoke gets out, it stops!
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 01:16pm 12 Nov 2017
Copy link to clipboard 
Print this post

If somebody have a time to go through it.

2017-11-12_231511_eeprom18July.zip


Option explicit
Option base 0
Const red=RGB(255,0,0),green=RGB(0,255,0),blue=RGB(0,0,250)
Const black=RGB(0,0,0),white=RGB(255,255,255),dwhite=RGB(220,220,220),yellow=RGB(250,250,0)
Const gray=RGB(160,160,160),dblue=RGB(0,0,160),svetla=RGB(220,220,200),lilja=RGB(240,136,233)
Const dred=RGB(170,0,0),dgreen=RGB(0,120,0),dyellow=RGB(120,120,0)
Dim redica,kolona,keypress,saatot1,index,indexold,i,r,g,b,pole(672) As integer
Dim max_taster,greska(11),suma_greska,agol,ekran,mem_timer,err_sensor,hld,trghld ' dimenzionirana e hld i trighld (ovoj e 1 samo ako bojlerot
Dim taster$,tocno$,text$,broj$,ime$,temperatura$ ' e povisok za 10C od solarnoto
Dim b1max,b2max,b3max,s1max,s2max,kotelmax,parnomax,poolmax,rtc,S,EEPROM,VLEZ,UX,X1,Y,T,TMAX,k(12) As integer
Dim b1enable,b2enable,b3enable,s1enable,s2enable,kotelenable,parnoenable,poolenable,RADIO,PREKINUVAC,HOLLiDAY,winter As integer
Dim saatot,minutata,denot,mesecot,godinata,podesi_vreme_index,podesi_max_index,podesi_saat,podesi_minuta,podesi_den,podesi_m esec,podesi_godina
Dim test_index,podesi_timer_index,keypressx,keypressy,pritisnato(6,4),boja' matrica sto pokazuva dali e setuvan nekoj period (0-1h)(1-2h)....
Dim zavrsimax,zavrsimax_kraj,oldtemperatura1,oldtemperatura2,oldtemperatura3,max(2,5)
Dim prethodnax,prethodnay,slednax,slednay,c,n,m As integer
Dim niska,visoka,zapisi,period As integer
Dim merenje_start1,merenje_end1,merenje_start2,merenje_end2,ntc3,ntc5,ntc7,grafik As integer
Dim sdis%(16),testbox%(12),ss%(16)
Dim install$="00000000000"
dim gasiLed as integer
ntc3=2:ntc5=4:ntc7=6:greska(0)=2
VAR restore
podesi_max_index=0:taster$="":ekran=1:rtc=104:eeprom=80
SetPin 10,ain:SetPin 8,dout:SetPin 9,dout:setpin 11,dout:SetPin 37,dout:SetPin 38,dout
SetPin 23,dout:SetPin 24,dout:SetPin 25,dout:SetPin 26,dout:SetPin 27,dout
SetPin 19,dout:SetPin 21,dout:SetPin 22,dout:SetPin 15,dout:SetPin 30,dout:SetPin 31,dout:SetPin 32,dout:SetPin 13,dout:SetPin 36,dout
I2C open 100,200
settick 30000,gasi,1
WatchDog 5000
rtc settime 16,06,15,12,0,0
ss%(12)=3
'If MM.I2C <> 0 Then Error "PCF8563 not responding"
RTC GETTIME
I2C write eeprom,0,2,0,0
Pause 4
For n=0 To 3
For m=0 To 5
I2C read eeprom,0,1,i
pritisnato(m,n)=i
Next
Next
I2C write eeprom,0,2,0,24
Pause 4
For n= 0 To 4
For m=0 To 1:I2C read eeprom,0,1,i:max(m,n)=i:Next
Next
I2C write eeprom,0,2,0,144
Pause 4
I2C read eeprom,0,1,prekinuvac:I2C read eeprom,0,1,radio:I2C read eeprom,0,1,holliday:I2C read eeprom,0,1,index:I2C read eeprom,0,1,winter
visoka=301\256:niska=301 Mod 256:I2C write eeprom,0,2,visoka,niska:Pause 4
For i=301 To 972
visoka=i\256:niska=i Mod 256:I2C read eeprom,0,1,pole(i-301)
Next
For n=0 To 11
testbox%(n)=0
Next
pocetok:
CLS(DBLUE):GoSub ekran1:SetTick 60000,saat,2
Do

Select Case index
Case 1
if ss%(12)=0 then
install$="01110000111" ' vo prvata kombinacija, koga ima kotel (ss%(12)=0) ima senzori na S1,S2,S3,S8,S9,S10
else
install$="01110000000" ' znaci install$ pokazuva koi senzori se aktivni za koja kombinacija
endif
Case 2
install$="01111111000"
Case 3
if ss%(12)=0 then
install$="01111100100"
else
install$="01111100000"
endif
Case 4
if ss%(12)=0 then
install$="11110000100"
else
install$="11110000000"
endif
End Select
If greska(err_sensor)=2 Then
strelkadg 280,200:strelkalg 8,200
Text 45,200,"P1":Text 65,200,"P2":Text 85,200,"P3":Text 105,200,"P4"
Text 125,200,"P5":Text 145,200,"R1":Text 165,200,"R2":Text 185,200,"R3"
Text 205,200,"R4":Text 225,200,"R5":Text 245,200,"R6":Text 265,200,"B"
For n=0 To 11
If k(n)=0 Then
boja=red
Else
boja=green
EndIf
Circle 50+(n*20),225,7,1,1,dblue,boja
Next
Else
Box 2,197,315,40,2,dblue,dblue
Select Case greska(err_sensor)
Case 10
Text 60,200,"sensor"+Str$(err_sensor)+" short !!",lt,1,2,red,dblue
Case 20
Text 60,200,"sensor"+Str$(err_sensor)+" open !!",lt,1,2,red,dblue
End Select
Pause 1000
Box 2,197,315,40,2,dblue,dblue
EndIf

izmeri
If sdis%(3)=0 Then
ntc3=3
Else
ntc3=2
EndIf
If sdis%(5)=1 Then
ntc5=4
Else
ntc5=5
EndIf
If sdis%(7)=1 Then
ntc7=6
Else
ntc7=7
EndIf
On index GoSub sl1,sl2,sl3,sl4
If holliday=1 Then
hld=ss%(2)-ss%(1)
If hld>10 Then
trghld=1 ' aktivirana e trighld, taa mu kazuva na slucaite deka e uslovot ispolnet
Select Case index
Case 1
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1
CASE 2
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:pin(21)=1:k(6)=1:pin(22)=1:k(7)=1
case 3
pin(23)=1:k(0)=1:pin(19)=1:k(5)=1:pin(22)=1:k(7)=1
Case 4
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:Pin(21)=1:k(6)=1
End Select
elseIf hld>0 And hld<5 Then '
trghld=0 ' resetirana e trighld
Select Case index
Case 1
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0
CASE 2
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0:pin(21)=0:k(6)=0:pin(22)=0:k(7)=0
case 3
pin(23)=0:k(0)=0:pin(19)=0:k(5)=0:pin(22)=0:k(7)=0
Case 4
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0:Pin(21)=0:k(6)=0
End Select
EndIf
EndIf

If ekran=1 Then
If oldtemperatura1<>ss%(1) Then
RBox 51,8,100,59,10,BLUE,blue:Text 55,13,Str$(ss%(1)),LT,2,1,WHITE,BLUE:oldtemperatura1=ss%(1)
Else If oldtemperatura2<>ss%(2) Then
RBox 51,87,80,59,10,BLUE,blue:Text 55,92,Str$(ss%(2)),LT,2,1,WHITE,BLUE:oldtemperatura2=ss%(2)
EndIf
EndIf
SKENIRAJ:
WatchDog 2000
If Touch(x) <> -1 And Touch(y) <> -1 Then
gasiLed=0:pin(36)=0
If ekran=4 And podesi_vreme_index=1 And 0 < Touch(x) And Touch(x) < 319 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
GoSub vreme_analiza:RTC settime godinata-2000,mesecot,denot,saatot,minutata,30:podesi_vreme_index=0:GoSub EKRAN4
EndIf
If 280 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If EKRAN<=4 Then
EKRAN=EKRAN+1
EndIf
If ekran=5 Then
ekran=1
EndIf
On EKRAN GoSub EKRAN1,ekran2,EKRAN3,EKRAN4
EndIf
If 5 < Touch(x) And Touch(x) < 37 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If EKRAN>0 Then
EKRAN=EKRAN-1
EndIf
If ekran=0 Then
ekran=4
EndIf
On EKRAN GoSub EKRAN1,ekran2,EKRAN3,EKRAN4
EndIf

If EKRAN=1 Then
SetTick 60000,saat,2
If 220 < Touch(x) And Touch(x) < 300 And 40 < Touch(y) And Touch(y) < 100 And PREKINUVAC=0 Then
gasiLed=0:pin(36)=0
SW_ON 220,40:LED_ON 260,20:PREKINUVAC=1:Pin(32)=1:k(11)=1: I2C write eeprom,0,3,0,144,prekinuvac
buzer
pause 500
EndIf
If 220 < Touch(x) And Touch(x) < 300 And 40 < Touch(y) And Touch(y) < 100 And PREKINUVAC=1 Then
gasiLed=0:pin(36)=0
SW_OFF 220,40:LED_OFF 260,20:PREKINUVAC=0:Pin(32)=0:k(11)=0: I2C write eeprom,0,3,0,144,prekinuvac
buzer
pause 500
EndIf
If 210 < Touch(X) And Touch(X)<260 And 110<Touch(Y) And Touch(Y)<150 And RADIO=0 Then
gasiLed=0:pin(36)=0
RADIO_ON 225,110,"TIMER":RADIO=1:I2C write eeprom,0,3,0,145,radio:buzer
EndIf
If 210 < Touch(X)And Touch(X)<260 And 150<Touch(Y) And Touch(Y)<190 And RADIO=1 Then
gasiLed=0:pin(36)=0
RADIO_OFF 225,110,"TIMER":RADIO=0:I2C write eeprom,0,3,0,145,radio:buzer
EndIf
If 145 < Touch(x) And Touch(x) < 200 And 145 < Touch(y) And Touch(y) < 189 Then
gasiLed=0:pin(36)=0
If HOLLIDAY=0 Then
_box_ON 160,162,"HOLIDAY":HOLLIDAY=1:I2C write eeprom,0,3,0,146,holliday:buzer
Else
_box_OFF 160,162,"HOLIDAY":HOLLIDAY=0:I2C write eeprom,0,3,0,146,holliday:buzer
EndIf
EndIf
If 220 < Touch(x) And Touch(x) < 300 And 0 < Touch(y) And Touch(y) < 60 Then
gasiLed=0:pin(36)=0
WatchDog 4000
Pause 2000
If 220 < Touch(x) And Touch(x) < 300 And 0 < Touch(y) And Touch(y) < 60 Then
SetTick 0,0,2:GoTo pocni
EndIf
EndIf
EndIf
If ekran=4 And podesi_vreme_index=0 And podesi_timer_index=0 And podesi_max_index=0 Then
If 22 < Touch(X) And Touch(X)<82 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
podesi_vreme_index=1:buzer:GoSub podesi_vreme
EndIf
If 93 < Touch(X) And Touch(X)<153 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
podesi_timer_index=1:buzer:GoSub podesi_timer:GoSub EKRAN4
EndIf
If 164 < Touch(X) And Touch(X)<224 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
podesi_max_index=1:buzer:GoSub podesi_max:podesi_max_index=0:GoSub EKRAN4
EndIf
If 235 < Touch(X) And Touch(X)<295 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
test_index=1:buzer:GoSub test:test_index=0:GoSub EKRAN4
EndIf
ElseIf ekran=4 And podesi_vreme_index=1 Then
' ********** promena na saati
If 60 < Touch(x) And Touch(x) < 140 And 5 < Touch(y) And Touch(y) < 50 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
saatot=saatot+1:buzer
If saatot=24 Then
saatot=0
EndIf
Time$=Str$(saatot)+Right$(Time$,6)
GoSub podesi_vreme
EndIf
If 60 < Touch(x) And Touch(x) < 140 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
saatot=saatot-1:buzer
If saatot=-1 Then
saatot=23
EndIf
Time$=Str$(saatot)+Right$(Time$,6)
GoSub podesi_vreme ' podesi vreme display
EndIf
'************* promena na minuti
If 170 < Touch(x) And Touch(x) < 240 And 5 < Touch(y) And Touch(y) < 50 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
minutata=minutata+1:buzer
If minutata=60 Then
minutata=0
EndIf
Time$=Left$(Time$,3)+Str$(minutata)
GoSub podesi_vreme
EndIf
If 170 < Touch(x) And Touch(x) < 240 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
minutata=minutata-1:buzer
If minutata=-1 Then
minutata=59
EndIf
Time$=Left$(Time$,3)+Str$(minutata)
GoSub podesi_vreme
EndIf
' ********** promena na denovi
If 5 < Touch(x) And Touch(x) < 65 And 110 < Touch(y) And Touch(y) < 150 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
denot=denot+1:buzer
If denot=32 Then
denot=1
EndIf
Date$=Str$(denot)+Right$(Date$,8)
GoSub podesi_vreme
EndIf

If 5 < Touch(x) And Touch(x) < 65 And 155 < Touch(y) And Touch(y) < 195 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
denot=denot-1:buzer
If denot=-1 Then
denot=31
EndIf
Date$=Str$(denot)+Right$(Date$,8)
GoSub podesi_vreme
EndIf
'***************8 promena na meseci
If 95 < Touch(x) And Touch(x) < 155 And 110 < Touch(y) And Touch(y) < 150 Then 'up nad saatot
gasiLed=0:pin(36)=0
GoSub vreme_analiza
mesecot=mesecot+1:buzer
If mesecot=13 Then
mesecot=1
EndIf
Date$=Left$(Date$,3)+Str$(mesecot)+Right$(Date$,5)
GoSub podesi_vreme
EndIf
If 95 < Touch(x) And Touch(x) < 155 And 155 < Touch(y) And Touch(y) < 195 Then 'udown nad saatot
gasiLed=0:pin(36)=0
GoSub vreme_analiza
mesecot=mesecot-1:buzer
If mesecot=-1 Then
mesecot=12
EndIf
Date$=Left$(Date$,3)+Str$(mesecot)+Right$(Date$,5)
GoSub podesi_vreme
EndIf
'******************** promena na godini
If 185 < Touch(x) And Touch(x) < 305 And 110 < Touch(y) And Touch(y) < 150 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza:godinata=godinata+1:buzer:Date$=Left$(Date$,6)+Str$(godinata):GoSub podesi_vreme
EndIf

If 185 < Touch(x) And Touch(x) < 305 And 155 < Touch(y) And Touch(y) < 195 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza:godinata=godinata-1:buzer:Date$=Left$(Date$,6)+Str$(godinata):GoSub podesi_vreme
EndIf
EndIf
EndIf
If ekran <>2 Then GoTo zaobikoli:EndIf
If sdis%(0)=0 Then
Text 70,17,Str$(ss%(0))+" C",lt,1,1,yellow,blue
Else
Text 70,17,Str$(ss%(0))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(1)=0 Then
Text 70,37,Str$(ss%(1))+" C",lt,1,1,yellow,blue
Else
Text 70,37,Str$(ss%(1))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(2)=0 Then
Text 70,77,Str$(ss%(2))+" C",lt,1,1,yellow,blue
Else
Text 70,77,Str$(ss%(2))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(3)=0 Then
Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,yellow,blue
Else
Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(4)=0 Then
Text 70,97,Str$(ss%(4))+" C",lt,1,1,yellow,blue
Else
Text 70,97,Str$(ss%(4))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(5)=0 Then
Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,yellow,blue
Else
Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(6)=0 Then
Text 70,117,Str$(ss%(6))+" C",lt,1,1,yellow,blue
Else
Text 70,117,Str$(ss%(6))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(7)=0 Then
Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,yellow,blue
Else
Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(8)=0 Then
Text 70,137,Str$(ss%(8))+" C",lt,1,1,yellow,blue
Else
Text 70,137,Str$(ss%(8))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(10)=0 Then
Text 70,157,Str$(ss%(10))+" C",lt,1,1,yellow,blue
Else
Text 70,157,Str$(ss%(10))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(9)=0 Then
Text 70,177,Str$(ss%(9))+" C",lt,1,1,yellow,blue
Else
Text 70,177,Str$(ss%(9))+" C",lt,1,1,dwhite,dblue
EndIf
zaobikoli:
Loop
ekran2:
GoSub crtaj_ekran
Text 5,20,"Solar0:",lt,1,1,white,dblue
If sdis%(0)=0 Then
RBox 65,15,50,18,5,white,blue
Text 70,17,Str$(ss%(0))+" C",lt,1,1,yellow,blue
Else
RBox 65,15,50,18,5,dwhite,dblue
Text 70,17,Str$(ss%(0))+" C",lt,1,1,dwhite,dblue
EndIf
RBox 120,15,50,18,5,white,blue:Text 125,17,Str$(max(0,0)),lt,1,1,green,blue:Line 180,30,190,30:Line 190,30,185,20:Line 185,20,180,30
Text 195,20,"t1:",lt,1,1,white,dblue:RBox 220,15,50,18,5,white,blue:Text 225,17,Str$(max(1,3))+" C",lt,1,1,white,blue:Text 5,40,"Solar1:",lt,1,1,white,dblue
If sdis%(1)=0 Then
RBox 65,35,50,18,5,white,blue
Text 70,37,Str$(ss%(1))+" C",lt,1,1,yellow,blue
Else
RBox 65,35,50,18,5,dwhite,dblue
Text 70,37,Str$(ss%(1))+" C",lt,1,1,dwhite,dblue
EndIf
RBox 120,35,50,18,5,white,blue:Text 125,37,Str$(max(0,1)),lt,1,1,green,blue:Line 180,50,190,50:Line 190,50,185,40:Line 185,40,180,50
Text 195,40,"t2:",lt,1,1,white,dblue:RBox 220,35,50,18,5,white,blue:Text 225,37,Str$(max(1,4))+" C",lt,1,1,white,blue:Text 5,80,"Tank1:",lt,1,1,white,dblue
If sdis%(2)=0 Then
RBox 65,75,50,18,5,white,blue:Text 70,77,Str$(ss%(2))+" C",lt,1,1,yellow,blue
Else
RBox 65,75,50,18,5,dwhite,dblue:Text 70,77,Str$(ss%(2))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(3)=0 Then
RBox 120,75,50,18,5,white,blue:Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,yellow,blue
Else
RBox 120,75,50,18,5,dwhite,dblue:Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,dwhite,dblue
EndIf
RBox 220,75,50,18,5,white,blue:Text 225,77,Str$(max(0,2))+" C",lt,1,1,white,blue:Text 180,77,"max:",lt,1,1,white,dblue:Text 5,100,"Tank2:",lt,1,1,white,dblue
If sdis%(4)=0 Then
RBox 65,95,50,18,5,white,blue:Text 70,97,Str$(ss%(4))+" C",lt,1,1,yellow,blue
Else
RBox 65,95,50,18,5,dwhite,dblue:Text 70,97,Str$(ss%(4))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(5)=0 Then
RBox 120,95,50,18,5,white,blue:Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,yellow,blue
Else
RBox 120,95,50,18,5,dwhite,dblue:Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,dwhite,dblue
EndIf

RBox 220,95,50,18,5,white,blue:Text 225,97,Str$(max(0,3))+" C",lt,1,1,white,blue:Text 180,97,"max:",lt,1,1,white,dblue:Text 5,120,"Tank3:",lt,1,1,white,dblue
If sdis%(6)=0 Then
RBox 65,115,50,18,5,white,blue:Text 70,117,Str$(ss%(6))+" C",lt,1,1,yellow,blue
Else
RBox 65,115,50,18,5,dwhite,dblue:Text 70,117,Str$(ss%(6))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(7)=0 Then
RBox 120,115,50,18,5,white,blue:Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,yellow,blue
Else
RBox 120,115,50,18,5,dwhite,dblue:Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,dwhite,dblue
EndIf

RBox 220,115,50,18,5,white,blue:Text 225,117,Str$(max(0,4))+" C",lt,1,1,white,blue:Text 180,117,"max:",lt,1,1,white,dblue
Text 5,140,"Kotel:",lt,1,1,white,dblue:RBox 220,135,50,18,5,white,blue:Text 180,137,"max:",lt,1,1,white,dblue:Text 225,137,Str$(max(1,0))+" C",lt,1,1,white,blue
If sdis%(8)=0 Then
RBox 65,135,50,18,5,white,blue:Text 70,137,Str$(ss%(8))+" C",lt,1,1,yellow,blue
Else
RBox 65,135,50,18,5,dwhite,dblue:Text 70,137,Str$(ss%(8))+" C",lt,1,1,dwhite,dblue
EndIf

Text 5,160,"Podno:",lt,1,1,white,dblue:RBox 220,155,50,18,5,white,blue:Text 180,157,"max:",lt,1,1,white,dblue:Text 225,157,Str$(max(1,2))+" C",lt,1,1,white,blue
If sdis%(10)=0 Then
RBox 65,155,50,18,5,white,blue:Text 70,157,Str$(ss%(10))+" C",lt,1,1,yellow,blue
Else
RBox 65,155,50,18,5,dwhite,dblue:Text 70,157,Str$(ss%(10))+" C",lt,1,1,dwhite,dblue
EndIf
Text 5,180,"Radia:",lt,1,1,white,dblue:RBox 220,175,50,18,5,white,blue:Text 180,180,"max:",lt,1,1,white,dblue:Text 225,177,Str$(max(1,1))+" C",lt,1,1,white,blue
If sdis%(9)=0 Then
RBox 65,175,50,18,5,white,blue:Text 70,177,Str$(ss%(9))+" C",lt,1,1,yellow,blue
Else
RBox 65,175,50,18,5,dwhite,dblue:Text 70,177,Str$(ss%(9))+" C",lt,1,1,dwhite,dblue
EndIf
Return
sl1:
gosub bojler_on ' ispituva dali e zagrean bojlerot, ako bil pusten manuelno na struja da se gree
If (ss%(1)-ss%(ntc3))> max(1,3) And ss%(ntc3)<70 Then ' ovdeka ja prepraviv 70C na baranje od Goran
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:Pin(21)=1:k(6)=1
ElseIf (ss%(1)-ss%(ntc3))<max(1,4) or ss%(ntc3)>=71 Then
if trghld=0 then
Pin(21)=0:k(6)=0
endif
If (ss%(1)-ss%(2))>max(1,3) And ss%(2)<70 Then
Pin(19)=1:k(5)=1:Pin(23)=1:k(0)=1:pin(21)=0:k(6)=0
ElseIf (ss%(1)-ss%(2))<= max(1,4) or ss%(ntc3)>=71 Then
if trghld=0 then
Pin(19)=0:k(5)=0:Pin(23)=0:k(0)=0
endif
EndIf
EndIf

Port(8,2,37,2)=12 ' ispituva dali jumperot za zimo/leto e priklucen
if pin(10)<1 then ' ako pin(10)=0 togas e priklucen jumperot i ima kotel
If ss%(9)>max(1,1) Then ' ako sonda9> max na parnoto
Pin(24)=1:k(1)=1:Pin(30)=1:k(9)=1 ' P2=1 R5=0 go vrti maliot krug, golema temp na vlezot
Else
Pin(24)=1:k(1)=1:Pin(30)=0:k(9)=0 ' P2=1 R5=1 zema toplina od bojlerot
EndIf
If ss%(10)>max(1,2) Then ' ako sonda 10> max na podnoto
Pin(25)=1:k(2)=1:Pin(31)=1:k(10)=1 ' P3=1 R6=0 maliot krug
Else
Pin(25)=1:k(2)=1:Pin(31)=0:k(10)=0' P3=1 R6=1 zema od bojlerot
EndIf
if ss%(8)>max(1,0) then ' ova e za da se izbegni "kondenz" kako so rece Goran, samo nad odredena temp. na bojler da ima uslov
if (ss%(8)-ss%(2))>max(1,3) and ss%(ntc3)<max(0,2) then ' ako e zagrean kotelot ima razmena so bojlerot
Pin(27)=1:k(4)=1:Pin(22)=1:k(7)=1:Pin(26)=1:k(3)=1
elseif (ss%(8)-ss%(2))<max(1,4) or ss%(ntc3)>=max(0,2) then ' a koga e laden togas nema
Pin(27)=0:k(4)=0:Pin(22)=0:k(7)=0:Pin(26)=0:k(3)=0
EndIf
elseif ss%(8)<(max(1,0)-2) then ' ako padni temp na kotelot, da iskluci se
Pin(27)=0:k(4)=0:Pin(22)=0:k(7)=0:Pin(26)=0:k(3)=0
endif
Else
Pin(25)=0:k(2)=0:Pin(24)=0:k(1)=0:Pin(30)=0:k(9)=0:Pin(31)=0:k(10)=0:Pin(27)=0:k(4)=0:Pin(22)=0:k(7)=0:Pin(26)=0:k(3)=0
endif
Return
sl2:
gosub bojler_on

Port(8,2,37,2)=11 ' dali dzamperot so prioritet e priklucen
watchdog 3000
if pin(10)>1 then ' slucaj bez prioritet
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>= 91 then ' ogas ne ja gleda max temp zadadena
if trghld=0 then
Pin(19)=0:k(5)=0 ' tuku 90C kako max na bojlerite
endif
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(19)=1:k(5)=1
endif
If (ss%(1)-ss%(4))<max(1,4) Or ss%(ntc5)>=91 Then
if trghld=0 then
Pin(21)=0:k(6)=0
endif
elseif (ss%(1)-ss%(4))> max(1,3) and ss%(ntc5)<90 then
Pin(21)=1:k(6)=1
endif
If (ss%(1)-ss%(6))< max(1,4) Or ss%(ntc7)>=91 Then
pin(22)=0:k(7)=0
elseif (ss%(1)-ss%(6))> max(1,3) and ss%(ntc7)<90 Then
pin(22)=1:k(7)=1
endif
if k(5)=0 and k(6)=0 and k(7)=0 then
if trghld=0 then
k(0)=0:pin(23)=0
endif
else
k(0)=1:pin(23)=1
endif
else
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>= max(0,2) Then
If (ss%(1)-ss%(4))< max(1,4) Or ss%(ntc5)>= max(0,3) Then
If (ss%(1)-ss%(6))< max(1,4) Or ss%(ntc7)>= max(0,4) Then
if trghld=0 then
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0:Pin(21)=0:k(6)=0:Pin(22)=0:k(7)=0
endif
ElseIf (ss%(1)-ss%(6))> max(1,3) and ss%(ntc7)<max(0,4) Then
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:Pin(21)=0:k(6)=0:Pin(22)=1:k(7)=1
EndIf
ElseIf (ss%(1)-ss%(4))> max(1,3) and ss%(ntc5)< max(0,3) Then
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:Pin(21)=1:k(6)=1:Pin(22)=0:k(7)=0
EndIf
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<max(0,2) Then
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:Pin(21)=0:k(6)=0:Pin(22)=0:k(7)=0
EndIf
endif
Return
sl3:

Port(8,2,37,2)=12 ' ispituva dali kotelot e priklucen (zima)
if pin(10)>1 then
if trghld=0 then
Pin(24)=0:k(1)=0:Pin(21)=0:k(6)=0:Pin(15)=0:k(8)=0 ' nema dzamper, znaci nema kotel
endif
endif
gosub bojler_on

Port(8,2,37,2)=11
'watchdog 3000
if pin(10)>1 then ' nema prioritet, jumperot e OFF
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>=91 then
if trghld=0 then
Pin(19)=0:k(5)=0
endif
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(19)=1:k(5)=1
endif
If (ss%(1)-ss%(4))<max(1,4) Or ss%(ntc5)>=91 Then
if trghld=0 then
Pin(22)=0:k(7)=0
endif
elseif (ss%(1)-ss%(4))> max(1,3) and ss%(ntc5)<90 then
Pin(22)=1:k(7)=1
endif
if k(5)=0 and k(7)=0 then
if trghld=0 then
k(0)=0:pin(23)=0
endif
else
k(0)=1:pin(23)=1
endif

Port(8,2,37,2)=12
if pin(10)<1 then ' prisuten e dzamperot za kotel
if ss%(8)>max(1,0) then ' isto kako vo sl1:, za da se izbegni "kondenz"
if (ss%(8)-ss%(ntc3))<max(1,4)Or ss%(ntc3)>= max(0,2) then ' namesto da sporeduva ss%(8) so ss(2) sega sporeduva so ss(ntc3)...spored Goran
if trghld=0 then
Pin(21)=0:k(6)=0
endif
ElseIf (ss%(8)-ss%(ntc3))> max(1,3) and ss%(ntc3)<max(0,2) then
Pin(21)=1:k(6)=1
endif
if (ss%(8)-ss%(ntc5))<max(1,4)Or ss%(ntc5)>= max(0,3) then
Pin(15)=0:k(8)=0
ElseIf (ss%(8)-ss%(ntc5))> max(1,3) and ss%(ntc5)<max(0,3) then
Pin(15)=1:k(8)=1
endif
if k(6)=0 and k(8)=0 then
k(1)=0:pin(24)=0
else
k(1)=1:pin(24)=1
endif
endif
endif
else ' ima prioritet
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>= max(0,2) Then
If (ss%(1)-ss%(4))< max(1,4) Or ss%(ntc5)>= max(0,3) Then
if trghld=0 then
pin(23)=0:k(0)=0:pin(19)=0:k(5)=0:pin(22)=0:k(7)=0
endif
ElseIf (ss%(1)-ss%(4))> max(1,3) Then
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:pin(22)=1:k(7)=1
EndIf
ElseIf (ss%(1)-ss%(2))> max(1,3) Then
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:pin(22)=0:k(7)=0
EndIf

Port(8,2,37,2)=12 ' kotelot e priklucen
if pin(10)<1 then ' vo kombinacijata ima prioritet, sega ima i kotel
if ss%(8)>max(1,0) then ' za izbegnuvanje "kondenz"
if (ss%(8)-ss%(ntc3))<max(1,4) or ss%(ntc3)>=max(0,2) then
if (ss%(8)-ss%(ntc5))<max(1,4) or ss%(ntc5)>=max(0,3) then
if trghld=0 then
pin(21)=0:k(6)=0:pin(15)=0:k(8)=0:pin(24)=0:k(1)=0
endif
elseif (ss%(8)-ss%(ntc5))>max(1,3) and ss%(ntc5)<max(0,3) then
pin(15)=1:k(8)=1:pin(21)=0:k(6)=0:pin(24)=1:k(1)=1
endif
elseif (ss%(8)-ss%(ntc3))>max(1,3) and ss%(ntc3)<max(0,2) then
pin(21)=1:k(6)=1:pin(15)=0:k(8)=0:pin(24)=1:k(1)=1
endif
elseif ss%(8)<(max(1,0)-2) then
if trghld=0 then
pin(21)=0:k(6)=0:pin(15)=0:k(8)=0:pin(24)=0:k(1)=0 ' ako temp na kotelot padni, da se isklucat site ventili i pumpi
endif
endif
endif
EndIf
return
sl4:
Port(8,2,37,2)=12
if pin(10)>1 then ' ne e kotelot priklucen
Pin(24)=0:k(1)=0:Pin(22)=0:k(7)=0
endif
gosub bojler_on
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>=91 Then
if trghld=0 then
Pin(19)=0:k(5)=0
endif
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(19)=1:k(5)=1
endif
If (ss%(0)-ss%(2))< max(1,4) Or ss%(ntc3)>=91 Then
if trghld=0 then
Pin(21)=0:k(6)=0
endif
ElseIf (ss%(0)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(21)=1:k(6)=1
EndIf
if k(5)=0 and k(6)=0 then
if trghld=0 then
pin(23)=0:k(0)=0
endif
else
pin(23)=1:k(0)=1
endif

Port(8,2,37,2)=12
If pin(10)<2 Then
if ss%(8)>max(1,0) then ' za da se izbegni "kondenz" i vo ovoj slucaj
if (ss%(8)-ss%(ntc3))<max(1,4) or ss%(ntc3)>=max(0,2) then
if trghld=0 then
Pin(24)=0:k(1)=0:Pin(22)=0:k(7)=0
endif
elseif (ss%(8)-ss%(ntc3))>max(1,3) and ss%(ntc3)< max(0,2) Then
Pin(24)=1:k(1)=1:Pin(22)=1:k(7)=1
EndIf
elseif ss%(8)<(max(1,0)-2) then ' ko temp na kotelot padni, da iskluci se
if trghld=0 then
Pin(24)=0:k(1)=0:Pin(22)=0:k(7)=0
endif
endif
EndIf
return
ekran1:
GoSub crtaj_ekran:oldtemperatura1=0:oldtemperatura2=0
If PREKINUVAC=0 Then
SW_OFF 220,40:LED_OFF 260,20:Pin(32)=0:k(11)=0
Else
SW_ON 220,40:LED_ON 260,20:Pin(32)=1:k(11)=1
EndIf
If RADIO =0 Then
RADIO_OFF 225,110,"TIMER"
Else
RADIO_ON 225,110,"TIMER"
EndIf
RBox 50,6,130,65,10,white,blue:RBox 51,7,128,63,10,WHITE,BLUE:Text 10,15,"S",LT,1,4,WHITE,dBLUE
For n=0 To 2
Circle 165,20,5+n
Next
RBox 50,85,130,65,10,white,blue:RBox 51,86,128,63,10,white,blue:Text 10,94,"B",LT,1,4,WHITE,dBLUE
For n=0 To 2
Circle 165,99,5+n
Text 140,120,Str$(max(0,2)),lt,1,2,green,blue
Next
If holliday=0 Then:_box_OFF 160,162,"HOLIDAY":Else:_box_on 160,162,"HOLIDAY": EndIf
Return
ekran3:
On index GoSub d1,d2,d3,d4,d5
RBox 135,218,80,20,3,dblue,dblue
Return
EKRAN4:
ekran=4
GoSub crtaj_ekran:Box 0,0,319,195,3,WHITE,lilja:Text 30,30,"SETUP PARAMETARS ",LT,1,2,WHITE,LILJA
For N=22 To 237 Step 71:RBox N,80,60,100,10,BLACK,BLACK:RBox N-5,80,60,100,10,WHITE,BLUE:Next
Text 32,155,"TIME",LT,1,1,WHITE,BLUE:Circle 47,115,20,3,1,green:Line 47,115,47,99:Line 47,115,59,115
Text 95,155,"ON/OFF",LT,1,1,WHITE,BLUE:Circle 118,115,20,3,1,yellow:Line 118,115,118,99:Line 118,115,130,115
Text 175,155,"TEMP",LT,1,1,WHITE,BLUE:Circle 185,140,8,1,1,WHITE,RED:RBox 182,100,7,35,2:Line 184,101,184,145,4,RED
For N=105 To 130 Step 12:Line 200,N,205,N:Next
Text 245,155,"TEST",lt,1,1,white,blue:Box 250,130,20,20,2:Box 250,100,20,20,2:Line 250,100,270,120:Line 250,120,270,100
Return
podesi_vreme:
Box 0,0,319,195,3,white,lilja:Text 90,5,"h",lt,1,2,white,lilja:Box 60,30,80,60,3,white,blue:Text 68,35,Left$(Time$,2),lt,2,1,white,blue
Circle 155,45,5,1,1,white,white:Circle 155,75,5,1,1,white,white:Text 190,5,"min",lt,1,2,white,lilja:Box 170,30,80,60,3,white,blue
Text 178,35,Mid$(Time$,4,2),lt,2,1,white,blue:Box 5,130,60,45,3,white,blue:Text 15,133,Left$(Date$,2),lt,1,3,white,blue:Circle 80,140,5,1,1,white,white
Circle 80,165,5,1,1,white,white:Box 95,130,60,45,3,white,blue:Text 105,133,Mid$(Date$,4,2),lt,1,3,white,blue:Circle 170,140,5,1,1,white,white
Circle 170,165,5,1,1,white,white:Box 185,130,120,45,3,white,blue:Text 195,133,Right$(Date$,4),lt,1,3,white,blue:Text 30,100,"d",lt,1,2,white,lilja
Text 120,100,"m",lt,1,2,white,lilja:Text 210,100,"year",lt,1,2,white,lilja:Box 0,195,319,44,2,white,dblue:strelkadg 280,200:strelkalg 5,200
Return
podesi_timer: ' rutina za podesuvanje tajmerot
Box 0,0,319,195,3,white,dblue:Box 25,5,270,180,3
For n=0 To 5
For m=0 To 3
If pritisnato(n,m)=1 Then
boja=red
Else
boja=dblue
EndIf
Box 25+n*45,(m*45)+5,45,45,1,white,boja
Next
Next
For n=0 To 23
Text 30+45*(n Mod 6),35+45*(n\6),Str$(n)
Next
Do While Not (0 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239)
WatchDog 2000
If Touch(x)<>-1 And Touch(y)<>-1 Then
gasiLed=0:pin(36)=0
If 25<Touch(x) And Touch(x)<295 And Touch(y)<185 Then
gasiLed=0:pin(36)=0
keypressx=Touch(x)-25:keypressy=Touch(y):keypressx=keypressx\45:keypressy=keypressy\45:buzer
If pritisnato(keypressx,keypressy)=0 Then
Box 25+keypressx*45,(keypressy*45)+5,45,45,1,white,red
Else
Box 25+keypressx*45,keypressy*45+5,45,45,1,white,dblue
EndIf
pritisnato(keypressx,keypressy)=Not pritisnato(keypressx,keypressy):i=keypressy*6+keypressx
I2C write eeprom,0,3,0,i,pritisnato(keypressx,keypressy)
Pause 4
For n=0 To 23
Text 30+45*(n Mod 6),35+45*(n\6),Str$(n)
Next
EndIf
EndIf
Loop
buzer
podesi_timer_index=0
Return
podesi_max:
zavrsimax_kraj=0
Do
WatchDog 2000
zavrsimax=0
I2C write eeprom,0,2,0,24
Pause 4
For n= 0 To 4
For m=0 To 1
I2C read eeprom,0,1,i
max(m,n)=i
Next
Next
GoSub crtaj_ekran
Text 10,10,"S1max",lt,1,1,white,dblue:Text 10,48,"S2max",lt,1,1,white,dblue:Text 10,86,"B1max",lt,1,1,white,dblue:Text 10,124,"B2max",lt,1,1,white,dblue
Text 10,162,"B3max",lt,1,1,white,dblue:Text 170,10,"Kotel",lt,1,1,white,dblue:Text 170,48,"Parno",lt,1,1,white,dblue:Text 170,86,"Podno",lt,1,1,white,dblue
Line 170,134,180,134:Line 180,134,175,124:Line 175,124,170,134:Text 185,124,"max",lt,1,1,white,dblue:Line 170,174,180,174:Line 180,174,175,164:Line 175,164,170,174
Text 185,164,"min",lt,1,1,white,dblue
For n=5 To 165 Step 38
For m=60 To 220 Step 160
RBox m,n,60,30,5,white,blue:Text m+70,n+5,"C",lt,1,2,yellow,dblue:c=(m-60)\160:i=(n-5)\38:Text m+5,n+2,Str$(max(c,i)),lt,1,2,white,blue
Next
Next
Do
WatchDog 2000
If Touch(x)<>-1 And Touch(y)<>-1 Then
gasiLed=0:pin(36)=0
If 60<Touch(x) And Touch(x)<120 And 5<Touch(y) And Touch(y)<195 Then ' zadavanje vrednost na prvata kolona (S1max, S2max, B1max,B2max, B3max)
gasiLed=0:pin(36)=0
keypressx=(Touch(x)-60)\60:keypressy=(Touch(y)-5)\38
GoSub tastaturasub
Pause 200
EndIf
If 220<Touch(x) And Touch(x)<280 And 5<Touch(y) And Touch(y)<195 Then ' zadavanje vrenost na 2ta kolona
gasiLed=0:pin(36)=0
keypressx=(Touch(x)-220+60)\60:keypressy=(Touch(y)-5)\38
GoSub tastaturasub
Pause 200
EndIf
EndIf
If 0 < Touch(x) And Touch(x) < 319 And 200 < Touch(y) And Touch(y) < 239 Then
gasiLed=0:pin(36)=0
buzer: zavrsimax_kraj=1
Exit Do
EndIf
Loop Until zavrsimax=1
Loop Until zavrsimax_kraj=1
Return

test:
Port(21,7,15,1,19,1,30,3)=0
GoSub crtaj_ekran

_box_off 130,10,"PUMP #1"
_box_off 130,40,"PUMP #2"
_box_off 130,70,"PUMP #3"
_box_off 130,100,"PUMP #4"
_box_off 130,130,"PUMP #5"
_box_off 130,160,"BOILER "
_box_off 290,10,"VALVE 1"
_box_off 290,40,"VALVE 2"
_box_off 290,70,"VALVE 3"
_box_off 290,100,"VALVE 4"
_box_off 290,130,"VALVE 5"
_box_off 290,160,"VALVE 6"

Do While Not (0 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239)
WatchDog 2000
If Touch(x)<>-1 And Touch(y)<>-1 Then
If 5<Touch(x) And Touch(x)<315 And Touch(y)<185 Then
gasiLed=0:pin(36)=0
keypressx=Touch(x)-5
keypressy=Touch(y)-5
keypressx=keypressx\155
keypressy=keypressy\30
n=keypressy+keypressx*6
buzer
testbox%(n)=Not testbox%(n)
Select Case n
Case 0
Select Case testbox%(n)
Case 0
_box_off 130,10,"PUMP #1":Pin(23)=0:k(0)=0
Case 1
_box_on 130,10,"PUMP #1":Pin(23)=1:k(0)=1
End Select
Case 1
Select Case testbox%(n)
Case 0
_box_off 130,40,"PUMP #2":Pin(24)=0:k(1)=0
Case 1
_box_on 130,40,"PUMP #2":Pin(24)=1:k(1)=1
End Select
Case 2
Select Case testbox%(n)
Case 0
_box_off 130,70,"PUMP #3":Pin(25)=0:k(2)=0
Case 1
_box_on 130,70,"PUMP #3":Pin(25)=1:k(2)=1
End Select
Case 3
Select Case testbox%(n)
Case 0
_box_off 130,100,"PUMP #4":Pin(26)=0:k(3)=0
Case 1
_box_on 130,100,"PUMP #4":Pin(26)=1:k(3)=1
End Select
Case 4
Select Case testbox%(n)
Case 0
_box_off 130,130,"PUMP #5":Pin(27)=0:k(4)=0
Case 1
_box_on 130,130,"PUMP #5":Pin(27)=1:k(4)=1
End Select
Case 5
Select Case testbox%(n)
Case 0
_box_off 130,160,"BOILER ":Pin(32)=0:k(11)=0
Case 1
_box_on 130,160,"BOILER ":Pin(32)=1:k(11)=1
End Select
Case 6
Select Case testbox%(n)
Case 0
_box_off 290,10,"VALVE 1":Pin(19)=0:k(5)=0
Case 1
_box_on 290,10,"VALVE 1":Pin(19)=1:k(5)=1
End Select
Case 7
Select Case testbox%(n)
Case 0
_box_off 290,40,"VALVE 2":Pin(21)=0:k(6)=0
Case 1
_box_on 290,40,"VALVE 2":Pin(21)=1:k(6)=1
End Select
Case 8
Select Case testbox%(n)
Case 0
_box_off 290,70,"VALVE 3":Pin(22)=0:k(7)=0
Case 1
_box_on 290,70,"VALVE 3":Pin(22)=1:k(7)=1
End Select
Case 9
Select Case testbox%(n)
Case 0
_box_off 290,100,"VALVE 4":Pin(15)=0:k(8)=0
Case 1
_box_on 290,100,"VALVE 4":Pin(15)=1:k(8)=1
End Select
Case 10
Select Case testbox%(n)
Case 0
_box_off 290,130,"VALVE 5":Pin(30)=0:k(9)=0
Case 1
_box_on 290,130,"VALVE 5":Pin(30)=1:k(9)=1
End Select
Case 11
Select Case testbox%(n)
Case 0
_box_off 290,160,"VALVE 6":Pin(31)=0:k(10)=0
Case 1
_box_on 290,160,"VALVE 6":Pin(31)=1:k(10)=1
End Select
End Select
EndIf
EndIf
Loop
nadvor:
buzer
For n=0 To 11
k(n)=0
Next
Port(21,7,15,1,19,1,30,3)=0

Return
crtaj_ekran:
Box 0,0,319,195,2,white,dblue:Box 0,195,319,44,2,white,dblue:strelkadg 280,200:strelkalg 8,200
Return
saat:
saatot1=Val(Left$(Time$,2))
I2C write eeprom,0,2,0,saatot1
Pause 4
I2C read eeprom,0,1,mem_timer
If radio=1 Then
If mem_timer=1 Then
if ss%(ntc3)<(max(0,2)-2) then ' tajmerot e pusten i ispituva dali bijlerot e zagrean
Pin(32)=1:k(11)=1 ' vo intervalot na tajmerot
I2C write eeprom,0,3,0,144,1
If ekran=1 Then
SW_ON 220,40:LED_ON 260,20
EndIf
elseif ss%(ntc3)>=(max(0,2)) then
Pin(32)=0:k(11)=0 ' iskluci go bojlerot ako e zagrean
'I2C write eeprom,0,3,0,144,1 ' ne treba da se zapisuva nula vo memorijata
If ekran=1 Then
SW_off 220,40:LED_off 260,20
EndIf
endif
Else
Pin(32)=0:k(11)=0
I2C write eeprom,0,3,0,144,0
If ekran=1 Then
SW_Off 220,40:LED_Off 260,20
EndIf
EndIf
EndIf
EndIf
IReturn
Sub IZMERI
For n=0 To 10
'Port(8,2,37,2)=n
Port(8,2,37,2)=n
For m=1 To 5
Ux=Ux+Pin(10)
Next
Ux=Ux/5
select case n
case 0,1,2,4,6,8,9,10
If Val(Mid$(install$,n+1,1))=1 Then
If (0.04 < Ux) And (Ux <2.8) Then
sdis%(n)=0
greska(n)=2
Else
err_sensor=n
buzer
Pause 200
If Ux<0.04 Then
greska(err_sensor)=10:ss%(err_sensor)=max(0,2)
ElseIf Ux>2.8 Then
greska(err_sensor)=20:ss%(err_sensor)=max(0,2)
EndIf
GoTo preskokni
EndIf
Else
sdis%(n)=1
GoTo preskokni
EndIf
case 3,5,7
If Val(Mid$(install$,n+1,1))=1 Then
If (0.04 < Ux) And (Ux <2.8) Then
sdis%(n)=0:greska(n)=2
elseif Ux<0.04 then
err_sensor=n:buzer:pause 200:greska(err_sensor)=10
goto preskokni
elseif Ux>2.8 then
sdis%(n)=1
goto preskokni
endif
else
sdis%(n)=1
goto preskokni
endif
end select
UX=990847/(298.15*(Log(Ux/(3.3-Ux)))+3380)
UX=UX-273.15:ss%(n)=UX
preskokni:
Ux=0
Next
For n=11 To 13
'Port(8,2,37,2)=n
Port(8,2,37,2)=n
ss%(n)=Pin(10)
Next

End Sub
pocni:
index=1:indexold=0
GoSub d1
Do
WatchDog 2000
If Touch(x)<>-1 Or Touch(y)<>-1 Then
gasiLed=0:pin(36)=0
If 280 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If index< 7 Then
index=index+1
EndIf
EndIf
If 5 < Touch(x) And Touch(x) < 37 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If index>1 Then
index=index-1
EndIf
EndIf
If 130 < Touch(x) And Touch(x) < 210 And 215 < Touch(y) And Touch(y) < 239 Then
gasiLed=0:pin(36)=0
I2C write eeprom,0,3,0,147,index:buzer
Exit Do
EndIf
If index<>indexold Then
pin(23)=0:k(0)=0:pin(24)=0:k(1)=0:pin(25)=0:k(2)=0:pin(26)=0:k(3)=0:pin(27)=0:k(4)=0
pin(19)=0:k(5)=0:pin(21)=0:k(6)=0:pin(22)=0:k(7)=0:pin(15)=0:k(8)=0:pin(30)=0:k(9)=0: pin(31)=0:k(10)=0
On index GoSub d1,d2,d3,d4
EndIf
indexold=index
EndIf
Loop
GoTo pocetok
d1:
strelki
pgore 2,110:Text 15,95,"P1":lsolarno 10,60:bojler 100,100:Text 160,110,"T3":Text 160,175,"T2":Line 10,60,10,162,1,green:Line 10,162,100,162,1,green
Line 60,30,60,70,1,red:Line 60,70,30,70,1,red:Line 30,70,30,147,1,red:Line 30,147,100,147,1,red:vhor 50,139:Text 50,126,"R1"
Line 100,118,30,118,1,red:vhor 50,110:Text 50,97,"R2":Line 100,132,80,132,1,green:Line 80,132,80,162,1,green:RBox 135,218,80,20,3,white,yellow:Text 138,223,"S1 ENTER",lt,1,1,black,yellow
if ss%(12)=0 then
pgore 168,30:Text 185,30,"P2":pgore 222,30:Text 240,30,"P3":vdesno 170,60:Text 150,60,"R5":vdesno 225,60:Text 235,75,"R6":Line 185,65,215,65,1,red:radijator 180,10:Text 160,5,"T9"
Line 185,68,215,68,1,green:Line 180,20,175,20,1,green:Line 175,20,175,105,1,green:Line 175,105,140,105,1,green:Line 215,20,215,20,1,red:Line 215,20,215,130,1,red
Line 215,130,140,130,1,red:radijator 235,10:Text 272,5,"T10":Line 240,68,274,68,1,green:Line 240,65,274,65,1,red:Line 235,20,230,20,1,green:Line 230,20,230,105,1,green
Line 230,105,175,105,1,green:Line 270,18,275,18,1,red:Line 275,18,275,140,1,red:Line 275,140,140,140,1,red:kotel 275,145:Line 275,150,140,150,1,red:vhor 230,142
Text 230,157,"R3":Line 275,170,180,170,1,green:Line 180,170,180,160,1,green:Line 180,160,140,160,1,green:pdesno 200,162:Text 200,182,"P5":Text 290,105,"P4"
Line 285,145,285,125,1,red:Line 285,125,310,125,1,red:Line 310,125,310,145,1,red:pdesno 290,118
endif
Return
d2:
strelki
lsolarno 10,60:bojler 70,100:Text 115,125,"T3":Text 115,150,"T2":bojler 160,100:Text 205,125,"T5":Text 205,150,"T4":bojler 250,100:Text 295,125,"T7":Text 295,150,"T6"
Line 10,60,10,162,1,green:Line 10,162,70,162,1,green:Line 60,30,60,146,1,red:Line 60,146,70,146,1,red:Line 160,146,135,146,1,red:Line 135,146,135,80,1,red
Line 135,80,60,80,1,red:Line 160,162,135,162,1,green:Line 135,162,135,190,1,green:Line 135,190,10,190,1,green:Line 10,190,10,162,1,green:Line 250,146,230,146,1,red
Line 230,146,230,80,1,red:Line 230,80,138,80,1,red:Line 250,161,230,161,1,green:Line 230,161,230,205,1,green:Line 230,205,10,205,1,green:Line 10,205,10,180,1,green
vver 52,90:Text 35,90,"R1":vver 127,90:Text 110,90,"R2":vver 222,90:Text 205,90,"R3":RBox 135,218,80,20,3,white,yellow
pgore 2,90:Text 22,115,"P1":Text 138,223,"S2 ENTER",lt,1,1,black,yellow
Return
d3:
strelki
lsolarno 10,45:Text 50,30,"T1":bojler 70,95:Text 115,100,"T3":Text 115,150,"T2":bojler 190,95:Text 235,100,"T5":Text 235,150,"T4":pgore 2,120
Text 15,145,"P1":Line 10,45,10,180,1,green:Line 10,180,150,180,1,green:Line 150,180,150,157,1,green:Line 150,157,190,157,1,green
Line 70,144,30,144,1,red:Line 30,144,30,75,1,red:Line 30,75,145,75,1,red:Line 145,75,145,144,1,red:Line 145,144,190,144,1,red
Line 68,10,68,75,1,red:Line 68,10,60,10,1,red:vver 22,90:Text 25,114,"R1":vver 137,90:Text 140,114,"R3"
RBox 135,218,80,20,3,white,yellow:Text 138,223,"S3 ENTER",lt,1,1,black,yellow: Line 60,180,60,157,1,green:Line 60,157,70,157,1,green
if ss%(12)=0 then
Line 55,85,270,85,1,red:Line 70,113,55,113,1,red:Line 55,113,55,85,1,red:Line 190,113,170,113,1,red:Line 170,113,170,85,1,red
Line 260,188,260,120,1,green:Line 260,120,270,120,1,green:Line 50,188,50,127,1,green:Line 50,127,70,127,1,green:Line 140,127,190,127,1,green
kotel 270,80:pgore 252,140:Text 275,145,"P2":Text 50,114,"R2":Text 165,114,"R4":vver 47,90:vver 162,90:Line 140,127,140,188,1,green:Line 260,188,50,188,1,green
endif
Return
d4:
strelki
lsolarno 10,60:Text 195,150,"T2":Text 195,100,"T3":Line 10,60,10,162,1,green:Line 10,162,152,162,1,green:pgore 3,120:Text 15,140,"P1":bojler 150,100
Line 60,30,60,147,1,red:Line 60,147,150,147,1,red:vver 52,45:Text 30,55,"R1"
dsolarno 80,25:Line 80,26,80,65,1,red:line 80,65,60,65,1,red:vver 72,45:text 90,45,"R2":line 130,55,130,75,1,green:line 130,75,10,75,1,green:RBox 135,218,80,20,3,white,yellow:Text 138,223,"S4 ENTER",lt,1,1,black,yellow
if ss%(12)=0 then
Line 150,132,120,132,1,green:Line 120,132,120,80,1,green:Line 120,80,220,80,1,green:Line 220,80,220,140,1,green:Line 220,140,280,140,1,green:Line 130,118,130,90,1,red:Line 150,118,130,118,1,red
kotel 280,100:Text 235,70,"R3":Text 240,150,"P2" :Line 130,90,260,90,1,red:Line 260,90,260,115,1,red:Line 260,115,280,115,1,red:pdesno 240,132:vhor 235,82
endif
return
Sub strelki
CLS(dblue):strelkadg 280,200:strelkalg 5,200
End Sub
Sub radio_ON(x,y,text$)
RBox x,y,70,80,10:Circle x+15,y+25,8:Circle x+15,y+55,8:Text x+15,y-5,text$:Circle X+15,Y+25,6,1,1,WHITE,WHITE:Text X+40,Y+20,"ON":Circle X+15,Y+55,6,1,1,DBLUE,DBLUE:Text X+40,Y+50,"OFF"
End Sub
Sub radio_OFF(x,y,text$)
RBox x,y,70,80,10:Circle x+15,y+25,8:Circle x+15,y+55,8:Text x+15,y-5,text$:Circle X+15,Y+25,6,1,1,DBLUE,DBLUE:Text X+40,Y+20,"ON":Circle X+15,Y+55,6,1,1,WHITE,WHITE:Text X+40,Y+50,"OFF"
End Sub
Sub SW_OFF(X,Y)
Box X,Y,80,60,1,yellow,yellow:Box X+5,Y+5,70,50,1,DRED,DRED:Text X+18,Y+10,"OFF",LT,1,2,WHITE,DRED:Text X+18,Y+40,"BOILER",LT,1,,WHITE,DRED
End Sub
Sub SW_ON(X,Y)
Box X,Y,80,60,1,yellow,yellow:Box X+5,Y+5,70,50,1,RED,RED:Text X+25,Y+10,"ON",LT,1,2,WHITE,RED:Text X+18,Y+40,"BOILER",LT,1,1,WHITE,RED
End Sub
Sub LED_ON(X,Y)
Circle X,Y,15,3:Circle X,Y,12,1,1,RED,RED
End Sub
Sub LED_OFF(X,Y)
Circle X,Y,15,3:Circle X,Y,12,1,1,DRED,DRED
End Sub
Sub _box_ON(X,Y,ime$)
Text x-Len(IME$)*17,y-3,ime$,LT,1,2,green,DBLUE:Box X,Y,20,20,2:Line x+2,y+2,x+18,y+18:Line x+2,y+3,x+18,y+19:Line x+2,y+18,x+18,y+2:Line x+2,y+19,x+18,y+3
End Sub
Sub _box_OFF(X,Y,ime$)
Text x-Len(IME$)*17,y-3,ime$,LT,1,2,red,DBLUE:Box X,Y,20,20,2,WHITE,DBLUE
End Sub
Sub lsolarno(x,y)
Line x,y,x+50,y-30,1,red:Line x+50,y-30,x+48,y-33,1,red:Line x+48,y-33,x-2,y-3,1,red:Line x-2,y-3,x,y,1,red:Line x-1,y-2,x+49,y-32,1,red
Line x+48,y-33,x+46,y-36,1,green:Line x+46,y-36,x-4,y-6,1,green:Line x-4,y-6,x-2,y-3,1,green:Line x+46,y-36,x+50,y-38,1,green:Circle x+53,y-41,3,1,1,red,red:Text x+30,y-60,"T1"
Circle x+10,y-50,5,1,1,yellow,yellow
For agol=0 To 6.28 Step 1.06
Line x+10,y-50,x+10+10*Cos(agol),y-50+10*Sin(agol),1,yellow
Next
End Sub
Sub dsolarno(x,y)
Line x,y,x+50,y+30,1,red:Line x+50,y+30,x+52,y+27,1,red:Line x+52,y+27,x+2,y-3,1,red:Line x+2,y-3,x,y,1,red:Line x+51,y+29,x+1,y-1,1,red:Line x+52,y+27,x+54,y+25,1,green
Line x+54,y+25,x+4,y-5,1,green:Line x+4,y-5,x+2,y-3,1,green:Line x+1,y-1,x-3,y-4,1,green:Circle x-7,y-7,3,1,1,red,red:Text x,y-25,"T0"
End Sub
Sub bazent(x,y)
Box x,y,4,15,1,gray,gray:Box x,y+15,50,4,1,gray,gray:Box x+50,y,4,19,1,gray,gray:Box x+5,y+4,44,12,1,blue,blue:Line x+54,y+2,x+59,y+2,2,green:Circle x+62,y+2,3,1,1,red,red:Text x+51,y-16,"T6"
End Sub
Sub Vdesno(x,y)
For i=0 To 30 Step 2
BitMap x,y+(i/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+i/2,pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Vlevo(x,y)
For i=32 To 62 Step 2
BitMap x,y+((i-32)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-32)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Vgore(x,y)
For i=64 To 94 Step 2
BitMap x,y+((i-64)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-64)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Vdolu(x,y)
For i=96 To 126 Step 2
BitMap x,y+((i-96)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-96)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Pdesno(x,y)
For i=128 To 158 Step 2
BitMap x,y+((i-128)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-128)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Plevo(x,y)
For i=160 To 190 Step 2
BitMap x,y+((i-160)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-160)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Pgore(x,y)
For i=192 To 222 Step 2
BitMap x,y+((i-192)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-192)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Pdolu(x,y)
For i=224 To 254 Step 2
BitMap x,y+((i-224)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-224)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub kotel(x,y)
Box x,y,40,50,2,white,gray:Box x+8,y+20,23,25,2,black,white:Text x+19,y+8,"T8",cm,1,1,white,gray
For i=256 To 286 Step 2
BitMap x+12,y+26+((i-256)/2),pole(i),2,8,1,red,white:BitMap x+8+12,y+26+((i-256)/2),pole(i+1),2,8,1,red,white
Next
End Sub
Sub strelkadg(x,y)
For i=352 To 478 Step 4
BitMap x,y+((i-352)/4),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-352)/4),pole(i+1),2,8,1,white,dblue:BitMap x+16,y+((i-352)/4),pole(i+2),2,8,1,white,dblue:BitMap x+24,y+((i-352)/4),pole(i+3),2,8,1,white,dblue
Next
End Sub
Sub strelkalg(x,y)
For i=480 To 606 Step 4
BitMap x,y+((i-480)/4),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-480)/4),pole(i+1),2,8,1,white,dblue:BitMap x+16,y+((i-480)/4),pole(i+2),2,8,1,white,dblue:BitMap x+24,y+((i-480)/4),pole(i+3),2,8,1,white,dblue
Next
End Sub

Sub vhor(x,y)
For i=608 To 638 Step 2
BitMap x,y+((i-608)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+(i-608)/2,pole(i+1),2,8,1,white,dblue
Next
End Sub

Sub vver(x,y)
For i=640 To 670 Step 2
BitMap x,y+((i-640)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+(i-640)/2,pole(i+1),2,8,1,white,dblue
Next
End Sub
' subrutina bojler **********************
Sub bojler(x,y)
RBox x,y,40,80,8:RBox x+1,y+60,38,18,6,blue,blue:Box x+1,y+10,38,50,1,blue,blue:Line x+41,y+70,x+50,y+70,2,green:Circle x+53,y+70,3,1,1,red,red
Line x+41,y+20,x+50,y+20,2,green:Circle x+53,y+20,3,1,1,red,red:Line x-2,y+61,x+20,y+61,3,green:Line x+20,y+60,x+10,y+55,1,green:Line x+10,y+55,x+20,y+50,1,red
Line x+20,y+46,x-2,y+46,3,red:Line x-2,y+31,x+20,y+31,3,green:Line x+20,y+30,x+10,y+25,1,green:Line x+10,y+25,x+20,y+20,1,red:Line x+20,y+16,x-2,y+16,3,red
End Sub
Sub radijator (x,y)
Box x,y,30,15,2
For i=2 To 28 Step 5
Line x+2+i,y+4,x+2+i,y+15
Next
Text x+10,y-15,"T7"
End Sub
Sub buzer
Pin(13)=1:Pause 80:Pin(13)=0
End Sub
tastaturasub:
greska:
SetTick 0,0,2
max_taster=4:taster$="":n=0:RBox 0,0,319,239,1,white,dblue
For kolona=20 To 120 Step 50
For redica=20 To 120 Step 50
RBox redica,kolona,40,40,10:RBox redica+1,kolona+1,38,38,10,white,blue:n=n+1:broj$=Str$(n):Text redica+10,kolona+5,broj$,lt,1,2,white,blue
Next
Next
RBox 170,20,140,40:RBox 171,21,138,38:RBox 20,170,40,40:RBox 21,171,38,38,10,white,blue:Text 40,190,"0",cm,1,2,white,blue
RBox 70,170,90,40:RBox 71,171,88,38,10,white,blue:Text 115,190,"ENTER",cm,1,2,white,blue:n=1:tocno$=""
Do
WatchDog 2000
If Touch(x) <> -1 And Touch(y) <> -1 Then
gasiLed=0:pin(36)=0
If 221 < Touch(x) And Touch(x) < 309 And 172 < Touch(y) And Touch(y) < 208 Then
gasiLed=0:pin(36)=0
buzer: CLS:Exit Do
EndIf

If 20 < Touch(x) And Touch(x) < 60 And 20 < Touch(y) And Touch(y) < 60 Then
gasiLed=0:pin(36)=0
keypress = 1: buzer
Else If 70 < Touch(x) And Touch(x) < 110 And 20 < Touch(y) And Touch(y) < 60 Then
gasiLed=0:pin(36)=0
keypress = 2: buzer
Else If 120 < Touch(x) And Touch(x) < 160 And 20 < Touch(y) And Touch(y) <60 Then
gasiLed=0:pin(36)=0
keypress = 3: buzer
Else If 20 < Touch(x) And Touch(x) < 60 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
keypress = 4: buzer
Else If 70 < Touch(x) And Touch(x) < 110 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
keypress = 5: buzer
Else If 120 < Touch(x) And Touch(x) < 160 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
keypress = 6: buzer
Else If 20 < Touch(x) And Touch(x) < 60 And 120 < Touch(y) And Touch(y) < 160 Then
gasiLed=0:pin(36)=0
keypress = 7: buzer
Else If 70< Touch(x) And Touch(x) < 110 And 120 < Touch(y) And Touch(y) < 160 Then
gasiLed=0:pin(36)=0
keypress = 8: buzer
Else If 120 < Touch(x) And Touch(x) < 160 And 120 < Touch(y) And Touch(y) < 160 Then
gasiLed=0:pin(36)=0
keypress = 9: buzer
Else If 20 < Touch(x) And Touch(x) < 60 And 170 < Touch(y) And Touch(y) < 210 Then
gasiLed=0:pin(36)=0
keypress = 0: buzer
Else If 70 < Touch(x) And Touch(x) < 160 And 170 < Touch(y) And Touch(y) < 210 Then
gasiLed=0:pin(36)=0
keypress = 10: buzer
Else
keypress = 99
EndIf

If keypress=10 Then
i=(keypressY*2+keypressx)+24
if (i=28 or i=30 or i=32) and val(taster$)>90 then
taster$="90"
elseif i=27 and val(taster$)>60 then
taster$="60"
elseif i=29 and val(taster$)>40 then
taster$="40"
'goto greska
endif

I2C write eeprom,0,3,i\256,i Mod 256,Val(taster$):Pause 4

endif
If keypress<10 And keypress<>99 And n<max_taster Then
taster$=taster$+Str$(keypress):n=n+1:Text 200,41,taster$,Lm,1,2,white,dblue:Pause 250
EndIf
EndIf
IZLEZ:
Loop Until keypress=10:SetTick 60000,saat,2:keypress=99:zavrsimax=1
Return
bojler_on: ' go isklucuva bojlerot ako e zagrean, a so prekinuvacot bil prethodno pusten
if prekinuvac=1 and (ss%(ntc3)>max(0,2)) then
if ekran=1 then
SW_off 220,40:LED_off 260,20
endif
PREKINUVAC=0:Pin(32)=0:k(11)=0: I2C write eeprom,0,3,0,144,prekinuvac
endif
return
vreme_analiza:
saatot=Val(Left$(Time$,2)):minutata=Val(Mid$(Time$,4,2)):denot=Val(Left$(Date$,2)):mesecot=Val(Mid$(Date$,4,2)):godinata =Val(Right$(Date$,4))
Return
gasi:
If Touch(x) <> -1 And Touch(y) <> -1 Then
gasiLed=0
endif
gasiLed=gasiLed+1
if gasiLed=10 then
pin(36)=1
endif
ireturn
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 01:26pm 12 Nov 2017
Copy link to clipboard 
Print this post

If somebody have a time to go through it.

https://www.dropbox.com/s/qj0vl04eipqhxc5/PCB.pdf?dl=0&m=

2017-11-12_231511_eeprom18July.zip


Option explicit
Option base 0
Const red=RGB(255,0,0),green=RGB(0,255,0),blue=RGB(0,0,250)
Const black=RGB(0,0,0),white=RGB(255,255,255),dwhite=RGB(220,220,220),yellow=RGB(250,250,0)
Const gray=RGB(160,160,160),dblue=RGB(0,0,160),svetla=RGB(220,220,200),lilja=RGB(240,136,233)
Const dred=RGB(170,0,0),dgreen=RGB(0,120,0),dyellow=RGB(120,120,0)
Dim redica,kolona,keypress,saatot1,index,indexold,i,r,g,b,pole(672) As integer
Dim max_taster,greska(11),suma_greska,agol,ekran,mem_timer,err_sensor,hld,trghld ' dimenzionirana e hld i trighld (ovoj e 1 samo ako bojlerot
Dim taster$,tocno$,text$,broj$,ime$,temperatura$ ' e povisok za 10C od solarnoto
Dim b1max,b2max,b3max,s1max,s2max,kotelmax,parnomax,poolmax,rtc,S,EEPROM,VLEZ,UX,X1,Y,T,TMAX,k(12) As integer
Dim b1enable,b2enable,b3enable,s1enable,s2enable,kotelenable,parnoenable,poolenable,RADIO,PREKINUVAC,HOLLiDAY,winter As integer
Dim saatot,minutata,denot,mesecot,godinata,podesi_vreme_index,podesi_max_index,podesi_saat,podesi_minuta,podesi_den,podesi_m esec,podesi_godina
Dim test_index,podesi_timer_index,keypressx,keypressy,pritisnato(6,4),boja' matrica sto pokazuva dali e setuvan nekoj period (0-1h)(1-2h)....
Dim zavrsimax,zavrsimax_kraj,oldtemperatura1,oldtemperatura2,oldtemperatura3,max(2,5)
Dim prethodnax,prethodnay,slednax,slednay,c,n,m As integer
Dim niska,visoka,zapisi,period As integer
Dim merenje_start1,merenje_end1,merenje_start2,merenje_end2,ntc3,ntc5,ntc7,grafik As integer
Dim sdis%(16),testbox%(12),ss%(16)
Dim install$="00000000000"
dim gasiLed as integer
ntc3=2:ntc5=4:ntc7=6:greska(0)=2
VAR restore
podesi_max_index=0:taster$="":ekran=1:rtc=104:eeprom=80
SetPin 10,ain:SetPin 8,dout:SetPin 9,dout:setpin 11,dout:SetPin 37,dout:SetPin 38,dout
SetPin 23,dout:SetPin 24,dout:SetPin 25,dout:SetPin 26,dout:SetPin 27,dout
SetPin 19,dout:SetPin 21,dout:SetPin 22,dout:SetPin 15,dout:SetPin 30,dout:SetPin 31,dout:SetPin 32,dout:SetPin 13,dout:SetPin 36,dout
I2C open 100,200
settick 30000,gasi,1
WatchDog 5000
rtc settime 16,06,15,12,0,0
ss%(12)=3
'If MM.I2C <> 0 Then Error "PCF8563 not responding"
RTC GETTIME
I2C write eeprom,0,2,0,0
Pause 4
For n=0 To 3
For m=0 To 5
I2C read eeprom,0,1,i
pritisnato(m,n)=i
Next
Next
I2C write eeprom,0,2,0,24
Pause 4
For n= 0 To 4
For m=0 To 1:I2C read eeprom,0,1,i:max(m,n)=i:Next
Next
I2C write eeprom,0,2,0,144
Pause 4
I2C read eeprom,0,1,prekinuvac:I2C read eeprom,0,1,radio:I2C read eeprom,0,1,holliday:I2C read eeprom,0,1,index:I2C read eeprom,0,1,winter
visoka=301\256:niska=301 Mod 256:I2C write eeprom,0,2,visoka,niska:Pause 4
For i=301 To 972
visoka=i\256:niska=i Mod 256:I2C read eeprom,0,1,pole(i-301)
Next
For n=0 To 11
testbox%(n)=0
Next
pocetok:
CLS(DBLUE):GoSub ekran1:SetTick 60000,saat,2
Do

Select Case index
Case 1
if ss%(12)=0 then
install$="01110000111" ' vo prvata kombinacija, koga ima kotel (ss%(12)=0) ima senzori na S1,S2,S3,S8,S9,S10
else
install$="01110000000" ' znaci install$ pokazuva koi senzori se aktivni za koja kombinacija
endif
Case 2
install$="01111111000"
Case 3
if ss%(12)=0 then
install$="01111100100"
else
install$="01111100000"
endif
Case 4
if ss%(12)=0 then
install$="11110000100"
else
install$="11110000000"
endif
End Select
If greska(err_sensor)=2 Then
strelkadg 280,200:strelkalg 8,200
Text 45,200,"P1":Text 65,200,"P2":Text 85,200,"P3":Text 105,200,"P4"
Text 125,200,"P5":Text 145,200,"R1":Text 165,200,"R2":Text 185,200,"R3"
Text 205,200,"R4":Text 225,200,"R5":Text 245,200,"R6":Text 265,200,"B"
For n=0 To 11
If k(n)=0 Then
boja=red
Else
boja=green
EndIf
Circle 50+(n*20),225,7,1,1,dblue,boja
Next
Else
Box 2,197,315,40,2,dblue,dblue
Select Case greska(err_sensor)
Case 10
Text 60,200,"sensor"+Str$(err_sensor)+" short !!",lt,1,2,red,dblue
Case 20
Text 60,200,"sensor"+Str$(err_sensor)+" open !!",lt,1,2,red,dblue
End Select
Pause 1000
Box 2,197,315,40,2,dblue,dblue
EndIf

izmeri
If sdis%(3)=0 Then
ntc3=3
Else
ntc3=2
EndIf
If sdis%(5)=1 Then
ntc5=4
Else
ntc5=5
EndIf
If sdis%(7)=1 Then
ntc7=6
Else
ntc7=7
EndIf
On index GoSub sl1,sl2,sl3,sl4
If holliday=1 Then
hld=ss%(2)-ss%(1)
If hld>10 Then
trghld=1 ' aktivirana e trighld, taa mu kazuva na slucaite deka e uslovot ispolnet
Select Case index
Case 1
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1
CASE 2
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:pin(21)=1:k(6)=1:pin(22)=1:k(7)=1
case 3
pin(23)=1:k(0)=1:pin(19)=1:k(5)=1:pin(22)=1:k(7)=1
Case 4
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:Pin(21)=1:k(6)=1
End Select
elseIf hld>0 And hld<5 Then '
trghld=0 ' resetirana e trighld
Select Case index
Case 1
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0
CASE 2
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0:pin(21)=0:k(6)=0:pin(22)=0:k(7)=0
case 3
pin(23)=0:k(0)=0:pin(19)=0:k(5)=0:pin(22)=0:k(7)=0
Case 4
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0:Pin(21)=0:k(6)=0
End Select
EndIf
EndIf

If ekran=1 Then
If oldtemperatura1<>ss%(1) Then
RBox 51,8,100,59,10,BLUE,blue:Text 55,13,Str$(ss%(1)),LT,2,1,WHITE,BLUE:oldtemperatura1=ss%(1)
Else If oldtemperatura2<>ss%(2) Then
RBox 51,87,80,59,10,BLUE,blue:Text 55,92,Str$(ss%(2)),LT,2,1,WHITE,BLUE:oldtemperatura2=ss%(2)
EndIf
EndIf
SKENIRAJ:
WatchDog 2000
If Touch(x) <> -1 And Touch(y) <> -1 Then
gasiLed=0:pin(36)=0
If ekran=4 And podesi_vreme_index=1 And 0 < Touch(x) And Touch(x) < 319 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
GoSub vreme_analiza:RTC settime godinata-2000,mesecot,denot,saatot,minutata,30:podesi_vreme_index=0:GoSub EKRAN4
EndIf
If 280 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If EKRAN<=4 Then
EKRAN=EKRAN+1
EndIf
If ekran=5 Then
ekran=1
EndIf
On EKRAN GoSub EKRAN1,ekran2,EKRAN3,EKRAN4
EndIf
If 5 < Touch(x) And Touch(x) < 37 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If EKRAN>0 Then
EKRAN=EKRAN-1
EndIf
If ekran=0 Then
ekran=4
EndIf
On EKRAN GoSub EKRAN1,ekran2,EKRAN3,EKRAN4
EndIf

If EKRAN=1 Then
SetTick 60000,saat,2
If 220 < Touch(x) And Touch(x) < 300 And 40 < Touch(y) And Touch(y) < 100 And PREKINUVAC=0 Then
gasiLed=0:pin(36)=0
SW_ON 220,40:LED_ON 260,20:PREKINUVAC=1:Pin(32)=1:k(11)=1: I2C write eeprom,0,3,0,144,prekinuvac
buzer
pause 500
EndIf
If 220 < Touch(x) And Touch(x) < 300 And 40 < Touch(y) And Touch(y) < 100 And PREKINUVAC=1 Then
gasiLed=0:pin(36)=0
SW_OFF 220,40:LED_OFF 260,20:PREKINUVAC=0:Pin(32)=0:k(11)=0: I2C write eeprom,0,3,0,144,prekinuvac
buzer
pause 500
EndIf
If 210 < Touch(X) And Touch(X)<260 And 110<Touch(Y) And Touch(Y)<150 And RADIO=0 Then
gasiLed=0:pin(36)=0
RADIO_ON 225,110,"TIMER":RADIO=1:I2C write eeprom,0,3,0,145,radio:buzer
EndIf
If 210 < Touch(X)And Touch(X)<260 And 150<Touch(Y) And Touch(Y)<190 And RADIO=1 Then
gasiLed=0:pin(36)=0
RADIO_OFF 225,110,"TIMER":RADIO=0:I2C write eeprom,0,3,0,145,radio:buzer
EndIf
If 145 < Touch(x) And Touch(x) < 200 And 145 < Touch(y) And Touch(y) < 189 Then
gasiLed=0:pin(36)=0
If HOLLIDAY=0 Then
_box_ON 160,162,"HOLIDAY":HOLLIDAY=1:I2C write eeprom,0,3,0,146,holliday:buzer
Else
_box_OFF 160,162,"HOLIDAY":HOLLIDAY=0:I2C write eeprom,0,3,0,146,holliday:buzer
EndIf
EndIf
If 220 < Touch(x) And Touch(x) < 300 And 0 < Touch(y) And Touch(y) < 60 Then
gasiLed=0:pin(36)=0
WatchDog 4000
Pause 2000
If 220 < Touch(x) And Touch(x) < 300 And 0 < Touch(y) And Touch(y) < 60 Then
SetTick 0,0,2:GoTo pocni
EndIf
EndIf
EndIf
If ekran=4 And podesi_vreme_index=0 And podesi_timer_index=0 And podesi_max_index=0 Then
If 22 < Touch(X) And Touch(X)<82 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
podesi_vreme_index=1:buzer:GoSub podesi_vreme
EndIf
If 93 < Touch(X) And Touch(X)<153 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
podesi_timer_index=1:buzer:GoSub podesi_timer:GoSub EKRAN4
EndIf
If 164 < Touch(X) And Touch(X)<224 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
podesi_max_index=1:buzer:GoSub podesi_max:podesi_max_index=0:GoSub EKRAN4
EndIf
If 235 < Touch(X) And Touch(X)<295 And 80<Touch(Y) And Touch(Y)<180 Then
gasiLed=0:pin(36)=0
test_index=1:buzer:GoSub test:test_index=0:GoSub EKRAN4
EndIf
ElseIf ekran=4 And podesi_vreme_index=1 Then
' ********** promena na saati
If 60 < Touch(x) And Touch(x) < 140 And 5 < Touch(y) And Touch(y) < 50 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
saatot=saatot+1:buzer
If saatot=24 Then
saatot=0
EndIf
Time$=Str$(saatot)+Right$(Time$,6)
GoSub podesi_vreme
EndIf
If 60 < Touch(x) And Touch(x) < 140 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
saatot=saatot-1:buzer
If saatot=-1 Then
saatot=23
EndIf
Time$=Str$(saatot)+Right$(Time$,6)
GoSub podesi_vreme ' podesi vreme display
EndIf
'************* promena na minuti
If 170 < Touch(x) And Touch(x) < 240 And 5 < Touch(y) And Touch(y) < 50 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
minutata=minutata+1:buzer
If minutata=60 Then
minutata=0
EndIf
Time$=Left$(Time$,3)+Str$(minutata)
GoSub podesi_vreme
EndIf
If 170 < Touch(x) And Touch(x) < 240 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
minutata=minutata-1:buzer
If minutata=-1 Then
minutata=59
EndIf
Time$=Left$(Time$,3)+Str$(minutata)
GoSub podesi_vreme
EndIf
' ********** promena na denovi
If 5 < Touch(x) And Touch(x) < 65 And 110 < Touch(y) And Touch(y) < 150 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
denot=denot+1:buzer
If denot=32 Then
denot=1
EndIf
Date$=Str$(denot)+Right$(Date$,8)
GoSub podesi_vreme
EndIf

If 5 < Touch(x) And Touch(x) < 65 And 155 < Touch(y) And Touch(y) < 195 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza
denot=denot-1:buzer
If denot=-1 Then
denot=31
EndIf
Date$=Str$(denot)+Right$(Date$,8)
GoSub podesi_vreme
EndIf
'***************8 promena na meseci
If 95 < Touch(x) And Touch(x) < 155 And 110 < Touch(y) And Touch(y) < 150 Then 'up nad saatot
gasiLed=0:pin(36)=0
GoSub vreme_analiza
mesecot=mesecot+1:buzer
If mesecot=13 Then
mesecot=1
EndIf
Date$=Left$(Date$,3)+Str$(mesecot)+Right$(Date$,5)
GoSub podesi_vreme
EndIf
If 95 < Touch(x) And Touch(x) < 155 And 155 < Touch(y) And Touch(y) < 195 Then 'udown nad saatot
gasiLed=0:pin(36)=0
GoSub vreme_analiza
mesecot=mesecot-1:buzer
If mesecot=-1 Then
mesecot=12
EndIf
Date$=Left$(Date$,3)+Str$(mesecot)+Right$(Date$,5)
GoSub podesi_vreme
EndIf
'******************** promena na godini
If 185 < Touch(x) And Touch(x) < 305 And 110 < Touch(y) And Touch(y) < 150 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza:godinata=godinata+1:buzer:Date$=Left$(Date$,6)+Str$(godinata):GoSub podesi_vreme
EndIf

If 185 < Touch(x) And Touch(x) < 305 And 155 < Touch(y) And Touch(y) < 195 Then
gasiLed=0:pin(36)=0
GoSub vreme_analiza:godinata=godinata-1:buzer:Date$=Left$(Date$,6)+Str$(godinata):GoSub podesi_vreme
EndIf
EndIf
EndIf
If ekran <>2 Then GoTo zaobikoli:EndIf
If sdis%(0)=0 Then
Text 70,17,Str$(ss%(0))+" C",lt,1,1,yellow,blue
Else
Text 70,17,Str$(ss%(0))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(1)=0 Then
Text 70,37,Str$(ss%(1))+" C",lt,1,1,yellow,blue
Else
Text 70,37,Str$(ss%(1))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(2)=0 Then
Text 70,77,Str$(ss%(2))+" C",lt,1,1,yellow,blue
Else
Text 70,77,Str$(ss%(2))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(3)=0 Then
Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,yellow,blue
Else
Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(4)=0 Then
Text 70,97,Str$(ss%(4))+" C",lt,1,1,yellow,blue
Else
Text 70,97,Str$(ss%(4))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(5)=0 Then
Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,yellow,blue
Else
Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(6)=0 Then
Text 70,117,Str$(ss%(6))+" C",lt,1,1,yellow,blue
Else
Text 70,117,Str$(ss%(6))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(7)=0 Then
Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,yellow,blue
Else
Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(8)=0 Then
Text 70,137,Str$(ss%(8))+" C",lt,1,1,yellow,blue
Else
Text 70,137,Str$(ss%(8))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(10)=0 Then
Text 70,157,Str$(ss%(10))+" C",lt,1,1,yellow,blue
Else
Text 70,157,Str$(ss%(10))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(9)=0 Then
Text 70,177,Str$(ss%(9))+" C",lt,1,1,yellow,blue
Else
Text 70,177,Str$(ss%(9))+" C",lt,1,1,dwhite,dblue
EndIf
zaobikoli:
Loop
ekran2:
GoSub crtaj_ekran
Text 5,20,"Solar0:",lt,1,1,white,dblue
If sdis%(0)=0 Then
RBox 65,15,50,18,5,white,blue
Text 70,17,Str$(ss%(0))+" C",lt,1,1,yellow,blue
Else
RBox 65,15,50,18,5,dwhite,dblue
Text 70,17,Str$(ss%(0))+" C",lt,1,1,dwhite,dblue
EndIf
RBox 120,15,50,18,5,white,blue:Text 125,17,Str$(max(0,0)),lt,1,1,green,blue:Line 180,30,190,30:Line 190,30,185,20:Line 185,20,180,30
Text 195,20,"t1:",lt,1,1,white,dblue:RBox 220,15,50,18,5,white,blue:Text 225,17,Str$(max(1,3))+" C",lt,1,1,white,blue:Text 5,40,"Solar1:",lt,1,1,white,dblue
If sdis%(1)=0 Then
RBox 65,35,50,18,5,white,blue
Text 70,37,Str$(ss%(1))+" C",lt,1,1,yellow,blue
Else
RBox 65,35,50,18,5,dwhite,dblue
Text 70,37,Str$(ss%(1))+" C",lt,1,1,dwhite,dblue
EndIf
RBox 120,35,50,18,5,white,blue:Text 125,37,Str$(max(0,1)),lt,1,1,green,blue:Line 180,50,190,50:Line 190,50,185,40:Line 185,40,180,50
Text 195,40,"t2:",lt,1,1,white,dblue:RBox 220,35,50,18,5,white,blue:Text 225,37,Str$(max(1,4))+" C",lt,1,1,white,blue:Text 5,80,"Tank1:",lt,1,1,white,dblue
If sdis%(2)=0 Then
RBox 65,75,50,18,5,white,blue:Text 70,77,Str$(ss%(2))+" C",lt,1,1,yellow,blue
Else
RBox 65,75,50,18,5,dwhite,dblue:Text 70,77,Str$(ss%(2))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(3)=0 Then
RBox 120,75,50,18,5,white,blue:Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,yellow,blue
Else
RBox 120,75,50,18,5,dwhite,dblue:Text 125,77,Str$(ss%(ntc3))+" C",lt,1,1,dwhite,dblue
EndIf
RBox 220,75,50,18,5,white,blue:Text 225,77,Str$(max(0,2))+" C",lt,1,1,white,blue:Text 180,77,"max:",lt,1,1,white,dblue:Text 5,100,"Tank2:",lt,1,1,white,dblue
If sdis%(4)=0 Then
RBox 65,95,50,18,5,white,blue:Text 70,97,Str$(ss%(4))+" C",lt,1,1,yellow,blue
Else
RBox 65,95,50,18,5,dwhite,dblue:Text 70,97,Str$(ss%(4))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(5)=0 Then
RBox 120,95,50,18,5,white,blue:Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,yellow,blue
Else
RBox 120,95,50,18,5,dwhite,dblue:Text 125,97,Str$(ss%(ntc5))+" C",lt,1,1,dwhite,dblue
EndIf

RBox 220,95,50,18,5,white,blue:Text 225,97,Str$(max(0,3))+" C",lt,1,1,white,blue:Text 180,97,"max:",lt,1,1,white,dblue:Text 5,120,"Tank3:",lt,1,1,white,dblue
If sdis%(6)=0 Then
RBox 65,115,50,18,5,white,blue:Text 70,117,Str$(ss%(6))+" C",lt,1,1,yellow,blue
Else
RBox 65,115,50,18,5,dwhite,dblue:Text 70,117,Str$(ss%(6))+" C",lt,1,1,dwhite,dblue
EndIf
If sdis%(7)=0 Then
RBox 120,115,50,18,5,white,blue:Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,yellow,blue
Else
RBox 120,115,50,18,5,dwhite,dblue:Text 125,117,Str$(ss%(ntc7))+" C",lt,1,1,dwhite,dblue
EndIf

RBox 220,115,50,18,5,white,blue:Text 225,117,Str$(max(0,4))+" C",lt,1,1,white,blue:Text 180,117,"max:",lt,1,1,white,dblue
Text 5,140,"Kotel:",lt,1,1,white,dblue:RBox 220,135,50,18,5,white,blue:Text 180,137,"max:",lt,1,1,white,dblue:Text 225,137,Str$(max(1,0))+" C",lt,1,1,white,blue
If sdis%(8)=0 Then
RBox 65,135,50,18,5,white,blue:Text 70,137,Str$(ss%(8))+" C",lt,1,1,yellow,blue
Else
RBox 65,135,50,18,5,dwhite,dblue:Text 70,137,Str$(ss%(8))+" C",lt,1,1,dwhite,dblue
EndIf

Text 5,160,"Podno:",lt,1,1,white,dblue:RBox 220,155,50,18,5,white,blue:Text 180,157,"max:",lt,1,1,white,dblue:Text 225,157,Str$(max(1,2))+" C",lt,1,1,white,blue
If sdis%(10)=0 Then
RBox 65,155,50,18,5,white,blue:Text 70,157,Str$(ss%(10))+" C",lt,1,1,yellow,blue
Else
RBox 65,155,50,18,5,dwhite,dblue:Text 70,157,Str$(ss%(10))+" C",lt,1,1,dwhite,dblue
EndIf
Text 5,180,"Radia:",lt,1,1,white,dblue:RBox 220,175,50,18,5,white,blue:Text 180,180,"max:",lt,1,1,white,dblue:Text 225,177,Str$(max(1,1))+" C",lt,1,1,white,blue
If sdis%(9)=0 Then
RBox 65,175,50,18,5,white,blue:Text 70,177,Str$(ss%(9))+" C",lt,1,1,yellow,blue
Else
RBox 65,175,50,18,5,dwhite,dblue:Text 70,177,Str$(ss%(9))+" C",lt,1,1,dwhite,dblue
EndIf
Return
sl1:
gosub bojler_on ' ispituva dali e zagrean bojlerot, ako bil pusten manuelno na struja da se gree
If (ss%(1)-ss%(ntc3))> max(1,3) And ss%(ntc3)<70 Then ' ovdeka ja prepraviv 70C na baranje od Goran
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:Pin(21)=1:k(6)=1
ElseIf (ss%(1)-ss%(ntc3))<max(1,4) or ss%(ntc3)>=71 Then
if trghld=0 then
Pin(21)=0:k(6)=0
endif
If (ss%(1)-ss%(2))>max(1,3) And ss%(2)<70 Then
Pin(19)=1:k(5)=1:Pin(23)=1:k(0)=1:pin(21)=0:k(6)=0
ElseIf (ss%(1)-ss%(2))<= max(1,4) or ss%(ntc3)>=71 Then
if trghld=0 then
Pin(19)=0:k(5)=0:Pin(23)=0:k(0)=0
endif
EndIf
EndIf

Port(8,2,37,2)=12 ' ispituva dali jumperot za zimo/leto e priklucen
if pin(10)<1 then ' ako pin(10)=0 togas e priklucen jumperot i ima kotel
If ss%(9)>max(1,1) Then ' ako sonda9> max na parnoto
Pin(24)=1:k(1)=1:Pin(30)=1:k(9)=1 ' P2=1 R5=0 go vrti maliot krug, golema temp na vlezot
Else
Pin(24)=1:k(1)=1:Pin(30)=0:k(9)=0 ' P2=1 R5=1 zema toplina od bojlerot
EndIf
If ss%(10)>max(1,2) Then ' ako sonda 10> max na podnoto
Pin(25)=1:k(2)=1:Pin(31)=1:k(10)=1 ' P3=1 R6=0 maliot krug
Else
Pin(25)=1:k(2)=1:Pin(31)=0:k(10)=0' P3=1 R6=1 zema od bojlerot
EndIf
if ss%(8)>max(1,0) then ' ova e za da se izbegni "kondenz" kako so rece Goran, samo nad odredena temp. na bojler da ima uslov
if (ss%(8)-ss%(2))>max(1,3) and ss%(ntc3)<max(0,2) then ' ako e zagrean kotelot ima razmena so bojlerot
Pin(27)=1:k(4)=1:Pin(22)=1:k(7)=1:Pin(26)=1:k(3)=1
elseif (ss%(8)-ss%(2))<max(1,4) or ss%(ntc3)>=max(0,2) then ' a koga e laden togas nema
Pin(27)=0:k(4)=0:Pin(22)=0:k(7)=0:Pin(26)=0:k(3)=0
EndIf
elseif ss%(8)<(max(1,0)-2) then ' ako padni temp na kotelot, da iskluci se
Pin(27)=0:k(4)=0:Pin(22)=0:k(7)=0:Pin(26)=0:k(3)=0
endif
Else
Pin(25)=0:k(2)=0:Pin(24)=0:k(1)=0:Pin(30)=0:k(9)=0:Pin(31)=0:k(10)=0:Pin(27)=0:k(4)=0:Pin(22)=0:k(7)=0:Pin(26)=0:k(3)=0
endif
Return
sl2:
gosub bojler_on

Port(8,2,37,2)=11 ' dali dzamperot so prioritet e priklucen
watchdog 3000
if pin(10)>1 then ' slucaj bez prioritet
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>= 91 then ' ogas ne ja gleda max temp zadadena
if trghld=0 then
Pin(19)=0:k(5)=0 ' tuku 90C kako max na bojlerite
endif
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(19)=1:k(5)=1
endif
If (ss%(1)-ss%(4))<max(1,4) Or ss%(ntc5)>=91 Then
if trghld=0 then
Pin(21)=0:k(6)=0
endif
elseif (ss%(1)-ss%(4))> max(1,3) and ss%(ntc5)<90 then
Pin(21)=1:k(6)=1
endif
If (ss%(1)-ss%(6))< max(1,4) Or ss%(ntc7)>=91 Then
pin(22)=0:k(7)=0
elseif (ss%(1)-ss%(6))> max(1,3) and ss%(ntc7)<90 Then
pin(22)=1:k(7)=1
endif
if k(5)=0 and k(6)=0 and k(7)=0 then
if trghld=0 then
k(0)=0:pin(23)=0
endif
else
k(0)=1:pin(23)=1
endif
else
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>= max(0,2) Then
If (ss%(1)-ss%(4))< max(1,4) Or ss%(ntc5)>= max(0,3) Then
If (ss%(1)-ss%(6))< max(1,4) Or ss%(ntc7)>= max(0,4) Then
if trghld=0 then
Pin(23)=0:k(0)=0:Pin(19)=0:k(5)=0:Pin(21)=0:k(6)=0:Pin(22)=0:k(7)=0
endif
ElseIf (ss%(1)-ss%(6))> max(1,3) and ss%(ntc7)<max(0,4) Then
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:Pin(21)=0:k(6)=0:Pin(22)=1:k(7)=1
EndIf
ElseIf (ss%(1)-ss%(4))> max(1,3) and ss%(ntc5)< max(0,3) Then
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:Pin(21)=1:k(6)=1:Pin(22)=0:k(7)=0
EndIf
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<max(0,2) Then
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:Pin(21)=0:k(6)=0:Pin(22)=0:k(7)=0
EndIf
endif
Return
sl3:

Port(8,2,37,2)=12 ' ispituva dali kotelot e priklucen (zima)
if pin(10)>1 then
if trghld=0 then
Pin(24)=0:k(1)=0:Pin(21)=0:k(6)=0:Pin(15)=0:k(8)=0 ' nema dzamper, znaci nema kotel
endif
endif
gosub bojler_on

Port(8,2,37,2)=11
'watchdog 3000
if pin(10)>1 then ' nema prioritet, jumperot e OFF
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>=91 then
if trghld=0 then
Pin(19)=0:k(5)=0
endif
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(19)=1:k(5)=1
endif
If (ss%(1)-ss%(4))<max(1,4) Or ss%(ntc5)>=91 Then
if trghld=0 then
Pin(22)=0:k(7)=0
endif
elseif (ss%(1)-ss%(4))> max(1,3) and ss%(ntc5)<90 then
Pin(22)=1:k(7)=1
endif
if k(5)=0 and k(7)=0 then
if trghld=0 then
k(0)=0:pin(23)=0
endif
else
k(0)=1:pin(23)=1
endif

Port(8,2,37,2)=12
if pin(10)<1 then ' prisuten e dzamperot za kotel
if ss%(8)>max(1,0) then ' isto kako vo sl1:, za da se izbegni "kondenz"
if (ss%(8)-ss%(ntc3))<max(1,4)Or ss%(ntc3)>= max(0,2) then ' namesto da sporeduva ss%(8) so ss(2) sega sporeduva so ss(ntc3)...spored Goran
if trghld=0 then
Pin(21)=0:k(6)=0
endif
ElseIf (ss%(8)-ss%(ntc3))> max(1,3) and ss%(ntc3)<max(0,2) then
Pin(21)=1:k(6)=1
endif
if (ss%(8)-ss%(ntc5))<max(1,4)Or ss%(ntc5)>= max(0,3) then
Pin(15)=0:k(8)=0
ElseIf (ss%(8)-ss%(ntc5))> max(1,3) and ss%(ntc5)<max(0,3) then
Pin(15)=1:k(8)=1
endif
if k(6)=0 and k(8)=0 then
k(1)=0:pin(24)=0
else
k(1)=1:pin(24)=1
endif
endif
endif
else ' ima prioritet
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>= max(0,2) Then
If (ss%(1)-ss%(4))< max(1,4) Or ss%(ntc5)>= max(0,3) Then
if trghld=0 then
pin(23)=0:k(0)=0:pin(19)=0:k(5)=0:pin(22)=0:k(7)=0
endif
ElseIf (ss%(1)-ss%(4))> max(1,3) Then
Pin(23)=1:k(0)=1:Pin(19)=0:k(5)=0:pin(22)=1:k(7)=1
EndIf
ElseIf (ss%(1)-ss%(2))> max(1,3) Then
Pin(23)=1:k(0)=1:Pin(19)=1:k(5)=1:pin(22)=0:k(7)=0
EndIf

Port(8,2,37,2)=12 ' kotelot e priklucen
if pin(10)<1 then ' vo kombinacijata ima prioritet, sega ima i kotel
if ss%(8)>max(1,0) then ' za izbegnuvanje "kondenz"
if (ss%(8)-ss%(ntc3))<max(1,4) or ss%(ntc3)>=max(0,2) then
if (ss%(8)-ss%(ntc5))<max(1,4) or ss%(ntc5)>=max(0,3) then
if trghld=0 then
pin(21)=0:k(6)=0:pin(15)=0:k(8)=0:pin(24)=0:k(1)=0
endif
elseif (ss%(8)-ss%(ntc5))>max(1,3) and ss%(ntc5)<max(0,3) then
pin(15)=1:k(8)=1:pin(21)=0:k(6)=0:pin(24)=1:k(1)=1
endif
elseif (ss%(8)-ss%(ntc3))>max(1,3) and ss%(ntc3)<max(0,2) then
pin(21)=1:k(6)=1:pin(15)=0:k(8)=0:pin(24)=1:k(1)=1
endif
elseif ss%(8)<(max(1,0)-2) then
if trghld=0 then
pin(21)=0:k(6)=0:pin(15)=0:k(8)=0:pin(24)=0:k(1)=0 ' ako temp na kotelot padni, da se isklucat site ventili i pumpi
endif
endif
endif
EndIf
return
sl4:
Port(8,2,37,2)=12
if pin(10)>1 then ' ne e kotelot priklucen
Pin(24)=0:k(1)=0:Pin(22)=0:k(7)=0
endif
gosub bojler_on
If (ss%(1)-ss%(2))< max(1,4) Or ss%(ntc3)>=91 Then
if trghld=0 then
Pin(19)=0:k(5)=0
endif
ElseIf (ss%(1)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(19)=1:k(5)=1
endif
If (ss%(0)-ss%(2))< max(1,4) Or ss%(ntc3)>=91 Then
if trghld=0 then
Pin(21)=0:k(6)=0
endif
ElseIf (ss%(0)-ss%(2))> max(1,3) and ss%(ntc3)<90 Then
Pin(21)=1:k(6)=1
EndIf
if k(5)=0 and k(6)=0 then
if trghld=0 then
pin(23)=0:k(0)=0
endif
else
pin(23)=1:k(0)=1
endif

Port(8,2,37,2)=12
If pin(10)<2 Then
if ss%(8)>max(1,0) then ' za da se izbegni "kondenz" i vo ovoj slucaj
if (ss%(8)-ss%(ntc3))<max(1,4) or ss%(ntc3)>=max(0,2) then
if trghld=0 then
Pin(24)=0:k(1)=0:Pin(22)=0:k(7)=0
endif
elseif (ss%(8)-ss%(ntc3))>max(1,3) and ss%(ntc3)< max(0,2) Then
Pin(24)=1:k(1)=1:Pin(22)=1:k(7)=1
EndIf
elseif ss%(8)<(max(1,0)-2) then ' ko temp na kotelot padni, da iskluci se
if trghld=0 then
Pin(24)=0:k(1)=0:Pin(22)=0:k(7)=0
endif
endif
EndIf
return
ekran1:
GoSub crtaj_ekran:oldtemperatura1=0:oldtemperatura2=0
If PREKINUVAC=0 Then
SW_OFF 220,40:LED_OFF 260,20:Pin(32)=0:k(11)=0
Else
SW_ON 220,40:LED_ON 260,20:Pin(32)=1:k(11)=1
EndIf
If RADIO =0 Then
RADIO_OFF 225,110,"TIMER"
Else
RADIO_ON 225,110,"TIMER"
EndIf
RBox 50,6,130,65,10,white,blue:RBox 51,7,128,63,10,WHITE,BLUE:Text 10,15,"S",LT,1,4,WHITE,dBLUE
For n=0 To 2
Circle 165,20,5+n
Next
RBox 50,85,130,65,10,white,blue:RBox 51,86,128,63,10,white,blue:Text 10,94,"B",LT,1,4,WHITE,dBLUE
For n=0 To 2
Circle 165,99,5+n
Text 140,120,Str$(max(0,2)),lt,1,2,green,blue
Next
If holliday=0 Then:_box_OFF 160,162,"HOLIDAY":Else:_box_on 160,162,"HOLIDAY": EndIf
Return
ekran3:
On index GoSub d1,d2,d3,d4,d5
RBox 135,218,80,20,3,dblue,dblue
Return
EKRAN4:
ekran=4
GoSub crtaj_ekran:Box 0,0,319,195,3,WHITE,lilja:Text 30,30,"SETUP PARAMETARS ",LT,1,2,WHITE,LILJA
For N=22 To 237 Step 71:RBox N,80,60,100,10,BLACK,BLACK:RBox N-5,80,60,100,10,WHITE,BLUE:Next
Text 32,155,"TIME",LT,1,1,WHITE,BLUE:Circle 47,115,20,3,1,green:Line 47,115,47,99:Line 47,115,59,115
Text 95,155,"ON/OFF",LT,1,1,WHITE,BLUE:Circle 118,115,20,3,1,yellow:Line 118,115,118,99:Line 118,115,130,115
Text 175,155,"TEMP",LT,1,1,WHITE,BLUE:Circle 185,140,8,1,1,WHITE,RED:RBox 182,100,7,35,2:Line 184,101,184,145,4,RED
For N=105 To 130 Step 12:Line 200,N,205,N:Next
Text 245,155,"TEST",lt,1,1,white,blue:Box 250,130,20,20,2:Box 250,100,20,20,2:Line 250,100,270,120:Line 250,120,270,100
Return
podesi_vreme:
Box 0,0,319,195,3,white,lilja:Text 90,5,"h",lt,1,2,white,lilja:Box 60,30,80,60,3,white,blue:Text 68,35,Left$(Time$,2),lt,2,1,white,blue
Circle 155,45,5,1,1,white,white:Circle 155,75,5,1,1,white,white:Text 190,5,"min",lt,1,2,white,lilja:Box 170,30,80,60,3,white,blue
Text 178,35,Mid$(Time$,4,2),lt,2,1,white,blue:Box 5,130,60,45,3,white,blue:Text 15,133,Left$(Date$,2),lt,1,3,white,blue:Circle 80,140,5,1,1,white,white
Circle 80,165,5,1,1,white,white:Box 95,130,60,45,3,white,blue:Text 105,133,Mid$(Date$,4,2),lt,1,3,white,blue:Circle 170,140,5,1,1,white,white
Circle 170,165,5,1,1,white,white:Box 185,130,120,45,3,white,blue:Text 195,133,Right$(Date$,4),lt,1,3,white,blue:Text 30,100,"d",lt,1,2,white,lilja
Text 120,100,"m",lt,1,2,white,lilja:Text 210,100,"year",lt,1,2,white,lilja:Box 0,195,319,44,2,white,dblue:strelkadg 280,200:strelkalg 5,200
Return
podesi_timer: ' rutina za podesuvanje tajmerot
Box 0,0,319,195,3,white,dblue:Box 25,5,270,180,3
For n=0 To 5
For m=0 To 3
If pritisnato(n,m)=1 Then
boja=red
Else
boja=dblue
EndIf
Box 25+n*45,(m*45)+5,45,45,1,white,boja
Next
Next
For n=0 To 23
Text 30+45*(n Mod 6),35+45*(n\6),Str$(n)
Next
Do While Not (0 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239)
WatchDog 2000
If Touch(x)<>-1 And Touch(y)<>-1 Then
gasiLed=0:pin(36)=0
If 25<Touch(x) And Touch(x)<295 And Touch(y)<185 Then
gasiLed=0:pin(36)=0
keypressx=Touch(x)-25:keypressy=Touch(y):keypressx=keypressx\45:keypressy=keypressy\45:buzer
If pritisnato(keypressx,keypressy)=0 Then
Box 25+keypressx*45,(keypressy*45)+5,45,45,1,white,red
Else
Box 25+keypressx*45,keypressy*45+5,45,45,1,white,dblue
EndIf
pritisnato(keypressx,keypressy)=Not pritisnato(keypressx,keypressy):i=keypressy*6+keypressx
I2C write eeprom,0,3,0,i,pritisnato(keypressx,keypressy)
Pause 4
For n=0 To 23
Text 30+45*(n Mod 6),35+45*(n\6),Str$(n)
Next
EndIf
EndIf
Loop
buzer
podesi_timer_index=0
Return
podesi_max:
zavrsimax_kraj=0
Do
WatchDog 2000
zavrsimax=0
I2C write eeprom,0,2,0,24
Pause 4
For n= 0 To 4
For m=0 To 1
I2C read eeprom,0,1,i
max(m,n)=i
Next
Next
GoSub crtaj_ekran
Text 10,10,"S1max",lt,1,1,white,dblue:Text 10,48,"S2max",lt,1,1,white,dblue:Text 10,86,"B1max",lt,1,1,white,dblue:Text 10,124,"B2max",lt,1,1,white,dblue
Text 10,162,"B3max",lt,1,1,white,dblue:Text 170,10,"Kotel",lt,1,1,white,dblue:Text 170,48,"Parno",lt,1,1,white,dblue:Text 170,86,"Podno",lt,1,1,white,dblue
Line 170,134,180,134:Line 180,134,175,124:Line 175,124,170,134:Text 185,124,"max",lt,1,1,white,dblue:Line 170,174,180,174:Line 180,174,175,164:Line 175,164,170,174
Text 185,164,"min",lt,1,1,white,dblue
For n=5 To 165 Step 38
For m=60 To 220 Step 160
RBox m,n,60,30,5,white,blue:Text m+70,n+5,"C",lt,1,2,yellow,dblue:c=(m-60)\160:i=(n-5)\38:Text m+5,n+2,Str$(max(c,i)),lt,1,2,white,blue
Next
Next
Do
WatchDog 2000
If Touch(x)<>-1 And Touch(y)<>-1 Then
gasiLed=0:pin(36)=0
If 60<Touch(x) And Touch(x)<120 And 5<Touch(y) And Touch(y)<195 Then ' zadavanje vrednost na prvata kolona (S1max, S2max, B1max,B2max, B3max)
gasiLed=0:pin(36)=0
keypressx=(Touch(x)-60)\60:keypressy=(Touch(y)-5)\38
GoSub tastaturasub
Pause 200
EndIf
If 220<Touch(x) And Touch(x)<280 And 5<Touch(y) And Touch(y)<195 Then ' zadavanje vrenost na 2ta kolona
gasiLed=0:pin(36)=0
keypressx=(Touch(x)-220+60)\60:keypressy=(Touch(y)-5)\38
GoSub tastaturasub
Pause 200
EndIf
EndIf
If 0 < Touch(x) And Touch(x) < 319 And 200 < Touch(y) And Touch(y) < 239 Then
gasiLed=0:pin(36)=0
buzer: zavrsimax_kraj=1
Exit Do
EndIf
Loop Until zavrsimax=1
Loop Until zavrsimax_kraj=1
Return

test:
Port(21,7,15,1,19,1,30,3)=0
GoSub crtaj_ekran

_box_off 130,10,"PUMP #1"
_box_off 130,40,"PUMP #2"
_box_off 130,70,"PUMP #3"
_box_off 130,100,"PUMP #4"
_box_off 130,130,"PUMP #5"
_box_off 130,160,"BOILER "
_box_off 290,10,"VALVE 1"
_box_off 290,40,"VALVE 2"
_box_off 290,70,"VALVE 3"
_box_off 290,100,"VALVE 4"
_box_off 290,130,"VALVE 5"
_box_off 290,160,"VALVE 6"

Do While Not (0 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239)
WatchDog 2000
If Touch(x)<>-1 And Touch(y)<>-1 Then
If 5<Touch(x) And Touch(x)<315 And Touch(y)<185 Then
gasiLed=0:pin(36)=0
keypressx=Touch(x)-5
keypressy=Touch(y)-5
keypressx=keypressx\155
keypressy=keypressy\30
n=keypressy+keypressx*6
buzer
testbox%(n)=Not testbox%(n)
Select Case n
Case 0
Select Case testbox%(n)
Case 0
_box_off 130,10,"PUMP #1":Pin(23)=0:k(0)=0
Case 1
_box_on 130,10,"PUMP #1":Pin(23)=1:k(0)=1
End Select
Case 1
Select Case testbox%(n)
Case 0
_box_off 130,40,"PUMP #2":Pin(24)=0:k(1)=0
Case 1
_box_on 130,40,"PUMP #2":Pin(24)=1:k(1)=1
End Select
Case 2
Select Case testbox%(n)
Case 0
_box_off 130,70,"PUMP #3":Pin(25)=0:k(2)=0
Case 1
_box_on 130,70,"PUMP #3":Pin(25)=1:k(2)=1
End Select
Case 3
Select Case testbox%(n)
Case 0
_box_off 130,100,"PUMP #4":Pin(26)=0:k(3)=0
Case 1
_box_on 130,100,"PUMP #4":Pin(26)=1:k(3)=1
End Select
Case 4
Select Case testbox%(n)
Case 0
_box_off 130,130,"PUMP #5":Pin(27)=0:k(4)=0
Case 1
_box_on 130,130,"PUMP #5":Pin(27)=1:k(4)=1
End Select
Case 5
Select Case testbox%(n)
Case 0
_box_off 130,160,"BOILER ":Pin(32)=0:k(11)=0
Case 1
_box_on 130,160,"BOILER ":Pin(32)=1:k(11)=1
End Select
Case 6
Select Case testbox%(n)
Case 0
_box_off 290,10,"VALVE 1":Pin(19)=0:k(5)=0
Case 1
_box_on 290,10,"VALVE 1":Pin(19)=1:k(5)=1
End Select
Case 7
Select Case testbox%(n)
Case 0
_box_off 290,40,"VALVE 2":Pin(21)=0:k(6)=0
Case 1
_box_on 290,40,"VALVE 2":Pin(21)=1:k(6)=1
End Select
Case 8
Select Case testbox%(n)
Case 0
_box_off 290,70,"VALVE 3":Pin(22)=0:k(7)=0
Case 1
_box_on 290,70,"VALVE 3":Pin(22)=1:k(7)=1
End Select
Case 9
Select Case testbox%(n)
Case 0
_box_off 290,100,"VALVE 4":Pin(15)=0:k(8)=0
Case 1
_box_on 290,100,"VALVE 4":Pin(15)=1:k(8)=1
End Select
Case 10
Select Case testbox%(n)
Case 0
_box_off 290,130,"VALVE 5":Pin(30)=0:k(9)=0
Case 1
_box_on 290,130,"VALVE 5":Pin(30)=1:k(9)=1
End Select
Case 11
Select Case testbox%(n)
Case 0
_box_off 290,160,"VALVE 6":Pin(31)=0:k(10)=0
Case 1
_box_on 290,160,"VALVE 6":Pin(31)=1:k(10)=1
End Select
End Select
EndIf
EndIf
Loop
nadvor:
buzer
For n=0 To 11
k(n)=0
Next
Port(21,7,15,1,19,1,30,3)=0

Return
crtaj_ekran:
Box 0,0,319,195,2,white,dblue:Box 0,195,319,44,2,white,dblue:strelkadg 280,200:strelkalg 8,200
Return
saat:
saatot1=Val(Left$(Time$,2))
I2C write eeprom,0,2,0,saatot1
Pause 4
I2C read eeprom,0,1,mem_timer
If radio=1 Then
If mem_timer=1 Then
if ss%(ntc3)<(max(0,2)-2) then ' tajmerot e pusten i ispituva dali bijlerot e zagrean
Pin(32)=1:k(11)=1 ' vo intervalot na tajmerot
I2C write eeprom,0,3,0,144,1
If ekran=1 Then
SW_ON 220,40:LED_ON 260,20
EndIf
elseif ss%(ntc3)>=(max(0,2)) then
Pin(32)=0:k(11)=0 ' iskluci go bojlerot ako e zagrean
'I2C write eeprom,0,3,0,144,1 ' ne treba da se zapisuva nula vo memorijata
If ekran=1 Then
SW_off 220,40:LED_off 260,20
EndIf
endif
Else
Pin(32)=0:k(11)=0
I2C write eeprom,0,3,0,144,0
If ekran=1 Then
SW_Off 220,40:LED_Off 260,20
EndIf
EndIf
EndIf
EndIf
IReturn
Sub IZMERI
For n=0 To 10
'Port(8,2,37,2)=n
Port(8,2,37,2)=n
For m=1 To 5
Ux=Ux+Pin(10)
Next
Ux=Ux/5
select case n
case 0,1,2,4,6,8,9,10
If Val(Mid$(install$,n+1,1))=1 Then
If (0.04 < Ux) And (Ux <2.8) Then
sdis%(n)=0
greska(n)=2
Else
err_sensor=n
buzer
Pause 200
If Ux<0.04 Then
greska(err_sensor)=10:ss%(err_sensor)=max(0,2)
ElseIf Ux>2.8 Then
greska(err_sensor)=20:ss%(err_sensor)=max(0,2)
EndIf
GoTo preskokni
EndIf
Else
sdis%(n)=1
GoTo preskokni
EndIf
case 3,5,7
If Val(Mid$(install$,n+1,1))=1 Then
If (0.04 < Ux) And (Ux <2.8) Then
sdis%(n)=0:greska(n)=2
elseif Ux<0.04 then
err_sensor=n:buzer:pause 200:greska(err_sensor)=10
goto preskokni
elseif Ux>2.8 then
sdis%(n)=1
goto preskokni
endif
else
sdis%(n)=1
goto preskokni
endif
end select
UX=990847/(298.15*(Log(Ux/(3.3-Ux)))+3380)
UX=UX-273.15:ss%(n)=UX
preskokni:
Ux=0
Next
For n=11 To 13
'Port(8,2,37,2)=n
Port(8,2,37,2)=n
ss%(n)=Pin(10)
Next

End Sub
pocni:
index=1:indexold=0
GoSub d1
Do
WatchDog 2000
If Touch(x)<>-1 Or Touch(y)<>-1 Then
gasiLed=0:pin(36)=0
If 280 < Touch(x) And Touch(x) < 312 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If index< 7 Then
index=index+1
EndIf
EndIf
If 5 < Touch(x) And Touch(x) < 37 And 200 < Touch(y) And Touch(y) < 239 Then
buzer
gasiLed=0:pin(36)=0
If index>1 Then
index=index-1
EndIf
EndIf
If 130 < Touch(x) And Touch(x) < 210 And 215 < Touch(y) And Touch(y) < 239 Then
gasiLed=0:pin(36)=0
I2C write eeprom,0,3,0,147,index:buzer
Exit Do
EndIf
If index<>indexold Then
pin(23)=0:k(0)=0:pin(24)=0:k(1)=0:pin(25)=0:k(2)=0:pin(26)=0:k(3)=0:pin(27)=0:k(4)=0
pin(19)=0:k(5)=0:pin(21)=0:k(6)=0:pin(22)=0:k(7)=0:pin(15)=0:k(8)=0:pin(30)=0:k(9)=0: pin(31)=0:k(10)=0
On index GoSub d1,d2,d3,d4
EndIf
indexold=index
EndIf
Loop
GoTo pocetok
d1:
strelki
pgore 2,110:Text 15,95,"P1":lsolarno 10,60:bojler 100,100:Text 160,110,"T3":Text 160,175,"T2":Line 10,60,10,162,1,green:Line 10,162,100,162,1,green
Line 60,30,60,70,1,red:Line 60,70,30,70,1,red:Line 30,70,30,147,1,red:Line 30,147,100,147,1,red:vhor 50,139:Text 50,126,"R1"
Line 100,118,30,118,1,red:vhor 50,110:Text 50,97,"R2":Line 100,132,80,132,1,green:Line 80,132,80,162,1,green:RBox 135,218,80,20,3,white,yellow:Text 138,223,"S1 ENTER",lt,1,1,black,yellow
if ss%(12)=0 then
pgore 168,30:Text 185,30,"P2":pgore 222,30:Text 240,30,"P3":vdesno 170,60:Text 150,60,"R5":vdesno 225,60:Text 235,75,"R6":Line 185,65,215,65,1,red:radijator 180,10:Text 160,5,"T9"
Line 185,68,215,68,1,green:Line 180,20,175,20,1,green:Line 175,20,175,105,1,green:Line 175,105,140,105,1,green:Line 215,20,215,20,1,red:Line 215,20,215,130,1,red
Line 215,130,140,130,1,red:radijator 235,10:Text 272,5,"T10":Line 240,68,274,68,1,green:Line 240,65,274,65,1,red:Line 235,20,230,20,1,green:Line 230,20,230,105,1,green
Line 230,105,175,105,1,green:Line 270,18,275,18,1,red:Line 275,18,275,140,1,red:Line 275,140,140,140,1,red:kotel 275,145:Line 275,150,140,150,1,red:vhor 230,142
Text 230,157,"R3":Line 275,170,180,170,1,green:Line 180,170,180,160,1,green:Line 180,160,140,160,1,green:pdesno 200,162:Text 200,182,"P5":Text 290,105,"P4"
Line 285,145,285,125,1,red:Line 285,125,310,125,1,red:Line 310,125,310,145,1,red:pdesno 290,118
endif
Return
d2:
strelki
lsolarno 10,60:bojler 70,100:Text 115,125,"T3":Text 115,150,"T2":bojler 160,100:Text 205,125,"T5":Text 205,150,"T4":bojler 250,100:Text 295,125,"T7":Text 295,150,"T6"
Line 10,60,10,162,1,green:Line 10,162,70,162,1,green:Line 60,30,60,146,1,red:Line 60,146,70,146,1,red:Line 160,146,135,146,1,red:Line 135,146,135,80,1,red
Line 135,80,60,80,1,red:Line 160,162,135,162,1,green:Line 135,162,135,190,1,green:Line 135,190,10,190,1,green:Line 10,190,10,162,1,green:Line 250,146,230,146,1,red
Line 230,146,230,80,1,red:Line 230,80,138,80,1,red:Line 250,161,230,161,1,green:Line 230,161,230,205,1,green:Line 230,205,10,205,1,green:Line 10,205,10,180,1,green
vver 52,90:Text 35,90,"R1":vver 127,90:Text 110,90,"R2":vver 222,90:Text 205,90,"R3":RBox 135,218,80,20,3,white,yellow
pgore 2,90:Text 22,115,"P1":Text 138,223,"S2 ENTER",lt,1,1,black,yellow
Return
d3:
strelki
lsolarno 10,45:Text 50,30,"T1":bojler 70,95:Text 115,100,"T3":Text 115,150,"T2":bojler 190,95:Text 235,100,"T5":Text 235,150,"T4":pgore 2,120
Text 15,145,"P1":Line 10,45,10,180,1,green:Line 10,180,150,180,1,green:Line 150,180,150,157,1,green:Line 150,157,190,157,1,green
Line 70,144,30,144,1,red:Line 30,144,30,75,1,red:Line 30,75,145,75,1,red:Line 145,75,145,144,1,red:Line 145,144,190,144,1,red
Line 68,10,68,75,1,red:Line 68,10,60,10,1,red:vver 22,90:Text 25,114,"R1":vver 137,90:Text 140,114,"R3"
RBox 135,218,80,20,3,white,yellow:Text 138,223,"S3 ENTER",lt,1,1,black,yellow: Line 60,180,60,157,1,green:Line 60,157,70,157,1,green
if ss%(12)=0 then
Line 55,85,270,85,1,red:Line 70,113,55,113,1,red:Line 55,113,55,85,1,red:Line 190,113,170,113,1,red:Line 170,113,170,85,1,red
Line 260,188,260,120,1,green:Line 260,120,270,120,1,green:Line 50,188,50,127,1,green:Line 50,127,70,127,1,green:Line 140,127,190,127,1,green
kotel 270,80:pgore 252,140:Text 275,145,"P2":Text 50,114,"R2":Text 165,114,"R4":vver 47,90:vver 162,90:Line 140,127,140,188,1,green:Line 260,188,50,188,1,green
endif
Return
d4:
strelki
lsolarno 10,60:Text 195,150,"T2":Text 195,100,"T3":Line 10,60,10,162,1,green:Line 10,162,152,162,1,green:pgore 3,120:Text 15,140,"P1":bojler 150,100
Line 60,30,60,147,1,red:Line 60,147,150,147,1,red:vver 52,45:Text 30,55,"R1"
dsolarno 80,25:Line 80,26,80,65,1,red:line 80,65,60,65,1,red:vver 72,45:text 90,45,"R2":line 130,55,130,75,1,green:line 130,75,10,75,1,green:RBox 135,218,80,20,3,white,yellow:Text 138,223,"S4 ENTER",lt,1,1,black,yellow
if ss%(12)=0 then
Line 150,132,120,132,1,green:Line 120,132,120,80,1,green:Line 120,80,220,80,1,green:Line 220,80,220,140,1,green:Line 220,140,280,140,1,green:Line 130,118,130,90,1,red:Line 150,118,130,118,1,red
kotel 280,100:Text 235,70,"R3":Text 240,150,"P2" :Line 130,90,260,90,1,red:Line 260,90,260,115,1,red:Line 260,115,280,115,1,red:pdesno 240,132:vhor 235,82
endif
return
Sub strelki
CLS(dblue):strelkadg 280,200:strelkalg 5,200
End Sub
Sub radio_ON(x,y,text$)
RBox x,y,70,80,10:Circle x+15,y+25,8:Circle x+15,y+55,8:Text x+15,y-5,text$:Circle X+15,Y+25,6,1,1,WHITE,WHITE:Text X+40,Y+20,"ON":Circle X+15,Y+55,6,1,1,DBLUE,DBLUE:Text X+40,Y+50,"OFF"
End Sub
Sub radio_OFF(x,y,text$)
RBox x,y,70,80,10:Circle x+15,y+25,8:Circle x+15,y+55,8:Text x+15,y-5,text$:Circle X+15,Y+25,6,1,1,DBLUE,DBLUE:Text X+40,Y+20,"ON":Circle X+15,Y+55,6,1,1,WHITE,WHITE:Text X+40,Y+50,"OFF"
End Sub
Sub SW_OFF(X,Y)
Box X,Y,80,60,1,yellow,yellow:Box X+5,Y+5,70,50,1,DRED,DRED:Text X+18,Y+10,"OFF",LT,1,2,WHITE,DRED:Text X+18,Y+40,"BOILER",LT,1,,WHITE,DRED
End Sub
Sub SW_ON(X,Y)
Box X,Y,80,60,1,yellow,yellow:Box X+5,Y+5,70,50,1,RED,RED:Text X+25,Y+10,"ON",LT,1,2,WHITE,RED:Text X+18,Y+40,"BOILER",LT,1,1,WHITE,RED
End Sub
Sub LED_ON(X,Y)
Circle X,Y,15,3:Circle X,Y,12,1,1,RED,RED
End Sub
Sub LED_OFF(X,Y)
Circle X,Y,15,3:Circle X,Y,12,1,1,DRED,DRED
End Sub
Sub _box_ON(X,Y,ime$)
Text x-Len(IME$)*17,y-3,ime$,LT,1,2,green,DBLUE:Box X,Y,20,20,2:Line x+2,y+2,x+18,y+18:Line x+2,y+3,x+18,y+19:Line x+2,y+18,x+18,y+2:Line x+2,y+19,x+18,y+3
End Sub
Sub _box_OFF(X,Y,ime$)
Text x-Len(IME$)*17,y-3,ime$,LT,1,2,red,DBLUE:Box X,Y,20,20,2,WHITE,DBLUE
End Sub
Sub lsolarno(x,y)
Line x,y,x+50,y-30,1,red:Line x+50,y-30,x+48,y-33,1,red:Line x+48,y-33,x-2,y-3,1,red:Line x-2,y-3,x,y,1,red:Line x-1,y-2,x+49,y-32,1,red
Line x+48,y-33,x+46,y-36,1,green:Line x+46,y-36,x-4,y-6,1,green:Line x-4,y-6,x-2,y-3,1,green:Line x+46,y-36,x+50,y-38,1,green:Circle x+53,y-41,3,1,1,red,red:Text x+30,y-60,"T1"
Circle x+10,y-50,5,1,1,yellow,yellow
For agol=0 To 6.28 Step 1.06
Line x+10,y-50,x+10+10*Cos(agol),y-50+10*Sin(agol),1,yellow
Next
End Sub
Sub dsolarno(x,y)
Line x,y,x+50,y+30,1,red:Line x+50,y+30,x+52,y+27,1,red:Line x+52,y+27,x+2,y-3,1,red:Line x+2,y-3,x,y,1,red:Line x+51,y+29,x+1,y-1,1,red:Line x+52,y+27,x+54,y+25,1,green
Line x+54,y+25,x+4,y-5,1,green:Line x+4,y-5,x+2,y-3,1,green:Line x+1,y-1,x-3,y-4,1,green:Circle x-7,y-7,3,1,1,red,red:Text x,y-25,"T0"
End Sub
Sub bazent(x,y)
Box x,y,4,15,1,gray,gray:Box x,y+15,50,4,1,gray,gray:Box x+50,y,4,19,1,gray,gray:Box x+5,y+4,44,12,1,blue,blue:Line x+54,y+2,x+59,y+2,2,green:Circle x+62,y+2,3,1,1,red,red:Text x+51,y-16,"T6"
End Sub
Sub Vdesno(x,y)
For i=0 To 30 Step 2
BitMap x,y+(i/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+i/2,pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Vlevo(x,y)
For i=32 To 62 Step 2
BitMap x,y+((i-32)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-32)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Vgore(x,y)
For i=64 To 94 Step 2
BitMap x,y+((i-64)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-64)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Vdolu(x,y)
For i=96 To 126 Step 2
BitMap x,y+((i-96)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-96)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Pdesno(x,y)
For i=128 To 158 Step 2
BitMap x,y+((i-128)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-128)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Plevo(x,y)
For i=160 To 190 Step 2
BitMap x,y+((i-160)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-160)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Pgore(x,y)
For i=192 To 222 Step 2
BitMap x,y+((i-192)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-192)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub Pdolu(x,y)
For i=224 To 254 Step 2
BitMap x,y+((i-224)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-224)/2),pole(i+1),2,8,1,white,dblue
Next
End Sub
Sub kotel(x,y)
Box x,y,40,50,2,white,gray:Box x+8,y+20,23,25,2,black,white:Text x+19,y+8,"T8",cm,1,1,white,gray
For i=256 To 286 Step 2
BitMap x+12,y+26+((i-256)/2),pole(i),2,8,1,red,white:BitMap x+8+12,y+26+((i-256)/2),pole(i+1),2,8,1,red,white
Next
End Sub
Sub strelkadg(x,y)
For i=352 To 478 Step 4
BitMap x,y+((i-352)/4),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-352)/4),pole(i+1),2,8,1,white,dblue:BitMap x+16,y+((i-352)/4),pole(i+2),2,8,1,white,dblue:BitMap x+24,y+((i-352)/4),pole(i+3),2,8,1,white,dblue
Next
End Sub
Sub strelkalg(x,y)
For i=480 To 606 Step 4
BitMap x,y+((i-480)/4),pole(i),2,8,1,white,dblue:BitMap x+8,y+((i-480)/4),pole(i+1),2,8,1,white,dblue:BitMap x+16,y+((i-480)/4),pole(i+2),2,8,1,white,dblue:BitMap x+24,y+((i-480)/4),pole(i+3),2,8,1,white,dblue
Next
End Sub

Sub vhor(x,y)
For i=608 To 638 Step 2
BitMap x,y+((i-608)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+(i-608)/2,pole(i+1),2,8,1,white,dblue
Next
End Sub

Sub vver(x,y)
For i=640 To 670 Step 2
BitMap x,y+((i-640)/2),pole(i),2,8,1,white,dblue:BitMap x+8,y+(i-640)/2,pole(i+1),2,8,1,white,dblue
Next
End Sub
' subrutina bojler **********************
Sub bojler(x,y)
RBox x,y,40,80,8:RBox x+1,y+60,38,18,6,blue,blue:Box x+1,y+10,38,50,1,blue,blue:Line x+41,y+70,x+50,y+70,2,green:Circle x+53,y+70,3,1,1,red,red
Line x+41,y+20,x+50,y+20,2,green:Circle x+53,y+20,3,1,1,red,red:Line x-2,y+61,x+20,y+61,3,green:Line x+20,y+60,x+10,y+55,1,green:Line x+10,y+55,x+20,y+50,1,red
Line x+20,y+46,x-2,y+46,3,red:Line x-2,y+31,x+20,y+31,3,green:Line x+20,y+30,x+10,y+25,1,green:Line x+10,y+25,x+20,y+20,1,red:Line x+20,y+16,x-2,y+16,3,red
End Sub
Sub radijator (x,y)
Box x,y,30,15,2
For i=2 To 28 Step 5
Line x+2+i,y+4,x+2+i,y+15
Next
Text x+10,y-15,"T7"
End Sub
Sub buzer
Pin(13)=1:Pause 80:Pin(13)=0
End Sub
tastaturasub:
greska:
SetTick 0,0,2
max_taster=4:taster$="":n=0:RBox 0,0,319,239,1,white,dblue
For kolona=20 To 120 Step 50
For redica=20 To 120 Step 50
RBox redica,kolona,40,40,10:RBox redica+1,kolona+1,38,38,10,white,blue:n=n+1:broj$=Str$(n):Text redica+10,kolona+5,broj$,lt,1,2,white,blue
Next
Next
RBox 170,20,140,40:RBox 171,21,138,38:RBox 20,170,40,40:RBox 21,171,38,38,10,white,blue:Text 40,190,"0",cm,1,2,white,blue
RBox 70,170,90,40:RBox 71,171,88,38,10,white,blue:Text 115,190,"ENTER",cm,1,2,white,blue:n=1:tocno$=""
Do
WatchDog 2000
If Touch(x) <> -1 And Touch(y) <> -1 Then
gasiLed=0:pin(36)=0
If 221 < Touch(x) And Touch(x) < 309 And 172 < Touch(y) And Touch(y) < 208 Then
gasiLed=0:pin(36)=0
buzer: CLS:Exit Do
EndIf

If 20 < Touch(x) And Touch(x) < 60 And 20 < Touch(y) And Touch(y) < 60 Then
gasiLed=0:pin(36)=0
keypress = 1: buzer
Else If 70 < Touch(x) And Touch(x) < 110 And 20 < Touch(y) And Touch(y) < 60 Then
gasiLed=0:pin(36)=0
keypress = 2: buzer
Else If 120 < Touch(x) And Touch(x) < 160 And 20 < Touch(y) And Touch(y) <60 Then
gasiLed=0:pin(36)=0
keypress = 3: buzer
Else If 20 < Touch(x) And Touch(x) < 60 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
keypress = 4: buzer
Else If 70 < Touch(x) And Touch(x) < 110 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
keypress = 5: buzer
Else If 120 < Touch(x) And Touch(x) < 160 And 70 < Touch(y) And Touch(y) < 110 Then
gasiLed=0:pin(36)=0
keypress = 6: buzer
Else If 20 < Touch(x) And Touch(x) < 60 And 120 < Touch(y) And Touch(y) < 160 Then
gasiLed=0:pin(36)=0
keypress = 7: buzer
Else If 70< Touch(x) And Touch(x) < 110 And 120 < Touch(y) And Touch(y) < 160 Then
gasiLed=0:pin(36)=0
keypress = 8: buzer
Else If 120 < Touch(x) And Touch(x) < 160 And 120 < Touch(y) And Touch(y) < 160 Then
gasiLed=0:pin(36)=0
keypress = 9: buzer
Else If 20 < Touch(x) And Touch(x) < 60 And 170 < Touch(y) And Touch(y) < 210 Then
gasiLed=0:pin(36)=0
keypress = 0: buzer
Else If 70 < Touch(x) And Touch(x) < 160 And 170 < Touch(y) And Touch(y) < 210 Then
gasiLed=0:pin(36)=0
keypress = 10: buzer
Else
keypress = 99
EndIf

If keypress=10 Then
i=(keypressY*2+keypressx)+24
if (i=28 or i=30 or i=32) and val(taster$)>90 then
taster$="90"
elseif i=27 and val(taster$)>60 then
taster$="60"
elseif i=29 and val(taster$)>40 then
taster$="40"
'goto greska
endif

I2C write eeprom,0,3,i\256,i Mod 256,Val(taster$):Pause 4

endif
If keypress<10 And keypress<>99 And n<max_taster Then
taster$=taster$+Str$(keypress):n=n+1:Text 200,41,taster$,Lm,1,2,white,dblue:Pause 250
EndIf
EndIf
IZLEZ:
Loop Until keypress=10:SetTick 60000,saat,2:keypress=99:zavrsimax=1
Return
bojler_on: ' go isklucuva bojlerot ako e zagrean, a so prekinuvacot bil prethodno pusten
if prekinuvac=1 and (ss%(ntc3)>max(0,2)) then
if ekran=1 then
SW_off 220,40:LED_off 260,20
endif
PREKINUVAC=0:Pin(32)=0:k(11)=0: I2C write eeprom,0,3,0,144,prekinuvac
endif
return
vreme_analiza:
saatot=Val(Left$(Time$,2)):minutata=Val(Mid$(Time$,4,2)):denot=Val(Left$(Date$,2)):mesecot=Val(Mid$(Date$,4,2)):godinata =Val(Right$(Date$,4))
Return
gasi:
If Touch(x) <> -1 And Touch(y) <> -1 Then
gasiLed=0
endif
gasiLed=gasiLed+1
if gasiLed=10 then
pin(36)=1
endif
ireturn
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1671
Posted: 02:19pm 12 Nov 2017
Copy link to clipboard 
Print this post

Hi ztoti,

thanks for the source code! Is there a reason for the double post? (edit: Maybe an admin can/should correct this)
Anyhow, it is good to have it here. Members can learn how much work it is.
As far as I could see you've used the EEPROM as replacement for DATA/(READ) statements, not for executible code. Correct?

How did you transfer die HEX-Data to the EEPROM? IN the regular way over I2C and a small For/Next-loop?

Thanks again, I think far too few members publish example codes here.

Michael
Edited by twofingers 2017-11-14
causality ≠ correlation ≠ coincidence
 
ztoti
Regular Member

Joined: 27/10/2011
Location: Canada
Posts: 65
Posted: 03:11pm 12 Nov 2017
Copy link to clipboard 
Print this post

Sorry for the double post. I just added a link to the Dropbox and that was like second post. Sorry again.
Programming EEPROM I do with PicKit 2 (or any I2C programmer).
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025