PM 2 plant-buddy / Mbed OS PM2_Plant_buddy

Dependencies:   ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini

Time/Adafruit_Display/clock_display.cpp

Committer:
ackerden
Date:
2021-04-27
Revision:
25:863e6ef1245f

File content as of revision 25:863e6ef1245f:

/*#include "mbed.h"
#include "Adafruit_LED_Backpack.h"
#include "Adafruit_GFX.h"

#include "clock_display.h"

#define TIME_24_HOUR      true
#define DISPLAY_ADDRESS   0x70
/*
Adafruit_7segment clockDisplay = Adafruit_7segment();
clockDisplay.begin(DISPLAY_ADDRESS);
bool blinkColon = false;


void clock_display(int seconds, int minutes, int hours){
    /*if (minutes == 0) {
        hours = now.hour();
        minutes = now.minute();
    }*/

  // Show the time on the display by turning it into a numeric
  // value, like 3:30 turns into 330, by multiplying the hour by
  // 100 and then adding the minutes.
   /* int displayValue = hours*100 + minutes;

  // Now print the time value to the display.
    clockDisplay.print(displayValue, DEC);

  // Add zero padding when in 24 hour mode and it's midnight.
  // In this case the print function above won't have leading 0's
  // which can look confusing.  Go in and explicitly add these zeros.
    if (TIME_24_HOUR && hours == 0) {
    // Pad hour 0.
        clockDisplay.writeDigitNum(1, 0);
    // Also pad when the 10's minute is 0 and should be padded.
        if (minutes < 10) {
            clockDisplay.writeDigitNum(2, 0);
        }
    }

  // Blink the colon by flipping its value every loop iteration
  // (which happens every second).
    blinkColon = !blinkColon;
    clockDisplay.drawColon(blinkColon);

  // Now push out to the display the new values that were set above.
    clockDisplay.writeDisplay();

  // Pause for a second for time to elapse.  This value is in milliseconds
  // so 1000 milliseconds = 1 second.
    delay(1000);

  // Now increase the seconds by one.
    seconds += 1;
  // If the seconds go above 59 then the minutes should increase and
  // the seconds should wrap back to 0.
    if (seconds > 59) {
        seconds = 0;
        minutes += 1;
    // Again if the minutes go above 59 then the hour should increase and
    // the minutes should wrap back to 0.
        if (minutes > 59) {
            minutes = 0;
            hours += 1;
      // Note that when the minutes are 0 (i.e. it's the top of a new hour)
      // then the start of the loop will read the actual time from the DS1307
      // again.  Just to be safe though we'll also increment the hour and wrap
      // back to 0 if it goes above 23 (i.e. past midnight).
        if (hours > 23) {
            hours = 0;
        }
        }
   /* }}*/