static void HandleProperty(unsigned char Options) { if (Options & PROPERTY_READ) CreateAndSendMessage(PropRespMsg, GetProperty(PROP_ALL)); else { SetProperty(PROP_ALL, Options & PROP_ALL); CreateAndSendMessage(PropRespMsg, MSG_OPT_NONE); CreateAndSendMessage(UpdateDisplayMsg, IDLE_MODE | MSG_OPT_NEWUI); } }
/* This originally was for battery charge control, but now it handles * other things that must be periodically checked such as * mux control and task check in (watchdog) */ static void MonitorBattery(void) { static unsigned char LastPercent = 101; #if CHECK_CSTACK if (LastPercent == 101) CheckCStack(); #endif unsigned char ClipChanged = CheckClip(); CheckBattery(); if (ClipChanged || Charging() || CurrentPage[PageType] == StatusPage) { unsigned char CurrPercent = BatteryPercentage(); if (CurrPercent != LastPercent || ClipChanged) { if (CurrentPage[PageType] == StatusPage) DrawWatchStatusScreen(); else UpdateClock(); // must be the last to avoid screen mess-up LastPercent = CurrPercent; } } /* Watchdog requires each task to check in. * If the background task reaches here then it can check in. * Send a message to the other tasks so that they must check in. */ TaskCheckIn(eDisplayTaskCheckInId); CreateAndSendMessage(WrapperTaskCheckInMsg, MSG_OPT_NONE); #if TASK_DEBUG UTL_FreeRtosTaskStackCheck(); #endif }
void Init(void) { __disable_interrupt(); ENABLE_LCD_LED(); DISABLE_LCD_POWER(); /* clear shipping mode, if set to allow configuration */ PMMCTL0_H = PMMPW_H; PM5CTL0 &= ~LOCKLPM5; PMMCTL0_H = 0x00; /* disable DMA during read-modify-write cycles */ DMACTL4 = DMARMWDIS; #ifdef BOOTLOADER /* * enable RAM alternate interrupt vectors * these are defined in AltVect.s43 and copied to RAM by cstartup */ SYSCTL |= SYSRIVECT; ClearBootloaderSignature(); #else SaveResetSource(); #endif SetupClockAndPowerManagementModule(); CheckResetCode(); if (niReset != NORMAL_RESET_CODE) { InitProperty(); } InitBufferPool(); // message queue InitBattery(); CheckClip(); PrintF("*** %s:%s", niReset == FLASH_RESET_CODE ? "FLASH" : (niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL"), niBuild); ShowWatchdogInfo(); WhoAmI(); /* timer for battery checking at a regular frequency. */ StartTimer(BatteryTimer); InitVibration(); InitRealTimeClock(); // enable rtc interrupt LcdPeripheralInit(); DrawSplashScreen(); SerialRamInit(); /* turn the radio on; initialize the serial port profile or BLE/GATT */ CreateAndSendMessage(TurnRadioOnMsg, MSG_OPT_NONE); DISABLE_LCD_LED(); }
/*! Switch from other-mode/menu page back to idle type page */ static void IdleUpdateHandler(void) { PageType = PAGE_TYPE_IDLE; UpdateClock(); if (OnceConnected()) CreateAndSendMessage(UpdateDisplayMsg, IDLE_MODE | MSG_OPT_NEWUI | MSG_OPT_UPD_INTERNAL); else DrawConnectionScreen(); }
void UTL_FreeRtosTaskStackCheck(void) { taskInfoArray[PrintTaskIndex].FreeEntries = uxTaskGetStackHighWaterMark(taskInfoArray[PrintTaskIndex].taskHandle); /* free, used, total */ PrintF("%s %d %d %d", (char*)pcTaskGetTaskName(taskInfoArray[PrintTaskIndex].taskHandle), taskInfoArray[PrintTaskIndex].FreeEntries, taskInfoArray[PrintTaskIndex].Depth - taskInfoArray[PrintTaskIndex].FreeEntries, taskInfoArray[PrintTaskIndex].Depth)); PrintTaskIndex ++; if (rintTaskIndex >= TaskIndex) { PrintTaskIndex = 3; CreateAndSendMessage(&Msg, QueryMemoryMsg, MSG_OPT_NONE); } }
static void BootloaderHandler(void) { PrintString("bootloader handler\r\n"); CreateAndSendMessage(MenuButtonMsg, MENU_BUTTON_OPTION_ENTER_BOOTLOADER_MODE); }
static void DrawCallNotification(unsigned char const *pVal, int Len) { PrintW("-DrwCall:"); PrintQ(pVal, Len); Draw_t const *pItem = CallItem; Draw_t Info; unsigned char i = 0; ClearSram(NOTIF_MODE); // quit icon memcpy(&Info, pItem++, sizeof(Draw_t)); Draw(&Info, NULL, NOTIF_MODE); // small phone icon memcpy(&Info, pItem++, sizeof(Draw_t)); Draw(&Info, NULL, NOTIF_MODE); // timestamp icon memcpy(&Info, pItem++, sizeof(Draw_t)); Draw(&Info, NULL, NOTIF_MODE); // timestamp memcpy(&Info, pItem++, sizeof(Draw_t)); Draw(&Info, NULL, NOTIF_MODE); // call from memcpy(&Info, pItem++, sizeof(Draw_t)); Info.Width = sizeof(Text) - 1; Draw(&Info, Text, NOTIF_MODE); // caller name memcpy(&Info, pItem, sizeof(Draw_t)); if (*pVal >= '0' && *pVal <= '9' || *pVal == '+') { SetCallerNumber(pVal, Len); pVal = NoName; Len = sizeof(NoName) - 1; } // split and draw first, last names and call number if available // while (Len >= 0) // { // i = 0; while (pVal[i] != SPACE && i < Len) i++; // // PrintF(" W:%u", i); // Info.Width = i; // Draw(&Info, pVal, NOTIF_MODE); // // memcpy(&Info, pItem, sizeof(Draw_t)); // Info.Y += CALLER_NAME_HEIGHT; // pVal += i + 1; // Len -= i + 1; // } i = 0; while (pVal[i] != SPACE && i < Len) i++; PrintF(" W:%u", i); Info.Width = i; Draw(&Info, pVal, NOTIF_MODE); if (i < Len - 1) { memcpy(&Info, pItem, sizeof(Draw_t)); Info.Y += CALLER_NAME_HEIGHT; pVal += i + 1; Len -= i + 1; Info.Width = Len; Draw(&Info, pVal, NOTIF_MODE); } if (pCallerNumber) { memcpy(&Info, &CallItem[CALLER_NUMBER_ITEM], sizeof(Draw_t)); Info.Width = NumberLen; Draw(&Info, pCallerNumber, NOTIF_MODE); vPortFree(pCallerNumber); pCallerNumber = NULL; } CreateAndSendMessage(ChangeModeMsg, NOTIF_MODE | MSG_OPT_UPD_INTERNAL); }
void SetWidgetList(tMessage *pMsg) { static Widget_t *pCurrWidget = NULL; // point to Widget in current Widget[] static Widget_t *pNextWidget = NULL; // point to Widget in new Widget[] static unsigned char ChangedClockWidget = INVALID_ID; xSemaphoreTake(SramMutex, portMAX_DELAY); WidgetList_t *pMsgWgtLst = (WidgetList_t *)pMsg->pBuffer; unsigned char WidgetNum = pMsg->Length / WIDGET_HEADER_LEN; unsigned char i = 0; PrintF(">SetWLst I:%d %s %d %s %d", WGTLST_INDEX(pMsg->Options), "T:", WGTLST_TOTAL(pMsg->Options), "Num:", WidgetNum); for(; i<WidgetNum; ++i) {PrintH(pMsgWgtLst[i].Id); PrintH(pMsgWgtLst[i].Layout);} PrintR(); if (pNextWidget == NULL) // first time call, only add widgets { pCurrWidget = pCurrWidgetList; pNextWidget = &Widget[0]; } else { if (WGTLST_INDEX(pMsg->Options) == 0 && (pCurrWidget != pCurrWidgetList || (pNextWidget != &Widget[0] && pNextWidget != &Widget[MAX_WIDGET_NUM]))) { // last SetWLst failed in the middle.Clean up whole list PrintS("# Last SetWgtLst broken!"); pCurrWidget = pCurrWidgetList; pNextWidget = &Widget[0] + (&Widget[MAX_WIDGET_NUM] - pCurrWidgetList); } } while (WidgetNum) // number of list items { /* old clock widgets */ if (!IS_CLOCK_WIDGET(pMsgWgtLst->Layout) && pMsgWgtLst->Id <= CLOCK_WIDGET_ID_RANGE) TestFaceId(pMsgWgtLst); unsigned char Change = GetWidgetChange(pCurrWidget->Id, pCurrWidget->Layout, pMsgWgtLst->Id, pMsgWgtLst->Layout); switch (Change) { case WGT_CHG_CLK_FACE: PrintS("Chg ClkFce"); if (ON_CURRENT_PAGE(pMsgWgtLst->Layout)) ChangedClockWidget = pMsgWgtLst->Id; case WGT_CHG_SETTING: //cpy layout to curr; cpy curr to next; msg, curr, next ++ PrintF("=%02X", pCurrWidget->Id); pCurrWidget->Id = pMsgWgtLst->Id; pCurrWidget->Layout = pMsgWgtLst->Layout; *pNextWidget++ = *pCurrWidget++; pMsgWgtLst ++; WidgetNum --; break; case WGT_CHG_CLK_ADD: PrintS("+Clk"); if (ON_CURRENT_PAGE(pMsgWgtLst->Layout)) ChangedClockWidget = pMsgWgtLst->Id; case WGT_CHG_ADD: //pCurrWidget->Id > pMsgWgtLst->Id) // add new widget: cpy msg to next; msg and next ++; curr stays PrintF("+%02X", pMsgWgtLst->Id); pNextWidget->Id = pMsgWgtLst->Id; pNextWidget->Layout = pMsgWgtLst->Layout; AssignWidgetBuffer(pNextWidget); pNextWidget ++; pMsgWgtLst ++; WidgetNum --; break; case WGT_CHG_REMOVE: // remove widget: curr ++ PrintF("-%02X", pCurrWidget->Id); FreeWidgetBuffer(pCurrWidget); pCurrWidget ++; break; default: break; } } PrintR(); // if part index + 1 == parts, SetWidgetList complete if (WGTLST_TOTAL(pMsg->Options) == WGTLST_INDEX(pMsg->Options) + 1) { // PrintS("C:"); // for (i=0; pCurrWidgetList[i].Id != INVALID_ID && i < MAX_WIDGET_NUM; ++i) PrintH(pCurrWidgetList[i].Id); // PrintR(); while (pCurrWidget->Id != INVALID_ID && pCurrWidget < &pCurrWidgetList[MAX_WIDGET_NUM]) { FreeWidgetBuffer(pCurrWidget); pCurrWidget->Id = INVALID_ID; pCurrWidget ++; } for (i = 0; i < MAX_WIDGET_NUM; ++i) { if (pCurrWidgetList[i].Id != INVALID_ID) { // clear the widget id in the curr list pCurrWidgetList[i].Id = INVALID_ID; } } pNextWidget = pCurrWidgetList; pCurrWidgetList = &Widget[0] + (&Widget[MAX_WIDGET_NUM] - pCurrWidgetList); pCurrWidget = pCurrWidgetList; // PrintS("N:"); // for (i=0; pCurrWidgetList[i].Id != INVALID_ID; ++i) PrintH(pCurrWidgetList[i].Id); // PrintR(); PrintF("Tg:%04X", BufTag); if (ChangedClockWidget != INVALID_ID) { CreateAndSendMessage(DrawClockWidgetMsg, ChangedClockWidget); ChangedClockWidget = INVALID_ID; } } xSemaphoreGive(SramMutex); }