Shop OBEX P1 Docs P2 Docs Learn Events
How do i launch a object in the new cog? check out this code — Parallax Forums

How do i launch a object in the new cog? check out this code

grasshoppergrasshopper Posts: 438
edited 2008-06-29 19:12 in Propeller 1
Whats wrong with the code it wont launch the lcd.init

{

  Update Example


}
con

  slow          = 60_000_000    'Led flashing speed slow
  fast          = 2_000_000     'Led flashing speed fast
  On            = 1
  Off           = 0
  LEDPIN        = 20            'Led Pin
        
Var

  Long Stack[noparse][[/noparse]32]


obj

  lcd   :"LCDdriver"
  fs    : "floatString"
  
PUB start (Info,Mode,Time) : success

  dira[noparse][[/noparse]pin]~~
  lcd.init
  lcd.cls
  
  Success := Cognew(Display(Info,Mode,Time),@stack)


Pub Dispaly (Info,Mode,Time)
  
  Fs. SetPrecision(4)  
  If (Mode == 0)                       
      lcd.pos(1,1)
      lcd.writestr(@screen)
      lcd.writestr(fs.Floattostring(Info))
      lcd.pos(2,1)
      lcd.writestr(@screen1)
      waitcnt(Time + cnt)
      lcd.cls
      
  If (Mode == 10)    
      lcd.cls
      lcd.pos(1,1)
      lcd.writestr(@Flashscreen1)
      lcd.pos(2,1)
      lcd.writestr(@flashscreen2)
      pause_it(5,factor1)
      waitcnt(Time + cnt)  
      lcd.cls
      
    
DAT

  screen1                       byte    "Top of",eos
  screen2                       byte    "Value = ",eos
  Flashscreen1                 BYTE    "Software",eos
  Flashscreen2                 Byte    "Version 3.2",eos  





Now if i do this it works


Pub Dispaly (Info,Mode,Time)

    dira[noparse][[/noparse] pin ]~~
    lcd.init
    lcd.cls

  Fs. SetPrecision(4)  
  If (Mode == 0)                       
      lcd.pos(1,1)
      lcd.writestr(@screen)
      lcd.writestr(fs.Floattostring(Info))
      lcd.pos(2,1)
      lcd.writestr(@screen1)
      waitcnt(Time + cnt)
      lcd.cls
      
  If (Mode == 10)    
      lcd.cls
      lcd.pos(1,1)
      lcd.writestr(@Flashscreen1)
      lcd.pos(2,1)
      lcd.writestr(@flashscreen2)
      pause_it(5,factor1)
      waitcnt(Time + cnt)  
      lcd.cls




My problem is that I dont want to keep running lcd.init when I update the
"Pub Dispaly (Info,Mode,Time)" from my main code.


Pub Dispaly (Info,Mode,Time)

this line will continue to be updated form another object

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2008-06-28 19:15
    dira is per cog, setting it in the main cog doesn't change the direction in the Display cog
  • grasshoppergrasshopper Posts: 438
    edited 2008-06-28 19:46
    I am not worried about dira sorry for the confusion it my lcddriver object that wont work correctly
  • TimmooreTimmoore Posts: 1,031
    edited 2008-06-28 19:51
    You sure that lcd.init isn't setting direction pins since it needs to write to output pins? i.e. same problem differnt pins
  • grasshoppergrasshopper Posts: 438
    edited 2008-06-28 20:13
    Good point ill check it thanks
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-06-29 19:12
    Hello Grashopper,

    there is a difference in the methodnames

    the PUB-definition is named "Dispaly"

    in your cognew statement it is named "Display"

    looks like a mistyping

    you did not post your complete code as an attachment

    so there are some questions left:

    where is constant "pin" defined ?

    could it be that there is a method display that still exists but you made all the changes inside Dispaly ??

    Your code-snippet has a method PUB start (Info,Mode,Time) : success

    Is this the TOPLEVEL object ?

    Then the parameters are not initialized in the code-snippet.

    the code that is posted in the first post: is this the COMPLETE code ?
    I don't think so. Could you please post ALL files as an attachment.
    This means: your mainfile AND LCDDriver.spin AND floatstring.spin AND whatever else is depending on those files?


    best regards

    Stefan
Sign In or Register to comment.