24 to 12 hour
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- LitingWolf
- Posts: 41
- Joined: Thu Jan 02, 2020 3:03 pm
24 to 12 hour
I have ds3231 rtc how do I change to 12 hour I know I have to change the bit but I don't know how to do that
- LitingWolf
- Posts: 41
- Joined: Thu Jan 02, 2020 3:03 pm
Re: 24 to 12 hour
im using the adafruit rtc3231 lib
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: 24 to 12 hour
The CircuitPython module for the DS3231 doesn't have a function that changes the 12/24 setting, so you'll have to add one.
The instructions from the Register module explain how to do that in general terms:
https://github.com/adafruit/Adafruit_Ci ... n_Register
The instructions from the Register module explain how to do that in general terms:
https://github.com/adafruit/Adafruit_Ci ... n_Register
- LitingWolf
- Posts: 41
- Joined: Thu Jan 02, 2020 3:03 pm
Re: 24 to 12 hour
Its Adafruit DS3231 Precision RTC Breakout the one i have
- adafruit_support_bill
- Posts: 88155
- Joined: Sat Feb 07, 2009 10:11 am
Re: 24 to 12 hour
Without knowing what language you are programming in, it is hard to provide specific advice. If programming in Python, you need to use the Registers module as Mike suggests. If programming in Arduino, you can use Wire._I2C_WRITE(). The 12/24 hour mode selection bit is bit 6 of register 0.02 as detailed on page 11 of the data sheet.
https://cdn-shop.adafruit.com/product-f ... DS3231.pdf
Note that changing the mode of the chip may confuse other functions in the library that may be expecting things in 24 hour mode.
A simpler approach is to just leave the chip the default mode and handle it in your code:
something like:
https://cdn-shop.adafruit.com/product-f ... DS3231.pdf
Note that changing the mode of the chip may confuse other functions in the library that may be expecting things in 24 hour mode.
A simpler approach is to just leave the chip the default mode and handle it in your code:
something like:
Code: Select all
if (hour > 12
{
hour = hour - 12;
PM = true;
}
Please be positive and constructive with your questions and comments.