void ArrowLineComp::Write (ostream& out) { LineComp::Write(out); ArrowLine* arrow = GetArrowLine(); out << arrow->Head() << " " << arrow->Tail() << " "; out << arrow->ArrowScale() << " "; WritePattern(arrow->GetPattern(), out); }
void MultiLineComp::Write (ostream& out) { VerticesComp::Write(out); SF_MultiLine* ml = GetMultiLine(); const Coord* x, *y; int count = ml->GetOriginal(x, y); WriteVertices(x, y, count, out); WriteBgFilled(ml->BgFilled(), out); WriteColor(ml->GetFgColor(), out); WriteColor(ml->GetBgColor(), out); WriteBrush(ml->GetBrush(), out); WritePattern(ml->GetPattern(), out); WriteTransformer(ml->GetTransformer(), out); }
void RectComp::Write (ostream& out) { GraphicComp::Write(out); SF_Rect* rect = GetRect(); Coord x0, y0, x1, y1; rect->GetOriginal(x0, y0, x1, y1); out << x0 << " " << y0 << " " << x1 << " " << y1 << " "; WriteBgFilled(rect->BgFilled(), out); WriteColor(rect->GetFgColor(), out); WriteColor(rect->GetBgColor(), out); WriteBrush(rect->GetBrush(), out); WritePattern(rect->GetPattern(), out); WriteTransformer(rect->GetTransformer(), out); }
void SplineComp::Write (ostream& out) { VerticesComp::Write(out); SFH_OpenBSpline* spline = GetSpline(); const Coord* x, *y; int count = spline->GetOriginal(x, y); WriteVertices(x, y, count, out); WriteBgFilled(spline->BgFilled(), out); WriteColor(spline->GetFgColor(), out); WriteColor(spline->GetBgColor(), out); WriteBrush(spline->GetBrush(), out); WritePattern(spline->GetPattern(), out); WriteTransformer(spline->GetTransformer(), out); }
void EllipseComp::Write (ostream& out) { GraphicComp::Write(out); SF_Ellipse* ellipse = GetEllipse(); Coord x0, y0; int r1, r2; ellipse->GetOriginal(x0, y0, r1, r2); out << x0 << " " << y0 << " " << r1 << " " << r2 << " "; WriteBgFilled(ellipse->BgFilled(), out); WriteColor(ellipse->GetFgColor(), out); WriteColor(ellipse->GetBgColor(), out); WriteBrush(ellipse->GetBrush(), out); WritePattern(ellipse->GetPattern(), out); WriteTransformer(ellipse->GetTransformer(), out); }
unsigned int PreloaderCmd::CMD_BootAsFastboot(BOOT_ARG_S * pArg) { unsigned int iRet = S_DONE; //Check parameters if(NULL == pArg) { printf( "Incorrect parameters!(NULL pointer)\n"); return S_INVALID_ARGUMENTS; } //Set parameters and open/configure port SetParameters(pArg); if(0 != (iRet = SetPort(pArg))) { printf("Set port fail!\n"); return iRet; } //printf("Start handshake with Preloader...\n"); //Read pattern "READY" PATTERN_INFO_S stPattern; stPattern.m_uStatus = S_DONE; stPattern.m_uLen = strlen(kStrReady); strcpy(stPattern.m_szPattern, kStrReady); iRet = ReadPattern(&stPattern, 1); if(S_DONE == iRet) { //printf("PreloaderCmd::CMD_BootAsFastboot(): Receive READY succeed!\n"); } else { printf( "Cannot receive pattern wanted!Ret(%u).\n", iRet); m_cPort.Close(); return iRet; } //Write pattern "FASTBOOT" and its parameters PL_MODE_PARA_S tModePara; PARA_VALUE_S_V1 tValue; tValue.m_cKernelUSBType = (pArg->m_bIsCompositeDeviceEnable) ? (0) : (1); tValue.m_cKernelUSBNum= 0; tValue.dummy1= 0; tValue.dummy2= 0; memcpy(tModePara.m_aMode, kStrFBTReq, strlen(kStrFBTReq)); tModePara.m_uParaLen = sizeof(PARA_VALUE_S_V1); tModePara.m_uParaVer = 1; tModePara.m_nParaVal.m_tParaV1 = tValue; //iRet = WritePattern(kStrFBTReq, strlen(kStrFBTReq)); iRet = WritePattern((char *)&tModePara, sizeof(PL_MODE_PARA_S)); if(S_DONE == iRet) { //printf( "Send Request.\n"); } else { printf("Send request fail. Ret(%u).\n", iRet); m_cPort.Close(); return iRet; } //Read pattern "TOOBTSAF" PATTERN_INFO_S stFBTPattern[1]; stFBTPattern[0].m_uStatus = S_DONE; stFBTPattern[0].m_uLen = strlen(kStrFBTSuccess); strcpy(stFBTPattern[0].m_szPattern, kStrFBTSuccess); //stFBTPattern[1].m_uStatus = S_PL_MODE_FORBIDDEN; //stFBTPattern[1].m_uLen = strlen(kStrFBTInvalid); //strcpy(stFBTPattern[1].m_szPattern, kStrFBTInvalid); iRet = ReadPattern(stFBTPattern, 1); #if 0 stPattern.m_uStatus = S_DONE; stPattern.m_uLen = strlen(kStrFBTSuccess); strcpy(stPattern.m_szPattern, kStrFBTSuccess); iRet = ReadPattern(&stPattern, 1); #endif if(S_DONE == iRet) { //printf("Receive confirm succeed.\n"); } else if(S_PL_MODE_INVALID_ARGUMETS == iRet) { printf("FASTBOOT mode arguments is invalid!\n"); } else { printf("Cannot receive pattern wanted!Err(%u).\n", iRet); } m_cPort.Close(); return iRet; }
/* ********************************************************************* * NAME: CollisionAvoidanceTask * CALLED BY: Created by main() thread * DESCRIPTION: Thread to Display movement of Car. This car speed * is controlled the measured distance. * INPUT PARAMETERS: TimeoutFlagLocal : used for ending this task * RETURN VALUES: None ***********************************************************************/ void* CollisionAvoidanceTask(void *TimeoutFlagLocal) { int FdDisplay; unsigned char count = 0, LoopIndex,SlowdownFlag = 0,LocalLineNum = 0,ReadBuff; /* Pattern that defines the CAR structure */ const unsigned char PatternESP[8][8] = { {0x00, 0x7c, 0x44, 0x47, 0x41, 0x7f, 0x22, 0x00}, {0x00, 0x3e, 0x22, 0xa3, 0xa0, 0xbf, 0x11, 0x00}, {0x00, 0x1f, 0x11, 0xd1, 0x50, 0xdf, 0x88, 0x00}, {0x00, 0x8f, 0x88, 0xe8, 0x28, 0xef, 0x44, 0x00}, {0x00, 0xc7, 0x44, 0x74, 0x14, 0xf7, 0x22, 0x00}, {0x00, 0xe3, 0x22, 0x3a, 0x0a, 0xfb, 0x11, 0x00}, {0x00, 0xf1, 0x11, 0x1d, 0x05, 0xfd, 0x88, 0x00}, {0x00, 0xf8, 0x88, 0x8e, 0x82, 0xfe, 0x44, 0x00} }; /* Two speeds for the car */ unsigned short DisplaySequenceRun[10][2]={ {0,CAR_DEFAULT_SPEED},{1,CAR_DEFAULT_SPEED},{2,CAR_DEFAULT_SPEED}, {3,CAR_DEFAULT_SPEED},{4,CAR_DEFAULT_SPEED},{5,CAR_DEFAULT_SPEED}, {6,CAR_DEFAULT_SPEED},{7,CAR_DEFAULT_SPEED},{0,0}, {0,0} }; unsigned short DisplaySequenceSlow[10][2]={ {0,CAR_SLOWDOW_SPEED},{1,CAR_SLOWDOW_SPEED},{2,CAR_SLOWDOW_SPEED}, {3,CAR_SLOWDOW_SPEED},{4,CAR_SLOWDOW_SPEED},{5,CAR_SLOWDOW_SPEED}, {6,CAR_SLOWDOW_SPEED},{7,CAR_SLOWDOW_SPEED},{0,0}, {0,0} }; FdDisplay = open("/dev/spi_led",O_RDWR); if (FdDisplay < 0) { printf("\n spi_led driver file open failed"); } /* Check if the display is free to accept new pattern */ do { #ifdef DEBUG printf("Waiting for display to get free "); #endif usleep(1000); }while (0 > read(FdDisplay,&ReadBuff,1)); /* write the car pattern */ for (LoopIndex = 0; LoopIndex < 8; LoopIndex++) { WritePattern(LoopIndex,&(PatternESP[LoopIndex][0]),FdDisplay); } /* Keep sending the sequence untill the timeout */ do { /* poll if the display has become free to accept new sequnece */ do { #ifdef DEBUG printf("Waiting for display to get free "); #endif usleep(1000); }while (0 > read(FdDisplay,&ReadBuff,1)); /* Read the distance and decide whether the car needs to be slowed down */ pthread_mutex_lock(&DistanceMutex); SlowdownFlag = (GlobalDistance < MINIMUM_DISTANCE_TO_STOP) ? (1) : (0); pthread_mutex_unlock(&DistanceMutex); /* Check whether car needs to be slowed down */ if(1 == SlowdownFlag) { /* Car needs to be slowed down , hence send the slow movement sequence */ write(FdDisplay,&DisplaySequenceSlow,sizeof(DisplaySequenceSlow)); } else { /* No obstacle with in the scan area, hence send full run sequence */ write(FdDisplay,&DisplaySequenceRun,sizeof(DisplaySequenceRun)); } }while(0 == (*((unsigned char *)TimeoutFlagLocal))); #ifdef DEBUG printf("\n Display programmed %i \n",Result); #endif return NULL; }
/* ********************************************************************* * NAME: ESPDisplayTask * CALLED BY: Created by main() thread * DESCRIPTION: Thread to display moving alphabets "ESP" * INPUT PARAMETERS: TimeoutFlagLocal : Not used * RETURN VALUES: None ***********************************************************************/ void* ESPDisplayTask(void *TimeoutFlagLocal) { int FdDisplay; unsigned char count = 0, LoopIndex, ReadBuff; const unsigned char PatternESP[23][8] = { {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, {0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}, {0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07}, {0x0f, 0x0f, 0x0c, 0x0f, 0x0f, 0x0c, 0x0f, 0x0f}, {0x1f, 0x1f, 0x18, 0x1f, 0x1f, 0x18, 0x1f, 0x1f}, {0x3e, 0x3e, 0x30, 0x3e, 0x3e, 0x30, 0x3e, 0x3e}, {0x7d, 0x7d, 0x61, 0x7d, 0x7d, 0x60, 0x7d, 0x7d}, {0xfb, 0xfb, 0xc3, 0xfb, 0xfb, 0xc0, 0xfb, 0xfb}, {0xf7, 0xf7, 0x86, 0xf7, 0xf7, 0x81, 0xf7, 0xf7}, {0xef, 0xef, 0x0c, 0xef, 0xef, 0x03, 0xef, 0xef}, {0xde, 0xde, 0x18, 0xde, 0xde, 0x06, 0xde, 0xde}, {0xbd, 0xbd, 0x31, 0xbd, 0xbd, 0x0d, 0xbd, 0xbd}, {0x7b, 0x7b, 0x63, 0x7b, 0x7b, 0x1b, 0x7b, 0x7b}, {0xf7, 0xf7, 0xc6, 0xf6, 0xf7, 0x36, 0xf6, 0xf6}, {0xef, 0xef, 0x8c, 0xec, 0xef, 0x2c, 0xec, 0xec}, {0xdf, 0xdf, 0x19, 0xd9, 0xdf, 0xd8, 0xd8, 0xd8}, {0xbe, 0xbe, 0x32, 0xb2, 0xbe, 0xb0, 0xb0, 0xb0}, {0x7c, 0x7c, 0x64, 0x64, 0x7c, 0x60, 0x60, 0x60}, {0xf8, 0xf8, 0xc8, 0xc8, 0xf8, 0xc0, 0xc0, 0xc0}, {0xf0, 0xf0, 0x90, 0x90, 0xf0, 0x80, 0x80, 0x80}, {0xe0, 0xe0, 0x20, 0x20, 0xe0, 0x00, 0x00, 0x00}, {0xc0, 0xc0, 0x40, 0x40, 0xc0, 0x00, 0x00, 0x00}, {0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00} }; unsigned short DisplaySequence[10][2]={ {0,500},{1,500},{2,500}, {3,500},{4,500},{5,500}, {6,500},{7,500},{8,500}, {9,400}/*Last one will be followed by a pattern change, hence less time*/ }; FdDisplay = open("/dev/spi_led",O_RDWR); if (FdDisplay < 0) { printf("\n spi_led driver file open failed"); } /* write first 10 pattern */ for(LoopIndex = 0; LoopIndex < 10; LoopIndex++) { WritePattern(LoopIndex,&(PatternESP[LoopIndex][0]),FdDisplay); } /* Write the display sequence */ write(FdDisplay,&DisplaySequence,sizeof(DisplaySequence)); /* poll if the display has become free to accept new pattern */ do { usleep(10000); }while (0 > read(FdDisplay,&ReadBuff,1)); /* By now it will be ready to accept new commands */ /* write next 10 pattern */ for(LoopIndex = 0; LoopIndex < 10; LoopIndex++) { WritePattern(LoopIndex,&(PatternESP[LoopIndex + 10][0]),FdDisplay); } /* Write the display sequence */ write(FdDisplay,&DisplaySequence,sizeof(DisplaySequence)); /* poll if the display has become free to accept new pattern */ do { usleep(10000); }while (0 > read(FdDisplay,&ReadBuff,1)); /* By now it will be ready to accept new commands */ /* write next 10 pattern */ for(LoopIndex = 0; LoopIndex < 3; LoopIndex++) { WritePattern(LoopIndex,&(PatternESP[LoopIndex + 20][0]),FdDisplay); } /* Display only last 3 patterns */ DisplaySequence[3][0] = 0; DisplaySequence[3][1] = 0; /* Write the display sequence */ write(FdDisplay,&DisplaySequence,sizeof(DisplaySequence)); #ifdef DEBUG printf("\n Display programmed %i \n",Result); #endif close(FdDisplay); return NULL; }