making color touchscreen into digital photo frame

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by gonzales, Jul 7, 2008.

  1. gonzales

    gonzales

    Joined:
    Nov 29, 2006
    Messages:
    8
    Likes Received:
    0
    Location:
    Mexico
    Hey Amigos,

    You know how you can use your color touchscreen to store a couple photos and cycle between them, so you can use it like a digital photo frame. But when you have filled the memory in the CTC, you have hit them limits.

    I want a way to show lots of photos but the screen does not allow Windows file sharing to access a folder on another computer.

    Here in mexico we have lots of time to spare so instead of siesta, I have been made a way to a digital photo phrame on my color touchscreen.

    Here is recipe. Follow carefully!


    On your remote machine:

    1/ Download and install Apache web server.

    You can get it here: http://httpd.apache.org/ Follow the download links, and the select for installing the Win32 Binary without crypto. This is MSI installer install on Windows XP by double clicking it. Other versions of Windows will probably also be ok but you might need to check.

    If you are on a stand-alone network then when prompted for network domain, server name, etc, you can pretty much make up whatever you want, its not too important.

    Install for all users on port 80, as a service.

    2/ Download and install PHP5.

    You can get it here: http://www.php.net/downloads.php. You want the windows installer (not the ZIP package). The installer is bigger but easier to install.

    During the PHP install, select the version of the web server you are using. If you follow the info about it will be Apache 2.2.x Module.

    You will probably have to select the Apache configuration directory to:
    C:\Program Files\Apache Software Foundation\Apache2.2\conf\

    You don't need to turn on any extensions.

    3/ Make sure your new web server is working:

    Point a browser at the location:

    localhost:80

    You should see a page saying "It Works!"

    4/ use the Apache Monitor down in your tray to RESTART the Apache service.

    5/ Go to the Apache web root folder (C:\Program Files\Apache Software Foundation\Apache2.2\htdocs):

    - rename the file index.html to index.html.old

    - create a new file index.php, and paste EXACTLY the following contents of the "Code" part into it
    Code:
    [FONT="Courier New"]<?php
    
    $HTBase      = "C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs";
    $Photos      = "photophrame";
    $Dir         = "$HTBase\\$Photos";
    $LastOneName = "lastone.dat";
    $LastOnePath = "$Dir\\$LastOneName";
    
    global $Dir;
    global $LastOneName;
    
    
    // Make the record of where we got to if it does not exist
    if (! file_exists($LastOnePath))
      {
        $first = FindFirst();
        file_put_contents($LastOnePath, $first);
      }
    
    // Find the next file name. Getting to end of directory is messy.
    if ($dh = opendir($Dir))
      {
        // Get the last file name that was displayed
        $lastfile = file_get_contents($LastOnePath);
        $nextfile = $lastfile;
    
        while (true)
          {
            if (($nextfile = readdir($dh)) === false)
              {
                // Error - Found EOF - Should not happen
                closedir($dh);
                $nextfile = FindFirst();
                break;
              }
    
            // Read was not past end of dir, find next file
            if ("$nextfile" == "$lastfile")
              {
                // Found the name displayed previously, get next
                if (($nextfile = readdir($dh)) !== false)
                  {
                    // Not EOF, was it the name of our records?
                    if ("$nextfile" != "$LastOneName")
                      {
                        // Was not the records file name, so its OK.
                        closedir($dh);
                        break;
                      }
                    else
                      {
                        // Yes it was, try next file or start again
                        if (($nextfile = readdir($dh)) === false)
                          {
                            closedir($dh);
                            $nextfile = FindFirst();
                            break;
                          }
                        else
                          {
                            closedir($dh);
                            break;
                          }
                      }
                  }
                else
                  {
                    // Got to end, find and return first dir entry (should not happen)
                    closedir($dh);
                    $nextfile = FindFirst();
                    break;
                  }
              }
          }
    
        file_put_contents($LastOnePath, "$nextfile");
    
        $file_type = ltrim(strrchr($nextfile, "."), ".");
    
        header("Content-type: image/$file_type");
        readfile("$Photos/$nextfile");
      }
    
    function FindFirst()
    {
      global $Dir;
      global $LastOneName;
    
      $dh = opendir($Dir);
    
      while (($file = readdir($dh)) !== false)
        {
          if (($file[0] != '.')
              &&
              ($file != $LastOneName))
            {
              $nextfile = $file;
              break;
            }
        }
      closedir($dh);
    
      return $nextfile;
    }
    
    ?>[/FONT]
    6. In the Apache web root folder (C:\Program Files\Apache Software Foundation\Apache2.2\htdocs), make new folder called "photophrame".

    7. Into that folder, copy JPG images you want to use on your Color Touch photo frame.

    8. Now in PICED make a timeout page. On that page make a link so when you touch it, it will go to your home / entry / start page. And on that page, put a full screen sized WEB CAMERA component. Point the URL to http://your-server-name/index.php. Set the page to update maybe every minute or something like.

    9. Test in PICED, then load it to the color touch and sit back and enjoy. Watch your screen with nice cold beer in hand.

    Adios Amigos!
     
    Last edited by a moderator: Dec 30, 2008
    gonzales, Jul 7, 2008
    #1
  2. gonzales

    gonzales

    Joined:
    Nov 29, 2006
    Messages:
    8
    Likes Received:
    0
    Location:
    Mexico
    Stupido forum... my php code indenting is gone. El stupido!
     
    gonzales, Jul 7, 2008
    #2
  3. gonzales

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,392
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    Some suggestions for improvements, gonzales:

    It would be a good idea for you to NOT put in your photos straight from your camera (at resolutions of thousands x thousands) because the CTC will just have to resize them all down to suit its 640 x 480 screen. This just chews the CTC processor up. And the CTC does not have oodles of RAM to play in either.

    So use something like PICASA to select the photos you want to display, and use its EXPORT function to resize all the images down to 640 pixels wide. There is less junk to transfer and less work for the CTC to do.

    Another practical thing you might find is that the web server (and more specifically the PHP module plugged into it) might need that file (lastone.dat) set with the right permissions, so that the web server can update it. But you don't want to open the permissions of the folders too much especially if you have external access to that web server! In unix you would need to fiddle with some chmod commands. In windows... ?? not sure. You should be able to do it all in the PHP.
     
    ashleigh, Jul 8, 2008
    #3
  4. gonzales

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    Awesome... thanks gonzales.

    I set this up last night on Mac OS-X which has apache built in... I'd never done any php before so there were a few things that I had to sort out with some help from mr google.. all in all it only took me about half an hour though, and it's so easy to add photos without updating the touchscreen project.. I love it!

    The paths : the "C:\\Program File\\..." is for PC hosts.. It's a bit is different for unix paths.. aside from the fact the location is completely different, the format of the path changes.. all the the "\\" change to "/"

    In OS-X the path to the root of the webserver that you find with http://localhost/ is :

    /Library/Webserver/Documents

    so

    Code:
    $HTBase = "C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs";
    $Photos = "photophrame";
    $Dir = "$HTBase\\$Photos";
    $LastOneName = "lastone.dat";
    $LastOnePath = "$Dir\\$LastOneName";
    becomes

    Code:
    $HTBase = "/Library/Webserver/Documents";
    $Photos = "photophrame";
    $Dir = "$HTBase/$Photos";
    $LastOneName = "lastone.dat";
    $LastOnePath = "$Dir/$LastOneName";
    Thanks again,

    Nick
     
    Last edited by a moderator: Jul 8, 2008
    NickD, Jul 8, 2008
    #4
  5. gonzales

    ICS-GS

    Joined:
    Nov 1, 2004
    Messages:
    347
    Likes Received:
    0
    Location:
    SE Melbourne
    good to see someone else thinking alsong the same lines as me!

    I used a trial version of software called 'slide show pilot' (i think) which created the html page and scaled the images.

    And the IIS server built into windows, it is kinda heavy (bloatware), but has worked a dream for 2 years now.

    Cheers

    Grant
     
    ICS-GS, Jul 10, 2008
    #5
  6. gonzales

    JJE

    Joined:
    Dec 9, 2004
    Messages:
    27
    Likes Received:
    0
    Hi all. Come across this the other day and followed the instructions but can not get it to work. I am running vista. Is it compatible with vista? Everything appears to work until PICED. Is there something else besides what is in the instructions that i am missing? Any help would be greatly appreciated
     
    JJE, Oct 26, 2008
    #6
  7. gonzales

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    You say it works "until PICED"...

    If you've checked that the webserver is working as described in the instructions, then that's probably the biggest step.

    Next you can test the php installation... there are some instructions on how to do this here... it's very simple.

    If that's all working you should be able to type the url you're putting into the PICED webcam component into your normal web browser and it will give you a new picture each time you refresh...

    Can you tell us if this works?

    If not there is probably something wrong in your changes to the php code.

    Nick
     
    NickD, Oct 27, 2008
    #7
  8. gonzales

    JJE

    Joined:
    Dec 9, 2004
    Messages:
    27
    Likes Received:
    0
    False alarm. I followed the link you posted about testing PHP installation and followed the instructions but that partially work. When viewing the info.php file through the browser i was getting a blank screen not invalid link etc...So i asked a co worker to set it up on his computer and it worked straight away. I then went back to PICED on my computer and it was working. I cant for the life of me explain why it was suddenly working but it is. I had spent 2 or so hours the day before installing and uninstalling trying to get it working. I have only been able to get it to work if I type the IP address of the remote computer instead of server name. We did notice why you need to use a web cam component instead of html component because PICED appears to use internet explorer and PHP at the moment doesn't like to play with explorer and thats why i was having problems testing it. PICED would ask me to save or open file index.php and internet explorer didn't know what to do with it and open it with notepad as mumbo jumbo. Thank you everyone for your help. It works a treat. The only thing that would be good is to give the user the ability (system io or Tools/Options) for refreshing the page so that they can adjust the "photo hold time" which I was giving them with the old method I was using for displaying photos. I though you might be able to do it through Tools/Option but that only gives you time out parameters. Switching between pages doesn't do it, only refreshing the page appears to be the way.

    Darren? Can we add this to your already fabulous product?
     
    JJE, Oct 29, 2008
    #8
  9. gonzales

    brodricj

    Joined:
    Mar 27, 2007
    Messages:
    117
    Likes Received:
    0
    Location:
    Perth
    I am still laboring through this trying to get a grip of what to do here in OSX.
    I have downloaded and installed php for Apache v1.3 found here:

    http://www.entropy.ch/software/macosx/php/

    To test whether its working it says do this:

    PHP should now be up and running. You can test it by dropping a file named test.php into your Sites folder in your home directory. Into that file, write this line:
    <?php phpinfo() ?>.

    Now open up http://127.0.0.1/~your_username/test.php in your web browser.
    You should see a status table with information about the PHP module.


    I have identified the Sites folder in my home directory, but I don't know what it means to drop a file named "test.php" into here, etc

    This is the bit I don't get. What does it mean by "drop a file named test.php into your sites folder in your home directory. Into that file write this line.."?
     
    Last edited by a moderator: Nov 13, 2008
    brodricj, Nov 13, 2008
    #9
  10. gonzales

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    It just means create a file called "test.php" in that directory.

    You can use a text editor.. such as "TextEdit" (which you'll find in the Utilities folder).. just make sure when you save the file

    a) you save it as plain text, not rich text
    b) you have the extension .php, not .php.txt (sometimes textedit seems to like to add .txt on the end.. even if you type in an extension).

    Nick
     
    NickD, Nov 13, 2008
    #10
  11. gonzales

    brodricj

    Joined:
    Mar 27, 2007
    Messages:
    117
    Likes Received:
    0
    Location:
    Perth
    This is still very confusing. Where I'm at:

    1. I made a file called "test.php" in which is written <?php phpinfo() ?> and dropped it into the Sites folder.

    2. In the Apache folder I renamed "index.html.en" to "index.html.old"

    3. I created a new file "index.php" put it in the Apache folder and dropped into it the following code:

    <?php

    $HTBase = "/Library/Webserver/Documents";
    $Photos = "photophrame";
    $Dir = "$HTBase/$Photos";
    $LastOneName = "lastone.dat";
    $LastOnePath = "$Dir/$LastOneName";

    global $Dir;
    global $LastOneName;


    // Make the record of where we got to if it does not exist
    if (! file_exists($LastOnePath))
    {
    $first = FindFirst();
    file_put_contents($LastOnePath, $first);
    }

    // Find the next file name. Getting to end of directory is messy.
    if ($dh = opendir($Dir))
    {
    // Get the last file name that was displayed
    $lastfile = file_get_contents($LastOnePath);
    $nextfile = $lastfile;

    while (true)
    {
    if (($nextfile = readdir($dh)) === false)
    {
    // Error - Found EOF - Should not happen
    closedir($dh);
    $nextfile = FindFirst();
    break;
    }

    // Read was not past end of dir, find next file
    if ("$nextfile" == "$lastfile")
    {
    // Found the name displayed previously, get next
    if (($nextfile = readdir($dh)) !== false)
    {
    // Not EOF, was it the name of our records?
    if ("$nextfile" != "$LastOneName")
    {
    // Was not the records file name, so its OK.
    closedir($dh);
    break;
    }
    else
    {
    // Yes it was, try next file or start again
    if (($nextfile = readdir($dh)) === false)
    {
    closedir($dh);
    $nextfile = FindFirst();
    break;
    }
    else
    {
    closedir($dh);
    break;
    }
    }
    }
    else
    {
    // Got to end, find and return first dir entry (should not happen)
    closedir($dh);
    $nextfile = FindFirst();
    break;
    }
    }
    }

    file_put_contents($LastOnePath, "$nextfile");

    $file_type = ltrim(strrchr($nextfile, "."), ".");

    header("Content-type: image/$file_type");
    readfile("$Photos/$nextfile");
    }

    function FindFirst()
    {
    global $Dir;
    global $LastOneName;

    $dh = opendir($Dir);

    while (($file = readdir($dh)) !== false)
    {
    if (($file[0] != '.')
    &&
    ($file != $LastOneName))
    {
    $nextfile = $file;
    break;
    }
    }
    closedir($dh);

    return $nextfile;
    }

    ?>

    4. After doing all that, in my browser I post http://localhost/ and it loads a web page "If you can see this, it means that the installation of the Apache web server software on this system was successful. You may now add content to this directory and replace this page...."

    5. Now in my browser when I post http://10.1.1.6/test.php I get "The requested URL was not found on this server" (10.1.1.6 is the IP of the Mac running Apache).

    6. I made a new folder "photophrame" and put in it a few pics scaled to 640x480 and for now have left it on the desktop.

    So where do I go from here?
     
    brodricj, Nov 13, 2008
    #11
  12. gonzales

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    The file you placed in your Sites folder will appear at

    http://10.1.1.6/~username/test.php

    If you want to access it at http://10.1.1.6/ then rather than putting it in the Sites folder, you need to put it in /Library/Webserver/Documents

    Nick
     
    NickD, Nov 14, 2008
    #12
  13. gonzales

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,392
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    Not sure - you probably should be using Apache 2, not apache 1. Not sure if thats appropriate for MAC but it is for other platforms.
     
    ashleigh, Nov 14, 2008
    #13
  14. gonzales

    brodricj

    Joined:
    Mar 27, 2007
    Messages:
    117
    Likes Received:
    0
    Location:
    Perth
    I'm now trying a Windows (Vista) instal, as this computer will always be on at home for CTC to access the photophrame folder. I have done everything as per the original post (apache install tested OK), however I can't get the photophrame working in PICED. Regarding the naming of the index.php file, when I check the properties of that file it says index.php.txt - might this be causing the problem?? Windows is forcing the .txt extension, I can't rename it with a .php extension.
     
    Last edited by a moderator: Nov 16, 2008
    brodricj, Nov 15, 2008
    #14
  15. gonzales

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,392
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    That is the cause of your problem.

    Rename the file from a command (DOS) prompt.

    OR:

    There is a setting in Windows "hide extensions for known file types", in windows explorer->Tools->Folder Options->View (in windows XP). Uncheck that option. you should then be able to rename the file to any type you want.
     
    ashleigh, Nov 16, 2008
    #15
  16. gonzales

    JJE

    Joined:
    Dec 9, 2004
    Messages:
    27
    Likes Received:
    0
    Thanks everyone for your help. I have tried it on a job but as soon as i transfer the project to the touch screen it stops working. The web component just sits there blank. When testing it on my computer just before transferring it displays the photos. The photo's are stored on the computer i am using to transfer to the touch screen by the way. I then tried it at home and the same. I am thinking its a networking issue. I am using http://192.168.0.7/index.php which works on the work network and in web browsers as the domain name etc. doesn't seem to work. Is this the issue?
    Is there anything that i can check. I haven't got a great deal of experience in this area so i will be flying blind. I want to try it at home before stuffing up the customers network. Any help would be fantastic.
     
    JJE, Mar 26, 2009
    #16
  17. gonzales

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,392
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    You may be using the wrong IP address on the customers network.

    Onthe customer network, make sure DHCP is disabled for the customer PC, then give it a fixed static IP address outside the range of DHCP addresses.

    Typical (for example) IP addresses will be dished by a router or similar, usually as 192.168.0.X (where X is 1 to something... maybe 10, maybe 50, maybe more).

    Set up whatever is dishing out DHCP IP addresses to limit the upper end of the range to (say) 50.

    Then set te customer PC to (say) 192.168.0.100. Then make sure the CTC is set up to point to that address.

    The IP addresses you use at work are likely to be different to those on the customer site. Further, its very likely that at work your IP addresses come from DHCP.

    Rule of thumb: anytime you want an IP device to get STUFF from another IP device, then the one serving up the STUFF ***must*** have a fixed IP. If its using DHCP it can change. So you walk off the site and it works, then you get a call week later saying it doesn't.
     
    ashleigh, Mar 26, 2009
    #17
  18. gonzales

    JJE

    Joined:
    Dec 9, 2004
    Messages:
    27
    Likes Received:
    0
    Thanks Ashliegh. Yeah i know that the IP addresses need to be right and i have done that but i think the firewall settings on the router are prohibiting the touch screen from accessing the designated IP address of the computer holding the photos. I have been playing around with it at home but can't seem to get it to work. Is there anything else you could suggest i check? Thanks in advance.
     
    JJE, Mar 30, 2009
    #18
  19. gonzales

    JJE

    Joined:
    Dec 9, 2004
    Messages:
    27
    Likes Received:
    0
    I have been playing a bit more and it seems that when i toggle windows firewall on and off i seem to enable and disable the photos being displayed on the touch screen. Is there a way of opening a port just for the photo's to display without turning firewall protection off completely?
     
    JJE, Mar 30, 2009
    #19
  20. gonzales

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You will need to open port 80 in the firewall. The method of doing this depends on the particular firewall you have.

    It is possible that the firewall popped up a message about port 80 and you clicked on the "deny" button. In this case you will need to find that firewall "rule" and delete it.

    Some firewalls allow you to permit all access between particular devices. If you add the colour C-Touch IP Address to this list, that may also work.
     
    Darren, Mar 31, 2009
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.