Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

107 lines (85 sloc) 2.48 KB
B4J=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=4.2
@EndOfDesignText@
Sub Class_Globals
Dim App As AWTRIX
'Declare your variables here
Dim first_name As String
End Sub
' ignore
public Sub GetNiceName() As String
Return App.AppName
End Sub
' ignore
public Sub Run(Tag As String, Params As Map) As Object
Return App.AppControl(Tag,Params)
End Sub
' Config your App
Public Sub Initialize() As String
App.Initialize(Me,"App")
'App name (must be unique, avoid spaces)
App.AppName="Template"
'Version of the App
App.AppVersion="2.0"
'Description of the App. You can use HTML to format it
App.AppDescription=$"
This is just a template<br/>
<small>Created by AWTRIX</small>
"$
'SetupInstructions. You can use HTML to format it
App.SetupInfos= $"
<b>CustomText:</b>Text wich will be shown<br/>
"$
'How many downloadhandlers should be generated
App.NeedDownloads=1
'IconIDs from AWTRIXER. You can add multiple if you want to display them at the same time
App.Icons=Array As Int(6)
'Tickinterval in ms (should be 65 by default, for smooth scrolling))
App.TickInterval=65
'If set to true AWTRIX will wait for the "finish" command before switch to the next app.
App.LockApp=False
'needed Settings for this App (Wich can be configurate from user via webinterface)
App.appSettings=CreateMap("CustomText":"Hello World")
App.MakeSettings
Return "AWTRIX2"
End Sub
'this sub is called right before AWTRIX will display your App
Sub App_Started
End Sub
'Called with every update from Awtrix
'return one URL for each downloadhandler
Sub App_startDownload(jobNr As Int)
Select jobNr
Case 1
App.DownloadURL= "https://reqres.in/api/users/2"
End Select
End Sub
'process the response from each download handler
'if youre working with JSONs you can use this online parser
'to generate the code automaticly
'https://json.blueforcer.de/
Sub App_evalJobResponse(Resp As JobResponse)
Try
If Resp.success Then
Select Resp.jobNr
Case 1
Dim parser As JSONParser
parser.Initialize(Resp.ResponseString)
Dim root As Map = parser.NextObject
Dim data As Map = root.Get("data")
first_name = data.Get("first_name")
End Select
End If
Catch
Log("Error in: "& App.AppName & CRLF & LastException)
Log("API response: " & CRLF & Resp.ResponseString)
End Try
End Sub
'With this sub you build your frame.
Sub App_genFrame
App.genText(App.get("CustomText") & " " & first_name ,True,1,Null)
App.drawBMP(0,0,App.getIcon(6),8,8)
End Sub
You can’t perform that action at this time.