Bit-o-help for Info-widget

Talk about YBoxen, widgets, Propeller hacking, etc!

Moderators: adafruit_support_bill, adafruit

Bit-o-help for Info-widget

Postby JuJuBee » Wed Apr 29, 2009 3:40 pm

okay - I need a collective bit-o-help with the info widget. I understand that the widget goes to a webpage that only outputs text and uses the TV object to display. Here are my questions:

1. How can I create my own webpage that only creates text (without HTML source code) easily, just like the weather page. My thoughts are, I want to have a .txt file in webroot and be able to just edit the .txt file to update the output on webpage - thus the output from the tv object. The info widget would poll the webpage - and whatever the backend process would be - could deliver the contents of the .txt file.

2. Am i on the wrong path? Is there an easier way to perform this?

3. what line in the info widget works with the output from the webpage (i know...sounds like a newbie - i am) - so I can take a look at the formatting side of spin.

JuJuBee
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 4:32 pm

Re: Bit-o-help for Info-widget

Postby adafruit » Sat May 02, 2009 6:43 pm

you could do that, which would work great. or have a php script do it 'on the fly'
whichever! the ybox doesnt know, it just dumps whatever it finds
User avatar
adafruit
 
Posts: 10546
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Bit-o-help for Info-widget

Postby JuJuBee » Sat May 09, 2009 10:58 pm

Okay - looking at the info widget weather page. Where does the output get the information to turn the first line green and have a solid white line underneath the green header? I am thinking it is in the info widget - I cannot find this anywhere in the prop code? Or is it an output from the PHP scripting and the propeller understands the codes for lines and colors...no....no...no...it has to be somewhere coded into the info widget.

Where would I look to change the color from green to something else - what does that command look like? Are there imbedded TV_Text codes in the PHP script that actually tell what the screen to do?

