element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Wireless Power - Beyond the Phone
  • Challenges & Projects
  • Design Challenges
  • Wireless Power - Beyond the Phone
  • More
  • Cancel
Wireless Power - Beyond the Phone
Blog Beyond the Phone - eLIST progress 5 (Webserver)
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: mcb1
  • Date Created: 26 Jun 2014 12:41 PM Date Created
  • Views 684 views
  • Likes 2 likes
  • Comments 0 comments
  • texas-instruments
  • epaper
  • würth
  • beyond_the_phone
  • raspberry-pi
  • kobo
  • eink
  • wireless-power
Related
Recommended

Beyond the Phone - eLIST progress 5 (Webserver)

mcb1
mcb1
26 Jun 2014

eList

 

The concept is the device sits on the charger and receives entries to the list using a wireless solution.

Entries can be added or subtracted using a web server application, that formats and transmits the list contents to the eLIST.

see the previous posts  Beyond the Phone - eLIST progress 4 (Transmitter modifications) Beyond the Phone - eLIST progress 3 eLIST progress 2 , eLIST progress , eLIST - KOBO Touch , 5W Load Schematic

 

Webserver

I'm using a Raspberry Pi as the webserver for this application.

It connects to the Wireless Charging Transmitter to detect when the eLIST is present, and changes the home page accordingly.

 

It's been an interesting Challenge, as I wanted to minimize the 'add-ons' to both the eLIST device and the RPi, which meant a mixture of html and php to do what I wanted.

This has been the most frustrating and time consuming part of the exercise, but I have learnt a lot (apart from my coding skills suck).

 

I intend to detail the complete setup of the RPi, but not tonight as I have other things to sort out for something not related to this project.

I also wanted to start with a fresh install, as I have loaded a few things I think aren't necessary.

 

The index page is a simple menu with the messages showing.

Its been optimized to fit the KOBO screen, so is a little small on the big screen.

 

image

 

The index.php script is

<html>
<head>
<META http-equiv="REFRESH" content="5; url=index.php">
<title>Welcome to eLIST</title>
</head>
<body>
<h2><strong>Welcome to eLIST</strong></h2>
What would you like to do ?<br>
<hr>
<small>Leave a message </small><a href="Message.php"> Messages </a>.<small>    Show List </small><a href="ShopList.php">List </a>.
<br>
<hr>
<?php
for($i=1; $i < 5; $i++)
{
  $f = 'Message' . $i . '.txt';
  if (file_exists($f))
  {
    print '<small>' . '  Message ' . $i . ' contents ' . ' </small>' . '<br>';
    print '<textarea readonly rows="2" cols="30">';
    $file = fopen($f, "r");
    while(!feof($file))
    {
  
      $filetext = fgets($file);
      print $filetext;
    }
    fclose($file);
    print '</textarea>';
    print '<br>';
   }

}

?>
<img src="/images/element14logo.jpg" alt="element14" width="180" height="46">
<img src="/images/ti_logo_jan31.gif" alt="Texas Instruments" width="123" height="31">
<img src="/images/we_logo_jan31.gif" alt="Wurth" width="68" height="31">
</body>
</html>

 

If you choose to add or change a Message, the link takes you to Message.php

 

image

 

The message creation script is another php that caused me grief due its peculiar methods and my lack of skills.

I finally resorted to dealing with it as 4 files, and repeating the script. (not elegant but functional)

 

<h3>This allows you to enter and store a message for the eLIST screen.</h3>
<hr>

<P>


<h4><strong>Enter your message</strong></h4>


<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<strong>  Message 1 </strong><p>

<?php

  $f = 'Message1.txt';
  if (file_exists($f))
  {
    print '<TEXTAREA name="Message1text" rows="3" cols="40">';
    $file = fopen($f, "r");
    while(!feof($file))
    {
      $filetext = fgets($file);
      $Message1text = $filetext;
      echo $Message1text;
    }
    fclose($file);
    print '</textarea><br>';
  }

?>

<input type ="submit" name = "Message1" value ="send"> your message.<br>

<hr>
<strong>  Message 2 </strong><p>

