Soundgraph iMon LCD - display icons
#1
While browsing the LCDProc source to see how feasible it was to add support for the icons round the edge of the display I discovered that LCDProc already has a command in the protocol (OUTPUT) which can be customised in each driver and in the imon lcd driver this command controls the additional display icons.

After discovering this i figured rather than modifying xbmc sourcecode it would be quite simple to write a perl script that runs in the background and queries xbmc via the http interface and lights up icons based on the currently playing file.

Here is my first attempt. It does work and should not be too difficult to customise if you wish but doesnt have much in the way of error trapping (eg. checking the responses for LCDproc)...

Code:
#!/usr/bin/perl
use HTTP::Request::Common;
use LWP::UserAgent;
use IO::Socket;

my $sockres;
my $sock;

#see here for details of imon lcd driver output control bits
#http://lcdproc.cvs.sourceforge.net/viewvc/lcdproc/lcdproc/server/drivers/imonlcd.c?view=markup


$sock = new IO::Socket::INET (PeerAddr => 'localhost', PeerPort => '13666', Proto => 'tcp', );

die "Could not create socket: $!\n" unless $sock;

print $sock "hello\n";

$sockres = readline $sock;

do
{

my $output = "";

my $progress = 0;
my $icondata = 0;

my $ua = LWP::UserAgent->new;
my $res = $ua->request(GET 'http://localhost:8080/xbmcCmds/xbmcHttp?command=GetCurrentlyPlaying');

if ($res->is_success)
{
   $output = $res->content;

   #remove html tags
   $output =~ s/<html>//gi;
   $output =~ s/<.html>//gi;
   $output =~ s/<li>//gi;
}

my @lines = split(/\n/, $output);

foreach my $val (@lines)
{
   if ($val =~ /Filename:/i)
   {
      if ($val =~ /.mpg/i)  { $icondata = $icondata | (1<<19) }; #turn on MPG icon
      if ($val =~ /.mpeg/i) { $icondata = $icondata | (1<<19) }; #turn on MPG icon
      if ($val =~ /.avi/i)  { $icondata = $icondata | (2<<19) }; #turn on DIVX icon
      if ($val =~ /.wmv/i)  { $icondata = $icondata | (4<<19) }; #turn on WMV icon

      if ($val =~ /.wma/i) { $icondata = $icondata | (3<<13) }; #turn on WMA icon
      if ($val =~ /.mp3/i) { $icondata = $icondata | (1<<13) }; #turn on MP3 icon
      if ($val =~ /.ogg/i) { $icondata = $icondata | (2<<13) }; #turn on OGG icon
      if ($val =~ /.wav/i) { $icondata = $icondata | (4<<13) }; #turn on WAV icon
   }

   if ($val =~ /Type:/)
   {
      if ($val =~ /Video/i) { $icondata = $icondata | (2<<1) }; #turn on MOVIE icon
      if ($val =~ /Video/i) { $icondata = $icondata | 1 }; # enable play animation
      if ($val =~ /Audio/i) { $icondata = $icondata | (1<<1) }; # turn on MUSIC icon
      if ($val =~ /Audio/i) { $icondata = $icondata | 1 }; # enable play animation
      if ($val =~ /Picture/i) { $icondata = $icondata | (3<<1) }; # turn on PHOTO icon
   }

   if ($val =~ /Percentage:/)
   {
      $val =~ s/Percentage://i;
      $progress = $val *32 / 100;
   }
}


printf $sock "output %i\n",$icondata;

$sockres = readline $sock;

sleep 1;

printf $sock "output %i\n",(($progress <<6) | (1<<28)); # configure upper progress bar

$sockres = readline $sock;

sleep 1;

} while 1;

close $sock;
Reply
#2
Fantastic! Works for me. I had to remove the password I set on XBMC, but after that, it works like a charm. Nice to see the icons.
Reply
#3
Ty so much working perfectly.
Reply
#4
So where exactly do I need to put this? Smile

Thanks for the hard work!
-Erik
Reply
#5
Great! Good job, I will check it out later this week I always wanted to get that working. Did you find a command that would turn off the display? Like, when a movie is playing the display would go black. I know XBMC has an option to not display messages during playback, but that darn backlight is awefull bright.

