Question about Code

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
goldeneyes1987
Posts: 2
Joined: Wed Nov 02, 2011 9:29 am

Question about Code

Post by goldeneyes1987 »

Hi guys,

by using the MultiWiiCopter and reading Code i found a "1" with unkonw meaning!
I added a pic who see the codesection and notified postition.
Can anybody tell me why "1" is added to the DTerm?


Kind regards
goldenEyes
Attachments
question.JPG

goldeneyes1987
Posts: 2
Joined: Wed Nov 02, 2011 9:29 am

Re: Question about Code

Post by goldeneyes1987 »

Nobody knows????

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Question about Code

Post by Alexinparis »

Integer math approx for division
(x+(y/2))/y is more accurate than x/y

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Question about Code

Post by timecop »

Let's turn this thread into catch-all for asking stupid questions about the code.

I've got doubts about this:

Code: Select all

#define LEDPIN_SWITCH              PINB |= 1<<5;


According to doc8025, all of PINB is read-only.
14.4.4 PINB – The Port B Input Pins Address
... Is there ANY reason this code exists, and if so, what exactly does it do?
Is this some clever trick that makes AVR do something?

Answering to myself after some irc discussions... Apparently that's equivalent of PORTB ^= 1 << 5; .....
the mind boggles.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Question about Code

Post by Alexinparis »

AVR secrets ;)
http://billgrundmann.wordpress.com/2009 ... tedigital/

dongs wrote:Let's turn this thread into catch-all for asking stupid questions about the code.

I've got doubts about this:

Code: Select all

#define LEDPIN_SWITCH              PINB |= 1<<5;


According to doc8025, all of PINB is read-only.
14.4.4 PINB – The Port B Input Pins Address
... Is there ANY reason this code exists, and if so, what exactly does it do?
Is this some clever trick that makes AVR do something?

Answering to myself after some irc discussions... Apparently that's equivalent of PORTB ^= 1 << 5; .....
the mind boggles.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Question about Code

Post by timecop »

The 'switch' part combined with read-onlyness of PINB is what threw me off.
Normally this is called "toggle".

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Question about Code

Post by Alexinparis »

dongs wrote:The 'switch' part combined with read-onlyness of PINB is what threw me off.
Normally this is called "toggle".

You're right, toggle is more appropriate.
French usually don't speak very well foreign languages ;)

Post Reply