Serout question


Closed Thread
Results 1 to 4 of 4

Thread: Serout question

  1. #1

    Default Serout question

    I have a 4x40 LCD from NewHaven. The first line is a header that changes based on a few conditions. The second, third, and fourth row contain time or rpm variables that can be edited by the user.

    I have the code working pretty good yet I want to format the variables based on the type of data, meaning time or rpm. With time I want to have X.XXX and rpm X,XXX.

    I can parse out the second and thousand rpm values plus the remaining time or RPM. My question is how can I minimize the SEROUTS. Can I write the formatted time/rpm to an Array variable that contains the decimal or comma then SEROUT the array values? Instead of having a bunch of If/Thens that direct the code to a specific SEROUT?

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Tobias View Post
    I have a 4x40 LCD from NewHaven. The first line is a header that changes based on a few conditions. The second, third, and fourth row contain time or rpm variables that can be edited by the user.

    I have the code working pretty good yet I want to format the variables based on the type of data, meaning time or rpm. With time I want to have X.XXX and rpm X,XXX.

    I can parse out the second and thousand rpm values plus the remaining time or RPM. My question is how can I minimize the SEROUTS. Can I write the formatted time/rpm to an Array variable that contains the decimal or comma then SEROUT the array values? Instead of having a bunch of If/Thens that direct the code to a specific SEROUT?
    serout portb.0,t2400,[$FE,2,"time is",MyVar.0,":",MyVar.1,":",MyVar.2] or something to that effect
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Sep 2007
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    You can easily store a single character (comma or decimal point) in a byte variable.

    Code:
    IF type = rpm THEN
        delimiter = ","
        value = rpmvalue
    ELSE
        delimiter = "."
        value = timevalue
    ENDIF
    
    DEBUG  DEC (value/1000), delimiter, DEC3 value
    Charles Leo
    microEngineering Labs, Inc.
    http://melabs.com

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Thanks that makes it alot simpilier.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26
  5. Serout Question
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd April 2005, 02:21

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts