################################################################################# # Web UI for Leds animation # ################################################################################# var leds_animation = module('leds_animation') ################################################################################# # Leds_animation_UI # # WebUI for the Leds animation ################################################################################# class Leds_animation_UI def init() tasmota.add_driver(self) end # create a method for adding a button to the main menu # the button 'Leds animation' redirects to '/leds_anim?' def web_add_button() import webserver webserver.content_send( "

") end ####################################################################### # Show background colors ####################################################################### def show_background_color() import webserver var back_color = 0xFF8800 var back_anim_time = 5.0 webserver.content_send("
 Background  " "
") # webserver.content_send(f"") # webserver.content_send("
") webserver.content_send("") webserver.content_send(f"") webserver.content_send("

") webserver.content_send("") webserver.content_send("") webserver.content_send(f"" "" "" "") webserver.content_send("" "" "" "") webserver.content_send("" "" "" "") webserver.content_send("" "" "" "") webserver.content_send("
Static
Palette1
Palette1
Palette1
") webserver.content_send("

" "

") end ####################################################################### # Show main config ####################################################################### def show_main_config() import webserver var leds_anim_enabled = true var leds_size = 25 webserver.content_send("
 Leds configuration  " "

Check the Leds animation documentation.

" "
") # checkbox for Matter enable var leds_anim_enabled_checked = leds_anim_enabled ? 'checked' : '' webserver.content_send(f"

") webserver.content_send("

") webserver.content_send("") webserver.content_send(f"") webserver.content_send("

" "

") end ####################################################################### # Display the complete page ####################################################################### def page_view() import webserver if !webserver.check_privileged_access() return nil end webserver.content_start("Leds animation") #- title of the web page -# webserver.content_send_style() #- send standard Tasmota styles -# self.show_main_config() self.show_background_color() webserver.content_button(webserver.BUTTON_MANAGEMENT) #- button back to management page -# webserver.content_stop() #- end of web page -# end #- ---------------------------------------------------------------------- -# # respond to web_add_handler() event to register web listeners #- ---------------------------------------------------------------------- -# #- this is called at Tasmota start-up, as soon as Wifi/Eth is up and web server running -# def web_add_handler() import webserver #- we need to register a closure, not just a function, that captures the current instance -# webserver.on("/leds_anim", / -> self.page_view(), webserver.HTTP_GET) webserver.on("/leds_anim", / -> self.page_ctl(), webserver.HTTP_POST) end end leds_animation.Leds_animation_UI = Leds_animation_UI #- create and register driver in Tasmota -# if tasmota var ui = leds_animation.Leds_animation_UI() ## can be removed if put in 'autoexec.bat' ui.web_add_handler() end return leds_animation #- Example import leds_animation -#