Shop OBEX P1 Docs P2 Docs Learn Events
writing to the lcd... — Parallax Forums

writing to the lcd...

freekfreek Posts: 22
edited 2005-04-26 13:47 in BASIC Stamp
I'm trying to modify the·lcd demo program that came w/ the stampworks kit and the ds1620 code here: http://www.emesystems.com/OL2d1620.htm,·to display the temp on the lcd.· i understand how to write from eeprom, but can't get it to write directly to the lcd. i have a BS2, and the stampworks board.
i can get the temp out as a signed decimal (+/-###.##), i figured i would do somthing like a this (psudeo code):

char            VAR     Byte                    ' character sent to LCD
index           VAR     Byte                    ' loop counter
temp VAR byte(9)                                'temperature (20.33)
degC VAR Word                                   'temp from ds1620
whole VAR Word                                  '=degC/100
decimal VAR Word                                '=degC
 
   
temperature= temp from ds1620 + "8"             'temperature (20.33*)                      
 
ReadTemp:
  char=tmperature(index)
  IF (char = "*") THEN Msg_Done                   ' if *, message is complete
  GOSUB LCD_Write                               ' write the character
  index = index + 1                             ' point to next character
  GOTO ReadTemp

what i can't figure out is how to read whole and decimal into the temperature array.

can i do temperature(index)= whole.byte(abs(index-3)) and temperature(index)=whole.byte(abs(index-7))? so the above temp of 20.33 if hard coded would be:

temperature(0) = whole.byte(3) '0 padding
temperature(1) = whole.byte(2) '0 could be 120 degrees
temperature(3) = whole.byte(1) '2
temperature(4) = whole.byte(0) '0
temperature(5) = %2E 'dec point
temperature(6) = decimal.byte(1) '3
temperature(7) = decimal.byte(0) '3
temperature(8) = %2A '*


does this make sense...?

Will

Comments

  • freekfreek Posts: 22
    edited 2005-04-23 00:33
    after looking at the stuff for the appMod lcd, I think I have figured it out...

    I will post some stuff later.

    Will
  • freekfreek Posts: 22
    edited 2005-04-25 18:16
    ok, I'm stuck...
    posted code will output temp to the lcd.· the problem i'm having is the formating.· the lcd will read 0025.68 when the temp is 25.68.· i'm trying to get rid of the leading zeros.
    LCD_DEC:
      FOR idx = 3 TO 0        ' loop through digits  3210=0025
        char = (value DIG idx) + "0"    ' convert to ASCII
        'IF (char<>"0" AND (idx<> 3 OR 2)) THEN GOSUB LCD_Write 'thought this might work
                                                                'but if temp gets over 29.99 the
                                                                'lcd will read 29.99 then 3.999
                                                                'because of the overwrite
        GOSUB LCD_Write
      NEXT
      RETURN
     
    

    any thoughts...?

    Will
  • freekfreek Posts: 22
    edited 2005-04-26 13:47
    This may or may not be an elegant solution, it came to me after i posted:
    LCD_DEC:
      IF degC.BIT15 =1 THEN GOSUB Make_Neg
      FOR idx = 2 TO 0        ' ignore the 1st digit, i doubt i will see 1000 deg c temps
        char = (value DIG idx) + "0"    ' convert to ASCII
        IF char="0" THEN idx=idx-1      ' if the next char is a zero then it must be only 2 digits, go to next digit
        char = (value DIG idx) + "0"
        GOSUB LCD_Write
      NEXT
      RETURN
    

    but it works nicly.· also added the negitive bit, doubt i'll see that either, but this could serve others.


    thanks,

    Will
Sign In or Register to comment.