Add files via upload
This commit is contained in:
@@ -21,7 +21,7 @@ except:
|
||||
print('Napaka OLED!')
|
||||
if dane('Resetiram(d/n)->'):
|
||||
machine.reset()
|
||||
|
||||
|
||||
|
||||
oled.text('OLED deluje!',0,0)
|
||||
oled.show()
|
||||
@@ -73,8 +73,7 @@ oled.show()
|
||||
statusled.value(1)
|
||||
alertled.value(0)
|
||||
|
||||
def konec(p):
|
||||
exit=1
|
||||
|
||||
|
||||
sleeptime=15
|
||||
count=0
|
||||
@@ -82,6 +81,20 @@ vlaga=0
|
||||
temp=0
|
||||
svetloba=0
|
||||
ms=sleeptime*1000
|
||||
exitf=0
|
||||
|
||||
|
||||
def exit():
|
||||
oled.fill(0)
|
||||
oled.text('<-------------->', 0, 15)
|
||||
oled.text('<NodeMCU Senzor>', 0, 25)
|
||||
oled.text('<-------------->', 0, 35)
|
||||
oled.text(' !Nasvidenje! ', 0, 50)
|
||||
oled.show()
|
||||
time.sleep(1.5)
|
||||
oled.fill(0)
|
||||
oled.show()
|
||||
oled.poweroff()
|
||||
|
||||
def updatescreen():
|
||||
global vlaga, temp, svetloba, sleeptime
|
||||
@@ -97,28 +110,29 @@ active=0
|
||||
|
||||
def carefulsleep():
|
||||
startticks=time.ticks_ms()
|
||||
global ms, active, lasttick, firsttick, exit
|
||||
while time.ticks_diff(time.ticks_ms(), startticks)<ms:
|
||||
global ms, active, lasttick, firsttick, exitf
|
||||
while time.ticks_diff(time.ticks_ms(), startticks) < ms:
|
||||
updatescreen()
|
||||
if not tipka.value():
|
||||
if firsttick==0:
|
||||
active=1
|
||||
firsttick=time.ticks_ms()
|
||||
lasttick=time.ticks_ms()
|
||||
if time.ticks_diff(lasttick, firsttick)>3000 and active==1:
|
||||
print('ttt')
|
||||
exit=3
|
||||
if time.ticks_diff(lasttick, firsttick) > 3000 and active==1:
|
||||
#print('ttt')
|
||||
exitf=3
|
||||
active=0
|
||||
if time.ticks_diff(time.ticks_ms(), lasttick)>60 and active==1:
|
||||
print("BING!")
|
||||
exit()
|
||||
if time.ticks_diff(time.ticks_ms(), lasttick) > 60 and active==1:
|
||||
#print("BING!")
|
||||
lasttick=0
|
||||
firsttick=0
|
||||
active=0
|
||||
setsleep(0)
|
||||
print(lasttick, firsttick,time.ticks_diff(lasttick, firsttick))
|
||||
|
||||
setsleep()
|
||||
#print(lasttick, firsttick,time.ticks_diff(lasttick, firsttick))
|
||||
|
||||
def setsleep(x):
|
||||
|
||||
def setsleep():
|
||||
global ms
|
||||
sleeptime=ms/1000
|
||||
if sleeptime==15:
|
||||
@@ -137,12 +151,9 @@ def setsleep(x):
|
||||
ms=sleeptime*1000
|
||||
#print('set to', sleeptime)
|
||||
updatescreen()
|
||||
|
||||
|
||||
#tipka.irq(trigger=Pin.IRQ_FALLING, handler=setsleep)
|
||||
|
||||
exit=0
|
||||
temp=0
|
||||
svetloba=0
|
||||
def acq():
|
||||
oled.text('BUSY...',70,55)
|
||||
alertled.value(1)
|
||||
@@ -159,7 +170,7 @@ def acq():
|
||||
except:
|
||||
print('Napaka v branju svetlobe!')
|
||||
svetloba='NAPAKA'
|
||||
|
||||
|
||||
try:
|
||||
vlaga=ne.main()
|
||||
except:
|
||||
@@ -169,18 +180,7 @@ def acq():
|
||||
lasttick=0
|
||||
firsttick=0
|
||||
|
||||
while exit<1:
|
||||
while exitf<1:
|
||||
acq()
|
||||
updatescreen()
|
||||
carefulsleep()
|
||||
|
||||
oled.fill(0)
|
||||
oled.text('<-------------->', 0, 15)
|
||||
oled.text('<NodeMCU Senzor>', 0, 25)
|
||||
oled.text('<-------------->', 0, 35)
|
||||
oled.text(' !Nasvidenje! ', 0, 50)
|
||||
time.sleep(1.5)
|
||||
oled.show()
|
||||
oled.fill(0)
|
||||
oled.show()
|
||||
oled.poweroff()
|
||||
Reference in New Issue
Block a user