Shop OBEX P1 Docs P2 Docs Learn Events
String problem or data type problem ? — Parallax Forums

String problem or data type problem ?

grasshoppergrasshopper Posts: 438
edited 2007-11-01 20:29 in Propeller 1
I need to know what data type this needs to be to correctly display. I am basicaly taking a temp reading and displaying it on my 2x20 lcd screen. The last line of code is were i get the compile error....


{{ Demo LCD
  Uses LCDDEMO Version 1.2
  Uses ADC0831 with Lm34 as a temp 

}}
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
  
  esc = $1B     'Escape code
  cr = $0D      'Carriage Return code                 
  lf = $0A      'Line Feed code
  eos = $FF     'End of string code
  eog = $FF     'End of graphics code
  space = $20   'Space character code


var
 byte lm34temp, temp
 
OBJ 
    LCD : "LCDDEMO" 

pub main

repeat
  dira :=0     'set pin 5 as input
  lm34temp :=0     'starts the lm34temp variable as 0
  temp:=ina    'sets the value of temp to the value of pin 5 (one or zero)
  dira[noparse][[/noparse]7]~~       'sets pin as output
  outa[noparse][[/noparse]7]~~       'sets pin 7 high  
  outa[noparse][[/noparse]7]~        'sets pin 7 low    'takes chip select low activating the adc       'the ADC0831

  repeat 8  
    dira[noparse][[/noparse]6]~~     'sets pin as output
    outa[noparse][[/noparse]6]:=1    'sets clock (pin 6) high      
    outa[noparse][[/noparse]6]:=0    'sets clock (pin 6)low  'takes the adc clk low 
      if ina==1  
         temp:=1
      else
         temp:=0        
    lm34temp:=lm34temp*2
    lm34temp:=lm34temp+temp


  waitcnt (1_000_000 * 50 + cnt )
  
  LCD.init                      'Initialize the display
  LCD.writestr(@LineIt1)    'Display 


  repeat                        'Just sit and run

  
dat
  LineIt1 byte "Holder = ",lm34temp,$DF," C",cr,eos   <----------------------------Here Lm34temp ? ? ? 
 





I get a compile error because i am not addressing the data type or something?

Help please
Thanks

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-11-01 20:13
    Oh dear!
    What do you want to tell him??
    when you say BYTE in DAT please only add constant byte values as 0, 255, -1, "A" or "ABC", the last is a simplification for "A", "B", "C".

    You can also use CONS names of course, but not "lm34temp". That is not a constant!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-01 20:29
    lm34temp is a byte variable and you can't just put this name in the list of byte values and strings. I assume you want to display the first part of the string, then the decimal value in lm34temp, then the rest of the string. You have to split this task into 3 parts to do this:
      LCD.writestr(@LineIt1)
      showDecimal(lm34temp)
      LCD.writestr(@LineIt2)
    
    PRI showDecimal(v) | p, t ' Display up to 3 digits, do zero supression
       t := 0          ' This is used as a string.  Leave a zero byte for a terminator
       p := @t+3   ' Point to the zero terminator and work backwards
       repeat
          byte[noparse][[/noparse] --p ] := v // 10 + "0" ' Generate the digits from right to left
          v /= 10     ' Go to the next digit to the left
       until v == 0 ' Stop when there are no more digits to display
       LCD.writestr(p)
       
    DAT
    LineIt1  byte "Holder = ",0
    LineIt2  byte $DF," C",cr,0
    
Sign In or Register to comment.