tweaked timings
This commit is contained in:
		
							
								
								
									
										6
									
								
								main.lua
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.lua
									
									
									
									
									
								
							@@ -10,7 +10,6 @@ function syncTimeFromInternet()
 | 
				
			|||||||
    sntp.sync(sntpserverhostname,
 | 
					    sntp.sync(sntpserverhostname,
 | 
				
			||||||
     function(sec,usec,server)
 | 
					     function(sec,usec,server)
 | 
				
			||||||
      print('sync', sec, usec, server)
 | 
					      print('sync', sec, usec, server)
 | 
				
			||||||
      displayTime()
 | 
					 | 
				
			||||||
      syncRunning=nil
 | 
					      syncRunning=nil
 | 
				
			||||||
     end,
 | 
					     end,
 | 
				
			||||||
     function()
 | 
					     function()
 | 
				
			||||||
@@ -23,6 +22,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
briPercent = 50
 | 
					briPercent = 50
 | 
				
			||||||
function displayTime()
 | 
					function displayTime()
 | 
				
			||||||
 | 
					    collectgarbage()
 | 
				
			||||||
     local sec, usec = rtctime.get()
 | 
					     local sec, usec = rtctime.get()
 | 
				
			||||||
     -- Handle lazy programmer:
 | 
					     -- Handle lazy programmer:
 | 
				
			||||||
     if (timezoneoffset == nil) then
 | 
					     if (timezoneoffset == nil) then
 | 
				
			||||||
@@ -135,7 +135,7 @@ function normalOperation()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        local setupCounter=5
 | 
					        local setupCounter=5
 | 
				
			||||||
	local alive=0
 | 
						local alive=0
 | 
				
			||||||
	looptimer:register(1000, tmr.ALARM_AUTO, function (lt)
 | 
						looptimer:register(2500, tmr.ALARM_AUTO, function (lt)
 | 
				
			||||||
            if (setupCounter > 4) then
 | 
					            if (setupCounter > 4) then
 | 
				
			||||||
                syncTimeFromInternet()
 | 
					                syncTimeFromInternet()
 | 
				
			||||||
                setupCounter=setupCounter-1
 | 
					                setupCounter=setupCounter-1
 | 
				
			||||||
@@ -155,7 +155,7 @@ function normalOperation()
 | 
				
			|||||||
                    displayTime()
 | 
					                    displayTime()
 | 
				
			||||||
                end
 | 
					                end
 | 
				
			||||||
                setupCounter=setupCounter-1
 | 
					                setupCounter=setupCounter-1
 | 
				
			||||||
	        elseif ( (alive % 300) == 0) then
 | 
						        elseif ( (alive % 120) == 0) then
 | 
				
			||||||
        	    -- sync the time every 5 minutes
 | 
					        	    -- sync the time every 5 minutes
 | 
				
			||||||
            	syncTimeFromInternet()
 | 
					            	syncTimeFromInternet()
 | 
				
			||||||
		        alive = alive + 1
 | 
							        alive = alive + 1
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								mqtt.lua
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								mqtt.lua
									
									
									
									
									
								
							@@ -158,7 +158,6 @@ function startMqttClient()
 | 
				
			|||||||
                local temp = nil
 | 
					                local temp = nil
 | 
				
			||||||
                if (t ~= nil) then
 | 
					                if (t ~= nil) then
 | 
				
			||||||
                    temp=readTemp()
 | 
					                    temp=readTemp()
 | 
				
			||||||
                    print(tostring(temp) .. "°C")
 | 
					 | 
				
			||||||
                end
 | 
					                end
 | 
				
			||||||
                if (oldBrightness ~= briPercent) then
 | 
					                if (oldBrightness ~= briPercent) then
 | 
				
			||||||
                 m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
 | 
					                 m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user