Files
nspanel-lovelace-ui/HMI/n2t-out/pageStartup.txt
2023-09-16 10:55:25 +00:00

415 lines
16 KiB
Plaintext

Page pageStartup
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Locked : no
Swide up page ID : disabled
Swide down page ID : disabled
Swide left page ID : disabled
Swide right page ID: disabled
Events
Preinitialize Event
vis p0,0
recmod=1
bauds=115200
vis tSend,0
vis tInstruction,0
vis tTmp,0
vis tId,0
vis bSendStartup,0
vis frame_ptr,0
vis spinner_w,0
vis frapic_w,0
vis usual_cnt,0
vis tMsg2,0
vis tMsg3,0
vis tVersion,0
dim=100
Postinitialize Event
//send messages by clicking button
click bSendStartup,1
Variable (string) strCommand
Attributes
Scope : local
Text :
Max. Text Size: 50
Variable (string) strTmp
Attributes
Scope : local
Text :
Max. Text Size: 2
Number frame_ptr
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Value : 0
Number frapic_w
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Value : 1960
Number spinner_w
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Value : 140
Number usual_cnt
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Value : 0
Text tId
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text :
Max. Text Size : 20
Text tInstruction
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text :
Max. Text Size : 20
Text tMsg1
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text : Waiting for content ...
Max. Text Size : 40
Text tMsg2
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text : This is taking longer than usual,
Max. Text Size : 100
Text tMsg3
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text : please check your backend configuration
Max. Text Size : 100
Text tSend
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text : newtxt
Max. Text Size : 100
Text tTmp
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text :
Max. Text Size : 30
Text tVersion
Attributes
Scope : local
Dragging : 0
Send Component ID : disabled
Associated Keyboard: none
Text : 53
Max. Text Size : 10
Picture p0
Attributes
Scope : local
Dragging : 0
Send Component ID: disabled
Button bSendStartup
Attributes
Scope : local
Dragging : 0
Send Component ID: disabled
State : unpressed
Text : startup
Max. Text Size : 10
Events
Touch Press Event
recmod=1
bauds=115200
// startup event
tSend.txt="event,startup,"+tVersion.txt+",eu"
//send calc crc
btlen tSend.txt,sys0
crcrest 1,0xffff // reset CRC
crcputh 55 bb
crcputs sys0,2
crcputs tSend.txt,0
//send cmd
printh 55 bb
prints sys0,2
prints tSend.txt,0
prints crcval,2
Hotspot mSpinner
Attributes
Scope : local
Dragging : 0
Send Component ID: disabled
Events
Touch Press Event
sys2=sys2+1
sys2%=10
//n0.val=sys2
if(sys2==9)
{
page pageTest
}
Timer tmSerial
Attributes
Scope : local
Period (ms): 50
Enabled : yes
Events
Timer Event
// data available
if(usize>1)
{
bufferPos=0
while(bufferPos<usize)
{
// check for 0x55 0xBB - Command Init Secuence
if(u[bufferPos]==187&&u[bufferPos-1]==85)
{
//remove garbage at the start of the buffer if there's any to free buffer for command
if(u[bufferPos]!=1)
{
udelete bufferPos-1
}
//instruction is now aligned with buffer, because we deleted garbage before instrcution
//get length after init sequence (check if there are more than to bytes in buffer)
if(3<usize)
{
// check if serial buffer has reached the announced length
ucopy payloadLength,2,2,0
// we are only checking payload length so we have to skip first 3 bytes (init+payload length) (-1 because of < instead of <=)
payloadLength+=3
// payload length does also not contain crc, so we are adding another 2 bytes for crc
payloadLength+=2
if(payloadLength<usize)
{
// calculate crc
crcrest 1,0xFFFF
// u[2] contains payload legth at 3rd pos in buffer, we are calculating crc from 3rd pos with number of bytes from payload length
//crcputu 3,u[2]
// u[2] cotnains payload length, we are calculating a crc over the whole message, so we have to add 3 to the length from u[2]
crcputu 0,payloadLength-1
// get recived crc to be able to compare it
ucopy recvCrc,payloadLength-1,2,0
// compare crc with recived value
if(crcval==recvCrc)
{
// crc is okay
// here is the location where acual code should be
// write command to variable strCommand
ucopy strCommand.txt,4,payloadLength-5,0
// write instruction to tInstuction (debug output, but used as variable here, ui elements will be disabled by default)
spstr strCommand.txt,tInstruction.txt,"~",0
if(tInstruction.txt=="time")
{
// get set time to global variable
spstr strCommand.txt,pageIcons.vaTime.txt,"~",1
}
if(tInstruction.txt=="date")
{
// get set date to global variable
spstr strCommand.txt,pageIcons.vaDate.txt,"~",1
}
if(tInstruction.txt=="dimmode")
{
// get value
spstr strCommand.txt,tTmp.txt,"~",1
covx tTmp.txt,dimValue,0,0
// get value normal
spstr strCommand.txt,tTmp.txt,"~",2
covx tTmp.txt,dimValueNormal,0,0
dim=dimValueNormal
// get background color
spstr strCommand.txt,tTmp.txt,"~",3
if(tTmp.txt!="")
{
covx tTmp.txt,defaultBcoColor,0,0
}
// get font color
spstr strCommand.txt,tTmp.txt,"~",4
if(tTmp.txt!="")
{
covx tTmp.txt,defaultFontColor,0,0
}
// get feature flag popup
spstr strCommand.txt,tTmp.txt,"~",5
if(tTmp.txt!="")
{
covx tTmp.txt,featNewSliders,0,0
}
}
if(tInstruction.txt=="timeout")
{
//set timeout to global var
spstr strCommand.txt,tTmp.txt,"~",1
covx tTmp.txt,sleepTimeout,0,0
}
if(tInstruction.txt=="pageType")
{
dim=100
//command format pageType,specialPageName
//write name of speical page to tId
spstr strCommand.txt,tId.txt,"~",1
//save second arg if there's one
spstr strCommand.txt,tTmp.txt,"~",2
//save third arg if there's one
spstr strCommand.txt,pageIcons.tTmp2.txt,"~",3
spstr strCommand.txt,pageIcons.tTmp3.txt,"~",4
//we are going to exit this page with this command, so we have to clear the buffer, so we are not getting into a stupid loop ...
udelete payloadLength-1
bufferPos=0
if(tId.txt=="pageStartup")
{
page pageStartup
}
if(tId.txt=="screensaver")
{
page screensaver
}
if(tId.txt=="screensaver2")
{
page screensaver2
}
if(tId.txt=="cardEntities")
{
page cardEntities
}
if(tId.txt=="cardGrid")
{
page cardGrid
}
if(tId.txt=="cardGrid2")
{
page cardGrid2
}
if(tId.txt=="popupLight")
{
pageIcons.tTmp1.txt=tTmp.txt
page popupLight
}
if(tId.txt=="popupShutter")
{
pageIcons.tTmp1.txt=tTmp.txt
page popupShutter
}
if(tId.txt=="popupNotify")
{
page popupNotify
}
if(tId.txt=="cardThermo")
{
page cardThermo
}
if(tId.txt=="cardMedia")
{
page cardMedia
}
if(tId.txt=="cardAlarm")
{
page cardAlarm
}
if(tId.txt=="cardQR")
{
page cardQR
}
if(tId.txt=="cardPower")
{
page cardPower
}
if(tId.txt=="cardChart")
{
page cardChart
}
if(tId.txt=="cardLChart")
{
page cardLChart
}
}
// end of user code
udelete payloadLength-1
bufferPos=0
}
}
}
}
// next character
bufferPos++
}
}
Timer tmSpinner
Attributes
Scope : local
Period (ms): 80
Enabled : yes
Events
Timer Event
xpic mSpinner.x,mSpinner.y,spinner_w.val,140,frame_ptr.val,0,9 // draw the current frame
frame_ptr.val+=spinner_w.val%frapic_w.val // advance the pointer to the next frame in the pic resource and roll over at the end
doevents // finish drawing before next timer event triggers
if(frame_ptr.val==1820)
{
usual_cnt.val+=1
sys0=usual_cnt.val%5
if(sys0==0)
{
// retry sending startup messages by clicking button
click bSendStartup,1
}
}
if(usual_cnt.val==10)
{
vis tMsg2,1
vis tMsg3,1
}