Beispiel #1
0
// *************************************************************************************************
// @fn          display_alarm
// @brief       Display alarm time. 24H / 12H time format.
// @param       u8 line	LINE1, LINE2
//		u8 update	DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR
// @return      none
// *************************************************************************************************
void display_alarm(u8 line, u8 update)
{
	
	if (update == DISPLAY_LINE_UPDATE_FULL)			
	{
	  display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sAlarm.hour, 2, 1, SEG_ON);
	  display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), _itoa(sAlarm.minute, 2, 0), SEG_ON);
	  display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON);

	  // Show blinking alarm icon
	  display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_ON);
	}
	else if (update == DISPLAY_LINE_CLEAR)			
	{
	  // Clean up function-specific segments before leaving function
	  display_symbol(LCD_SYMB_AM, SEG_OFF);

	  // Clear / set alarm icon
	  if (sAlarm.state == ALARM_DISABLED)
	  {
	    display_symbol(LCD_ICON_ALARM, SEG_OFF_BLINK_OFF);
	  }
	  else
	  {
	    display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_OFF);
	  }
	}
}
Beispiel #2
0
// *************************************************************************************************
// @fn          display_alarm
// @brief       Display alarm time. 24H / 12H time format.
// @param       u8 line	LINE1, LINE2
//		u8 update	DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR
// @return      none
// *************************************************************************************************
void display_alarm(u8 line, u8 update)
{
#ifndef CONFIG_METRIC_ONLY 
	u8 hour12;
#endif
	
	if (update == DISPLAY_LINE_UPDATE_FULL)			
	{
#ifdef CONFIG_METRIC_ONLY
		display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sAlarm.hour, 2, 0), SEG_ON); 
#else
		if (sys.flag.use_metric_units)
		{
			// Display 24H alarm time "HH:MM"
			display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sAlarm.hour, 2, 0), SEG_ON); 
		}
		else
		{
			// Display 12H alarm time "HH:MM" + AM/PM
			hour12 = convert_hour_to_12H_format(sAlarm.hour);
			display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(hour12, 2, 0), SEG_ON); 	
			
			// Display AM/PM symbol
			display_am_pm_symbol(sAlarm.hour);		
		}
#endif
		display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sAlarm.minute, 2, 0), SEG_ON); 
		display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON);

		// Show blinking alarm icon
		display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_ON);

//		// If alarm is enabled, show icon
// 		if (sAlarm.state == ALARM_ENABLED)
// 		{
// 			display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_OFF);
// 		}
//		// When alarm is disabled, blink icon to indicate that this is not current time!
// 		else if (sAlarm.state == ALARM_DISABLED) 
// 		{
// 		}
	}
	else if (update == DISPLAY_LINE_CLEAR)			
	{
		// Clean up function-specific segments before leaving function
		display_symbol(LCD_SYMB_AM, SEG_OFF);
		
		// Clear / set alarm icon
		if (sAlarm.state == ALARM_DISABLED) 
		{
			display_symbol(LCD_ICON_ALARM, SEG_OFF_BLINK_OFF);
		}
		else
		{
			display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_OFF);
		}
	}
}
Beispiel #3
0
// *************************************************************************************************
// @fn          display_sidereal
// @brief       Sidereal Clock display routine. Supports 24H and 12H time format,
//              through the helper display_hours_with_12_24.
// @param       u8 line			LINE1
//				u8 update		DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_UPDATE_PARTIAL
// @return      none
// *************************************************************************************************
void display_sidereal(u8 line, u8 update)
{
	// Partial update
	if (update == DISPLAY_LINE_UPDATE_PARTIAL)
	{
		if(sSidereal_time.drawFlag != 0)
		{
			if (sSidereal_time.line1ViewStyle == DISPLAY_DEFAULT_VIEW)
			{
				switch(sSidereal_time.drawFlag)
				{
					case 3:
						display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sSidereal_time.hour, 2, 1, SEG_ON);
					case 2:
						display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), _itoa(sSidereal_time.minute, 2, 0), SEG_ON);
				}
			}
			else
			{
				// Seconds are always updated
				display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), _itoa(sSidereal_time.second, 2, 0), SEG_ON);
			}
		}
	}
	else if (update == DISPLAY_LINE_UPDATE_FULL)
	{
		if (line == LINE1)
		{
			// display "i" (like in sIdereal) to distinguish sidereal time clock from normal clock
			display_symbol(LCD_UNIT_L1_I, SEG_ON);
		}
		// Full update
		if ( ( line == LINE1 && sSidereal_time.line1ViewStyle == DISPLAY_DEFAULT_VIEW ) || ( line == LINE2 && sSidereal_time.line2ViewStyle == DISPLAY_DEFAULT_VIEW ) )
		{
			// Display hours
			display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sSidereal_time.hour, 2, 1, SEG_ON);
			// Display minute
			display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), _itoa(sSidereal_time.minute, 2, 0), SEG_ON);
			display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON_BLINK_ON);
		}
		else
		{
			// Display seconds
			display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), _itoa(sSidereal_time.second, 2, 0), SEG_ON);
			display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
		}
	}
	else if (update == DISPLAY_LINE_CLEAR)
	{
		display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_OFF_BLINK_OFF);
