Go Down

Topic: RTC AM PM format setting in RTC &showing ON TFT (Read 138 times) previous topic - next topic

kolhapurkar

Hello ,

I am currently working on ARDUINO uno with RTC and the RTC data display on TFT.

I have done everything  regarding to RTC using the RTClib.h and wire.h in 12 hour format but still not set the Am pm format on it.

I started the RTC in 12 hour mode like these,

    DD = now.day();
    MM = now.month();
    YY = now.year();
    H = now.hour()%12;   ///the 12 hour format
    M = now.minute();
    S = now.second();
   

It work fine but, how can i call the Am & Pm in accordance with time update?


where I will change  to get the Am PM pattern and how I call it for TFT print?





pylon

Quote
It work fine but, how can i call the Am & Pm in accordance with time update?
By changing the sketch accordingly. We cannot help because you're keeping the sketch, the wiring and all information about the hardware secret.

Quote
where I will change  to get the Am PM pattern and how I call it for TFT print?
If that snippet above is your actual code, you get the flag

Code: [Select]
bool pm = now.hour() / 12;

kolhapurkar

#2
Dec 18, 2018, 11:37 am Last Edit: Dec 18, 2018, 11:40 am by kolhapurkar
sorry pylon for late reply ,

but  I managed to get the same structure from 24 hours,like these



if (now.hour() > 12 )
    {
      H  = now.hour() - 12;
     
     }
    else
    {
      H  = now.hour();
    }

   if (now.hour()>= 12 )
    {
      tft.setCursor(440, 300);
      tft.println("Pm");
    }
   else
    {
      tft.setCursor(440, 300);
      tft.println("Am");
    }

so thanks for your teply..

Go Up