/* Send interrupt notification to the phone or * read data from the accelerometer and send it to the phone */ static void AccelerometerSendDataHandler(void) { tMessage Msg; SetupMessageWithBuffer(&Msg, AccelIndMsg, MSG_OPT_NONE); if (Msg.pBuffer != NULL) { if (Control & WUF_ENABLE) { AccelerometerRead(KIONIX_XOUT_HPF_L, Data, XYZ_DATA_LENGTH); AccelerometerRead(KIONIX_INT_REL, Data, ONE_BYTE); //clear int } else AccelerometerRead(KIONIX_XOUT_L, Data, XYZ_DATA_LENGTH); Msg.pBuffer[0] = CONVERT_TO_8_BIT(0); Msg.pBuffer[1] = CONVERT_TO_8_BIT(2); Msg.pBuffer[2] = CONVERT_TO_8_BIT(4); Msg.Length = 3; RouteMsg(&Msg); PrintH(Msg.pBuffer[0]); PrintC(SPACE); PrintH(Msg.pBuffer[1]); PrintC(SPACE); PrintH(Msg.pBuffer[2]); PrintR(); } }
void EnableDebugUart(unsigned char Enable) { if (!UartMutex) { UCA3CTL1 = UCSWRST; /* set the baud rate to 115200 (from table 32-5 in slau208j) */ UCA3CTL1 |= UCSSEL__SMCLK; UCA3BR0 = 145; UCA3MCTL = UCBRS_5 + UCBRF_0; /* configure tx and rx pins */ P10SEL |= BIT4; P10SEL |= BIT5; /* clear status */ UCA3STAT = 0; /* take uart out of reset */ UCA3CTL1 &= ~UCSWRST; /* prime transmitter */ UCA3IE = 0; UCA3IFG = 0; //UCTXIFG; UartMutex = xSemaphoreCreateMutex(); xSemaphoreGive(UartMutex); DebugEnabled = TRUE; PrintR(); PrintC(STAR); PrintC(STAR); PrintC(STAR); PrintR(); } DebugEnabled = Enable; EnableTermMode(Enable); }
void ShowStateInfo(void) { if (!pStateLog) return; State_t *pState = (State_t *)pStateLog; PrintS("---- State before reset ----"); if (pState->ResetSource > 0x22) pState->ResetSource = 0x22; PrintS(ResetReason[pState->ResetSource >> 1]); PrintF("ResetCode:%s %u", ResetCode[pState->ResetCode], pState->ResetValue); PrintF("RadioIdle:%u", pState->RadioReadyToSleep); PrintF("DisplayQueue:%u", pState->DisplayQueue); PrintF("WrapperQueue:%u", pState->WrapperQueue); if (pState->ResetSource == SYSRSTIV_WDTTO || pState->ResetSource == SYSRSTIV_WDTKEY) { PrintF("# WDT %s", pState->ResetSource == SYSRSTIV_WDTTO ? "Failsafe" : "Forced"); pState->WdtNum ++; } PrintF("Total WDT:%u", pState->WdtNum); PrintF("MuxMode:%s", MuxMode[pState->MuxMode]); unsigned char i; PrintW("Property:"); for (i = 0; i < 7; ++i) { if (pState->Property & (1 << i)) {PrintW(Property[i]); PrintC(SPACE);} } PrintR(); PrintF("State:%s", Bluetooth[pState->Bluetooth]); PrintW("Conn:"); for (i = 0; i < 7; ++i) { if (pState->ConnType & (1 << i)) {PrintW(ConnType[i]); PrintC(SPACE);} } PrintR(); PrintF("Dscnn:%u", pState->Disconnects); PrintF("Battery:%u%c", pState->Battery, PERCENT); PrintF("SrvChgdHandle:%u", pState->SrvChgdHandle); PrintS("-------- State end --------"); }
void RestoreConfig() { int n; char *envname; char envbuf[256]; char *name; char *ptr; char buf[80]; SetColor(LIGHTWHITE); SetBackColor(BLUE); OpenWindow(10,10,3,60); SetColor(YELLOW); Print_At(10,13," Restore Predefined Configuration "); SetColor(LIGHTWHITE); Print_At(11,12,"Enter file name:"); name=InputString(11,30,37,cfgfilename); if(name!=NULL && name[0]!=0) { strcpy(buf,name); ptr=(char *)strchr(buf,'.'); if(ptr!=NULL) strset(ptr,0); strcpy(cfgfilename,buf); strcat(buf,".d32"); n=open(buf,O_RDONLY | O_BINARY); if(n==-1) { envname=getenv("DOS32A"); if(envname!=NULL) { ptr=strchr(envname,' '); if(ptr==NULL) ptr=strchr(envname,0); memset(envbuf,0,256); strncpy(envbuf,envname,(dword)ptr-(dword)envname); strcat(envbuf,"\\D32\\"); strcat(envbuf,buf); n=open(envbuf,O_RDWR | O_BINARY); } } if(n!=-1) { read(n,&id32,24); close(n); SetColor(LIGHTWHITE); SetBackColor(BLUE); strupr(buf); for(n=0; n<13; n++) { SetPos(24,66+n); PrintC(' '); } Print_At(24,66,"%.13s",buf); } else DiskError(); } ValidateConfig(); CloseWindow(); if(mainmenu_sel==1) ShowBannerStatus(); }
int main() { unsigned char chr; do { if(!top)cout<<"1. Add new books"<<endl; if(top) cout<<"2. Print information about all books sort by year"<<endl; if(top) cout<<"3. Print information about the C/C++ books"<<endl; cout<<"4. Exit\n"<<endl; cout<<"Enter command : "<<endl; cin>>chr; switch(chr) { case '1': cout<<"-------------------------------"<<endl; cout<<"Enter information about books"<<endl; cout<<"(end of entering - 0)"<<endl; cout<<"-------------------------------"<<endl; do { last=AddBook(last); } while (last!=NULL); break; case '2': if(top) { SortByYear(); PrintAllBooks(top); } break; case '3': if(top) { PrintC(top); } break; } cout<<endl; } while(chr != '4'); FreeList ( top ); system("pause"); return 0; }
void DrawBootloaderScreen(void) { #if BOOTLOADER FillMyBuffer(STARTING_ROW, LCD_ROW_NUM, 0x00); CopyRowsIntoMyBuffer(pBootloader, BOOTLOADER_START_ROW, BOOTLOADER_ROWS); // Draw version SetFont(MetaWatch5); gRow = 61; gColumn = 4; gBitColumnMask = BIT3; DrawString("V ", DRAW_OPT_BITWISE_OR); DrawString((char const *)VERSION, DRAW_OPT_BITWISE_OR); unsigned char i = 0; char const *pBootVer = BootVersion; PrintF("BL_VER addr:%04X", pBootVer); for (; i < 8; ++i) {PrintH(pBootVer[i]); PrintC(SPACE);} i = 0; while (*pBootVer && i++ < 8) { if ((*pBootVer < ZERO || *pBootVer > '9') && *pBootVer != '.') break; pBootVer ++; } if (i > 4) // at least x.x.x { gRow += 7; gColumn = 4; gBitColumnMask = BIT3; DrawString("B ", DRAW_OPT_BITWISE_OR); DrawString(BootVersion, DRAW_OPT_BITWISE_OR); } DrawLocalAddress(1, 80); SendMyBufferToLcd(STARTING_ROW, LCD_ROW_NUM); #endif }
void CreateConfig() { int n; char *name; char *ptr; char buf[80]; SetColor(LIGHTWHITE); SetBackColor(BLUE); OpenWindow(10,10,3,60); SetColor(YELLOW); Print_At(10,13," Create Predefined Configuration "); SetColor(LIGHTWHITE); Print_At(11,12,"Enter file name:"); name=InputString(11,30,37,cfgfilename); if(name!=NULL && name[0]!=0) { strcpy(buf,name); ptr=(char *)strchr(buf,'.'); if(ptr!=NULL) strset(ptr,0); strcpy(cfgfilename,buf); strcat(buf,".D32"); n=open(buf,O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU); if(n!=-1) { write(n,&id32,24); close(n); SetColor(LIGHTWHITE); SetBackColor(BLUE); strupr(buf); for(n=0; n<13; n++) { SetPos(24,66+n); PrintC(' '); } Print_At(24,66,"%.13s",buf); } else DiskError(); } CloseWindow(); }
char *InputString(int y, int x, int l, char *tmp) { int n,m, xx; char c; static char buf[80]; char *defbuf[] = { "DEFAULT.D32", "DOS4GW.D32", "FAILSAFE.D32", "MAXIMUM.D32", "MINIMUM.D32", "PMODEW.D32", "STANDARD.D32", "VERBOSE.D32", "CUSTOM.D32", "" }; m=-1; xx=x; if(tmp!=NULL) strcpy(buf,tmp); l8: Print_At(y,x-1,"<"); Print_At(y,x+l,">"); for(n=0; n<l; n++) Print_At(y,x+n,"."); for(n=0; buf[n]!=NULL; n++) { SetPos(y,x+n); PrintC(buf[n]); } for(; n<l; n++) { l0: SetBlink(1); Print_At(y,x+n,"Û"); SetBlink(0); do { GetKey(); c=toupper(keychar); if(c==0x1B) goto l1; if(c==0x0D) goto l1; if(c==0x08) break; if(keycode==UP) { m++; if(m>8) m=0; x=xx; strcpy(buf,defbuf[m]); goto l8; } if(keycode==DOWN) { m--; if(m<0) m=8; x=xx; strcpy(buf,defbuf[m]); goto l8; } } while(c<0x20); if(c==0x08) { if(n>0) { Print_At(y,x+n,"."); n--; goto l0; } else goto l0; } buf[n]=c; Print_At(y,x+n,"%c",c); } l1: buf[n]=0; Print_At(y,x-1," "); Print_At(y,x+l," "); for(n=0; n<l; n++) Print_At(y,x+n," "); keychar=keycode=0; if(c==0x1B) return(NULL); else if(strlen(buf)==0) return(NULL); else return(buf); }