Temperature is calcualted, only once
This commit is contained in:
		
							
								
								
									
										13
									
								
								main.lua
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								main.lua
									
									
									
									
									
								
							@@ -38,20 +38,15 @@ function displayTime()
 | 
				
			|||||||
     collectgarbage()
 | 
					     collectgarbage()
 | 
				
			||||||
     mydofile("wordclock")
 | 
					     mydofile("wordclock")
 | 
				
			||||||
     if (wc ~= nil) then
 | 
					     if (wc ~= nil) then
 | 
				
			||||||
     words = wc.timestat(time.hour, time.minute)
 | 
					       words = wc.timestat(time.hour, time.minute)
 | 
				
			||||||
     if ((dim ~= nil) and (dim == "on")) then
 | 
					       if ((dim ~= nil) and (dim == "on")) then
 | 
				
			||||||
        words.briPer=briPer
 | 
					        words.briPer=briPer
 | 
				
			||||||
        if (words.briPer ~= nil and words.briPer < 3) then
 | 
					        if (words.briPer ~= nil and words.briPer < 3) then
 | 
				
			||||||
          words.briPer=3
 | 
					          words.briPer=3
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
     else
 | 
					       else
 | 
				
			||||||
        words.briPer=nil
 | 
					        words.briPer=nil
 | 
				
			||||||
     end
 | 
					       end
 | 
				
			||||||
     end
 | 
					 | 
				
			||||||
     local tw=nil
 | 
					 | 
				
			||||||
     local tcol=nil
 | 
					 | 
				
			||||||
     if (mqttDispTemp ~= nil) then
 | 
					 | 
				
			||||||
	tw, tcol  = wc.temp(dw, rgbBuffer, invertRows)
 | 
					 | 
				
			||||||
     end
 | 
					     end
 | 
				
			||||||
     wc = nil
 | 
					     wc = nil
 | 
				
			||||||
     collectgarbage()
 | 
					     collectgarbage()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								mqtt.lua
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								mqtt.lua
									
									
									
									
									
								
							@@ -3,7 +3,8 @@ local m=nil
 | 
				
			|||||||
local mqttConnected = false
 | 
					local mqttConnected = false
 | 
				
			||||||
-- Temp:
 | 
					-- Temp:
 | 
				
			||||||
local t=nil
 | 
					local t=nil
 | 
				
			||||||
dispTemp=nil
 | 
					local tw=nil
 | 
				
			||||||
 | 
					local tcol=nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function handleSingleCommand(client, topic, data)
 | 
					function handleSingleCommand(client, topic, data)
 | 
				
			||||||
    if (data == "ON") then
 | 
					    if (data == "ON") then
 | 
				
			||||||
@@ -118,9 +119,20 @@ function registerMqtt()
 | 
				
			|||||||
            handleSingleCommand(client, topic, data)
 | 
					            handleSingleCommand(client, topic, data)
 | 
				
			||||||
	elseif (topic == (mqttPrefix .. "/cmd/temp")) then
 | 
						elseif (topic == (mqttPrefix .. "/cmd/temp")) then
 | 
				
			||||||
	    if ( data == "" ) then
 | 
						    if ( data == "" ) then
 | 
				
			||||||
		    dispTemp = nil
 | 
							    tw=nil
 | 
				
			||||||
 | 
							    tcol=nil
 | 
				
			||||||
	    else
 | 
						    else
 | 
				
			||||||
		    dispTemp = tonumber(data)
 | 
							    -- generate the temperatur to display, once as it will not change
 | 
				
			||||||
 | 
							    local dispTemp = tonumber(data)
 | 
				
			||||||
 | 
							    collectgarbage()
 | 
				
			||||||
 | 
							    mydofile("wordclock")
 | 
				
			||||||
 | 
							    if (wc ~= nil) then
 | 
				
			||||||
 | 
								tw, tcol  = wc.temp(dw, rgbBuffer, invertRows)
 | 
				
			||||||
 | 
								wc = nil
 | 
				
			||||||
 | 
							    else
 | 
				
			||||||
 | 
								print("MQTT | wordclock failed")
 | 
				
			||||||
 | 
							    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    end
 | 
						    end
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            -- Handle here the /cmd/# sublevel
 | 
					            -- Handle here the /cmd/# sublevel
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user