Hi,
hier habe ich nun ein weiteres Applet für die G19. Es zeigt das aktuelle Wetter sowie die Prognose für die nächsten drei Tage an. Mit einem druck auf die "Menu"-Taste der G19 erscheint ein Input indem man den Ort angeben kann der angezeigt werden soll.
Die folgenden Komponenten werden benötigt
Zum einen natürliche die UDF von Carsten 8: AdvanceLcd
Dann noch die entsprechende DLL aus AdvanceLcd. Im herruntergladenen Archiv unter Binary und dann entsprechend dem Betriebsystem x64 oder x86 zu finden.
Und hier nun das eigentliche Script (die vier Funktionen oben sind drin weil diese in der UDF fehlen) mit der bitte um Feadback:
Spoiler anzeigen
#include <String.au3>
#include <AdvanceLCD.au3>
#include <Array.au3>
OnAutoItExitRegister("killfunc")
Global $count
Func LcdSetPriority($hApplet, $nPriority = "LCD_PRIORITY_NORMAL", $bForeground = 0)
Local $ret = DllCall($dll, "int", "LcdSetPriority", "ptr", $hApplet, "int", $nPriority, "int", $bForeground)
If @error Then Return SetError(1, @error, 0)
Return $ret[0]
EndFunc ;==>LcdSetPriority
Func LcdDrawText($hApplet, $pString, $iX = 0, $iY = 0)
Local $ret = DllCall($dll, "int", "LcdDrawTextA", "ptr", $hApplet, "str", $pString, "int", $iX, "int", $iY)
If @error Then Return SetError(1, @error, 0)
Return $ret[0]
EndFunc ;==>LcdDrawText
Func LcdSetFont($hApplet, $hFont)
Local $ret = DllCall($dll, "int", "LcdSetFont", "ptr", $hApplet, "ptr", $hFont)
If @error Then Return SetError(1, @error, 0)
Return $ret[0]
EndFunc ;==>LcdSetFont
Func LcdLoadFont($sFamily, $iHeight, $iFlags, $sFile)
Local $ret = DllCall($dll, "ptr", "LcdLoadFontW", "wstr", $sFamily, "int", $iHeight, "int", $iFlags, "wstr", $sFile)
If @error Then Return SetError(1, @error, 0)
Return $ret[0]
EndFunc ;==>LcdLoadFont
LcdInitialize()
$hApplet = LcdCreateApplet("Wetteranzeige", 2, 1, 1)
LcdSetTarget($hApplet, 0)
LcdWaitActivation($hApplet)
LcdSetPriority($hApplet, $LCD_PRIORITY_NORMAL, 1)
_wetter()
[/autoit] [autoit][/autoit] [autoit]Func _wetter()
$count = 0
$ort = IniRead(@ScriptDir & "/config.ini", "Wetter", "Ort", "Frankfurt")
[/autoit] [autoit][/autoit] [autoit]LcdClear($hApplet, 0x000000)
[/autoit] [autoit][/autoit] [autoit]$wetter = BinaryToString(InetRead("http://www.google.com/ig/api?weather=" & $ort & "&hl=de", 16))
$currentdate = _StringBetween($wetter, "<current_conditions>", "</current_conditions>")
$Font = LcdLoadFont("Arial", 30, $LCD_FONT_DEFAULT, "arial.ttf")
LcdSetFont($hApplet, $Font)
LcdDrawText($hApplet, $ort, 0, 0)
$currentcondition = _StringBetween($currentdate[0], '<condition data="', '"/>')
LcdDrawText($hApplet, $currentcondition[0], 0, 30)
$currenttempc = _StringBetween($currentdate[0], '<temp_c data="', '"/>')
LcdDrawText($hApplet, $currenttempc[0] & "°", 0, 60)
$currenthumidity = _StringBetween($currentdate[0], '<humidity data="', '"/>')
LcdDrawText($hApplet, $currenthumidity[0], 0, 90)
$currenticon = _StringBetween($currentdate[0], '<icon data="', '"/>')
$curreniconname = StringSplit($currenticon[0], "/")
If $curreniconname[0] = 5 Then
InetGet("http://www.google.com" & $currenticon[0], @TempDir & "/" & $curreniconname[5], 16)
$currentimage = LcdLoadPixmap(@TempDir & "/" & $curreniconname[5])
LcdDrawPixmap($hApplet, $currentimage, 250, 15)
EndIf
$forecastdate = _StringBetween($wetter, "<forecast_conditions>", "</forecast_conditions>")
[/autoit] [autoit][/autoit] [autoit]$dayonename = _StringBetween($forecastdate[0], '<day_of_week data="', '"/>')
$daytwoname = _StringBetween($forecastdate[1], '<day_of_week data="', '"/>')
$daythreename = _StringBetween($forecastdate[2], '<day_of_week data="', '"/>')
$dayfourname = _StringBetween($forecastdate[3], '<day_of_week data="', '"/>')
$Font = LcdLoadFont("Arial", 15, $LCD_FONT_DEFAULT, "arial.ttf")
LcdSetFont($hApplet, $Font)
LcdDrawText($hApplet, $dayonename[0], 15, 175)
LcdDrawText($hApplet, $daytwoname[0], 95, 175)
LcdDrawText($hApplet, $daythreename[0], 175, 175)
LcdDrawText($hApplet, $dayfourname[0], 255, 175)
$dayoneicon = _StringBetween($forecastdate[0], '<icon data="', '"/>')
$daytwoicon = _StringBetween($forecastdate[1], '<icon data="', '"/>')
$daythreeicon = _StringBetween($forecastdate[2], '<icon data="', '"/>')
$dayfouricon = _StringBetween($forecastdate[3], '<icon data="', '"/>')
$dayoneiconname = StringSplit($dayoneicon[0], "/")
$daytwoiconname = StringSplit($daytwoicon[0], "/")
$daythreeiconname = StringSplit($daythreeicon[0], "/")
$dayfouriconname = StringSplit($dayfouricon[0], "/")
InetGet("http://www.google.com" & $dayoneicon[0], @TempDir & "/" & $dayoneiconname[5], 16)
InetGet("http://www.google.com" & $daytwoicon[0], @TempDir & "/" & $daytwoiconname[5], 16)
InetGet("http://www.google.com" & $daythreeicon[0], @TempDir & "/" & $daythreeiconname[5], 16)
InetGet("http://www.google.com" & $dayfouricon[0], @TempDir & "/" & $dayfouriconname[5], 16)
$dayoneimage = LcdLoadPixmap(@TempDir & "/" & $dayoneiconname[5])
LcdDrawPixmap($hApplet, $dayoneimage, 15, 195)
$daytwoimage = LcdLoadPixmap(@TempDir & "/" & $daytwoiconname[5])
LcdDrawPixmap($hApplet, $daytwoimage, 95, 195)
$daythreeimage = LcdLoadPixmap(@TempDir & "/" & $daythreeiconname[5])
LcdDrawPixmap($hApplet, $daythreeimage, 175, 195)
$dayfourimage = LcdLoadPixmap(@TempDir & "/" & $dayfouriconname[5])
LcdDrawPixmap($hApplet, $dayfourimage, 255, 195)
$dayonelow = _StringBetween($forecastdate[0], '<low data="', '"/>')
$daytwolow = _StringBetween($forecastdate[1], '<low data="', '"/>')
$daythreelow = _StringBetween($forecastdate[2], '<low data="', '"/>')
$dayfourlow = _StringBetween($forecastdate[3], '<low data="', '"/>')
LcdDrawText($hApplet, $dayonelow[0] & "°", 56, 220)
LcdDrawText($hApplet, $daytwolow[0] & "°", 136, 220)
LcdDrawText($hApplet, $daythreelow[0] & "°", 216, 220)
LcdDrawText($hApplet, $dayfourlow[0] & "°", 296, 220)
$dayonehigh = _StringBetween($forecastdate[0], '<high data="', '"/>')
$daytwohigh = _StringBetween($forecastdate[1], '<high data="', '"/>')
$daythreehigh = _StringBetween($forecastdate[2], '<high data="', '"/>')
$dayfourhigh = _StringBetween($forecastdate[3], '<high data="', '"/>')
LcdDrawText($hApplet, $dayonehigh[0] & "°", 56, 195)
LcdDrawText($hApplet, $daytwohigh[0] & "°", 136, 195)
LcdDrawText($hApplet, $daythreehigh[0] & "°", 215, 195)
LcdDrawText($hApplet, $dayfourhigh[0] & "°", 296, 195)
LcdUpdate($hApplet, 0)
EndFunc ;==>_wetter
While 1
Sleep(100)
If LcdButtonState($hApplet, $LCD_BUTTON_MENU) = True Then
$ort = InputBox("Ort eingeben", "Bitte den Ort angeben, dessen Wetter angezeigt werden soll.")
$ort = StringReplace($ort, "ä", "ae")
$ort = StringReplace($ort, "ö", "oe")
$ort = StringReplace($ort, "ü", "ue")
IniWrite(@ScriptDir & "/config.ini", "Wetter", "Ort", $ort)
_wetter()
EndIf
If $count > 36000 Then
_wetter()
Else
$count = $count + 1
EndIf
WEnd
Func killfunc()
LcdDeleteApplet($hApplet)
LcdDeInitialize()
EndFunc ;==>killfunc