CaryCoders / Mbed 2 deprecated demo_SX1276_standalone

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Modules/DateModule.cpp

Committer:
vtraveller
Date:
2014-08-10
Revision:
11:96146db429de
Parent:
10:3fcab08717fc
Child:
12:0fea8ebe6c1a

File content as of revision 11:96146db429de:

#include "mbed.h"
#include "DateModule.h"
#include "time_helper.h"

const char * k_aWeekDays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

DateModule::DateModule
(
    Adafruit_RGBLCDShield & in_cLCD,
    RTclock & in_cRTclock
)
    : Module(in_cLCD)
    , m_cRTclock(in_cRTclock)
{
}

DateModule::~DateModule()
{
}

void DateModule::change
(
    int         in_nIndexX,
    int         in_nCursorY,
    bool        in_bUp
)
{
    tm sTM;
    
    // to get the current time information
    if (!m_cRTclock.getTime(sTM)) GetTime(sTM);
    bool bTwelveHour = m_cRTclock.isTwelveHour();
    
#if 0
    switch (in_nIndexX)
    {
        case 0: m_nTemp += (in_bUp ? 1 : -1) * 10;  break;
        case 1: m_nTemp += (in_bUp ? 1 : -1); break;
    }
#endif

    if (!m_cRTclock.setTime(sTM,bTwelveHour)) SetTime(sTM);
}
  
int DateModule::setCursor
(
    int in_nIndex,
    int in_nCursorX,
    int in_nCursorY
)
{
    const int k_aCursor[] = { 2, 4, 5, 7, 8, 10, 11, 12, 13 };
    
    int nIndex = in_nIndex;
    if (nIndex < 0) nIndex = 0;
    if (nIndex >= _countof(k_aCursor)) nIndex = _countof(k_aCursor) - 1;
       
    int nCursorX = k_aCursor[nIndex];
    m_cLCD.setCursor(in_nCursorX + nCursorX,in_nCursorY);
    
    return nIndex;
}

void DateModule::show()
{
    tm sTM;
    
    // to get the current time information
    if (!m_cRTclock.getTime(sTM)) GetTime(sTM);

    m_cLCD.printf ("%s %02i/%02i/%04i      ", k_aWeekDays[sTM.tm_wday], sTM.tm_mday, sTM.tm_mon + 1, 1900 + sTM.tm_year);    
}