Bit-o-help for Info-widget

Talk about YBoxen, widgets, Propeller hacking, etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 5:32 pm

Bit-o-help for Info-widget

Post by JuJuBee »

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

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Bit-o-help for Info-widget

Post by adafruit »

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

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

Re: Bit-o-help for Info-widget

Post by JuJuBee »

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

thetribster
 
Posts: 28
Joined: Sat May 09, 2009 1:30 am

Re: Bit-o-help for Info-widget

Post by thetribster »

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.

User avatar
presence
 
Posts: 11
Joined: Wed Apr 29, 2009 8:37 pm

Re: Bit-o-help for Info-widget

Post by presence »

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

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Bit-o-help for Info-widget

Post by adafruit »

thanks that is very helpful!

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

Re: Bit-o-help for Info-widget

Post by JuJuBee »

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

User avatar
presence
 
Posts: 11
Joined: Wed Apr 29, 2009 8:37 pm

Re: Bit-o-help for Info-widget

Post by presence »

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.

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

Re: Bit-o-help for Info-widget

Post by JuJuBee »

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

User avatar
presence
 
Posts: 11
Joined: Wed Apr 29, 2009 8:37 pm

Re: Bit-o-help for Info-widget

Post by presence »

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) . " ";
   }
?>
[/color]
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!

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

Re: Bit-o-help for Info-widget

Post by JuJuBee »

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

User avatar
presence
 
Posts: 11
Joined: Wed Apr 29, 2009 8:37 pm

Re: Bit-o-help for Info-widget

Post by presence »

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.

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

Re: Bit-o-help for Info-widget

Post by JuJuBee »

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

User avatar
presence
 
Posts: 11
Joined: Wed Apr 29, 2009 8:37 pm

Re: Bit-o-help for Info-widget

Post by presence »

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:

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

Re: Bit-o-help for Info-widget

Post by JuJuBee »

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

Locked
Please be positive and constructive with your questions and comments.

Return to “YBox2 (discontinued)”