Ugh!  I think I figured it out, so no I can get back to my real job. 
See below.

erland;540753 Wrote: 
> 
> 
> I suspect we probably want to use something similar to the "timetext".
> 
I'm going to try an take a whack at it tomorrow - shouldn't be too
difficult.  Mainly it's just sending the "text" part to SDT for
processing using the code below.  Not much more than that - use JSON,
send request, get response.

> 
> Doesn't SuperDateTime also provide sport events/games scores ? 
> Are these also provided in the JSON response ?
> Another JSON command maybe ?
Probably - after weather is done, perhaps.

> I wonder how often we need to update these SDT items ? Do we need to do
> it once a minute ? Once an hour ?

I'd say update every minute to keep the clock running OK.

Only need to do the icon URL code in CustomClock.  Probably need a
TimeIcon item as well as TimeText.  This would fetch the current icon
number to fetch and display - it's just an integer 1-45, and it fetches a
PNG from a URL (local or internet)  I'm going to put that in unless you
have a preferred way.

You can handle the web UI part for these additions, right? :-)

I added this to the cliQuery of SuperDateTime.  This will automagically
take standard SDT setting strings (as seem from the web UI), and parse
them it.  Pretty neat.  Only for weather (all I care about).  Could do
sports, not sure how, probably using a similar method.

I also have a 120x120 pixel set of icons I'm going to use.  The current
customclock crashes with local (port 9000) urls, just FYI.  I bricked my
Touch about a dozen times trying to figure out the damn LUA non-regular
expression syntax, to no avail.  Anyway, it is what it is - should get
fixed.



sub cliQuery {
my $request = shift;
my $client = $request->client();

# get our parameters
my $SDTstring = $request->getParam('_p2');
$log->debug("INSIDE CLI- SDTstring: $SDTstring");
# my $client = $request->getParam('_p3');
$log->debug("INSIDE CLI- Client: $client");
my $period = $request->getParam('_p4');
$log->debug("INSIDE CLI- Period: $period");
my $mode   = $request->getParam('_mode');
$log->debug("INSIDE CLI- mode: $mode");

if ($mode eq 'SDTstring') {
if (!defined $period) {$period = 0;}
my $SDTtemp = replaceMacrosPer( $SDTstring, $period, $client
);
$log->debug("Result of replaceMacrosPer: $SDTtemp" );
$request->addResult( "SDTstring", $SDTtemp );
$request->addResult( "wetData", \%wetData );
}


and this is all you need to CustomClock to get the right timetext from
the SDT patterns.  You request an SDTstring, pass it the SDT pattern, the
period (parameter 4. 0 is current).  Parameter 3 was the player, but
that's not necessary.


function request(self)
        local player = appletManager:callService("getCurrentPlayer")
        local playerStatus = player:getPlayerStatus()
        if playerStatus.mode ~= 'play' or self:getSettings()["nowplaying"] ==
false then      
                local player = appletManager:callService("getCurrentPlayer")
                local server = player:getSlimServer()

                server:userRequest(
                        function(chunk, err)
                                if err then
                                        log:debug(err)
                                elseif chunk then
                                        self:response(chunk.data)
                                end
                        end,
                        player and player:getId(),
                        { 'SuperDateTime', 'SDTstring', '%2 (Sunset %S) %t/%h 
%1 PREC %x %z
%f  %a(%c %g)', '0', '0'}
                )
        end
end
-Dan


-- 
plympton
------------------------------------------------------------------------
plympton's Profile: http://forums.slimdevices.com/member.php?userid=12955
View this thread: http://forums.slimdevices.com/showthread.php?t=77864

_______________________________________________
jive mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive

Reply via email to