/*! Read the voltage of the battery. This provides power good, battery charging, * battery voltage, and battery voltage average. * * \param tHostMsg* pMsg is unused * */ static void ReadBatteryVoltageHandler(void) { tMessage OutgoingMsg; SetupMessageAndAllocateBuffer(&OutgoingMsg, ReadBatteryVoltageResponse, NO_MSG_OPTIONS); /* if the battery is not present then these values are meaningless */ OutgoingMsg.pBuffer[0] = QueryPowerGood(); OutgoingMsg.pBuffer[1] = QueryBatteryCharging(); unsigned int bv = ReadBatterySense(); OutgoingMsg.pBuffer[2] = bv & 0xFF; OutgoingMsg.pBuffer[3] = (bv >> 8 ) & 0xFF; bv = ReadBatterySenseAverage(); OutgoingMsg.pBuffer[4] = bv & 0xFF; OutgoingMsg.pBuffer[5] = (bv >> 8 ) & 0xFF; OutgoingMsg.Length = 6; RouteMsg(&OutgoingMsg); }
void DrawIdleScreen(void) { unsigned char msd; unsigned char lsd; unsigned char Row = 6; unsigned char Col = 0; /* display hour */ int Hour = GetRTCHOUR(); /* if required convert to twelve hour format */ if ( GetTimeFormat() == TWELVE_HOUR ) { if ( Hour == 0 ) { Hour = 12; } else if ( Hour > 12 ) { Hour -= 12; } } msd = Hour / 10; lsd = Hour % 10; /* if first digit is zero then leave location blank */ if ( msd != 0 ) { WriteTimeDigit(msd,Row,Col,LEFT_JUSTIFIED); } Col += 1; WriteTimeDigit(lsd,Row,Col,RIGHT_JUSTIFIED); Col += 2; /* the colon takes the first 5 bits on the byte*/ WriteTimeColon(Row,Col,RIGHT_JUSTIFIED); Col+=1; /* display minutes */ int Minutes = GetRTCMIN(); msd = Minutes / 10; lsd = Minutes % 10; WriteTimeDigit(msd,Row,Col,RIGHT_JUSTIFIED); Col += 2; WriteTimeDigit(lsd,Row,Col,LEFT_JUSTIFIED); if ( nvDisplaySeconds ) { /* the final colon's spacing isn't quite the same */ int Seconds = GetRTCSEC(); msd = Seconds / 10; lsd = Seconds % 10; Col +=2; WriteTimeColon(Row,Col,LEFT_JUSTIFIED); Col += 1; WriteTimeDigit(msd,Row,Col,LEFT_JUSTIFIED); Col += 1; WriteTimeDigit(lsd,Row,Col,RIGHT_JUSTIFIED); } else /* now things starting getting fun....*/ { DisplayAmPm(); if ( QueryBluetoothOn() == 0 ) { CopyColumnsIntoMyBuffer(pBluetoothOffIdlePageIcon, IDLE_PAGE_ICON_STARTING_ROW, IDLE_PAGE_ICON_SIZE_IN_ROWS, IDLE_PAGE_ICON_STARTING_COL, IDLE_PAGE_ICON_SIZE_IN_COLS); } else if ( QueryPhoneConnected() == 0 ) { CopyColumnsIntoMyBuffer(pPhoneDisconnectedIdlePageIcon, IDLE_PAGE_ICON_STARTING_ROW, IDLE_PAGE_ICON_SIZE_IN_ROWS, IDLE_PAGE_ICON_STARTING_COL, IDLE_PAGE_ICON_SIZE_IN_COLS); } else { if ( QueryBatteryCharging() ) { CopyColumnsIntoMyBuffer(pBatteryChargingIdlePageIconType2, IDLE_PAGE_ICON2_STARTING_ROW, IDLE_PAGE_ICON2_SIZE_IN_ROWS, IDLE_PAGE_ICON2_STARTING_COL, IDLE_PAGE_ICON2_SIZE_IN_COLS); } else { unsigned int bV = ReadBatterySenseAverage(); if ( bV < 3500 ) { CopyColumnsIntoMyBuffer(pLowBatteryIdlePageIconType2, IDLE_PAGE_ICON2_STARTING_ROW, IDLE_PAGE_ICON2_SIZE_IN_ROWS, IDLE_PAGE_ICON2_STARTING_COL, IDLE_PAGE_ICON2_SIZE_IN_COLS); } else { DisplayDayOfWeek(); DisplayDate(); } } } } }