I thought I found a command to turn it off, but it is more like a compiled program, can't read it.
Reply
#6
burritoboy9984 Wrote:So where exactly do I need to put this? Smile

Thanks for the hard work!
-Erik

anywhere you like. Just save it to a file somewhere and chmod +x it.
So for example you can save it to ~/imon.perl and then do chmod +x ~/imon.perl

Once this is done you can just run it from a shell using ~/imon.perl

You should also be able to add this to the startup applications.
Reply
#7
speed32219 Wrote:Great! Good job, I will check it out later this week I always wanted to get that working. Did you find a command that would turn off the display? Like, when a movie is playing the display would go black. I know XBMC has an option to not display messages during playback, but that darn backlight is awefull bright.

I thought I found a command to turn it off, but it is more like a compiled program, can't read it.

I dont think you can do this in LCDProc, so it would only be possible by sending commands directly to the lcd0 device - which you can only do if LCDd is stopped.

If you wanted the screen to go completely black during playback it would have to kill LCDd and restart it, I dont think this would work as XBMC would loose its connection to LCDd at that point.
Reply
#8
Any pictures or screen shots of what exactly this does or looks like? I have a Grandia GDM-02 Silverstone case that has an LCD on it and would love for the LCD to do something. Right now it just kind of sits there unplugged.
Reply
#9
Wrong thread.
Reply
#10
Dougie085 Wrote:Any pictures or screen shots of what exactly this does or looks like? I have a Grandia GDM-02 Silverstone case that has an LCD on it and would love for the LCD to do something. Right now it just kind of sits there unplugged.

Here is a picture of the LCD with all of the display icons active.

http://www.soundgraph.com/Images/product/oem_03.jpg

XBMC will control the central area. Displaying whatever you configure in LCD.xml.

What XBMC wont do is activate any of the icons around edge shown in the above picture. It also doesnt control the progress bars.

What my script does is activate the MUSIC, MOVIE or PHOTO icon depending on what is being played in XBMC. It also activates the MPEG, DIVX or WMV, MP3, OGG, WMA, WAV icons depending on the filename of the file being played and it also displays one of the top progress bars based on the position of the file curreently playing...
Reply
#11
Ohhh you have one of the VFD type displays.

http://www.silverstonetek.com/products/p...t&area=usa

This is what I have...I would love an app that utilizes it in a useful way for linux.
Reply
#12
How could I extend this to get the title of the currently playing file? Is there any way?
Reply
#13
XBMC already displays the currently playing file in the main area of the display. This script is purely to activate the icons around the edge of the display.
Reply
#14
Big Grin 
speed32219 Wrote:Great! Good job, I will check it out later this week I always wanted to get that working. Did you find a command that would turn off the display? Like, when a movie is playing the display would go black. I know XBMC has an option to not display messages during playback, but that darn backlight is awefull bright.

I thought I found a command to turn it off, but it is more like a compiled program, can't read it.

Turning off the display is very easy actually: XBMC should send the "backlight off" command when blanking and "backlight on" when it resumes (edit: it does.

This will require the backlight to actually turn off though, a feature that has just recently been enabled in LCDd for the imonlcd driver (it is most likely in the 0.5.3 release and for certain in the CVS version).

@Phantasm4489: Awesome work! I haven't tested it yet but as soon as I get it to work on my VFD display (imon 0038) I'll post a picture Smile

Edit: forgot that the HTTP interface is hopelessly broken in 64-bit Sad As soon as the SVN gets stable again I'll update as the webservice got fixed 8 weeks ago

Edit2: XBMC already turns off the display when blanking, I didn't see that before because I just updated to the latest drivers myself...
Reply
#15
Phantasm4489 Wrote:anywhere you like. Just save it to a file somewhere and chmod +x it.
So for example you can save it to ~/imon.perl and then do chmod +x ~/imon.perl

Once this is done you can just run it from a shell using ~/imon.perl

You should also be able to add this to the startup applications.

Hello!
Would this script work on a windows machine also? or is it Linux specific?

//trakster
Reply

Logout Mark Read Team Forum Stats Members Help
Soundgraph iMon LCD - display icons0