Do I have the right idea in the way I am commenting on the code commands.more to come
''A .pdf copy of the book is available from www.parallax.com, and also through
''the Propeller Tool software's Help menu (v1.2.6 or newer).
''
''File: LedsOnOff50PercentAgain.spin
''Leds alternate on/off 50% of
''the time with the ! operator.
PUB BlinkLeds
dira[4..9]~~ ' (~~) Post Set / sign-extend from bit 15
'
outa[4..9] := %100001 ' ( %100001 ) 1 = set or ON and 0 = clear or OFF
'
' ( [ ..] ) equal to the value of the symbol or
' expression to the right of
' the of the operator
repeat
!outa[4..9] ' ( !outa[4..9] ) invert pin direction state bits [x..y]
' ........ this is what mean " ! " by solo
waitcnt(clkfreq/4 + cnt) ' wait 1/4 of a second
Comments
Looks good from here..
OBC
Personally, I would say "invert pin direction state bits [x..y]", just because it speaks to exactly what is happening.
Is this any better I changed above
OBC
Just to let you by me doing this I am being to understand this a little more and I am VERY sure that will many more question like this as I go a long
If I do calculations, often I'll stuff those in there just as notes. They help me later when I go to change something that isn't programmed to happen automatically, like "magic numbers" in that I can see what the heck I did!
And I'm not the best commenter, but getting better.
When I first start writing P-basic code when I went through
What is a Micro Controller
I did not have to comment very much of it because I understood most of the basic code command there still some commands I do not understand how to write them or understand how they work but that very few
But now going through
Propeller Education Kit Lab
With Spin this a hole another story
To me the command are very different
Some of the basic command are hard for me to understand
The reason why something it is written the way it is .
Some people decorate such blocks with special character sequences to make them stand out. Such special decorations to make it easy to spot where key things like methods and routines start in the code. Be creative if you like, but don't over do it.
Just my .02
These for now are just outline for me to learn from but at some point I do want to clean them up so that other people can use them
I have one thing to ask is there any one out there that would be willing to help clean these comment up as I go along
Because I can see that this seem to be the best way for me to learn these command and how to use them
and
I wonder how many other people on this forum feel the same way comment are welcome
Please keep in mind that I want to have the comment so that a beginner can understand them
I want beginner and experts to Please leave there comments thanks
''This code example is from Propeller Education Kit Labs: Fundamentals, v1.2. ''A .pdf copy of the book is available from [url]www.parallax.com[/url], and also through ''the Propeller Tool software's Help menu (v1.2.6 or newer). '' ''File: LedsOnOff.spin ''All LEDS on for 1/4 s and off ''for 3/4 s. PUB BlinkLeds '' PUB = Public Method Block meaning that code routine are accessible inside and outside of the object '' '' BlinkLed = name of routine '' '' dira = Direction Register for I/O pins meaning that it is an output or input '' '' '' ( [ ..] ) equal to the value of the symbol or expression to the right of '' the of the operator '' '' ( := ) It sets the symbol to the left of the operator equal to the value '' of the symbol or expression to the right of the operator '' '' (:= %111111) will set bit to outputs pins 4 to 9 1 = output / 0 = input '' '' outa = Output State Register meaning that the output pin is set or clears / 1 = high / 0 = low or ON /OFF '' '' (:= %101010) set P4,clears P5, set P6,clears P7 '' and so on to pin 9 '' '' '' '' cnt - a register that counts system clock ticks '' '' clkfreq - a command that returns system clock frequency in Hz clock or '' a value that stores system clock ticks in one second '' '' waitcnt - a command that waits for the the cnt register to get '' to a certain value dira[4..9] := %111111 repeat outa[4..9] := %111111 '(:= %111111) will set bit to outputs pins 4 to 9 waitcnt(clkfreq/4 + cnt) '( clkfreq/4) wait 1/4 of a second outa[4..9] := %000000 '(:= %101010) set P4,clears P5, set P6,clears P7 and so on to pin 9 waitcnt(clkfreq/4*3 + cnt) '(clkfreq/4*3) wait 3/4ths of a second
I like to use big special character comments like this too:
'
' Setup the counters
'
mov A, B 'prepare to calculate frequency
add A, C 'add delta to base value
shl A, #2 'Multiply by 4
...etc.
Lots of ways to do it. It is good to work on how you do it, whatever that is, and just keep working to make it more consistent. That helps a lot because other people can pick up on the different formats and learn what programmers were trying to say.
And yes! You have exactly the right idea, BTW.
''This code example is from Propeller Education Kit Labs: Fundamentals, v1.2. ''A .pdf copy of the book is available from www.parallax.com, and also through ''the Propeller Tool software's Help menu (v1.2.6 or newer). '' ''File: LedsOnOff50PercentAgain.spin ''Leds alternate on/off 50% of ''the time with the ! operator. PUB BlinkLeds '' PUB = Public Method Block meaning that code routine are accessible inside and outside of the object '' '' BlinkLed = name of routine '' '' dira = Direction Register for I/O pins meaning that it is an output or input '' '' '' dira[4..9]~~ ' (~~) Post Set / set bits as outputs. ' ' outa[4..9] := %100001 ' ( %100001 ) 1 = set or ON and 0 = clear or OFF ' ' ( [ ..] ) equal to the value of the symbol or ' expression to the right of ' the of the operator ' repeat !outa[4..9] ' ( !outa[4..9] ) invert pin direction state bits [x..y]... ' ... this is what mean " ! " by solo '' cnt - a register that counts system clock ticks '' '' clkfreq - a command that returns system clock frequency in Hz clock or '' a value that stores system clock ticks in one second '' '' waitcnt - a command that waits for the the cnt register to get '' to a certain value '' '' waitcnt(clkfreq/4 + cnt) ' wait 1/4 of a second
''This code example is from Propeller Education Kit Labs: Fundamentals, v1.2. ''A .pdf copy of the book is available from www.parallax.com, and also through ''the Propeller Tool software's Help menu (v1.2.6 or newer). '' ''File: LedsOnOff50Percent.spin ''Leds alternate on/off 50% of ''the time. PUB BlinkLeds '' PUB = Public Method Block meaning that code routine are accessible inside and outside of the object '' '' BlinkLed = name of routine '' '' dira = Direction Register for I/O pins meaning that it is an output or input '' '' '' '' ( [ ..] ) equal to the value of the symbol or expression to the right of '' the of the operator '' '' (~~) Post Set / sign-extend from bit 15 '' '' ( := ) It sets the symbol to the left of the operator equal to the value '' of the symbol or expression to the right of the operator '' '' (:= %111111) will set bit to outputs pins 4 to 9 1 = output / 0 = input '' '' outa Output State Register meaning that the output pin is set or clears '' 1 = high / 0 = low or ON /OFF or set = 1 clear = 0 '' '' (:= %101010) set P4,clears P5, set P6,clears P7 '' and so on to pin 9 '' '' '' '' cnt - a register that counts system clock ticks '' '' clkfreq - a command that returns system clock frequency in Hz clock or '' a value that stores system clock ticks in one second '' '' waitcnt - a command that waits for the the cnt register to get '' to a certain value dira[4..9]~~ ' (~~) Post Set / set bits as outputs. repeat outa[4..9] := %100001 '(:= %111111) will set bit to outputs pins 4 to 9 waitcnt(clkfreq/4 + cnt) '( clkfreq/4) wait 1/4 of a second outa[4..9] := %011110 '(:= %011110) set P4,clears P5, set P6,clears P7 and so on to pin 9 waitcnt(clkfreq/4 + cnt) '( clkfreq/4) wait 1/4 of a second
dira[4..9]~~ ' (~~) Post Set / [COLOR="blue"]sign-extend from bit 15[/COLOR]
This may be confusing to some people. ~~ is used as post-operator, so why do you mention the sign extension (~~value)? It's not relevant in this context.I want to put something for ~~ I just asking what would be relevant in this context.
Please put something for a beginner to understand thanks
So far I have not anything in Propeller Education Kit Lab text that I have read so far