/***************************************************************************** * Function: TBannerChangeField * * Precondition: None. * * Overview: The function increases/decreases the selected clock field. * * Input: Direction of changing: 0 to decrement otherwise increment. * * Output: None. * *****************************************************************************/ void TBannerChangeField(char increment){ unsigned char data; if(_uTBannerSetup){ mRTCCUnlock(); switch(_uTBannerCurPos){ case TBNR_POS_WKDAY: break; case TBNR_POS_HOUR: data = mRTCCGetBinHour(); if(increment) data++; else data--; RTCCSetBinHour(data); break; case TBNR_POS_MIN: data = mRTCCGetBinMin(); if(increment) data++; else data--; RTCCSetBinMin(data); break; case TBNR_POS_SEC: data = mRTCCGetBinSec(); if(increment) data++; else data--; RTCCSetBinSec(data); break; case TBNR_POS_MONTH: data = mRTCCGetBinMonth(); if(increment) data++; else data--; RTCCSetBinMonth(data); RTCCCalculateWeekDay(); break; case TBNR_POS_DAY: data = mRTCCGetBinDay(); if(increment) data++; else data--; RTCCSetBinDay(data); RTCCCalculateWeekDay(); break; case TBNR_POS_YEAR: data = mRTCCGetBinYear(); if(increment) data++; else data--; RTCCSetBinYear(data); RTCCCalculateWeekDay(); break; default: ; }// End of switch(_uTBannerCurPos ... mRTCCSet(); } }
WORD ProcessMessageTime( WORD translatedMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg ) { signed char change; WORD controlID; signed char day; signed char dayMax; signed char hour; signed char minute; signed char month; signed char year; controlID = GetObjID(pObj); switch (controlID) { case ID_RTCC_BUTTON_NEXT: // Show the old control set as unselected. IndicateFocus( BLACK ); // Set the next control as active. currentControlSet ++; if (currentControlSet > CONTROL_SET_MAX) { currentControlSet = 0; } // Show the new control set as selected. IndicateFocus( WHITE ); return 0; // Hidden button break; case ID_RTCC_BUTTON_PREVIOUS: // Show the old control set as unselected. IndicateFocus( BLACK ); // Set the next control as active. currentControlSet --; if (currentControlSet < 0 ) { currentControlSet = CONTROL_SET_MAX; } // Show the new control set as selected. IndicateFocus( WHITE ); return 0; // Hidden button break; case ID_RTCC_BUTTON_HOME: screenState = SCREEN_DISPLAY_MAIN; return 0; // Hidden button break; case ID_DAY_PLUS: case ID_MONTH_PLUS: case ID_YEAR_PLUS: case ID_HOUR_PLUS: case ID_MINUTE_PLUS: if (translatedMsg == BTN_MSG_PRESSED) { change = +1; } else { return 1; } break; case ID_DAY_MINUS: case ID_MONTH_MINUS: case ID_YEAR_MINUS: case ID_HOUR_MINUS: case ID_MINUTE_MINUS: if (translatedMsg == BTN_MSG_PRESSED) { change = -1; } else { return 1; } break; default: return 0; } // Update the selected field. RTCCProcessEvents(); hour = RTCCGetBinHour(); minute = RTCCGetBinMin(); day = RTCCGetBinDay(); month = RTCCGetBinMonth(); year = RTCCGetBinYear(); dayMax = daysPerMonth[month-1]; // February has one day more for a leap year, unless it is on the thousands if ((month == 2) && ((year % 4) == 0) && (year != 0)) { dayMax ++; } // Change the appropriate setting. Allow the controls to roll over. switch (currentControlSet) { case CONTROL_SET_DAY: day += change; if (day < 1) { day = dayMax; } if (day > dayMax) { day = 1; } break; case CONTROL_SET_MONTH: month += change; if (month < 1) { month = 12; } if (month > 12) { month = 1; } break; case CONTROL_SET_YEAR: year += change; if (year < 0) { year = 99; } if (year > 99) { year = 0; } break; case CONTROL_SET_HOUR: hour += change; if (hour < 0) { hour = 23; } if (hour > 23) { hour = 0; } break; case CONTROL_SET_MINUTE: minute += change; if (minute < 0) { minute = 59; } if (minute > 59) { minute = 0; } break; default: return 0; } RTCCOff(); RTCCSetBinHour( hour ); RTCCSetBinMin( minute ); RTCCSetBinSec( 0 ); RTCCSetBinMonth( month ); RTCCSetBinYear( year ); RTCCSetBinDay( day ); RTCCCalculateWeekDay(); RTCCSet(); // Copy the new values to the RTCC registers UpdateDateTime(); // Update the display. return 1; // Call the default handler to show the button state. }