Further optimisation in webserver
This commit is contained in:
		
							
								
								
									
										9
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								init.lua
									
									
									
									
									
								
							| @@ -6,7 +6,7 @@ MAXLEDS=110 | ||||
| counter1=0 | ||||
| ws2812.write(string.char(0,0,0):rep(114)) | ||||
| local bootledtimer = tmr.create() | ||||
| bootledtimer:register(5000, tmr.ALARM_AUTO, function (t) | ||||
| bootledtimer:register(500, tmr.ALARM_AUTO, function (t) | ||||
|     counter1=counter1+1 | ||||
|     spaceLeds = math.max(MAXLEDS - (counter1*2), 0) | ||||
|     ws2812.write(string.char(128,0,0):rep(counter1) .. string.char(0,0,0):rep(spaceLeds) .. string.char(0,0,64):rep(counter1)) | ||||
| @@ -50,6 +50,8 @@ end | ||||
| initTimer = tmr.create() | ||||
| initTimer:register(5000, tmr.ALARM_SINGLE, function (t) | ||||
|     bootledtimer:unregister() | ||||
|     t:unregister() | ||||
|     collectgarbage() | ||||
|     if ( | ||||
|         (file.open("main.lua")) or  | ||||
|         (file.open("timecore.lua")) or  | ||||
| @@ -66,7 +68,7 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t) | ||||
|         print("Rebooting ...") | ||||
|         -- reboot repairs everything | ||||
|         node.restart() | ||||
|     elseif (file.open("main.lc")) then | ||||
|     else | ||||
|         if ( file.open("config.lua") ) then | ||||
|             --- Normal operation | ||||
|             print("Starting main")       | ||||
| @@ -79,9 +81,6 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t) | ||||
|             -- Logic for inital setup | ||||
|             startSetupMode() | ||||
|         end | ||||
|     else | ||||
|         print("No Main file found") | ||||
|     end | ||||
|     t:unregister() | ||||
| end) | ||||
| initTimer:start() | ||||
|   | ||||
| @@ -74,35 +74,16 @@ end | ||||
| function fillDynamicMap()     | ||||
|     replaceMap = {} | ||||
|     ssid, _ = wifi.sta.getconfig() | ||||
|  | ||||
|     if (ssid == nil) then | ||||
|         ssid="Not set" | ||||
|     end | ||||
|     if (sntpserverhostname == nil) then | ||||
|         sntpserverhostname="ptbtime1.ptb.de" | ||||
|     end | ||||
|     if (timezoneoffset == nil) then | ||||
|         timezoneoffset=1 | ||||
|     end | ||||
|     if (ssid == nil) then return replaceMap end | ||||
|     if (sntpserverhostname == nil) then sntpserverhostname="ptbtime1.ptb.de" end | ||||
|     if (timezoneoffset == nil) then timezoneoffset=1 end | ||||
|     -- Set the default color, if nothing is set | ||||
|     if (color == nil) then | ||||
|         color=string.char(0,0,250) | ||||
|     end | ||||
|     if (color1 == nil) then | ||||
|         color1=color | ||||
|     end | ||||
|     if (color2 == nil) then | ||||
|         color2=color | ||||
|     end | ||||
|     if (color3 == nil) then | ||||
|         color3=color | ||||
|     end | ||||
|     if (color4 == nil) then | ||||
|         color4=color | ||||
|     end | ||||
|     if (colorBg == nil) then | ||||
|         colorBg=string.char(0,0,0) -- black is the default background color | ||||
|     end | ||||
|     if (color == nil) then color=string.char(0,0,250) end | ||||
|     if (color1 == nil) then color1=color end | ||||
|     if (color2 == nil) then color2=color end | ||||
|     if (color3 == nil) then color3=color end | ||||
|     if (color4 == nil) then color4=color end | ||||
|     if (colorBg == nil) then colorBg=string.char(0,0,0) end | ||||
|     local hexColor = "#" .. string.format("%02x",string.byte(color,2)) .. string.format("%02x",string.byte(color,1)) .. string.format("%02x",string.byte(color,3)) | ||||
|     local hexColor1 = "#" .. string.format("%02x",string.byte(color1,2)) .. string.format("%02x",string.byte(color1,1)) .. string.format("%02x",string.byte(color1,3)) | ||||
|     local hexColor2 = "#" .. string.format("%02x",string.byte(color2,2)) .. string.format("%02x",string.byte(color2,1)) .. string.format("%02x",string.byte(color2,3)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user