// 		// Change display style to default (HH:MM)
// 		sSidereal_time.line1ViewStyle = DISPLAY_DEFAULT_VIEW;
		// Clean up AM/PM icon
		display_symbol(LCD_SYMB_AM, SEG_OFF);
		// cleanup "i" icon
		display_symbol(LCD_UNIT_L1_I, SEG_OFF);
	}
}
Beispiel #4
0
// *************************************************************************************************
// @fn          display_time
// @brief       Clock display routine. Supports 24H and 12H time format,
//              through the helper display_hours_with_12_24.
// @param       u8 line			LINE1
//				u8 update		DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_UPDATE_PARTIAL
// @return      none
// *************************************************************************************************
void display_time(u8 line, u8 update)
{
	// Partial update
	if (update == DISPLAY_LINE_UPDATE_PARTIAL)
	{
	  if(sTime.drawFlag != 0)
	  {
	    if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW)
	    {
	      switch(sTime.drawFlag)
	      {
	      case 3:
	        display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sTime.hour, 2, 1, SEG_ON);
	      case 2:
	        display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON);
	      }
	    }
	    else
	    {
	      // Seconds are always updated
	      display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON);
	    }
	  }
	}
	else if (update == DISPLAY_LINE_UPDATE_FULL)
	{
	  // Full update
	  if ( ( line == LINE1 && sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW ) || ( line == LINE2 && sTime.line2ViewStyle == DISPLAY_DEFAULT_VIEW ) )
	  {
	    // Display hours
	    display_hours_12_or_24(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), sTime.hour, 2, 1, SEG_ON);
	    // Display minute
	    display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON);
	    display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON_BLINK_ON);
	  }
	  else
	  {
	    // Display seconds
	    display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON);
	    display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
	  }
	}
	else if (update == DISPLAY_LINE_CLEAR)
	{
	  display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_OFF_BLINK_OFF);
	  // Change display style to default (HH:MM)
	  sTime.line1ViewStyle = DISPLAY_DEFAULT_VIEW;
	  // Clean up AM/PM icon
	  display_symbol(LCD_SYMB_AM, SEG_OFF);
	}
}
// *************************************************************************************************
// @fn          display_alarm
// @brief       Display alarm time. 24H / 12H time format.
// @param       u8 line         LINE1, LINE2
//                              u8 update       DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR
// @return      none
// *************************************************************************************************
void display_alarm(u8 line, u8 update)
{
    u8 hour12;

    if (update == DISPLAY_LINE_UPDATE_FULL)
    {
        if (sys.flag.use_metric_units)
        {
            // Display 24H alarm time "HH:MM"
            display_chars(switch_seg(line, LCD_SEG_L1_3_2,
                                     LCD_SEG_L2_3_2), int_to_array(sAlarm.hour, 2, 0), SEG_ON);
        }
        else
        {
            // Display 12H alarm time "HH:MM" + AM/PM
            hour12 = convert_hour_to_12H_format(sAlarm.hour);
            display_chars(switch_seg(line, LCD_SEG_L1_3_2,
                                     LCD_SEG_L2_3_2), int_to_array(hour12, 2, 0), SEG_ON);

            // Display AM/PM symbol
            display_am_pm_symbol(sAlarm.hour);
        }
        display_chars(switch_seg(line, LCD_SEG_L1_1_0,
                                 LCD_SEG_L2_1_0), int_to_array(sAlarm.minute, 2, 0), SEG_ON);
        display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON);

        // Show blinking alarm icon
        display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_ON);
    }
    else if (update == DISPLAY_LINE_CLEAR)
    {
        // Clean up function-specific segments before leaving function
        display_symbol(LCD_SYMB_AM, SEG_OFF);

        // Clear / set alarm icon
        if (sAlarm.state == ALARM_DISABLED)
        {
            display_symbol(LCD_ICON_ALARM, SEG_OFF_BLINK_OFF);
        }
        else
        {
            display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_OFF);
        }
    }
}
Beispiel #6
0
void display_makapaka(u8 line, u8 update) {
	u8* ma = "MA";
	u8* ka = "HA";
	u8* pa = "PA";

	if(update == DISPLAY_LINE_UPDATE_FULL) {
		display_symbol(LCD_ICON_ALARM, SEG_ON);
		display_symbol(LCD_ICON_HEART, SEG_ON);
		display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), ma, SEG_ON);
		display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), ka, SEG_ON);
		/* display_chars(switch_seg(line, LCD_SEG_L1_5_2, LCD_SEG_L2_5_2), pa, SEG_ON);
 */
		/* display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), ka, SEG_ON);
 */
	}
	else if(update == DISPLAY_LINE_CLEAR) {
		display_symbol(LCD_ICON_ALARM, SEG_OFF);
		display_symbol(LCD_ICON_HEART, SEG_OFF);
Beispiel #7
0
// *************************************************************************************************
// @fn          display_alarm
// @brief       Display alarm time. 24H / 12H time format.
// @param       u8 line	LINE1, LINE2
//		u8 update	DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR
// @return      none
// *************************************************************************************************
void display_alarm(u8 line, u8 update)
{

	if (update == DISPLAY_LINE_UPDATE_FULL)			
	{
		// Display 24H alarm time "HH:MM"
		display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), int_to_array(sAlarm.hour, 2, 0), SEG_ON);
		display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), int_to_array(sAlarm.minute, 2, 0), SEG_ON);
		display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON);

		// Show blinking alarm icon
		display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_ON);

