Zanduino / MCP7940

Arduino Library to access the MCP7940M, MCP7940N and MCP7940x Real-Time chips
GNU General Public License v3.0
37 stars 22 forks source link

Bit Mask hour register #26

Closed logicaprogrammabile closed 6 years ago

logicaprogrammabile commented 6 years ago

hi in your code the mask bit for the hour register is 7F

from DateTime MCP7940_Class::now()

_hh = bcd2int(Wire.read() & 0x7F);

the correct mask should be 0x3F because the bit6 set the 12/24 format and should be exclude it

the mask bit is present in the follow functions DateTime MCP7940_Class::now() DateTime MCP7940_Class::getPowerDown() DateTime MCP7940_Class::getPowerUp()

regards Marco

SV-Zanshin commented 6 years ago

Good catch on the mask. The library currently works in 24-Hour mode exclusively, so missing the bit that represents the AM/PM when set to 1 wasn't noticed during testing; but it is better to fix the error should the library be expanded to support AM/PM 12-hour mode in the future.

SV-Zanshin commented 6 years ago

Added fix to master branch