Setting X position over HTTP...

Talk about YBoxen, widgets, Propeller hacking, etc!

Moderators: adafruit_support_bill, adafruit

Setting X position over HTTP...

Postby iamalsohere » Sun Dec 28, 2008 8:51 am

Excellent kit (thankyou!), i built mine on christmas day and it worked perfectly! I followed the soldering guide and there are a few omissions but easy enough to work out.

Anyway, i've been working on a PHP class which wraps all of the formatting functions for the text output (so I can use it with the infowidget), and everything works (CRLF, Colours, clear screen, goHome etc) except for setting the column position (i.e. X axis) of the cursor. I can't seem to get it working properly - the text driver just displays symbols on the screen where the code should be changing the position. Changing the row/Y position is fine!

I checked out the tv_text.spin file and i can't see anything wrong in the code, and i can't see anything wrong in my PHP code either. Any pointers?

I'll upload the code for my PHP class when i'm done :)
iamalsohere
 
Posts: 3
Joined: Sun Dec 28, 2008 8:43 am

Re: Setting X position over HTTP...

Postby darco » Fri Jan 02, 2009 1:28 am

I'm not aware of any problems that TV_Text.spin has with the X position... Perhaps somehow the characters are being translated strangely? Have you tried setting the X position from within a spin program?
User avatar
darco
 
Posts: 118
Joined: Wed Jun 04, 2008 6:54 pm
Location: Campbell, CA

Re: Setting X position over HTTP...

Postby iamalsohere » Fri Jan 02, 2009 2:30 pm

Thanks for the reply draco - it seems to work fine from within a proper .spin program, just not when used in the infowidget. I'll persevere I guess (i'm writing an RSS reader which currently uses a modified infowidget and PHP script, might have to move it all to run inside a spin program!)

Heres a small bit of the class i'm developing...
Code: Select all
PHP5 code:

class ybox2_display {

   /*
     '' $00 = clear screen
      '' $01 = home
      '' $08 = backspace
      '' $09 = tab (8 spaces per)
      '' $0A = set X position (X follows)
      '' $0B = set Y position (Y follows)
      '' $0C = set color (color follows)
      '' $0D = return
    */
   
   const CHR_CLEAR_SCREEN = 0x00;
   const CHR_HOME         = 0x01;
   const CHR_BACKSPACE    = 0x08;
   const CHR_TAB          = 0x09;
   const CHR_SET_X        = 0x0A;
   const CHR_SET_Y        = 0x0B;
   const CHR_SET_COLOUR   = 0x0C;
   const CHR_CRLF         = 0x0D;
   
   const SCREEN_COLS      = 40;
   const SCREEN_ROWS      = 13;
   const SCREEN_TABWIDTH  = 7;
   
   private $pos_x = 0;  // aka col pos
   private $pos_y = 0;  // aka row pos

   public function crlf() {
      echo chr(self::CHR_CRLF);
      $this->pos_x = 0;
      $this->pos_y++;
   }
   
   public function goHome() {
      echo chr(self::CHR_HOME);
      $this->pos_x = 0;
      $this->pos_y = 0;
   }
   public function set_x($x) {
      echo chr(self::CHR_SET_X);
      echo chr(intval($x));
      $this->pos_x=$x;
   }
   public function set_y($y) {
      echo chr(self::CHR_SET_Y);
      echo chr(intval($y));
      $this->pos_y=$y;
   }
   

  /**
    * Writes a whole line of text and resets cursor position to next line
    *
    * @param string $line
    * @param int $pad_type (STR_PAD_LEFT, STR_PAD_BOTH, STR_PAD_RIGHT)
    */
   public function writeLine($line,$pad_type=STR_PAD_RIGHT) {
      
      // chop string at max length
      if (strlen($line)>self::SCREEN_COLS) { $line=substr($line,0,self::SCREEN_COLS); }
      
      echo (str_pad($line,self::SCREEN_COLS,' ',$pad_type));
      $this->pos_x = 0;
      $this->pos_y = $this->pos_y+1;
   }
}
iamalsohere
 
Posts: 3
Joined: Sun Dec 28, 2008 8:43 am

Re: Setting X position over HTTP...

Postby darco » Fri Jan 02, 2009 3:16 pm

Something must be getting mangled between the PHP script and when the bytes are being fed to the TV_Text object.

I would recommend modifying the infowidget temporarily to print out the hex value of the incoming characters so that you can verify that the bytes aren't being mangled somehow.
User avatar
darco
 
Posts: 118
Joined: Wed Jun 04, 2008 6:54 pm
Location: Campbell, CA

Re: Setting X position over HTTP...

Postby iamalsohere » Sat Jan 03, 2009 3:52 am

Good idea! will let you know how it pans out...
iamalsohere
 
Posts: 3
Joined: Sun Dec 28, 2008 8:43 am


Return to YBox2

Who is online

Users browsing this forum: No registered users and 0 guests

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


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
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[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


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