Mainloop is stopped on upload
This commit is contained in:
		
							
								
								
									
										8
									
								
								main.lua
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								main.lua
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
-- Main Module
 | 
					-- Main Module
 | 
				
			||||||
local looptimer = tmr.create()
 | 
					mlt = tmr.create() -- Main loop timer
 | 
				
			||||||
rowbgColor= {}
 | 
					rowbgColor= {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function syncTimeFromInternet()
 | 
					function syncTimeFromInternet()
 | 
				
			||||||
@@ -87,7 +87,7 @@ function normalOperation()
 | 
				
			|||||||
    -- Define the main loop
 | 
					    -- Define the main loop
 | 
				
			||||||
    local setupCounter=5
 | 
					    local setupCounter=5
 | 
				
			||||||
    local alive=0
 | 
					    local alive=0
 | 
				
			||||||
    looptimer:register(2500, tmr.ALARM_AUTO, function (lt)
 | 
					    mlt:register(2500, tmr.ALARM_AUTO, function (lt)
 | 
				
			||||||
      if (setupCounter > 4) then
 | 
					      if (setupCounter > 4) then
 | 
				
			||||||
        syncTimeFromInternet()
 | 
					        syncTimeFromInternet()
 | 
				
			||||||
        setupCounter=setupCounter-1
 | 
					        setupCounter=setupCounter-1
 | 
				
			||||||
@@ -167,7 +167,7 @@ function normalOperation()
 | 
				
			|||||||
        wifitimer=nil
 | 
					        wifitimer=nil
 | 
				
			||||||
        connect_counter=nil
 | 
					        connect_counter=nil
 | 
				
			||||||
        print('IP: ',wifi.sta.getip(), " heap: ", node.heap())
 | 
					        print('IP: ',wifi.sta.getip(), " heap: ", node.heap())
 | 
				
			||||||
        looptimer:start()
 | 
					        mlt:start()
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end)
 | 
					    end)
 | 
				
			||||||
    wifitimer:start()
 | 
					    wifitimer:start()
 | 
				
			||||||
@@ -185,7 +185,7 @@ local btnCounter=0
 | 
				
			|||||||
local btntimer = tmr.create()
 | 
					local btntimer = tmr.create()
 | 
				
			||||||
btntimer:register(5000, tmr.ALARM_AUTO, function (t)
 | 
					btntimer:register(5000, tmr.ALARM_AUTO, function (t)
 | 
				
			||||||
     if (gpio.read(3) == 0) then
 | 
					     if (gpio.read(3) == 0) then
 | 
				
			||||||
	looptimer:unregister()
 | 
						mlt:unregister()
 | 
				
			||||||
        print("Button pressed " .. tostring(btnCounter))
 | 
					        print("Button pressed " .. tostring(btnCounter))
 | 
				
			||||||
        btnCounter = btnCounter + 5
 | 
					        btnCounter = btnCounter + 5
 | 
				
			||||||
        local ledBuf= string.char(128,0,0):rep(btnCounter) .. string.char(0,0,0):rep(110 - btnCounter)
 | 
					        local ledBuf= string.char(128,0,0):rep(btnCounter) .. string.char(0,0,0):rep(110 - btnCounter)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								mqtt.lua
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								mqtt.lua
									
									
									
									
									
								
							@@ -95,8 +95,10 @@ function registerMqtt()
 | 
				
			|||||||
                m=nil
 | 
					                m=nil
 | 
				
			||||||
                t=nil
 | 
					                t=nil
 | 
				
			||||||
                mqttConnected = false
 | 
					                mqttConnected = false
 | 
				
			||||||
		if (looptimer ~= nil) then
 | 
							if (mlt ~= nil) then
 | 
				
			||||||
			looptimer:unregister()
 | 
						          mlt:unregister()
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
						          print("main loop unstoppable")
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
                collectgarbage()
 | 
					                collectgarbage()
 | 
				
			||||||
                mydofile("telnet")
 | 
					                mydofile("telnet")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user