//		// If alarm is enabled, show icon
// 		if (sAlarm.state == ALARM_ENABLED)
// 		{
// 			display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_OFF);
// 		}
//		// When alarm is disabled, blink icon to indicate that this is not current time!
// 		else if (sAlarm.state == ALARM_DISABLED) 
// 		{
// 		}
	}
	else if (update == DISPLAY_LINE_CLEAR)			
	{
		// Clean up function-specific segments before leaving function
		display_symbol(LCD_SYMB_AM, SEG_OFF);
		
		// Clear / set alarm icon
		if (sAlarm.state == ALARM_DISABLED) 
		{
			display_symbol(LCD_ICON_ALARM, SEG_OFF_BLINK_OFF);
		}
		else
		{
			display_symbol(LCD_ICON_ALARM, SEG_ON_BLINK_OFF);
		}
	}
}
Beispiel #8
0
// *************************************************************************************************
// @fn          display_date
// @brief       Display date in DD.MM format (metric units) or MM.DD (English units).
// @param       u8 line                 LINE1, LINE2
//                              u8 update               DISPLAY_LINE_UPDATE_FULL,
// DISPLAY_LINE_UPDATE_PARTIAL
// @return      none
// *************************************************************************************************
void display_date(u8 line, u8 update)
{
    u8 *str;

    if (update == DISPLAY_LINE_UPDATE_FULL)
    {
        if (sDate.display == DISPLAY_DEFAULT_VIEW)
        {
            // Convert day to string
            str = int_to_array(sDate.day, 2, 0);
            if (sys.flag.use_metric_units)
            {
                display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
            }
            else
            {
                display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);
            }

            // Convert month to string
            str = int_to_array(sDate.month, 2, 0);
            if (sys.flag.use_metric_units)
            {
                display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);
            }
            else
            {
                display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
            }

            // Display "." to separate day and month
            display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
        }
        else
        {
            // Convert year to string
            str = int_to_array(sDate.year, 4, 0);
            display_chars(switch_seg(line, LCD_SEG_L1_3_0, LCD_SEG_L2_3_0), str, SEG_ON);

            // Clear "."
            display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_OFF);
        }
    }
    else if (update == DISPLAY_LINE_CLEAR)
    {
        // Show day and month on display when coming around next time
        sDate.display = DISPLAY_DEFAULT_VIEW;
    }
}
Beispiel #9
0
// *************************************************************************************************
// @fn          display_time
// @brief       Clock display routine. Supports 24H and 12H time format. 
// @param       u8 line			LINE1
//				u8 update		DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_UPDATE_PARTIAL
// @return      none
// *************************************************************************************************
void display_time(u8 line, u8 update)
{
	u8 hour12;
	
	// Partial update
 	if (update == DISPLAY_LINE_UPDATE_PARTIAL) 
	{
		if(sTime.drawFlag != 0) 
		{
			if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW)
			{
				switch(sTime.drawFlag) 
				{
					case 3: if (sys.flag.use_metric_units)
							{
								// Display 24H time "HH" 
								display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sTime.hour, 2, 0), SEG_ON);
							}
							else
							{
								// Display 12H time "HH" + AM/PM
								hour12 = convert_hour_to_12H_format(sTime.hour);
								display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(hour12, 2, 0), SEG_ON); 
								display_am_pm_symbol(sTime.hour);
							}
							
					case 2: display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON); 
				}
			}
			else
			{
				// Seconds are always updated
				display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON);
			}
		}	
	}
	else if (update == DISPLAY_LINE_UPDATE_FULL)			
	{
		// Full update
		if (sTime.line1ViewStyle == DISPLAY_DEFAULT_VIEW)
		{	
			// Display 24H/12H time
			if (sys.flag.use_metric_units)
			{
				// Display 24H time "HH" 
				display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(sTime.hour, 2, 0), SEG_ON);
			}
			else
			{
				// Display 12H time "HH" + AM/PM information
				hour12 = convert_hour_to_12H_format(sTime.hour);
				display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), itoa(hour12, 2, 0), SEG_ON); 
				// Display AM/PM information
				if (line == LINE1)
				{
					display_am_pm_symbol(sTime.hour);
				}
			}
							
			// Display minute
			display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.minute, 2, 0), SEG_ON); 
			display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_ON_BLINK_ON);
		}
		else
		{
			// Display seconds
			display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), itoa(sTime.second, 2, 0), SEG_ON);
			display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
		}
	}
	else if (update == DISPLAY_LINE_CLEAR)
	{
		display_symbol(switch_seg(line, LCD_SEG_L1_COL, LCD_SEG_L2_COL0), SEG_OFF_BLINK_OFF);
		// Change display style to default (HH:MM)
		sTime.line1ViewStyle = DISPLAY_DEFAULT_VIEW;
		// Clean up AM/PM icon
		display_symbol(LCD_SYMB_AM, SEG_OFF);
	}
}
Beispiel #10
0
// *************************************************************************************************
// @fn          display_date
// @brief       Display date in DD.MM format (metric units) or MM.DD (English units).
// @param       line_t line			LINE1, LINE2
//				update_t update		DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_UPDATE_PARTIAL
// @return      none
// *************************************************************************************************
void display_date(line_t line, update_t update)
{
#ifdef CONFIG_DAY_OF_WEEK
	const u8 weekDayStr[7][3] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
#endif
	u8 * str;
	
	if (update == DISPLAY_LINE_UPDATE_FULL)
	{
		switch (sDate.view)
		{
			case 0: //WWW.DD
				// Convert day to string
#ifdef CONFIG_DAY_OF_WEEK
				str = _itoa(sDate.day, 2, 1);
				display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);

				//pfs BEGIN replace year display with day of week
				//pfs algorith from http://klausler.com/new-dayofweek.html
				#define BASE_YEAR 2001 // not a leap year, so no need to add 1
				u8 skew;
				skew = (sDate.year - BASE_YEAR)+(sDate.year - BASE_YEAR)/4; // compute number of leap years since BASE_YEAR
				if ((29 == get_numberOfDays(2, sDate.year)) && (sDate.month < 3))
				  skew--; // if this is a leap year but before February 29
				skew = (skew + sDate.day); // add day of current month
				//add this month's skew value
				switch(sDate.month) {
				  case 5:
					skew += 1;
					break;
				  case 8:
					skew += 2;
					break;
				  case 2:
				  case 3:
				  case 11:
					skew += 3;
					break;
				  case 6:
					skew += 4;
					break;
				  case 9:
				  case 12:
					skew += 5;
					break;
				  case 4:
				  case 7:
					skew += 6;
					break;
				  default:  //January and October
					break;
				}
				skew = skew%7;
				str = (u8 *)weekDayStr[skew];
				display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_4_2), str, SEG_ON);
				display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
				break;
