mwc 2.0 ++
Re: mwc 2.0 ++
On formatting:
seems my code snippet got garbled by the [ code ] formatting software.
So here are some snapshots from what Eclipse offers and how that looks like.
BSD
GNU
KuR
whitesmiths
I'd say no real benefit from GNU, but it uses the most vertical space - bad.
Personal favorite is KuR.
seems my code snippet got garbled by the [ code ] formatting software.
So here are some snapshots from what Eclipse offers and how that looks like.
BSD
GNU
KuR
whitesmiths
I'd say no real benefit from GNU, but it uses the most vertical space - bad.
Personal favorite is KuR.
Re: mwc 2.0 ++
+1 for KuR!
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: mwc 2.0 ++
Hi,
Please don't break the current indent
I tried to correct it in LCD.pde, but I gave up...
I use only Arduino IDE to code, nothing else.
I think It's something like K&R style + 2 space indent and no tab.
If you use a third party IDE like Eclipse, please adapt it to use the same style.
generally speaking:
something after a { should begin 2 spaces after on the next line.
something after a #if should begin 2 spaces after on the next line.
I don't know if keeping # statement at the same indent as the other code (and not at the beginning) is clean or not, but I find it more readable.
here is something which is difficult to read for me:
here is something more natural for me:
please try also to gather as possible the place where LOG_VALUES appears.
Please don't break the current indent
I tried to correct it in LCD.pde, but I gave up...
I use only Arduino IDE to code, nothing else.
I think It's something like K&R style + 2 space indent and no tab.
If you use a third party IDE like Eclipse, please adapt it to use the same style.
generally speaking:
something after a { should begin 2 spaces after on the next line.
something after a #if should begin 2 spaces after on the next line.
I don't know if keeping # statement at the same indent as the other code (and not at the beginning) is clean or not, but I find it more readable.
here is something which is difficult to read for me:
Code: Select all
case 0:
#if MAG
Mag_getADC();
#endif
break;
case 1:
#if BARO
Baro_update();
#if defined(LOG_VALUES)
if (BaroAlt > BaroAltMax) BaroAltMax = BaroAlt;
#endif
#endif
break;
case 2:
#if BARO
getEstimatedAltitude();
#endif
break;
case 3:
#if GPS
GPS_NewData();
#endif
break;
}
here is something more natural for me:
Code: Select all
switch (taskOrder) {
case 0:
#if MAG
Mag_getADC();
break;
#endif
case 1:
#if BARO
Baro_update();
break;
#endif
please try also to gather as possible the place where LOG_VALUES appears.
Hamburger wrote:coding style / indentation
seems we should decide on a coding style / indentation rules. Alex is always busy correcting indentation, this should not be neccessary. I would like to stick with something common. Eclipse offers some builtin variants.
K&R looks like this:Code: Select all
/*
* A sample source file for the code formatter preview
*/
#include <math.h>
class Point {
public:
Point(double x, double y) :
x(x), y(y) {
}
double distance(const Point& other) const;
double x;
double y;
};
double Point::distance(const Point& other) const {
double dx = x - other.x;
double dy = y - other.y;
return sqrt(dx * dx + dy * dy);
}
Available alternatives are GNU, BSD, Whitesmiths.
What do you think?
Re: mwc 2.0 ++
K&R, 2 space indent is fine.
Indenting the cpp macros may be different. Eclipse does not do it automatically and autocorrects it always. Not sure if that can be changed easily. Also in the old days cpp did not guarantee to always work on #something directives with leading white space. Not sure if they changed that.
Could we also agree on the following:
- macros are all capital letters with optional underscores
- variables either all lower case, or start with lower letter and use Camel style (cycleTimeMax) or get an all capitals prefix for the realm like GPS_latitude ( I found BaroAlt difficult to identify, rather prefer BAROalt or BARO_alt)
- function names ? it seems to be good practice in MWii to start with (optional the realm in all capital letters followed by) lower letter+Camel for functionality (like LCDconfiguration() or SOMESENSOR_init() ) - so same rules as for variables?
Please do not get me wrong, we do not want the Format Polizei; merely readable code without too much hassle and take the burden from Alex to re-format the code all the time.
Thanks.
Indenting the cpp macros may be different. Eclipse does not do it automatically and autocorrects it always. Not sure if that can be changed easily. Also in the old days cpp did not guarantee to always work on #something directives with leading white space. Not sure if they changed that.
Could we also agree on the following:
- macros are all capital letters with optional underscores
- variables either all lower case, or start with lower letter and use Camel style (cycleTimeMax) or get an all capitals prefix for the realm like GPS_latitude ( I found BaroAlt difficult to identify, rather prefer BAROalt or BARO_alt)
- function names ? it seems to be good practice in MWii to start with (optional the realm in all capital letters followed by) lower letter+Camel for functionality (like LCDconfiguration() or SOMESENSOR_init() ) - so same rules as for variables?
Please do not get me wrong, we do not want the Format Polizei; merely readable code without too much hassle and take the burden from Alex to re-format the code all the time.
Thanks.
Re: mwc 2.0 ++
Hamburger wrote:use Camel style (cycleTimeMax) or get an all capitals prefix for the realm like GPS_latitude ( I found BaroAlt difficult to identify, rather prefer BAROalt or BARO_alt)
everything with underscore or all upercase is const or a define, it is ok to use upper case for acronym or short word [1]
int GPSMaxSpeed = ok
define GPS_ALT_MAX 33000 = ok
int BAROalt = ok
int BARO_alt = bad
void INIT() = bad
int GPSHOME_latitude = bad
1 : http://en.wikipedia.org/wiki/CamelCase# ... _computing
Re: mwc 2.0 ++
while we are at it:
I think it is about time to create a proper Credits.txt file and remove the various names that are sprinkled all over the code sections.
ok?
I think it is about time to create a proper Credits.txt file and remove the various names that are sprinkled all over the code sections.
ok?
Re: mwc 2.0 ++
...and more importantly a Maintainers.list
Re: mwc 2.0 ++
Please have a look at _shared.
I created the credits file and reformatted LCD.pde.
Anyone know how to indent cpp in Eclipse?
I created the credits file and reformatted LCD.pde.
Anyone know how to indent cpp in Eclipse?
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: mwc 2.0 ++
Hi,
No problem to create a Credits file, but with exhaustive information. (I see some missing info about OpenLRS contribution).
It would be better if a small summary could be added for each contribution.
I know this is some more work for you, but it's your initiative
I'm not in favor of a Maintainers.list
No problem to create a Credits file, but with exhaustive information. (I see some missing info about OpenLRS contribution).
It would be better if a small summary could be added for each contribution.
I know this is some more work for you, but it's your initiative
I'm not in favor of a Maintainers.list
Re: mwc 2.0 ++
Alexinparis wrote:Hi,
No problem to create a Credits file, but with exhaustive information. (I see some missing info about OpenLRS contribution).
It would be better if a small summary could be added for each contribution.
I know this is some more work for you, but it's your initiative
ok, will do (with low priority). Just copy more of the CREDITS format over from linux. What is good for them should be good enough for us.
I'm not in favor of a Maintainers.list
ok.
- jevermeister
- Posts: 708
- Joined: Wed Jul 20, 2011 8:56 am
- Contact:
Re: mwc 2.0 ++
Can someone please upload a info.txt with coding rules into svn?
SAo we all know what to do to code correctly
SAo we all know what to do to code correctly
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: mwc 2.0 ++
Hi,
Look at the readme file in http://code.google.com/p/multiwii/sourc ... vn%2Ftrunk
note you already violated one rule
"no more tabs"
but your idea to add a buzzer tab is ok.
Look at the readme file in http://code.google.com/p/multiwii/sourc ... vn%2Ftrunk
note you already violated one rule
"no more tabs"
but your idea to add a buzzer tab is ok.
Re: mwc 2.0 ++
So far, the best I could come up with is
This still manipulates the cpp macros in an unwanted style. (Besides, on macosx 10.5 the included indent is not capable of this options set).
again - anyone?
Code: Select all
indent -kr -l100 -i2 -ppi 2 -nut -brf
This still manipulates the cpp macros in an unwanted style. (Besides, on macosx 10.5 the included indent is not capable of this options set).
Hamburger wrote:Anyone know how to indent cpp in Eclipse?
again - anyone?
Re: mwc 2.0 ++
May I ask why everyone hate tabs?
Tabs have one major advantage over indentation by spaces: You can adjust the visual represenation to your liking without changing the code. Want to see more? Just instruct your editor to show tabs with a width of 2 spaces. You cannot do that with spaces, you are bound to the width present in the source file. That makes tabs IMO superior. They distinguish the represenation of the application logic from its visual representation.
Tabs have one major advantage over indentation by spaces: You can adjust the visual represenation to your liking without changing the code. Want to see more? Just instruct your editor to show tabs with a width of 2 spaces. You cannot do that with spaces, you are bound to the width present in the source file. That makes tabs IMO superior. They distinguish the represenation of the application logic from its visual representation.
Re: mwc 2.0 ++
Tommie,
Your argument is true. But I do not care about tab vs zpaces. In eclipse refomating is only one keystroke away.
Now with indentation of cpp directives in sync with code indentation is a different matter.
Your argument is true. But I do not care about tab vs zpaces. In eclipse refomating is only one keystroke away.
Now with indentation of cpp directives in sync with code indentation is a different matter.
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: mwc 2.0 ++
Tommie wrote:May I ask why everyone hate tabs?
Tabs have one major advantage over indentation by spaces: You can adjust the visual represenation to your liking without changing the code. Want to see more? Just instruct your editor to show tabs with a width of 2 spaces. You cannot do that with spaces, you are bound to the width present in the source file. That makes tabs IMO superior. They distinguish the represenation of the application logic from its visual representation.
The only reason is to be compatible with what Arduino IDE provides