I have tried to hack the prop file to change the parameters from green to something else - to no avail (can't even find the right line - I did find other cool hacks). When the widget accesses the output of the server side script - the screen goes to a home position and clears. Is there a way to stop this?

Ladyada - would you be willing to share your PHP server script code for the weather widget - for deconstruction purposes?


The JuJuBee
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 4:32 pm

Re: Bit-o-help for Info-widget

Postby thetribster » Sun May 10, 2009 10:15 pm

I had some problems getting the infowidget working again after trying several other binaries. You can look at what is coming to the yBox by just launching directly in the browser and then looking at the source, like this:

http://www.ladyada.net/infowidget/?zipcode=19426

then right click and View Page Source. You'll see some funky characters that are being sent to the SPIN app. It isn't clear how the spin app handles this yet - I have to review the parallax docs to understand the code.

I agree, though - I like to see the server side code being executed.
thetribster
 
Posts: 28
Joined: Sat May 09, 2009 12:30 am

Re: Bit-o-help for Info-widget

Postby Presence » Mon May 11, 2009 2:09 am

I was exploring how to play with the Infowidget myself just last week, and below is an example PHP script I came up with. This script was to test how to draw lines and see what colors were loaded in the widget's palette.

In PHP, you can select a color by doing:
<? echo chr(0xC)."7"; // Color Palette Selection, #7 ?>
Instead of using a <br> for a new line on your YBox2, use:
<? echo chr(0xD); // new line ?>

Feel free to take a look at my test page's PHP source:
http://y.irev.net/20090501.phps
User avatar
Presence
 
Posts: 11
Joined: Wed Apr 29, 2009 7:37 pm
Location: Las Vegas, NV

Re: Bit-o-help for Info-widget

Postby adafruit » Mon May 11, 2009 10:56 am

thanks that is very helpful!
User avatar
adafruit
 
Posts: 10546
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Bit-o-help for Info-widget

Postby JuJuBee » Mon May 11, 2009 5:37 pm

That is excellent!! Very informative.

Question: Does the code that you used here - <? echo chr(0xD) will that work say in Cold Fusion - or is that just a PHP coding syntax.

I gather 0xD=$0d (return), but does that translate the same in other scripts? If not, how would I go about finding the proper conversion of the codes?

Thanks for the excellent post!

JuJuBee
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 4:32 pm

Re: Bit-o-help for Info-widget

Postby Presence » Mon May 11, 2009 11:07 pm

JuJuBee wrote:Question: Does the code that you used here - <? echo chr(0xD); ?> will that work say in Cold Fusion - or is that just a PHP coding syntax.
I am not a ColdFusion user, so I'm not terribly sure about this, but from what I have read, Cold Fusion does not have a syntax to create hexadecimal numbers. However, we both know that "0xD" in hex is really decimal "13". So, I think in cold fusion, you'd do something like:

<cfexecute name="echo #chr(13)# >
or
#chr(13)#

for a new line. Again, I do not know how ColdFusion "goes", but I'm thinking something like that will get you a newline character. My example in the previous post was in PHP only.
User avatar
Presence
 
Posts: 11
Joined: Wed Apr 29, 2009 7:37 pm
Location: Las Vegas, NV

Re: Bit-o-help for Info-widget

Postby JuJuBee » Sat May 16, 2009 2:17 pm

Presence - I used your code syntax in PHP - and got excellent results. Does anyone know where to find the complete chr() list to see actually what the Propeller can output?

Also - I think the output is first class - the only problem is the lack of a text wrapping feature. Anyone have ideas on how to incorporate a text wrap feature. Some of the output is terribly cut in half from one line to the other.

JuJubee
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 4:32 pm

Re: Bit-o-help for Info-widget

Postby Presence » Sat May 16, 2009 3:03 pm

JuJuBee wrote:Does anyone know where to find the complete chr() list to see actually what the Propeller can output?
If you have the Parallax "Propeller Tool" software, you can hit the "Help" menu and select "View Character Chart". When you hover your mouse cursor over a character, the preview window will tell you what the character's DECimal and HEX numbers are. The Propeller Tool is freely available at http://www.parallax.com/tabid/442/Default.aspx however Parallax doesn't seem to offer a Mac or Linux version of the application.

If you wanted, however, you could "cheat" and use the Infowidget and write a quick PHP script to print every character. I'd suggest starting at character ID# 14, since characters 13 and lower are "special". (13 being new line, 12 = color, 11 = "Y" coordinate, 10 = "X" coordinate, 9 = tab, 8 = backspace, 1 = home, 0 = blank screen)
Code: Select all
<?
   for ($ID = 14; $ID <= 255; $ID++) {
      // Loop through each character ID 14 through 255 and print out: "ID number" = "character"
      echo $ID . "=" . chr($ID) . " ";
   }
?>
JuJuBee wrote:Also - I think the output is first class - the only problem is the lack of a text wrapping feature. Anyone have ideas on how to incorporate a text wrap feature. Some of the output is terribly cut in half from one line to the other.
Well, since we know there are 40 columns in tv_text, you could buffer each line you intend to print. In fact, searching Google for "PHP word wrapping" leads to: http://www.namesuppressed.com/syneryder ... wrap.shtml which provides a short example script. Looks pretty great!
User avatar
Presence
 
Posts: 11
Joined: Wed Apr 29, 2009 7:37 pm
Location: Las Vegas, NV

Re: Bit-o-help for Info-widget

Postby JuJuBee » Sat May 16, 2009 5:03 pm

Presence:

That's great! Now, just thinking this through - if I incorporate the text wrap script, will that inject <br> into the output or just blank spaces? If it injects the carriage return, then the <br> will be printed to the screen.

Whatcha think?

JuJuBee
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 4:32 pm

Re: Bit-o-help for Info-widget

Postby Presence » Sat May 16, 2009 5:39 pm

Looking at the script at the URL we posted earlier, it seems that the author of the script is formatting the word-wrapped lines by using the ASCII characters for "carriage return" (\r) and "new line" (\n). You could edit the script and remove the "\r\n" stuff and put in "char(13)", maybe? Of course, I haven't tried any of this, but does look interesting!

I'm sure, with some time and effort, one could update the infowidget with internal word-wrapping ability. Taking a look at the example objects in Spin, like the util_strings.spin object, its not impossible. There isn't something like regular expressions in Spin from what I can tell, but a day's effort would get somewhere. There's also the "Format" object in the Parallax Object Exchange at http://obex.parallax.com/objects/230/ that seems to have some functions that could be useful.
User avatar
Presence
 
Posts: 11
Joined: Wed Apr 29, 2009 7:37 pm
Location: Las Vegas, NV

Re: Bit-o-help for Info-widget

Postby JuJuBee » Sat May 16, 2009 10:50 pm

That makes sense - now in your script example you have echo chr(0xD) for carriage return - but spin and your last post uses chr(13).

I am attempting to script that in - like \r\n, but which one would I want to insert?

I am not sure of the difference?

Edit: Okay - I tried this and it works: $m = wordwrap($field1, 40, chr(0xd),true);

This above line inserts a carriage return no more than 40 columns - looking at the source after the script processed it - looks great with no split words!


JuJuBee
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 4:32 pm

Re: Bit-o-help for Info-widget

Postby Presence » Sun May 17, 2009 1:11 am

Well, isn't that a thing? There's a wordwrap function right in PHP itself!
http://php.net/wordwrap
I feel like a dork, thats a good find, JuJuBee. That there is far more efficient!

Hook us up with a screen shot of what you're building, I'm totally curious now. :wink:
User avatar
Presence
 
Posts: 11
Joined: Wed Apr 29, 2009 7:37 pm
Location: Las Vegas, NV

Re: Bit-o-help for Info-widget

Postby JuJuBee » Tue May 19, 2009 3:17 pm

Thanks - well the page is not all that impressive but it works. It is a messaging system that I am trying to make as a proof of concept.

My concern is, sometimes the unit will just up and reboot! Hey, do ya think there is a way for it to hold more text information than just one page. Meaning, when it senses it is going to scroll the page, it instead will buffer to "Page 2" then after a bit o' time, it goes back to "Page 1". I think that is not a server based control - but a reworking of the infowidget altogether.

JuJuBee
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 4:32 pm


Return to YBox2

Who is online

Users browsing this forum: mibignistinly and 1 guest

Stuff to buy from the Adafruit store and links to product documentation!


New Products [114]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
Android[6]
 
BeagleBone[23]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]