From de7a8dd4bab867b6959c808cff47e0da16df4f18 Mon Sep 17 00:00:00 2001 From: destroyedlolo Date: Fri, 7 Aug 2020 23:32:08 +0200 Subject: [PATCH 1/4] Handle more than one card --- SeleniteDRMCairo/HDB.sel | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SeleniteDRMCairo/HDB.sel b/SeleniteDRMCairo/HDB.sel index 08392a6..14b2ada 100644 --- a/SeleniteDRMCairo/HDB.sel +++ b/SeleniteDRMCairo/HDB.sel @@ -15,6 +15,8 @@ end -- initialise graphical environment Selene.UseDRMCairo() +require (SELENE_SCRIPT_DIR .. "/LocalConfig") -- Local configuration + -- Open default card. -- As no argument is passed it's the default one -- /dev/dri/card0 @@ -22,7 +24,16 @@ card,err = SelDCCard.Open() if not card then print("*E* DRM :", err,msg) if SELPLUG_DRMCairo_FBEXTENSION then - card,err,msg = SelDCCard.OpenFB("/dev/fb1") + -- On my test env, I have 2 screen and DRM/KMS doesn't work + -- passing an argument allow to test on one or the other card + -- (default : external fb1) + local dev = "fb1" + if arg then + dev = arg[1] + MQTT_ClientID = MQTT_ClientID..dev + end + print("*C* using card", dev) + card,err,msg = SelDCCard.OpenFB("/dev/"..dev) if not card then print("*E* FB :", err,msg) os.exit() @@ -35,7 +46,6 @@ if not card then end -require (SELENE_SCRIPT_DIR .. "/LocalConfig") -- Local configuration require "Toile" Topics = {} -- Topics we are looking for From 62fea711679feaba7af6d818e7df762bd76caafc Mon Sep 17 00:00:00 2001 From: destroyedlolo Date: Sat, 8 Aug 2020 01:47:32 +0200 Subject: [PATCH 2/4] Bottom bar --- SeleniteDRMCairo/HDB.sel | 2 + SeleniteDRMCairo/HDB_320/10_Font.lua | 21 ++++++++++ SeleniteDRMCairo/HDB_320/20_Geometry.lua | 12 ++++++ SeleniteDRMCairo/HDB_320/40_BottomBar.lua | 48 +++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 SeleniteDRMCairo/HDB_320/10_Font.lua create mode 100644 SeleniteDRMCairo/HDB_320/20_Geometry.lua create mode 100644 SeleniteDRMCairo/HDB_320/40_BottomBar.lua diff --git a/SeleniteDRMCairo/HDB.sel b/SeleniteDRMCairo/HDB.sel index 14b2ada..65dd50a 100644 --- a/SeleniteDRMCairo/HDB.sel +++ b/SeleniteDRMCairo/HDB.sel @@ -155,8 +155,10 @@ if err then return end +--[[ -- Ensure first window is visible winlist[ 1 ].Visibility(true) +]] -- Display versions Notification.Log( "Séléné : ".. string.format("%.4f", SELENE_VERSION) ) diff --git a/SeleniteDRMCairo/HDB_320/10_Font.lua b/SeleniteDRMCairo/HDB_320/10_Font.lua new file mode 100644 index 0000000..7a240b6 --- /dev/null +++ b/SeleniteDRMCairo/HDB_320/10_Font.lua @@ -0,0 +1,21 @@ +-- Font to use +-- format { "facename", size } + +local finternal = SelDCFont.createInternal("") +local fontTT,err,msg = SelDCFont.createFreeType("/usr/share/fonts/liberation-fonts/LiberationSerif-BoldItalic.ttf") +if not fontTT then + print("*E*", err,msg) + os.exit() +end + +fonts={ + title = { font=finternal, size=20 }, + title1 = { font=fontTT, size=13 }, + digit = { font=finternal, size=17 }, + mdigit = { font=finternal, size=13 }, + sdigit = { font=finternal, size=10 }, + xstxt = { font=finternal, size=7 }, + stxt = { font=finternal, size=8 }, + mtxt = { font=finternal, size=10 }, + menu = { font=finternal, size=15 } +} diff --git a/SeleniteDRMCairo/HDB_320/20_Geometry.lua b/SeleniteDRMCairo/HDB_320/20_Geometry.lua new file mode 100644 index 0000000..55d8504 --- /dev/null +++ b/SeleniteDRMCairo/HDB_320/20_Geometry.lua @@ -0,0 +1,12 @@ +-- Global geometry of the display + +LBw = 100 -- Left bar width +HSGRPH = 20 -- Height of small graphs +NotLine = 4 -- Nbre of lines in notification area +BBh = fonts.xstxt.size * NotLine + 1 -- BottomBar's hight + +-- All sub windows geometry + +WINTOP = { x = LBw + 1, y = 0 } +WINSIZE = { w = psrf:GetWidth() - WINTOP.x, h = psrf:GetHight() - BBh } + diff --git a/SeleniteDRMCairo/HDB_320/40_BottomBar.lua b/SeleniteDRMCairo/HDB_320/40_BottomBar.lua new file mode 100644 index 0000000..739a654 --- /dev/null +++ b/SeleniteDRMCairo/HDB_320/40_BottomBar.lua @@ -0,0 +1,48 @@ +local function f() + local self = Surface( psrf, LBw, psrf:GetHight()-BBh, psrf:GetWidth() - LBw, BBh ) + local sw, sh = self.get():GetSize() + local srf = self.get() + local offx=0,offy + + function self.Clear() + -- notez-bien : full redrawing is not needed (yet ?) as this + -- bar is ALWAYS displayed + self.get():Clear(COL_BLACK.get() ) + self.setColor( COL_BORDER ) + srf:DrawLine( 0,0 , sw,0 ) + end + self.Clear() -- clean the surface before displaying + + local lvdonotif = ImageFiltreSurface( self, offx, 1, SELENE_SCRIPT_DIR .. "/Images/Mail.png" ) + condition_lvdo = Condition( lvdonotif, 0 ) + offx = offx + 24 + local poolnotif = ImageFiltreSurface( self, offx, 1, SELENE_SCRIPT_DIR .. "/Images/Piscine.png" ) + condition_pool = Condition( poolnotif, 0, { + ok_color = COL_DARKGREEN, + issue_color = COL_DARKRED + } ) + offx = offx + 24 + + local network = ImageFiltreSurface( self, offx,1, SELENE_SCRIPT_DIR .. "/Images/Network.png" ) + condition_network = Condition( network, .25, { issue_color=COL_RED } ) + table.insert( additionnalevents, condition_network.getTimer() ) + offx = offx + 24 + + local barriere = ImageFiltreSurface( self, offx,1, SELENE_SCRIPT_DIR .. "/Images/BarrierePoule.png" ) + condition_BarrierePoule = Condition( barriere, 0, {issue_color=COL_RED } ) + offx = offx + 24 + + Notification = NotificationArea( self, offx, 1, 125, sh, fonts.xstxt, COL_DARKGREEN, { bgcolor=COL_GFXBG } ) + local log = MQTTLog('messages', 'messages', Notification, { udata=-1 } ) + log.RegisterTopic('messages', 'messages/Erreur', { udata=3 } ) + offx = offx + 125 + + Saison( self, 'Saison', MAJORDOME ..'/Saison', offx, 1 ) + + -- Drawing finished and alway visible + self.Visibility(true) + + return self +end + +BottomBar = f() From 3b97e28318b9e81b5d29e57ad3a11f095d0f5285 Mon Sep 17 00:00:00 2001 From: destroyedlolo Date: Sat, 8 Aug 2020 02:11:35 +0200 Subject: [PATCH 3/4] Leftbar on WIP --- SeleniteDRMCairo/HDB_320/50_LeftBar.lua | 251 ++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 SeleniteDRMCairo/HDB_320/50_LeftBar.lua diff --git a/SeleniteDRMCairo/HDB_320/50_LeftBar.lua b/SeleniteDRMCairo/HDB_320/50_LeftBar.lua new file mode 100644 index 0000000..1fb0e8f --- /dev/null +++ b/SeleniteDRMCairo/HDB_320/50_LeftBar.lua @@ -0,0 +1,251 @@ +local function f() + local self = Surface( psrf, 0,0,LBw, psrf:GetHight() ) + + -- build graphics + + local w = self.get():GetWidth()-1 + local srf = self.get() + self.setColor( COL_BORDER ) + srf:DrawLine( w, 0, w, srf:GetHight() ) + + local offy = 0 + self.setColor( COL_TITLE ) + self.setFont( fonts.title1 ) + srf:DrawStringTop("Tension EDF :", 5, offy ) + offy = offy + self.get():GetFontExtents() + + local srf_tension = FieldBlink( self, animTimer, 10, offy, fonts.mdigit, COL_DIGIT, { + timeout = 30, + ndecimal=0, + align = ALIGN_RIGHT, + width = LBw - 20, + suffix = " V" + }) + offy = offy + srf_tension.getHight() + + local tension = MQTTDisplay( 'tension', 'onduleur/input.voltage', srf_tension, { condition=condition_network } ) + + ---- + + srf:DrawStringTop("Consommation :", 5, offy ) + offy = offy + self.get():GetFontExtents() + + local grd_conso = Gradient( { + [500] = COL_DIGIT, + [1500] = COL_ORANGE, + [4500] = COL_RED + }) + + local srf_consommation = Field( self, 10,offy, fonts.digit, COL_DIGIT, { + timeout = 10, + suffix = ' VA', + align = ALIGN_RIGHT, + width = LBw - 20, + gradient = grd_conso + } ) + offy = offy + srf_consommation.getHight() + + local srf_trndconso = GfxArea( self, 0, offy, w-5, HSGRPH, COL_ORANGE, COL_GFXBG,{ + heverylines={ {1000, COL_DARKGREY} }, + align=ALIGN_RIGHT, + gradient = grd_conso + } ) + + local srf_maxconso = FieldBlink( self, animTimer, 0, offy, fonts.sdigit, COL_DIGIT, { + align = ALIGN_RIGHT, + sample_text = "12345", + bgcolor = COL_TRANSPARENT, + ownsurface = true, + gradient = grd_conso + } ) + + local consommation = MQTTStoreGfx( 'consommation', 'TeleInfo/Consommation/values/PAPP', srf_consommation, srf_trndconso, + { + smax = srf_maxconso, + force_max_refresh = true, + forced_min = 0, + condition=condition_network + } + ) + offy = offy + HSGRPH + + ------- + + srf:DrawStringTop("Production :", 5, offy ) + offy = offy + self.get():GetFontExtents() + + local grd_prod = Gradient( { + [200] = COL_BLUE, + [750] = COL_YELLOW, + [1200] = COL_GREEN + } ) + + local srf_production = Field( self, 10,offy, fonts.digit, COL_DIGIT, { + timeout = 10, + align = ALIGN_RIGHT, + suffix = ' VA', + width = LBw - 20, + gradient = grd_prod + } ) + offy = offy + srf_production.getHight() + + local srf_trndprod = GfxArea( self, 0, offy, w-5, HSGRPH, COL_ORANGE, COL_GFXBG,{ + heverylines={ {500, COL_DARKGREY} }, + align = ALIGN_RIGHT, + gradient = grd_prod + } ) + + local srf_maxprod = FieldBlink( self, animTimer, 0, offy, fonts.sdigit, COL_DIGIT, { + align = ALIGN_RIGHT, + sample_text = "12345", + bgcolor = COL_TRANSPARENT, + ownsurface = true, + gradient = grd_prod + } ) + + local production = MQTTStoreGfx( 'production', 'TeleInfo/Production/values/PAPP', srf_production, srf_trndprod, + { + smax = srf_maxprod, + force_max_refresh = true, + forced_min = 0, + condition=condition_network + } + ) + + offy = offy + HSGRPH + + ------------ + +--[[ + local srf_onduleur = FieldBlink( self, animTimer, 0, offy, fonts.sdigit, COL_DIGIT, { + timeout = 30, + align = ALIGN_RIGHT, + sample_text = "888.8 W", + suffix = ' W' + } ) + + offx = srf_onduleur.getAfter() + + local srf_gaugeOnduleur = HGauge( self, offx+2, offy+4, w-offx-4, srf_onduleur.get():GetHight()-6, COL_WHITE, COL_GFXBG, COL_BORDER ) + + local onduleur = UPSdata('UPS', 'onduleur/ups.load', 'onduleur/ups.realpower.nominal', srf_onduleur, srf_gaugeOnduleur, { condition=condition_network }) + + offy = offy + srf_onduleur.get():GetHight() + + ------------ + + self.setFont( fonts.title1 ) + srf:DrawStringTop("Salon :", 35, offy ) + + local img,err = SelDCSurfaceImage.createFromPNG(SELENE_SCRIPT_DIR .. "/Images/Thermometre.png") + if not img then + print("*E*",err) + os.exit(EXIT_FAILURE) + end + + self.get():SaveContext() + local imgw, imgh = img:GetSize() + local simg = 90/imgh + self.get():Scale( simg, simg ) + self.get():Blit(img, 5/simg, (offy+5)/simg) -- Notez-bien : translation is also scaled + self.get():RestoreContext() + + offy = offy + self.get():GetFontExtents() + + local srf_TSalon = FieldBlink( self, animTimer, 50, offy, fonts.mdigit, COL_DIGIT, { + timeout = 310, + align = ALIGN_RIGHT, + sample_text = "-88.8", + gradient = GRD_TEMPERATURE + } ) + + local srf_Thermometre = VGauge( self, 14,330, 6,62, COL_RED, COL_WHITE, nil, { + min = 5, max = 40, + ascend = true + }) + + local TSalon = MQTTDisplay( 'TSalon', 'maison/Temperature/Salon', srf_TSalon ) + self.setFont( fonts.mdigit ) + srf:DrawStringTop("°C", srf_TSalon.getAfter()) + offy = offy + srf_TSalon.getHight() + + local function updthermo() + srf_Thermometre.Draw( TSalon.get() ) + end + TSalon.TaskOnceAdd( updthermo ) + + ---- + + self.setFont( fonts.title1 ) + srf:DrawStringTop("Extérieur :", 35, offy ) + offy = offy + self.get():GetFontExtents() + + self.srf_TDehors = FieldBlink( self, animTimer, 50, offy, fonts.mdigit, COL_DIGIT, { + timeout = 310, + align = ALIGN_RIGHT, + sample_text = "-88.8", + gradient = GRD_TEMPERATURE + } ) + + + local TDehors = MQTTDisplay( 'TDehors', 'maison/Temperature/Dehors', self.srf_TDehors ) + self.setFont( fonts.mdigit ) + srf:DrawStringTop("°C", self.srf_TDehors.getAfter()) + offy = offy + self.srf_TDehors.getHight() + + ---- + + self.setFont( fonts.sdigit ) + imgw = self.get():GetStringExtents( "8888" ) + local srf_dATM = FieldBlink( self, animTimer, (w-imgw)/2, offy+15, fonts.sdigit, COL_DIGIT, { + timeout = 310, + align = ALIGN_CENTER, + width = imgw + } ) + local srf_uATM = FieldBlink( self, animTimer, (w-imgw)/2, offy + srf_dATM.getHight() + 15, fonts.sdigit, COL_DIGIT, { + timeout = 310, + align = ALIGN_CENTER, + width = imgw + } ) + + local gfx_download = ArcGaugePercent( self, + 0, offy, + (w-imgw)/2-5, 3*srf_dATM.getHight(), + { + parts = 1/32 + } + ) + + local gfx_upload = ArcGaugePercent( self, + w - (w-imgw)/2 +2, offy, + (w-imgw)/2-5, 3*srf_dATM.getHight(), + { + align = ALIGN_RIGHT, + parts = 1/32 + } + ) + + local wdfreebox, _ = SelTimer.Create { when=40, clockid=SelTimer.ClockModeConst("CLOCK_MONOTONIC"), ifunc= function () + Notification.setColor( COL_RED ) + Notification.Log( "Freebox muette") + Notification.setColor( COL_WHITE ) + condition_freebox.report_issue() + end + } + + local dWAN = FAIdata( 'dWAN', 'Freebox/DownloadATM', 'Freebox/UploadTV', 'Freebox/DownloadWAN', srf_dATM, gfx_download, { watchdog=wdfreebox, condition=condition_freebox } ) + local uWAN = FAIdata( 'uWAN', 'Freebox/UploadATM', 'Freebox/DownloadTV', 'Freebox/UploadWAN', srf_uATM, gfx_upload ) + table.insert( additionnalevents, wdfreebox ) + +-- offy = offy + srf_dATM.getHight() + +--]] + + -- Drawing finished and alway visible + self.Visibility(true) + + return self +end + +LeftBar = f() + From 2ed6b7f2130e4e95c55bd49efaa6b6d5b48ec543 Mon Sep 17 00:00:00 2001 From: destroyedlolo Date: Sun, 11 Jun 2023 16:03:50 +0200 Subject: [PATCH 4/4] Add mode Canicule --- SeleniteDFB/HDB_320/70_ModePool.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/SeleniteDFB/HDB_320/70_ModePool.lua b/SeleniteDFB/HDB_320/70_ModePool.lua index 733f128..34ff8f7 100644 --- a/SeleniteDFB/HDB_320/70_ModePool.lua +++ b/SeleniteDFB/HDB_320/70_ModePool.lua @@ -12,6 +12,7 @@ function ModePool( titre, topic, y ) }, { { 'Heures Creuses', function () Brk:Publish( topic, 'Heures Creuses', true ) end }, + { 'Canicule', function () Brk:Publish( topic, 'Canicule', true ) end }, { 'Arret', function () Brk:Publish( topic, 'Arret', true ) end }, { 'Forcé', function () Brk:Publish( topic, 'Forcé', true ) end }, }, -- list