Skip to content

Commit

Permalink
Adding script
Browse files Browse the repository at this point in the history
  • Loading branch information
William Mayvis authored and William Mayvis committed Feb 6, 2022
1 parent 28a5e35 commit 3656db0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions flvss/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local a={en="Lua FLVSS",fr="FLVSS Lua"}local b=0;local c="1.0.0.1"local function d(e,f)e=tonumber(e)b=b*0.9+e*0.1;local g={0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,8,8,9,9,10,12,13,14,17,19,20,22,23,26,28,30,33,36,39,42,45,48,51,54,57,58,60,62,64,66,67,69,70,72,74,75,77,78,80,81,82,84,85,86,86,87,88,89,91,92,94,95,96,97,97,99,100}f=tonumber(f)if f>0 then local h=3;local i=0;local j=1;e=e*100;h=e/f;j=math.floor(h-298)if j>120 then j=120 end;if j<1 then j=1 end;return g[j]end end;local function k(l)if l<=100 and l>=75 then lcd.color(lcd.RGB(128,192,16))elseif l<=75 and l>=50 then lcd.color(lcd.RGB(250,152,5))elseif l<=50 and l>=25 then lcd.color(lcd.RGB(250,225,5))else lcd.color(lcd.RGB(255,0,0))end end;local function m(n,o,p,q,r,l,s,t)lcd.color(lcd.RGB(40,40,40))lcd.drawCircle(n,o,p)k(l)local u=p+5;lcd.drawAnnulusSector(n,o,0,u,q,r)lcd.color(lcd.RGB(255,255,255))lcd.drawCircle(n,o,p-5)lcd.color(lcd.RGB(40,40,40))lcd.drawFilledCircle(n,o,p-6)lcd.font(FONT_XS_BOLD)lcd.color(lcd.RGB(255,255,255))if s then lcd.drawText(n+3,o-7,l.."%",CENTERED)else lcd.drawText(n+3,o-7,t,CENTERED)end end;local function v(w)local y=system.getLocale()return a[y]or a["en"]end;local function z()local A=system.getSource("LiPo")return{sensor=A,value=nil}end;local function B(w)return{{"FLVSS v"..c,function()end}}end;local function C(w)if w.sensor~=nil then local D=40;local E=32;local F,G=lcd.getWindowSize()local l=d(w.sensor:value(),w.sensor:stringValue(OPTION_CELL_COUNT))local H=l/100*360;local I=10;local J=(E+I)*w.sensor:value(OPTION_CELL_COUNT)local K=0;m(60,J*0.1+25+K,35,0,H,l,true,w.sensor:stringValue())lcd.font(FONT_S)lcd.drawText(110,J*0.1+10,w.sensor:stringValue(OPTION_CELL_COUNT).." cells")lcd.font(FONT_L_BOLD)k(l)lcd.drawText(110,J*0.1+30,w.sensor:stringValue())x=60;D=J*0.1+130+K;for j=1,w.sensor:value(OPTION_CELL_COUNT)do local L=d(w.sensor:value(OPTION_CELL_INDEX(j)),1)local M=L/100*360;lcd.font(FONT_XS)if x>=F then x=60;D=D+70 end;m(x,D,30,0,H,l,false,w.sensor:stringValue(OPTION_CELL_INDEX(j)))x=x+87 end end end;local function N(w)local O=nil;if w.sensor==nil then w.sensor=system.getSource("LiPo")end;if w.sensor~=nil then O=w.sensor:stringValue()end;if w.value~=O then w.value=O;lcd.invalidate()end end;local function P()system.registerWidget({key="flvss",name=v,create=z,paint=C,wakeup=N,menu=B})end;return{init=P}

0 comments on commit 3656db0

Please sign in to comment.