/** * ユーザーがメニューの項目を選択したときに、フレームワークによって呼び出されます * @param[in] wParam パラメタ * @param[in] lParam パラメタ * @retval TRUE アプリケーションがこのメッセージを処理した * @retval FALSE アプリケーションがこのメッセージを処理しなかった */ BOOL CDebugUty1MB::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDM_SEGCS: SetSegment(CPU_CS); break; case IDM_SEGDS: SetSegment(CPU_DS); break; case IDM_SEGES: SetSegment(CPU_ES); break; case IDM_SEGSS: SetSegment(CPU_SS); break; case IDM_SEGTEXT: SetSegment(0xa000); break; default: return FALSE; } return TRUE; }
/*------------------------------------------------------------- ** DrawLine ** Draw a line. * blank_length is the distance from the center which the line begins. * length is the maximum length of the hand. * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating * how far around the circle (clockwise) from high noon. * * The blank_length feature is because I wanted to draw tick-marks around the * circle (for seconds). The obvious means of drawing lines from the center * to the perimeter, then erasing all but the outside most pixels doesn't * work because of round-off error (sigh). */ static void DrawLine ( DtClockGadget w, Dimension blank_length, Dimension length, double fraction_of_a_circle ) { double dblank_length = (double)blank_length, dlength = (double)length; double angle, cosangle, sinangle; double cos (); double sin (); int cx = w->clock.centerX, cy = w->clock.centerY, x1, y1, x2, y2; /* * A full circle is 2 PI radians. * Angles are measured from 12 o'clock, clockwise increasing. * Since in X, +x is to the right and +y is downward: * * x = x0 + r * sin (theta) * y = y0 - r * cos (theta) * */ angle = TWOPI * fraction_of_a_circle; cosangle = cos (angle); sinangle = sin (angle); /* break this out so that stupid compilers can cope */ x1 = cx + (int) (dblank_length * sinangle); y1 = cy - (int) (dblank_length * cosangle); x2 = cx + (int) (dlength * sinangle); y2 = cy - (int) (dlength * cosangle); SetSegment (w, x1, y1, x2, y2); }
KVBIC::KVBIC(Float_t pressure, Float_t bomb): KVChIo() { //BIC detector. //Give pressure in Torr // //Segmentation index = 1 //because particles passing through BIC can only hit 1 detector - SIB - behind it //this is analogous to the Si-CsI telescopes of ring 1. //The type of these detectors is "BIC" //Pressure units are Torr SetType("BIC"); SetSegment(1); fLinCal = 0; fBomb = bomb; //build detector AddAbsorber(new KVMaterial("Myl", 1.5 * KVUnits::um)); //mylar entry window Float_t e = GetEffectiveEntryThickness(); KVMaterial* gas = new KVMaterial("CF4", e * KVUnits::mm, pressure); AddAbsorber(gas); //gas between two windows AddAbsorber(new KVMaterial("Myl", 1.0 * KVUnits::um)); //interior window gas = new KVMaterial("CF4", 60 * KVUnits::mm, pressure); AddAbsorber(gas); //main body of gas SetActiveLayer(gas); //active layer - energy loss is measured AddAbsorber(new KVMaterial("Myl", 1.0 * KVUnits::um)); //2nd interor window gas = new KVMaterial("CF4", e * KVUnits::mm, pressure); AddAbsorber(gas); //gas between two exit windows AddAbsorber(new KVMaterial("Myl", 1.5 * KVUnits::um)); //exit window }
void CObject::LinkToSeg (int nSegment) { if ((nSegment < 0) || (nSegment >= gameData.segs.nSegments)) { nSegment = FindSegByPos (*GetPos (), 0, 0, 0); if (nSegment < 0) return; } SetSegment (nSegment); #if DBG if (IsLinkedToSeg (nSegment)) UnlinkFromSeg (); #else if (SEGMENTS [nSegment].m_objects == Index ()) return; #endif SetNextInSeg (SEGMENTS [nSegment].m_objects); #if DBG if ((info.nNextInSeg < -1) || (info.nNextInSeg >= LEVEL_OBJECTS)) SetNextInSeg (-1); #endif SetPrevInSeg (-1); SEGMENTS [nSegment].m_objects = Index (); if (info.nNextInSeg != -1) OBJECTS [info.nNextInSeg].SetPrevInSeg (Index ()); }
void AssignSeg( SYM_ENTRY *sym ) { SetFarHuge( sym, 1 ); if( (sym->stg_class == SC_AUTO) || (sym->stg_class == SC_REGISTER) || (sym->stg_class == SC_TYPEDEF) ) { /* if stack/register var, there is no segment */ sym->u.var.segment = 0; } else if( sym->stg_class != SC_EXTERN ) { /* if not imported */ if( (sym->flags & SYM_INITIALIZED) == 0 ) { if( sym->u.var.segment == 0 ) { /* 15-mar-92 */ SetSegment( sym ); } if( sym->u.var.segment == SEG_DATA ) { sym->u.var.segment = SEG_BSS; CompFlags.bss_segment_used = 1; } SetSegAlign( sym ); /* 02-feb-92 */ } } else if( sym->attrib & (FLAG_FAR | FLAG_HUGE) ) { sym->u.var.segment = SegImport; --SegImport; } else if( (SegData != 0) && (sym->attrib & FLAG_NEAR) ) { // imported and near sym->u.var.segment = SegData; } }
void SAC_ClockDisplay::SetFloat(float v, bool trailingZeros) { //Tlc.clear(); ClearSegments(); int iVal = (int)v; // integer part int fVal = 0; float frac = v - (float)iVal; if(iVal < 10000) { // which digit's decimal point do I use? int dp_pos = 0; if(iVal < 10) { dp_pos = 0; fVal = (int)(frac * 100.0); } else if(iVal < 100) { dp_pos = 1; fVal = (int)(frac * 10.0); } else if(iVal < 1000) { dp_pos = 2; fVal = (int)(frac); } else { dp_pos = 3; } //Debug("I: "); Debug(iVal); //Debug(", F: "); Debug(fVal); //DebugLn(""); SetSegment(dp_pos, DP); int p = 0; char buf[12]; ltoa(iVal,buf,10); while(p < 4 && buf[p] != '\0') { SetDigit(p,buf[p]); p++; } int offset = p; p = 0; ltoa(fVal,buf,10); while(p+offset < 4 && buf[p] != '\0') { SetDigit(p+offset,buf[p]); p++; } p = p+offset; while(p<4) { SetDigit(p,trailingZeros?'0':' '); p++; } Tlc.update(); } else { // value too big, what should I do? } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //KVBIC //Blocking Ionisation Chambers (BIC) for E416/E416a // //Here is the structure used to describe the Blocking Ionisation Chambers: //Begin_Html //<img src="http://indra.in2p3.fr/KaliVedaDoc/images/bic.gif"> //End_Html // //structure as absorbers: //GetAbsorber(0) - 1.5µm mylar entrance window //GetAbsorber(1) - CF4 at x Torr with thickness given by GetEffectiveEntryThickness() //GetAbsorber(2) - 1 µm mylar internal window //GetAbsorber(3) - 60 mm of CF4 at x Torr //GetAbsorber(4) - 1 µm mylar internal window //GetAbsorber(5) - CF4 at x Torr with thickness given by GetEffectiveEntryThickness() //GetAbsorber(6) - 1.5µm mylar exit window // //Bombage: // La valeur du bombage des fenetres externes a ete "estimee" par C. Mazur // pour des fenetres neuves. Il est peut-etre prudent de la passer a 5mm, // ce qui conduirait a une epaisseur moyenne de 4mm environ de CF4 a // l'entree. // //The bombage can be set/modified using SetBombage(). The default value is 5mm. //The effective thickness of CF4 between the two mylar windows, "averaged" over the whole surface of the //entry window, is then "estimated" according to the formula (see GetEffectiveEntryThickness() ): // e = bombage/2 + 1.5 [mm] //With the default bombage of 5mm, this gives e=4mm. KVBIC::KVBIC() { //default ctor //Segmentation index = 1 //because particles passing through BIC can only hit 1 detector - SIB - behind it //this is analogous to the Si-CsI telescopes of ring 1. SetType("BIC"); SetSegment(1); fLinCal = 0; }
/*------------------------------------------------------------- ** DrawHand ** Draw a hand. * * length is the maximum length of the hand. * width is the half-width of the hand. * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating * how far around the circle (clockwise) from high noon. * */ static void DrawHand( DtClockGadget w, Dimension length, Dimension width, double fraction_of_a_circle ) { register double angle, cosangle, sinangle; register double ws, wc; Position x, y, x1, y1, x2, y2; double cos (); double sin (); /* A full circle is 2 PI radians. * Angles are measured from 12 o'clock, clockwise increasing. * Since in X, +x is to the right and +y is downward: * * x = x0 + r * sin (theta) * y = y0 - r * cos (theta) */ angle = TWOPI * fraction_of_a_circle; cosangle = cos (angle); sinangle = sin (angle); /* Order of points when drawing the hand. * 1,4 * / \ * / \ * / \ * 2 ------- 3 */ wc = width * cosangle; ws = width * sinangle; SetSegment (w, x = w->clock.centerX + round (length * sinangle), y = w->clock.centerY - round (length * cosangle), x1 = w->clock.centerX - round (ws + wc), y1 = w->clock.centerY + round (wc - ws)); /* 1 ---- 2 */ SetSegment (w, x1, y1, x2 = w->clock.centerX - round (ws - wc), y2 = w->clock.centerY + round (wc + ws)); /* 2 ----- 3 */ SetSegment (w, x2, y2, x, y); /* 3 ----- 1 (4) */ }
void SegmentDisplay::Poll() { m_currentSegment++; if (m_currentSegment >= m_segmentsCount) { m_currentSegment = 0; } //reset: Reset(); SetSegment(m_currentSegment); SetSymbol(m_segments[m_currentSegment]); }
void CObject::Initialize (ubyte nType, ubyte nId, short nCreator, short nSegment, const CFixVector& vPos, const CFixMatrix& mOrient, fix xSize, ubyte cType, ubyte mType, ubyte rType) { SetSignature (gameData.objs.nNextSignature++); SetType (nType); SetId (nId); SetLastPos (vPos); SetSize (xSize); SetCreator ((sbyte) nCreator); SetOrient (&mOrient); SetControlType (cType); SetMovementType (mType); SetRenderType (rType); SetContainsType (-1); SetLifeLeft ( ((gameData.app.nGameMode & GM_ENTROPY) && (nType == OBJ_POWERUP) && (nId == POW_HOARD_ORB) && (extraGameInfo [1].entropy.nVirusLifespan > 0)) ? I2X (extraGameInfo [1].entropy.nVirusLifespan) : IMMORTAL_TIME); SetAttachedObj (-1); SetShields (I2X (20)); SetSegment (-1); //set to zero by memset, above LinkToSeg (nSegment); }
void AssignSeg( SYMPTR sym ) { SetFarHuge( sym, TRUE ); if( (sym->attribs.stg_class == SC_AUTO) || (sym->attribs.stg_class == SC_REGISTER) || (sym->attribs.stg_class == SC_TYPEDEF) ) { /* if stack/register var, there is no segment */ sym->u.var.segid = SEG_UNKNOWN; } else if( sym->attribs.stg_class != SC_EXTERN ) { /* if not imported */ if( (sym->flags & SYM_INITIALIZED) == 0 ) { if( sym->u.var.segid == SEG_UNKNOWN ) { SetSegment( sym ); } if( sym->u.var.segid == SEG_DATA ) { sym->u.var.segid = SEG_BSS; CompFlags.bss_segment_used = 1; } SetSegAlign( sym ); } } else if( sym->mods & (FLAG_FAR | FLAG_HUGE) ) { sym->u.var.segid = SegImport--; } else if( (SegData != SEG_UNKNOWN) && (sym->mods & FLAG_NEAR) ) { // imported and near sym->u.var.segid = SegData; } }
local void InitArrayVar( SYMPTR sym, SYM_HANDLE sym_handle, TYPEPTR typ ) { unsigned i; unsigned n; TYPEPTR typ2; SYM_HANDLE sym2_handle; SYM_ENTRY sym2; TREEPTR opnd; TREEPTR value; TOKEN token; typ2 = typ->object; SKIP_TYPEDEFS( typ2 ); switch( typ2->decl_type ) { case TYPE_CHAR: case TYPE_UCHAR: case TYPE_SHORT: case TYPE_USHORT: case TYPE_INT: case TYPE_UINT: case TYPE_LONG: case TYPE_ULONG: case TYPE_LONG64: case TYPE_ULONG64: case TYPE_FLOAT: case TYPE_DOUBLE: case TYPE_POINTER: case TYPE_LONG_DOUBLE: case TYPE_FIMAGINARY: case TYPE_DIMAGINARY: case TYPE_LDIMAGINARY: case TYPE_BOOL: NextToken(); // skip over T_LEFT_BRACE if( CharArray( typ->object ) ) { sym2_handle = MakeNewSym( &sym2, 'X', typ, SC_STATIC ); sym2.flags |= SYM_INITIALIZED; if( sym2.u.var.segment == 0 ) { /* 01-dec-91 */ SetFarHuge( &sym2, 0 ); SetSegment( &sym2 ); SetSegAlign( &sym2 ); /* 02-feb-92 */ } SymReplace( &sym2, sym2_handle ); GenStaticDataQuad( sym2_handle ); InitCharArray( typ ); AssignAggregate( VarLeaf( sym, sym_handle ), VarLeaf( &sym2, sym2_handle ), typ ); } else if( WCharArray( typ->object ) ) { sym2_handle = MakeNewSym( &sym2, 'X', typ, SC_STATIC ); sym2.flags |= SYM_INITIALIZED; if( sym2.u.var.segment == 0 ) { /* 01-dec-91 */ SetFarHuge( &sym2, 0 ); SetSegment( &sym2 ); SetSegAlign( &sym2 ); /* 02-feb-92 */ } SymReplace( &sym2, sym2_handle ); GenStaticDataQuad( sym2_handle ); InitWCharArray( typ ); AssignAggregate( VarLeaf( sym, sym_handle ), VarLeaf( &sym2, sym2_handle ), typ ); } else { n = typ->u.array->dimension; i = 0; for( ;; ) { // accept some C++ { {1},.. } token = CurToken; if( token == T_LEFT_BRACE ) NextToken(); opnd = VarLeaf( sym, sym_handle ); value = CommaExpr(); opnd = ExprNode( opnd, OPR_INDEX, IntLeaf( i ) ); opnd->expr_type = typ2; opnd->op.result_type = typ2; AddStmt( AsgnOp( opnd, T_ASSIGN_LAST, value ) ); if( token == T_LEFT_BRACE ) MustRecog( T_RIGHT_BRACE ); ++i; if( CurToken == T_EOF ) break; if( CurToken == T_RIGHT_BRACE )break; MustRecog( T_COMMA ); if( CurToken == T_RIGHT_BRACE )break; if( i == n ) { CErr1( ERR_TOO_MANY_INITS ); } } if( typ->u.array->unspecified_dim ) { typ->u.array->dimension = i; } else { while( i < n ) { value = IntLeaf( 0 ); opnd = VarLeaf( sym, sym_handle ); opnd = ExprNode( opnd, OPR_INDEX, IntLeaf( i ) ); opnd->expr_type = typ2; opnd->op.result_type = typ2; AddStmt( AsgnOp( opnd, T_ASSIGN_LAST, value ) ); ++i; } } } MustRecog( T_RIGHT_BRACE ); break; case TYPE_FCOMPLEX: case TYPE_DCOMPLEX: case TYPE_LDCOMPLEX: case TYPE_STRUCT: case TYPE_UNION: if( SimpleStruct( typ2 ) ) { unsigned base; unsigned size; NextToken(); // skip over T_LEFT_BRACE n = typ->u.array->dimension; i = 0; base = 0; size = SizeOfArg( typ2 ); for( ;; ) { token = CurToken; if( token == T_LEFT_BRACE ) { NextToken(); } InitStructVar( base, sym, sym_handle, typ2 ); if( token == T_LEFT_BRACE ) { MustRecog( T_RIGHT_BRACE ); } ++i; if( CurToken == T_EOF ) break; if( CurToken == T_RIGHT_BRACE ) break; MustRecog( T_COMMA ); if( CurToken == T_RIGHT_BRACE ) break; if( i == n ) { CErr1( ERR_TOO_MANY_INITS ); } base += size; } if( typ->u.array->unspecified_dim ) { typ->u.array->dimension = i; } else { while( i < n ) { // mop up base += size; InitStructVar( base, sym, sym_handle, typ2 ); ++i; } } NextToken(); // skip over T_RIGHT_BRACE break; } default: AggregateVarDeclEquals( sym, sym_handle ); break; } }
void StaticInit( SYMPTR sym, SYM_HANDLE sym_handle ) { TYPEPTR typ; TYPEPTR struct_typ; TYPEPTR last_array; GenStaticDataQuad( sym_handle ); CompFlags.non_zero_data = 0; struct_typ = NULL; last_array = NULL; typ = sym->sym_type; /* Follow chain of typedefs/structs/arrays */ for( ;; ) { SKIP_TYPEDEFS( typ ); if( typ->decl_type == TYPE_ARRAY ) { /* Remember innermost array type */ last_array = typ; typ = typ->object; } else if( typ->decl_type == TYPE_STRUCT ) { FIELDPTR field; /* Remember outermost structure type */ if( struct_typ == NULL ) { /* last_array cannot to be outside this struct! */ last_array = NULL; struct_typ = typ; } /* Determine the type of the last field in the struct */ field = typ->u.tag->u.field_list; if( field == NULL ) break; /* 10-sep-92 */ while( field->next_field != NULL ) field = field->next_field; typ = field->field_type; } else { break; } } typ = last_array; /* If innermost array had unspecified dimension, create new types whose * dimensions will be determined by number of initializers */ if( (typ != NULL) && typ->u.array->unspecified_dim ) { if( struct_typ == NULL ) { /* Array was not inside struct */ sym->sym_type = ArrayNode( typ->object ); /* 18-oct-88 */ sym->sym_type->u.array->unspecified_dim = TRUE; } else { typ = sym->sym_type; /* Create new structure type */ sym->sym_type = TypeNode( TYPE_STRUCT, ArrayNode( last_array->object ) ); sym->sym_type->u.tag = struct_typ->u.tag; struct_typ = sym->sym_type; /* Create new array types as necessary */ for( ;; ) { SKIP_TYPEDEFS( typ ); if( typ->decl_type != TYPE_ARRAY ) break; sym->sym_type = ArrayNode( sym->sym_type ); sym->sym_type->u.array->unspecified_dim = TRUE; typ = typ->object; } typ = last_array; } } else { struct_typ = NULL; } SymReplace( sym, sym_handle ); /* 31-aug-88 */ InitSymData( sym->sym_type, sym->sym_type, 0 ); SymGet( sym, sym_handle ); /* 31-aug-88 */ if( struct_typ != NULL ) { /* 17-mar-92 */ /* Structure contains an unspecified length array as last field */ struct_typ->object->u.array->dimension = typ->u.array->dimension; typ->u.array->unspecified_dim = TRUE; typ->u.array->dimension = 0; /* Reset back to 0 */ } if( sym->u.var.segment == 0 ) { /* 01-dec-91 */ SetFarHuge( sym, 0 ); SetSegment( sym ); SetSegAlign( sym ); /* 02-feb-92 */ } }
int CMob::StandingByProcessor(void) { int rt = FALSE; if (RouteType == 5 || Affect[0].Type == 24) { int Face = MOB.Equip[0].sIndex; if (Leader == 0 && (Affect[0].Type == 24 || Face >= 315 && Face <= 345)) { rt |= 0x100; return rt; } if (Leader <= 0 || Leader >= MAX_USER) { rt |= 1; return rt; } if (Affect[0].Type == 24 || Face >= 315 && Face <= 345) { int summoner = Summoner; if (summoner <= 0 || summoner >= MAX_USER) { rt |= 1; return rt; } int _leader = 0; if (Leader == summoner) _leader = 1; for (int i = 0; i < MAX_PARTY; ++i) { if (pMob[Leader].PartyList[i] == summoner) _leader = 1; } if (_leader == 0) { rt |= 1; return rt; } if (pUser[summoner].Mode != USER_PLAY) { rt |= 1; return rt; } int Distance = BASE_GetDistance(TargetX, TargetY, pMob[summoner].TargetX, pMob[summoner].TargetY); if (Distance >= 13) { NextX = pMob[summoner].TargetX; NextY = pMob[summoner].TargetY; rt = rt | 0x02; return rt; } if (Distance <= 4 || Distance >= 13) return rt; SegmentX = pMob[summoner].TargetX; SegmentY = pMob[summoner].TargetY; GetTargetPos(summoner); rt = rt | 0x01; return rt; } rt = rt |= 1; return rt; } else { if (Leader == 0) { int enemy = GetEnemyFromView(); if (enemy && TargetX <= SegmentX + HALFGRIDX && TargetX >= SegmentX - HALFGRIDX && TargetY >= SegmentY - HALFGRIDY && TargetY <= SegmentY + HALFGRIDY) return enemy | 0x10000000; } if (RouteType == 6 && TargetX == SegmentX && TargetY == SegmentY) return 0; if (SegmentX == TargetX && SegmentY == TargetY) { if(SegmentProgress == 4 && RouteType == 3) { if(WaitSec <= 0) return 0x10000; else WaitSec -= 6; return 0; } if (WaitSec <= 0 || RouteType == 6) { int Seg = SegmentWait[SegmentProgress]; if (Seg > 0) { WaitSec = Seg; return 0; } } else { WaitSec -= 6; if (WaitSec > 0) { if (RouteType && TargetX != SegmentListX[0] || TargetY != SegmentListY[0]) { if (MOB.BaseScore.AttackRun & 0xF) return rt | 0x10; return 0; } else return 0; } WaitSec = 0; } int SetSeg = SetSegment(); if (SetSeg == 1) return 0; if (SetSeg == 2) return rt | 1; if (SetSeg == 0x10) return rt | 1; } GetNextPos(0); if (NextX != TargetX || NextY != TargetY) return rt | 1; else { SetSegment(); return rt; } } return rt; }
/*********************************************************** 函数功能:停电模式循环 入口参数: 出口参数: 备注说明:1 空闲进入休眠,停显1屏,停电7天后关闭液晶显示 2 定时1s唤醒,判断是否上电,喂狗,每分钟RTC温度补偿 3 按键唤醒,低速运行一个轮显周期 4 检测到上电后直接复位 ***********************************************************/ uint16 PowerDowmMain(void) { uint32 timer500ms=0; uint32 timer1000ms=0; int16 temp; volatile uint8 BatteryFlag = 0; volatile uint8 BatteryState; DRV_WD_FeedDog(); //LvdGetManaul(); //设置LVD门限等 while(1) { //按键中断唤醒 if(scrKeyIntFlag) { scrKeyIntFlag=0; EXTI_DisableInt(EXTI_CH1); DRV_RTC_FlashTask(); //adc DRV_ADC_On(); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_Off(); BatteryState = BattLowStateGet(); if(BatteryState == 0) { BatteryFlag = 0; PowerSleepWakeInit(); //按键唤醒主循环 while(1) { if(runMe) { //5ms任务 runMe=0; timer500ms++; timer1000ms++; DRV_WD_FeedDog(); if(FM3_GPIO->PDIR1&= IO_PINx3) {//上电外部中断唤醒 if(PowerUpDetect()) { PowerWakeSleepInit();//设置唤醒源,退出低速运行 break; } } Key_Scr_DetectPowerDown_Task();//轮显按键驱动 //CoverDetectProcess(); //EventBatteryUpdateStateFlagProcess(); //500ms任务 if(timer500ms>100) { timer500ms=0; //DRV_RTC_FlashTask(); //Clock_CheckDST(); } DRV_RTC_FlashTask(); //1000ms任务 if(timer1000ms>200) { timer1000ms=0; PowerDownDisplayAlarmPro(); //LCD_Flag_Driver_Task(); Disp_Auto_Cycle_Task(); //显示 if(wakeUpTimer) //定时回到休眠 { wakeUpTimer--; } else { PowerWakeSleepInit();//设置唤醒源,退出低速运行 break; } } } } } else { DRV_LCD_Uninit(); } } //1s定时中断唤醒 if(SecFlag==1) { SecFlag=0; } //1min定时中断唤醒 if(MinFlag==1) { MinFlag=0; //adc DRV_ADC_On(); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_StartTask(); while(RESET != ADC12_GetScanStatusFlag(ADC12_UNIT0)); DRV_ADC_Off(); //RTC温度补偿 TempGet(&temp, 1); CalcPPM(temp); DRV_RTC_CalcSecDeviation(); //停电计算秒的误差 if(BattLowStateGet())//电池 { SetSegment(SEG_battery2,0); } else { SetSegment(SEG_battery2,1); } RefreshLCD(); //电池电压检测 BatteryState = BattLowStateGet(); if(BatteryState == 1) { if(BatteryFlag == 0) { Feed_watchdog(); BatteryFlag =1; SleepDispTimer = 0; } } else if(BatteryFlag == 1) { *(volatile unsigned long*)(0xE000ED0C)=0x05FA0004; while(1); //20140710加上 } //停电停显定时 if(SleepDispTimer) { SleepDispTimer--; } else { DRV_LCD_Uninit(); //关闭LCD } } //p13上电预判//尽量缩短检测时间 if(FM3_GPIO->PDIR1&= IO_PINx3) { if(PowerUpDetect()) { //if(POWER_UP_INIT_SUCESS == PowerUpInit()) //{ // return POWER_UP_INIT_SUCESS; //回到主循环 //} //else //{ // PowerDownInit(); // Feed_watchdog(); //LvdGetManaul(); //设置LVD门限等 //} *(volatile unsigned long*)(0xE000ED0C)=0x05FA0004; while(1); //20140710加上 } } //休眠 if(BatteryState == 1) { LowPwrCon_GoToStandByMode(STB_RTCMode,STB_IO_KEEP); } else { LowPwrCon_GoToStandByMode(STB_TimerMode,STB_IO_KEEP); } Feed_watchdog(); } }
void SAC_ClockDisplay::SetDigit(int digit, char value) { //Debug("SetDigit("); //Debug(digit); //Debug(", '"); Debug(value); DebugLn("')"); switch(value) { case '#': SetSegment(digit, A); SetSegment(digit, B); SetSegment(digit, C); SetSegment(digit, D); SetSegment(digit, E); SetSegment(digit, F); SetSegment(digit, G); SetSegment(digit, DP); break; case '0': SetSegment(digit, A); SetSegment(digit, B); SetSegment(digit, C); SetSegment(digit, D); SetSegment(digit, E); SetSegment(digit, F); break; case '1': SetSegment(digit, B); SetSegment(digit, C); break; case '2': SetSegment(digit, A); SetSegment(digit, B); SetSegment(digit, D); SetSegment(digit, E); SetSegment(digit, G); break; case '3': SetSegment(digit, A); SetSegment(digit, B); SetSegment(digit, C); SetSegment(digit, D); SetSegment(digit, G); break; case '4': SetSegment(digit, B); SetSegment(digit, C); SetSegment(digit, F); SetSegment(digit, G); break; case '5': SetSegment(digit, A); SetSegment(digit, C); SetSegment(digit, D); SetSegment(digit, F); SetSegment(digit, G); break; case '6': SetSegment(digit, A); SetSegment(digit, C); SetSegment(digit, D); SetSegment(digit, E); SetSegment(digit, F); SetSegment(digit, G); break; case '7': SetSegment(digit, A); SetSegment(digit, B); SetSegment(digit, C); break; case '8': SetSegment(digit, A); SetSegment(digit, B); SetSegment(digit, C); SetSegment(digit, D); SetSegment(digit, E); SetSegment(digit, F); SetSegment(digit, G); break; case '9': SetSegment(digit, A); SetSegment(digit, B); SetSegment(digit, C); SetSegment(digit, F); SetSegment(digit, G); break; case '.': SetSegment(digit, DP); break; case '-': SetSegment(digit, G); break; case ' ': break; case 'F': default: SetSegment(digit, A); SetSegment(digit, D); SetSegment(digit, E); SetSegment(digit, F); SetSegment(digit, G); break; } }
int CObject::Create (ubyte nType, ubyte nId, short nCreator, short nSegment, const CFixVector& vPos, const CFixMatrix& mOrient, fix xSize, ubyte cType, ubyte mType, ubyte rType) { #if DBG if (nType == OBJ_WEAPON) { nType = nType; if ((nCreator >= 0) && (OBJECTS [nCreator].info.nType == OBJ_ROBOT)) nType = nType; if (nId == FLARE_ID) nType = nType; if (gameData.objs.bIsMissile [(int) nId]) nType = nType; } else if (nType == OBJ_ROBOT) { #if 0 if (ROBOTINFO ((int) nId).bossFlag && (BOSS_COUNT >= MAX_BOSS_COUNT)) return -1; #endif } else if (nType == OBJ_HOSTAGE) nType = nType; else if (nType == OBJ_FIREBALL) nType = nType; else if (nType == OBJ_REACTOR) nType = nType; else if (nType == OBJ_DEBRIS) nType = nType; else if (nType == OBJ_MARKER) nType = nType; else if (nType == OBJ_PLAYER) nType = nType; else if (nType == OBJ_POWERUP) nType = nType; #endif SetSegment (FindSegByPos (vPos, nSegment, 1, 0)); if ((Segment () < 0) || (Segment () > gameData.segs.nLastSegment)) return -1; if (nType == OBJ_DEBRIS) { if (gameData.objs.nDebris >= gameStates.render.detail.nMaxDebrisObjects) return -1; } // Zero out object structure to keep weird bugs from happening in uninitialized fields. m_nId = OBJ_IDX (this); SetSignature (gameData.objs.nNextSignature++); SetType (nType); SetId (nId); SetLastPos (vPos); SetPos (&vPos); SetSize (xSize); SetCreator ((sbyte) nCreator); SetOrient (&mOrient); SetControlType (cType); SetMovementType (mType); SetRenderType (rType); SetContainsType (-1); SetLifeLeft ( ((gameData.app.nGameMode & GM_ENTROPY) && (nType == OBJ_POWERUP) && (nId == POW_HOARD_ORB) && (extraGameInfo [1].entropy.nVirusLifespan > 0)) ? I2X (extraGameInfo [1].entropy.nVirusLifespan) : IMMORTAL_TIME); SetAttachedObj (-1); m_xCreationTime = gameData.time.xGame; #if 0 if (GetControlType () == CT_POWERUP) CPowerupInfo::SetCount (1); // Init physics info for this CObject if (GetMovementType () == MT_PHYSICS) m_vStartVel.SetZero (); if (GetRenderType () == RT_POLYOBJ) CPolyObjInfo::SetTexOverride (-1); if (GetType () == OBJ_WEAPON) { CPhysicsInfo::SetFlags (CPhysInfo.GetFlags () | WI_persistent (m_info.nId) * PF_PERSISTENT); CLaserInfo::SetCreationTime (gameData.time.xGame); CLaserInfo::SetLastHitObj (0); CLaserInfo::SetScale (I2X (1)); } else if (GetType () == OBJ_DEBRIS) gameData.objs.nDebris++; if (GetControlType () == CT_POWERUP) CPowerupInfo::SetCreationTime (gameData.time.xGame); else if (GetControlType () == CT_EXPLOSION) { CAttachedInfo::SetPrev (-1); CAttachedInfo::SetNext (-1); CAttachedInfo::SetParent (-1); } #endif Link (); LinkToSeg (nSegment); return m_nId; }