Shop OBEX P1 Docs P2 Docs Learn Events
Arbitrary string length and LCD help. — Parallax Forums

Arbitrary string length and LCD help.

firestorm.v1firestorm.v1 Posts: 94
edited 2006-01-17 14:08 in BASIC Stamp
I am looking for a snippet of code that will help me determine the length of an arbitrary length string.
The input is a string that is entered from the debug port.

I bought a Basic Stamp from Radioshack (one of those "What is a Microcontroller" kits) to keep myself entertained at work. It is working quite well. I haven't found anything to do with it as of yet, but I have a few ideas.


On a similar vein, what proceedures do you recommend for keeping the LCD at bay? I looked at the LCD code for included with the parallax 2x16LCD (which is very similar to my 2x20 display.)

The code for the test takes up roughly 2/3 of the available RAM. Do you have any suggestions as to better optimizing the code for the LCD? (even if all i can do is turn this into a serial LCD)?

Thanks for your suggestions.

Matt

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-16 21:17
    If you take in one character at a time you can keep count yourself -- just use CR as the terminator to end the input and make sure you have a buffer big enough to hold the string.

    It's difficult to give guidance on optimizing your program unless you actually post it....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-01-16 21:54
    I haven't written all the code I want to do yet, but the very basic code to control the LCD by itself chewed up half the RAM space and this has me concerned about the size of available space to play in. What I was wanting to do was something with a password style lockout, where the LCD prompts for a password, there are buttons used for input (Up, Down, Next,Enter) and a relay or other device to work with other pieces of equipment, HVAC, line current appliances, lighting, door locks, etc...

    The issue is I'm having a heckuva time trying to control the LCD. Since I don't have much money, (the LCDs were something I found embedded in another device) I can't afford the luxury of one of the basic stamps that supports the LCDCMD functions. :P

    THanks for the quick reply, when I come up with the code, I'll definitely post it here. [noparse]:)[/noparse]
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-16 22:46
    firestorm -

    Do yourself a favor, and take a run over here:
    http://www.elabinc.com/

    Punch up the EDE IC's and take a look at the "LCD Screen Control" IC's. The EDE-702 is probably your best bet, if you're short on money at the moment.

    For about $9.00 US you can turn your existing parallel LCD into a serial LCD and remove 90% of the parallel LCD support code in your program. That gets replaced by a SEROUT statement whenever you want to display something.

    Regards,

    Bruce Bates
  • ForrestForrest Posts: 1,341
    edited 2006-01-17 00:35
    Here's another popular serial LCD controller - kit#107 for $4.95 www.phanderson.com/lcd106/lcd107.html
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-01-17 14:08
    I wanted to thank you all for helping me out with the suggestions that you all ahve provided.

    I am very excited to announce that after getting some coffee in me yesterday that I was actually able to make sense of the sample Parallax code and I am now able to control my LCDs.. [noparse]:)[/noparse]

    After learning how the DATA statements and how to READ from the memory I am making excellent progress in working with my basic stamp and should have a first version cranked out sometime this week.

    One thing that I think I have bypassed for now but will probably haunt me later is that I haven't come across anything in the pbasic code that deals with strings other than the DATA and READ statements. My scenario:

    I am trying to read from some user-generated text from a prompt created on the serial port.
    Ex:
    STAMP: Please enter your name:
    User: My name is Matt.

    Is there a way to sequentially read each letter from the string input listed above and process it individually? In BASIC, there was LEFT$, MID$ and RIGHT$ that would read certain positions from the string as well as LEN$ which would return the length of the string. Is there anything like this in PBASIC or do I need to write the memory of the string input to RAM before I can read it out again?

    Your thoughts are extremely appreciated. I will be keeping this thread linked so I can pull off some of the information for those LCD controllers. [noparse]:)[/noparse] Although my LCDs have a 2x20 display and have pin headers with 2 rows of 7 pins each, I have already wired up an LCD "converter board" for my basic stamp and wiring up another converter shouldn't be too difficult. [noparse]:)[/noparse]

    If yall are interested in the code for my parental lockout device of doom, please let me know, once I get all the bugs worked out, I'll post the code here. So far it's limited on features, but I'm up to this as of now:

    1: 4 digit code stored in Flash.
    2: configuration for switch behaviour: Toggle, On 1 seccond, Off one seccond
    3: Serial port allows for password reset.
    4: Will reset to last port state if power is lost.

    Things I was thinking of adding:

    1: Multiple codes (only admin codes can access configuration)
    2: Some kind of logging feature... however with the lack of an RTC on the basic stamp, I don't think I can pull this off.. [noparse]:([/noparse]

    Any suggestions?
    2:
Sign In or Register to comment.