<?php

  $f = 'Message2.txt';
  if (file_exists($f))
  {
    print '<TEXTAREA name="Message2text" rows="3" cols="40">';
    $file = fopen($f, "r");
    while(!feof($file))
    {
      $filetext = fgets($file);
      $Message2text = $filetext;
      echo $Message2text;
    }
    fclose($file);
    print '</textarea><br>';
  }

?>

<input type ="submit" name = "Message2" value ="send"> your message.<br>

<hr>
<strong>  Message 3 </strong><p>

<?php

  $f = 'Message3.txt';
  if (file_exists($f))
  {
    print '<TEXTAREA name="Message3text" rows="3" cols="40">';
    $file = fopen($f, "r");
    while(!feof($file))
    {
      $filetext = fgets($file);
      $Message3text = $filetext;
      echo $Message3text;
    }
    fclose($file);
    print '</textarea><br>';
  }

?>

<input type ="submit" name = "Message3" value ="send"> your message.<br>

<hr>
<strong>  Message 4 </strong><p>

<?php

  $f = 'Message4.txt';
  if (file_exists($f))
  {
    print '<TEXTAREA name="Message4text" rows="3" cols="40">';
    $file = fopen($f, "r");
    while(!feof($file))
    {
      $filetext = fgets($file);
      $Message4text = $filetext;
      echo $Message4text;
    }
    fclose($file);
    print '</textarea><br>';
  }

?>

<input type ="submit" name = "Message4" value ="send"> your message.<br>

<hr>
<?PHP

    if(isset($_POST['Message1']))
       {
      $MessageText = $_POST['Message1text'];
      $file = fopen("Message1.txt","w");
      $fileokay = fwrite($file,$MessageText);
      fclose($file);
      if ($fileokay != false)
      {
            $page = $_SERVER['PHP_SELF'];
         echo '<meta http-equiv="Refresh" content="0;' . $page . '">';
         }
    }
    if(isset($_POST['Message2']))
       {
      $MessageText = $_POST['Message2text'];
      $file = fopen("Message2.txt","w");
      $fileokay = fwrite($file,$MessageText);
      fclose($file);
      if ($fileokay != false)
      {
            $page = $_SERVER['PHP_SELF'];
         echo '<meta http-equiv="Refresh" content="0;' . $page . '">';
         }
    }
    if(isset($_POST['Message3']))
       {
      $MessageText = $_POST['Message3text'];
      $file = fopen("Message3.txt","w");
      $fileokay = fwrite($file,$MessageText);
      fclose($file);
      if ($fileokay != false)
      {
            $page = $_SERVER['PHP_SELF'];
         echo '<meta http-equiv="Refresh" content="0;' . $page . '">';
         }
    }
    if(isset($_POST['Message4']))
       {
      $MessageText = $_POST['Message4text'];
      $file = fopen("Message4.txt","w");
      $fileokay = fwrite($file,$MessageText);
      fclose($file);
      if ($fileokay != false)
      {
            $page = $_SERVER['PHP_SELF'];
         echo '<meta http-equiv="Refresh" content="0;' . $page . '">';
         }
    }


?>
</form>
<p>
<p>


<br>

</body>
</html>

 

 

 

If you choose to alter the Shopping List

It runs the ShopList.php script, which pulls the data from Choice.txt.

This is a simple text file with a comma separator and 0 or 1 for items with a check against them.

