Esempio n. 1
0
/* retrieve time over I2C in BCD from the DS3231M real-time clock module */
int get_Time(void) {
    int time;
    time = get_Hours();
    time <<= 8;
    time += get_Minutes();
    return time;
}
Esempio n. 2
0
/* Increment the minutes on the DS3231M Clock (for user-adjustment of time etc.) */
void inc_Minutes(void) {
    byte temp;
    temp = get_Minutes();
    if (temp <= 0x58) {
        temp++;
        if ((temp & 0x0F) >= 0x0A) temp = (temp & 0xF0) + 0x10;
    } else {
        temp = 0;
    }
    set_Minutes(temp);
}
Esempio n. 3
0
void Value_time_imp::Increment( void ) 
{
	// Used in tests only so make it just for our datetime parser be happy.

	if( mValue == 0 )
	{
		Init();
		return;
	}

	vuint16 hours = get_Hours();
	vuint16 minutes = get_Minutes();
	vuint16 seconds = get_Seconds();
	vuint16 ms = get_Milliseconds();

	if( ms < 999 )
	{
		put_Milliseconds( ++ms );
	}
	else if( seconds < 59 )
	{
		put_Milliseconds(0);
		put_Seconds( ++seconds );
	}
	else if( minutes < 59 )
	{
		put_Milliseconds(0);
		put_Seconds(0);
		put_Minutes( ++minutes );
	}
	else if( hours < 24 )
	{
		put_Milliseconds(0);
		put_Seconds(0);
		put_Minutes(0);
		put_Hours( ++hours );
	}
	else
	{
		// no nore time which makes parser happy. Actually we rarelly get here.
		Init();
	}
}
void Value_datetime_imp::Increment( void ) 
{
	// Used in tests only so make it just for our datetime parser be happy.
	if( mValue == 0 )
	{
		Init();
		return;
	}

	vuint16 day = get_Day();
	vuint16 month = get_Month();
	vint32 year = get_Year();
	vuint16 hours = get_Hours();
	vuint16 minutes = get_Minutes();
	vuint16 seconds = get_Seconds();
	vuint16 ms = get_Milliseconds();

	if( ms < 999 )
	{
		put_Milliseconds( ++ms );
	}
	else if( seconds < 59 )
	{
		put_Milliseconds(1);
		put_Seconds( ++seconds );
	}
	else if( minutes < 59 )
	{
		put_Milliseconds(1);
		put_Seconds(0);
		put_Minutes( ++minutes );
	}
	else if( hours < 24 )
	{
		put_Milliseconds(1);
		put_Seconds(0);
		put_Minutes(0);
		put_Hours( ++hours );
	}
	else
	{
		// no nore time which makes parser happy. Actually we rarelly get here.

		if( day < 31 )
		{
			put_Day( ++day );
		}
		else if( month < 12 )
		{	
			put_Day( 1 );
			put_Month( ++month );
		}
		else if( year < 9999 )
		{		
			put_Day(1);
			put_Month(1);
			put_Year( ++year );
		}
		else
		{
			// no nore date which makes parser happy. Actually we rarelly get here.
			Init();
		}
	}
}