Thread: Super MPGuino?
View Single Post
Old 02-24-2010, 02:13 AM   #74 (permalink)
bobski
EcoModding Apprentice
 
Join Date: Jan 2010
Location: Newark, DE
Posts: 143

'91 CRX - '91 Honda CRX DX
90 day: 34.91 mpg (US)
Thanks: 0
Thanked 14 Times in 14 Posts
Ugh.
If you're fully aware of this stuff, feel free to skip ahead.
Bitmasks are used to examine or exclude particular binary bits in a larger unit-group (such as a nibble, byte or word). You'll notice the bitmask values are all some value of 2^n... 1, 2, 4, 8, 16, 32, 64, 128 and so on. Those are the values of the digits of a binary number, but represented in decimal. So a bitmask of 1 would look at the 1st digit, 8 would look at the 4th digit, 16 at the 5th digit and 32 at the 6th digit.

The fact that the comment references ports and individual bits probably means that somewhere or other the program isn't using the digitalRead() and digitalWrite() commands that are easily portable between Arduino architectures. Instead, it's grabbing a whole port's worth of data (8 or maybe 16 bits) off of a register some place and sorting it out manually.
To get that to work would require finding the code that polls data from the ports and, realistically speaking, rewrite or replace it with code that is relevant to the mega's port / bit / register mappings.
This is exactly the kind of stuff I'm trying to avoid by working on my own version.

Last edited by bobski; 02-24-2010 at 02:25 AM..
  Reply With Quote