#else
				// skip this view
				sDate.view++;
#endif
			case 1: //MM  DD
				// Convert day to string
				display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
				// display date
#ifndef CONFIG_METRIC_ONLY
				if (!sys.flag.use_metric_units) {
					str = _itoa(sDate.day, 2, 0);
					display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);

					// Convert month to string
					str = _itoa(sDate.month, 2, 1);
					display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
				} else {
#else
				if (1) {
#endif
					str = _itoa(sDate.day, 2, 0);
					display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
					
					str = _itoa(sDate.month, 2, 0);
					display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);
				}
				break;
			case 2: //YYYY
				// Convert year to string
				str = _itoa(sDate.year, 4, 0);
				display_chars(switch_seg(line, LCD_SEG_L1_3_0, LCD_SEG_L2_3_0), str, SEG_ON);
				break;
			default:
				display_time(line, update);
				break;
		}
	}
	else if	(update == DISPLAY_LINE_UPDATE_PARTIAL)
	{
		if ((sDate.view == 3) || (display.flag.update_date))
			display_date(line, DISPLAY_LINE_UPDATE_FULL);
	}
	else if (update == DISPLAY_LINE_CLEAR)
	{
		// Do some display cleanup (or just do nothing if everything is OK)
		// This is NOT ONLY called on switch to next menu item
	}	
}
Beispiel #11
0
// *************************************************************************************************
// @fn          display_date
// @brief       Display date in DD.MM format (metric units) or MM.DD (English units).
// @param       u8 line                 LINE1, LINE2
//                              u8 update               DISPLAY_LINE_UPDATE_FULL,
// DISPLAY_LINE_UPDATE_PARTIAL
// @return      none
// *************************************************************************************************
void display_date(u8 line, u8 update)
{
#ifdef CONFIG_DAY_OF_WEEK
	const u8 weekDayStr[7][3] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
#endif
    u8 *str;

    if (update == DISPLAY_LINE_UPDATE_FULL)
    {
        switch (sDate.display)
		{
			case DISPLAY_DEFAULT_VIEW: //WWW.DD
				// Convert day to string
#ifdef CONFIG_DAY_OF_WEEK
				str = int_to_array(sDate.day, 2, 1);
				display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);

				//pfs BEGIN replace year display with day of week
				//pfs algorith from http://klausler.com/new-dayofweek.html
				#define BASE_YEAR 2001 // not a leap year, so no need to add 1
				u8 skew;
				skew = (sDate.year - BASE_YEAR)+(sDate.year - BASE_YEAR)/4; // compute number of leap years since BASE_YEAR
				if ((29 == get_numberOfDays(2, sDate.year)) && (sDate.month < 3))
				  skew--; // if this is a leap year but before February 29
				skew = (skew + sDate.day); // add day of current month
				//add this month's skew value
				switch(sDate.month) {
				  case 5:
					skew += 1;
					break;
				  case 8:
					skew += 2;
					break;
				  case 2:
				  case 3:
				  case 11:
					skew += 3;
					break;
				  case 6:
					skew += 4;
					break;
				  case 9:
				  case 12:
					skew += 5;
					break;
				  case 4:
				  case 7:
					skew += 6;
					break;
				  default:  //January and October
					break;
				}
				skew = skew%7;
				str = (u8 *)weekDayStr[skew];
				display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_4_2), str, SEG_ON);
				display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
				break;
