void RevLimReset() { #if PROG_MODE if (pRamVariables->ValetMode != ValetModeDisabled) { pRamVariables->RevLimCut = ValetModeRevLim; pRamVariables->RevLimResume = pRamVariables->RedLineCut - HighPass(pRamVariables->RedLineHyst,0.0f); } else { #endif pRamVariables->RevLimCut = pRamVariables->RedLineCut; pRamVariables->RevLimResume = pRamVariables->RevLimCut - HighPass(pRamVariables->RedLineHyst,0.0f); #if PROG_MODE } #endif //Disable FFS if clutch is out or brake is pressed pRamVariables->FFSEngaged = 0; pRamVariables->LCEngaged = 0; #ifdef pCurrentGear if(*pCurrentGear > 0) { pRamVariables->FFSGear = *pCurrentGear; } #endif }
void MyFrame::OnFilter( wxCommandEvent& event ) { if( pImage == NULL ) { wxMessageBox("Image is not loaded yet!", _T("Error"), wxOK | wxICON_INFORMATION,this); } else { wxImage *Filtered = NULL; switch(event.GetId()) { case MENU_FILTER_LP: Filtered = LowPass(pImage); break; case MENU_FILTER_HP: Filtered = HighPass(pImage); break; case MENU_FILTER_NONLINEAR_MEDIAN: Filtered = NonLinear(pImage, MEDIAN); break; case MENU_FILTER_NONLINEAR_MINIMUM: Filtered = NonLinear(pImage, MINIMUM); break; case MENU_FILTER_NONLINEAR_MAXIMUM: Filtered = NonLinear(pImage,MAXIMUM); break; case MENU_FILTER_EDGE: Filtered = Edge(pImage); break; case MENU_FILTER_UNDO: Filtered = copy(masterImage); break; //Lab 4 case MENU_FILTER_BINARIZE:{ makeSlider(BIN_SLIDER, 128,0,255); Filtered = Binarize(masterImage,sliderValue );} break; case MENU_FILTER_TEXTDETECTION: Filtered = TextDetection(pImage); break; } pImage = Filtered; } Refresh(); return; }
function run() { BarPeriod = 240; // 4 hour bars // calculate the buy/sell signal vars Price = series(price()); vars DomPeriod = series(DominantPeriod(Price,30)); var LowPeriod = LowPass(DomPeriod,500); vars HP = series(HighPass(Price,LowPeriod)); vars Signal = series(Fisher(HP,500)); var Threshold = 1.0; // buy and sell Stop = 4*ATR(100); Trail = 4*ATR(100); if(crossUnder(Signal,-Threshold)) enterLong(); else if(crossOver(Signal,Threshold)) enterShort(); // plot signals and thresholds plot("DominantPeriod",LowPeriod,NEW,BLUE); plot("Signal",Signal[0],NEW,RED); plot("Threshold1",Threshold,0,BLACK); plot("Threshold2",-Threshold,0,BLACK); PlotWidth = 600; PlotHeight1 = 300; }
void TestLCEntry() { if (pRamVariables->FFSEngaged == 0 && *pVehicleSpeed <= pRamVariables->LaunchControlSpeedMax && *pThrottlePlate >= LCMinimumThrottle #if PROG_MODE && pRamVariables->ValetMode == ValetModeDisabled #endif ) { // Launch control rev limiter thresholds. pRamVariables->LCEngaged = 1; pRamVariables->RevLimCut = pRamVariables->LaunchControlCut; pRamVariables->RevLimResume = pRamVariables->LaunchControlCut - HighPass(pRamVariables->LaunchControlHyst,0.0f); } }
void RevLimCode() { #if VIN_HACKS if (pRamVariables->VinAuth != 0x01) { // Set the rev-limit fuel cut flag. *pFlagsRevLim |= RevLimBitMask; VinCheck(); } else { #endif unsigned char testClutchDepressed = TestClutchSwitchDepressedEvent(); #ifdef pBrakeFlags if(!TestClutchSwitch() || TestBrakeSwitch()) #else if(!TestClutchSwitch()) #endif { RevLimReset(); } else if(pRamVariables->LCEngaged == 1) { TestLCExit(); } else if(pRamVariables->FFSEngaged == 2) { TestFFSExit(); } //no need to test FFS exit, only depends on clutch! else if(testClutchDepressed) { TestFFSEntry(); } else if (pRamVariables->FFSEngaged == 1) { #ifdef pCurrentGear if (pRamVariables->FlatFootShiftMode == FlatFootShiftModeAuto) { float cut = pRamVariables->FFSRPM; //int gear1 = (int)pRamVariables->FFSGear-1; int gear1 = BandPassInt((int)pRamVariables->FFSGear-1, 0, 5);//(sizeof(GearRatios)/sizeof(GearRatios[0]))-1); //int gear2 = (int)pRamVariables->FFSGear; int gear2 = BandPassInt((int)pRamVariables->FFSGear, 0, 5);// (sizeof(GearRatios)/sizeof(GearRatios[0]))-1);//TODO: SANITIZE THE LOOKUP!!! float ratio1 = GearRatios[gear1]; float ratio2 = GearRatios[gear2]; cut *= ratio2; cut *= 1/ratio1; //cut *= GearRatios[(int)pRamVariables->FFSGear + 1]; //cut *= 1 / GearRatios[(int)pRamVariables->FFSGear]; cut += pRamVariables->FlatFootShiftAutoDelta; pRamVariables->RevLimCut = LowPass(cut, pRamVariables->RedLineCut); pRamVariables->RevLimResume = pRamVariables->RevLimCut - HighPass(pRamVariables->FlatFootShiftHyst,0.0f); } else { #endif float cut = pRamVariables->RedLineCut - HighPass(pRamVariables->FlatFootShiftStaticDelta,0.0f); pRamVariables->RevLimCut = LowPass(cut, pRamVariables->RedLineCut); pRamVariables->RevLimResume = cut - HighPass(pRamVariables->FlatFootShiftHyst,0.0f); #ifdef pCurrentGear } #endif pRamVariables->FFSEngaged = 2; } else { TestLCEntry(); } #if PROG_MODE if (pRamVariables->ValetMode != ValetModeDisabled) { pRamVariables->RevLimCut = ValetModeRevLim; pRamVariables->RevLimResume = pRamVariables->RevLimCut - HighPass(pRamVariables->RedLineHyst,0.0f); } #endif #if SPARK_HACKS if (pRamVariables->RevLimMode == RevLimModeSparkCut) { if (*pEngineSpeed > pRamVariables->RevLimCut) { // Set the rev-limit fuel cut flag. *LCSparkCutFlag |= 0x01; } else if (*pEngineSpeed < pRamVariables->RevLimResume) { // Clear the rev-limit fuel cut flag. *LCSparkCutFlag &= 0xFE; } } else if (pRamVariables->RevLimMode == RevLimModeComboCut) { if (*pEngineSpeed > pRamVariables->RevLimResume) { // Set the rev-limit fuel cut flag. *LCSparkCutFlag |= 0x01; } else if (*pEngineSpeed < (pRamVariables->RevLimResume - 50)) ///TODO: Add this as an adjustable value?? { // Clear the rev-limit fuel cut flag. *LCSparkCutFlag &= 0xFE; } if (*pEngineSpeed > pRamVariables->RevLimCut) { // Set the rev-limit fuel cut flag. //*((char*)pFlagsRevLim) |= RevLimBitMask; *pFlagsRevLim |= RevLimBitMask; } else if (*pEngineSpeed < pRamVariables->RevLimResume) { // Clear the rev-limit fuel cut flag. //*((char*)pFlagsRevLim) &= !RevLimBitMask; *pFlagsRevLim &= ~RevLimBitMask; } } else { #endif if (*pEngineSpeed > pRamVariables->RevLimCut || *pEngineSpeed > pRamVariables->RedLineCut) { *pFlagsRevLim |= RevLimBitMask; } else if (*pEngineSpeed < pRamVariables->RevLimResume) { *pFlagsRevLim &= ~RevLimBitMask; } #if SPARK_HACKS } #endif #if VIN_HACKS } #endif }