The idea was you could arrange it in any order, and add items to it manually. ( I didn't have time to do something fancy for adding items ...)

Bread,0

Milk Green,1

Milk Blue,0

Marg,1

Ham,0

Cheese,0

Biscuits,0

Rasp Jam,0

Marmalade,0

Honey,1

Apples,1

Bananas,1

Minion Beer,1

 

The script numbers the entries and presents it in a simple form that allows you to click on the checkbox or the text.

image

Once you press Send, the form refreshes and shows the contents (mainly while I was putting this together), and writes the choices back to Choice.txt.

It then reloads the page after 2 seconds.

 

<p>
<hr>

<h4>Show contents of Choice.txt</h4>
<hr>
<table style="width:300px">
<head>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
</head>
<?PHP
$file_handle = fopen("Choice.txt", "rb");
$ListCount = 1;
$Choice = array();
while (!feof($file_handle) )
{
  $lineA = fgets($file_handle);
  $partAa = explode(',', $lineA,2);

  if (strlen($partAa[0]>"1"))
  {
    $checktext = $partAa[0];
    print '<tr>';
    if ($partAa[1]==1)
      {
       print '<td>' . $ListCount . '</td> <td> <input type="checkbox" name="List[]" value= "' . $partAa[0] . '" id = "' . $partAa[0] . '" checked ="1" ><label for= "' . $partAa[0] . '"> ' . $partAa[0] .'</label></td>';
      }
    else
      {
       print '<td>' . $ListCount . '</td> <td> <input type="checkbox" name="List[]" value="' . $partAa[0] . '" id = "' . $partAa[0] . '"><label for= "' . $partAa[0] . '"> ' . $partAa[0] .'</label></td>';
      }
    print '</tr>';
    $Choice[$ListCount] = $partAa[0];
    ++$ListCount;
  }

}

fclose($file_handle);

print '</table> <p> <p>';

print '<input type="submit" name= "formSubmit" value="Send">';
print '<input type="submit" name= "formCancel" value="Cancel"> <br>';

print '</form>';

print '<hr>';

    if(isset($_POST['formSubmit']))
       {
        $Entry = $_POST['List']; 

        if(empty($Entry))
              {
               echo ("<p>The eLIST is empty.</p>\n");
        }
              else
              {
                     $N = count($Entry);

            echo("<p>The eLIST has $N entries: <br>");
            for($i=0; $i < $N; $i++)
            {
            echo ("$Entry[$i] <br>");
            }
            echo("</p>");
          }

        $file_handle = fopen("Choice.txt", "w");
        for($i=1; $i <$ListCount; $i++)
        {
            $txt = $Choice[$i] . "," . "0\n";
            for($j=0; $j < $N; $j++)
            {
           
              if ($Choice[$i] == $Entry[$j])
              {
                $txt = $Choice[$i] . "," . "1\n";
              }
            }
             fwrite($file_handle, $txt);
             echo $txt;
             echo ('<br>');
         
        }
        fclose($file_handle);
              print '<META http-equiv="REFRESH" content="2; url=ShopList.php">';
       }
    
?>

<br>
<hr>
</body>
</html>

 

These processes are all on the server side, and the intention was you would interact with any device, but the pages have been designed to allow the KOBO to also interact.

 

 

For the eLIST page, I presented a page that simply showed the checked content of Choice.txt with the checkboxes unticked.

image

 

The script eLIST.php presents it, so again any device could be used to uplift the file from the webserver.

 

<p>


<h4>eLIST</h4>
<hr>

<?PHP
$file_handle = fopen("Choice.txt", "rb");
$ListCount = 1;

while (!feof($file_handle) ) 
{
  $lineA = fgets($file_handle);
  $partAa = explode(',', $lineA,2);

  if (strlen($partAa[0]>"1"))
  {

    if ($partAa[1]==1)
      { 
       print '<input type="checkbox" name="List[]" value= "' . $partAa[0] . '" id = "' . $partAa[0] . '" ><label for= "' . $partAa[0] . '"> ' . $partAa[0] .'</label> <br>';
      }
    ++$ListCount;
  }

}

fclose($file_handle);
print '</form>';
?>

<br>
</body>
</html>

 

Because the KOBO can't use the Web Browser to open a file on its own storage, it needs to pick it up from the server.

However once it has that file, you can drop the wireless connection and put it to sleep, and it will still behave as if you are online.

This means you can tick the items on the eLIST as you put them in the trolley.

 

 

Conclusions

This has been a very interesting challenge, and I'm pleased I was chosen to take part.

I have a few things to complete :-

  • Detection of charging on the webserver.
  • Changing the Index page if the eLIST device is not on the charger
  • Change the charging receiver for the Wurth slim version (it hasn't arrived)
  • Build the stand (when the receiver arrives)
  • Sort out a means to add entries via the webserver.

 

 

Once again I want to thank the sponsors Wurth, Texas Instruments and element14

Because its really, really late this will be the last blog before the competition closes (today).

 

If you wish to vote the poll is here but not open for long  Community Choice - Beyond the Phone Challenge

 

edit Pictures are here Beyond the Phone - eLIST progress 6 - pictures

 

cheers

Mark Beckett

 

edit 01/07/14  missing " in the eLIST.php script which prevented the word from being selected to change the checkbox.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube