Newbe....with SPIN question...
denno
Posts: 223
Question...why won't the second STRING display on my Scott Edwards 4x40 display. If I comment out one or the other, it works just fine, and on the right line. posCMD,64 is the first line, and posCMD,144 is the second line....but, both lines will not display on the LCD, plus, it seems to "hang up" and not increment the test_number.
Comments
http://forums.parallax.com/showthread.php/129690-How-to-post-program-code-in-the-forum.?p=978076&viewfull=1#post978076
Had incorrect url
LCD.Dec(test_number,4)
LCD.str(STRING(clrLCD,posCMD,144,"TEST"))
LCD.Dec(test_number,4)
you are clearing the screen twice.
also clearing the screen each loop will end up causing the LCD to 'blink'
You should only launch Spin cogs from within the object they are located. Also cognew is almost always better than coginit.
10 longs of stack space is probably fine some some methods but a lot of methods will require more.
I don't know what the LCD.init method does but generally one only starts a new cog with code running in a loop. Often "Start" methods start a new cog while "Init" methods just configure I/O pins and get the object ready to use without starting a cog.
The start method will take care of any cog launching for you if it's needed.
Since "Init" methods often configure I/O pins, it's a good idea to call Init methods from the cog which will be calling the methods in the object.
I suggest replacing the line:
With:
Am I correct, if I want to put proto_LCD in cog 7, I should put cognew at the beginning of that OBJECT?
Cog #0 starts out running a Spin interpreter and generally continues to do so for the duration of most Spin programs.
When you launch Spin code with cognew, you're starting a cog running another instance of the Spin interpreter. The Spin code stays in the hub and Spin interpreter running in a cog executes the instructions as it reads them from the hub (which Cog #0 is also doing).
So much of the answer to your question depends on what you want "proto-LCD" to do.
There are lots of examples of launching cogs in various "Start" methods of objects. The Start method will either launch PASM code from the DAT section of the object or start a new Spin interpreter to run a Spin method which method generally contains a continuous loop.
I haven't programmed the BS_SX chips so I'm not aware of how the program slots are used. I think it's safe to assume the slots of the BS_SX chips have little in common with cogs of the Propeller.
I'm sure there are times with the coginit statement is the appropriate way of launching a cog but I personally have never used it and I think it's a good idea to use cognew unless there is some specific reason to use coginit.