#else
		               // Convert day to string
			        str = int_to_array(sDate.day, 2, 0);
			#ifndef CONFIG_METRIC_ONLY
			        if (sys.flag.use_metric_units)
		                {
			#endif
			                display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
			#ifndef CONFIG_METRIC_ONLY
		                }
		                else
			        {
			                display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);
		                }
			#endif

		               // Convert month to string
		               str = int_to_array(sDate.month, 2, 0);
			#ifndef CONFIG_METRIC_ONLY
		              if (sys.flag.use_metric_units)
		              {
			                display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);
		              }
        		      else
	                      {
			                display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
		              }
			#else
		              display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);
#endif //CONFIG_METRIC_ONLY

            // Display "." to separate day and month
		              display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
			      break;
#endif //CONFIG_DAY_OF_WEEK
            case DISPLAY_ALTERNATIVE_VIEW: //MM  DD
#ifdef CONFIG_DAY_OF_WEEK
		// Convert day to string
		display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_ON);
		// display date
		#ifndef CONFIG_METRIC_ONLY
		if (!sys.flag.use_metric_units) {
			str = int_to_array(sDate.day, 2, 0);
			display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);

			// Convert month to string
			str = int_to_array(sDate.month, 2, 1);
			display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
		} 
		else 
		#else
		if (1) 
		#endif //CONFIG_METRIC_ONLY
		{
			str = int_to_array(sDate.day, 2, 0);
			display_chars(switch_seg(line, LCD_SEG_L1_3_2, LCD_SEG_L2_3_2), str, SEG_ON);
					
			str = int_to_array(sDate.month, 2, 0);
			display_chars(switch_seg(line, LCD_SEG_L1_1_0, LCD_SEG_L2_1_0), str, SEG_ON);
		}
		break;
	    case DISPLAY_ALTERNATIVE2_VIEW: //YYYY
#endif //CONFIG_DAY_OF_WEEK
			// Convert year to string
			str = int_to_array(sDate.year, 4, 0);
			display_chars(switch_seg(line, LCD_SEG_L1_3_0, LCD_SEG_L2_3_0), str, SEG_ON);
	
			// Clear "."
	                display_symbol(switch_seg(line, LCD_SEG_L1_DP1, LCD_SEG_L2_DP), SEG_OFF);
		break;
		default:
			display_time(line, update);
			break;
	}
    }
    else if (update == DISPLAY_LINE_CLEAR)
    {
        // Show day and month on display when coming around next time
        sDate.display = DISPLAY_DEFAULT_VIEW;
    }
}