Пример #1
0
/*
 * Set an event flag, then wake up each state
 * set that might be waiting on that event flag.
 */
epicsShareFunc void epicsShareAPI seq_efSet(SS_ID ss, EV_ID ev_flag)
{
	SPROG	*sp = ss->sprog;

	DEBUG("efSet: sp=%p, ss=%p, ev_flag=%d\n", sp, ss,
		ev_flag);
	assert(ev_flag > 0 && ev_flag <= ss->sprog->numEvFlags);

	epicsMutexMustLock(sp->programLock);

	/* Set this bit */
	bitSet(sp->evFlags, ev_flag);

	/* Wake up state sets that are waiting for this event flag */
	seqWakeup(sp, ev_flag);

	epicsMutexUnlock(sp->programLock);
}
Пример #2
0
static uint16_t rf12_xfer (uint16_t cmd) {
    // the 2 loops below each spin 4 usec with a 2 MHz SPI clock
    uint16_t reply;

    bitClear(PORTB, 2); // much faster

    SPDR = cmd >> 8;
    while (!(SPSR & _BV(SPIF)))
        ;
    reply = SPDR << 8;
    SPDR = cmd;
    while (!(SPSR & _BV(SPIF)))
        ;
    reply |= SPDR;

    bitSet(PORTB, 2); 
    return reply;
}
Пример #3
0
//--------------------------------------------------------------------------------------------------
// Read current supply voltage
//--------------------------------------------------------------------------------------------------
long tools_readVcc() {
   bitClear(PRR, PRADC); ADCSRA |= bit(ADEN); // Enable the ADC
   long result;
   // Read 1.1V reference against Vcc
   #if defined(__AVR_ATtiny84__) 
    ADMUX = _BV(MUX5) | _BV(MUX0); // For ATtiny84
   #else
    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);  // For ATmega328
   #endif 
   delay(2); // Wait for Vref to settle
   ADCSRA |= _BV(ADSC); // Convert
   while (bit_is_set(ADCSRA,ADSC));
   result = ADCL;
   result |= ADCH<<8;
   result = 1126400L / result; // Back-calculate Vcc in mV
   ADCSRA &= ~ bit(ADEN); bitSet(PRR, PRADC); // Disable the ADC to save power
   return result;
} 
Пример #4
0
void AtmAudio::initialize()
{
	//use internal clock
	bitClear(ASSR,EXCLK);    //disable external clock
	bitClear(ASSR,AS2);      //clock timers from internal clock

	//Fast PWM mode
	bitSet(TCCR2A,WGM20);  //TOV flag set on max
	bitSet(TCCR2A,WGM21);  //Update OCRx at bottom
	bitClear(TCCR2B,WGM22);  //Top = 0xFF
	
	//Set non-inverting PWM on OC2B pin
	bitClear(TCCR2A,COM2B0);
	bitSet(TCCR2A,COM2B1);
	//set normal operation on OC2A pin
	bitClear(TCCR2A,COM2A0);
	bitClear(TCCR2A,COM2A1);
	
	//no prescaler
	bitSet(TCCR2B,CS20);
	bitClear(TCCR2B,CS21);
	bitClear(TCCR2B,CS22);
	
	// Set Timer 1 to update sample on interrupt

	cli();      //pause interrupts

	// Set CTC mode (Clear timer on compare match)
	bitClear(TCCR1A,WGM10);
	bitClear(TCCR1A,WGM11);
	bitSet(TCCR1B,WGM12);
	bitClear(TCCR1B,WGM13);

	//No prescaler
	bitSet(TCCR1B,CS10);
	bitClear(TCCR1B,CS11);
	bitClear(TCCR1B,CS12);

	// Set the compare register (OCR1A) initial value
	OCR1A = ocr1a;       //initialise with A=440hz.

	// Timer 1, output compare A match interrupt enable
	bitSet(TIMSK1,OCIE1A);

	sei();    //start interrupts
}
Пример #5
0
void RelayClass::Override(byte ID, byte type)
{
	if (type==0)  // Turn port off
	{
		if ( ID < 9 )
		{
			bitClear(RelayMaskOn,ID-1);
			bitClear(RelayMaskOff,ID-1);
		}
#ifdef RelayExp
		if ( (ID > 10) && (ID < 89) )
		{
			byte EID = byte(ID/10);
			bitClear(RelayMaskOnE[EID-1],(ID%10)-1);
			bitClear(RelayMaskOffE[EID-1],(ID%10)-1);
		}
#endif  // RelayExp
	}
	else if (type==1)  // Turn port on
	{
		if ( ID < 9 )
		{
			bitSet(RelayMaskOn,ID-1);
			bitSet(RelayMaskOff,ID-1);
		}
#ifdef RelayExp
		if ( (ID > 10) && (ID < 89) )
		{
			byte EID = byte(ID/10);
			bitSet(RelayMaskOnE[EID-1],(ID%10)-1);
			bitSet(RelayMaskOffE[EID-1],(ID%10)-1);
		}
#endif  // RelayExp
	}
	else if (type==2)  // Set port back to Auto
	{
		if ( ID < 9 )
		{
			bitClear(RelayMaskOn,ID-1);
			bitSet(RelayMaskOff,ID-1);
		}
#ifdef RelayExp
		if ( (ID > 10) && (ID < 89) )
		{
			byte EID = byte(ID/10);
			bitClear(RelayMaskOnE[EID-1],(ID%10)-1);
			bitSet(RelayMaskOffE[EID-1],(ID%10)-1);
		}
#endif  // RelayExp
	}
}
Пример #6
0
int sATCIPSENDACTION(int mode)
{
	uint8_t ret,idx, fase=0;
	int retHTTP=0;
	char c;
	uint32_t mark;
	gprs.sendCommand("AT+HTTPACTION=1");
	gprs.m_checkTimer=millis();
	PGM_PRINTLN("CK");
	gprs.m_bytesRecv = 0;
	ret=gprs.checkbuffer("ACTION:",NULL,60000);
	if (ret==1) {
		bitSet(ccStatus,CC_WIFI_INTERNET);
		led2_status=LED_APAGA;		
		mark=millis();
		idx=0;
		while (millis() - mark < 6000 && ret) {
			while (SSwifi.available()) {
				c=SSwifi.read();
				switch (c) {
				case ',':
					if (fase==1) {
						retHTTP=idx;
						debugvarln(retHTTP);	
						ret=0;		
					}
					fase++;
					idx=0;
					break;
				 default:
					idx= idx*10+(c-'0');
				} // switch
			}
		}
			
	} else {
		bitClear(ccStatus,CC_WIFI_INTERNET);
		led2_status=LED_PISCA_LONGO; // sem conexao ao roteador TAG_2		
	}
	debugvarln(retHTTP);
	esp8266Flush();
	return retHTTP;
}
Пример #7
0
void Sabre::setMonoChSelect(uint8_t value)
{
	if (value > useRightChannelInAllMonoMode)
	{
		value %= (useRightChannelInAllMonoMode + 1);
	}
	switch (value)
	{
		case useRightChannelInAllMonoMode:
		bitSet(sReg17, 7);
		Reg17.Use_Left_Channel = false;
		break;
		default:
		bitClear(sReg17, 7);
		Reg17.Use_Left_Channel = true;
		break;
	}
	writeSabreReg(REG17, sReg17);		// Reg 17: Write register for all_mono_mode
}
Пример #8
0
void transformTypeDigit(byte index, byte src, byte dest) {
	byte tmp = tube.getPattern(index);

	for (byte i = 0; i < 7; i++) {
		byte c = pgm_read_byte_near(STROCK_ORDER + 7 * src + 6- i);
		if (c < 8)
			bitClear(tmp, c);
		tube.setPattern(index, tmp);
		tube.display(0x40);
	}

	for (byte i = 0; i < 7; i++) {
		byte c = pgm_read_byte_near(STROCK_ORDER + 7 * dest + i);
		if (c < 8)
			bitSet(tmp, c);
		tube.setPattern(index, tmp);
		tube.display(0x40);
	}
}
Пример #9
0
void aioCreateTakeoutMothershipFast(struct AITeam *team,Ship *mothership)
{
    AlternativeShips alternatives;
//    SelectCommand *selectone;
    AITeamMove *attackmove;

    aiplayerLog((aiIndex, "%x Issuing Takeout Mothership Fast Order", team));

    SetNumAlternativesFlags(alternatives,11,ALTERNATIVE_RANDOM);
    SetAlternative(alternatives,0,IonCannonFrigate,10);
    SetAlternative(alternatives,1,IonCannonFrigate,10);
    SetAlternative(alternatives,2,IonCannonFrigate,10);
    SetAlternative(alternatives,3,IonCannonFrigate,30);
    SetAlternative(alternatives,4,MissileDestroyer,30);
    SetAlternative(alternatives,5,StandardDestroyer,30);
    SetAlternative(alternatives,6,StandardFrigate,10);
    SetAlternative(alternatives,7,StandardFrigate,10);
    SetAlternative(alternatives,8,MinelayerCorvette,7);
    SetAlternative(alternatives,9,HeavyCorvette,3);
    SetAlternative(alternatives,10,MultiGunCorvette,3);

    aimCreateFancyGetShips(team, IonCannonFrigate, 3, &alternatives, 0, TRUE, FALSE);

    aimCreateVarDec(team, aiCurrentAIPlayer->attackVarLabel, TRUE, FALSE);
//    aimCreateVarWait(team, aiCurrentAIPlayer->attackVarLabel, -1, TRUE, FALSE);
    aimCreateTempGuard(team, AIO_TOUT_MSHIP_FAST_TGRD_FORMATION, AIO_TOUT_MSHIP_FAST_TGRD_TACTICS, TRUE, FALSE);

    // aimCreateRequestGuardTeam();

//    selectone = memAlloc(sizeofSelectCommand(1),"takeoutsel",0);
//    selectone->numShips = 1;
//    selectone->ShipPtr[0] = mothership;
//    attackmove = aimCreateFlankAttack(team, selectone, FALSE, TRUE, FALSE);
    attackmove = aimCreateArmada(team, BROAD_FORMATION, Aggressive, TRUE, FALSE);
    aieHandlerSetGettingRocked(attackmove, TRUE, aihGenericGettingRockedHandler);
    aieHandlerSetFuelLow(attackmove, 15, TRUE, TRUE, aihGenericFuelLowHandler);

    aimCreateMoveDone(team, FALSE, FALSE);

    //this team can hyperspace attack
    bitSet(team->teamFlags, TEAM_Hyperspaceable);
}
Пример #10
0
/**
 * \brief recebe pacote em buffe conforme o moo
 * \param modo
 * \param buffer[out] dados lidos serao armazenados
 * \param buffer_size[in] tamanho do buffer
 * \param timeout[in] em ms
 * \param connectionId[in] nro da conexao, GSM nao usado
 * \return numero de bytes do buffer, se 0=timeout
 */
int recvPkg(uint8_t modo, uint8_t *buffer, uint16_t buffer_size, uint32_t timeout, uint8_t *connectionId)
{
	char c;
	uint16_t ret,i;
	unsigned long start;
	
	PGM_PRINT(">recvPkg ");
	//debugvarln(freeRAM());
	buffer[0]='\0';
	start = millis();
	ret=0;
	//wifi_len=SSwifi.available();
	//debugvarln(wifi_len);
	bitClear(ccStatus,CC_MATA_BUFFER);
	//ret = wifi_len > buffer_size ? buffer_size : wifi_len;
	ret = buffer_size-1;
	i=c=0;
	while (millis() - start < timeout && i<ret) {
			while(SSwifi.available() > 0 && i<ret) {
				c=SSwifi.read();
				#if DEBUG > 0
				SSdebug.write(c);
				#endif
				if (c=='\n') {
					ret=0;
					break;
				}
				if (!i && c=='C') bitSet(ccStatus,CC_MATA_BUFFER);
				buffer[i++] = c;
				start=millis();
			}
		}
	buffer[i]='\0';

	if (bitRead(ccStatus, CC_MATA_BUFFER)) {
		esp8266Flush();
	}
	//debugvar(i);
	//debugln((char*)buffer);
	PGM_PRINTLN("<recvPkg ");
	return i;
}
Пример #11
0
//fires the bursts for the ship
bool doBurstFire(Ship *ship)
{
    HeavyCorvetteSpec *spec = (HeavyCorvetteSpec *)ship->ShipSpecifics;
    sdword done;
    vector trajectory,heading;
    real32 range,one_over_range;
    SpaceObjRotImpTarg dummyTarg;

    vecSub(trajectory,spec->burstFireVector,ship->posinfo.position);
    range = vecMagnitudeSquared(trajectory);
    range = fsqrt(range);
    one_over_range = 1.0f/range;
    vecScalarMultiply(trajectory,trajectory,one_over_range);

    dummyTarg.objtype = OBJ_ShipType;
    dummyTarg.posinfo.position = spec->burstFireVector;
    dummyTarg.collInfo.collPosition = spec->burstFireVector;
    dummyTarg.currentLOD = ship->currentLOD;
    dummyTarg.collMyBlob = ship->collMyBlob;
    vecSet(dummyTarg.posinfo.velocity,0.0f,0.0f,0.0f);

    //track target even more precisely
    vecSub(heading,spec->burstFireVector,ship->posinfo.position);
    vecNormalize(&heading);
    aitrackHeadingWithFlags(ship,&heading,0.9999f,AITRACKHEADING_IGNOREUPVEC);

    //set special information that needs to be 'transmitted'
    //to the code in gunshoot.

    //fix later
    spec->bulletLifeTime = range*oneOverburstSpeed;

    bitSet(ship->specialFlags,SPECIAL_BurstFiring);
    done = gunShootGunsAtTarget(ship,&dummyTarg,0.0f,&trajectory);
    bitClear(ship->specialFlags,SPECIAL_BurstFiring);
    if(done == TRUE)
    {
        spec->cooldown = TRUE;
        spec->burstChargeState2 = burstCoolDownTime;
    }
    return done;
}
Пример #12
0
/*!
 *
 */
void unpackBlocks4(const uint8 * data, uint8 * pixels)
{
    for (int j = 0; j < 4; ++j) {
        for (int i = 0; i < 8; ++i) {
            if (bitSet(data[j], 7 - i)) {
                pixels[j * 8 + i] = 255;        // transparent
            } else {
                pixels[j * 8 + i] =
                    static_cast < uint8 >
                    ((bitValue(data[4 + j], 7 - i) << 0) & 0xff)
                    | static_cast < uint8 >
                    ((bitValue(data[8 + j], 7 - i) << 1) & 0xff)
                    | static_cast < uint8 >
                    ((bitValue(data[12 + j], 7 - i) << 2) & 0xff)
                    | static_cast < uint8 >
                    ((bitValue(data[16 + j], 7 - i) << 3) & 0xff);
            }
        }
    }
}
Пример #13
0
void door::detectPacket(int bitsRead, unsigned int *timings) {
    packet = 0;
    for(int i=1; i< bitsRead-1; i+=2) {
        int duration = timings[i];
        int next_duration = timings[i+1];

        if(duration > AVERAGE && next_duration < AVERAGE) {
          packet = packet << 1;
          bitSet(packet, 0);
        } else if(duration < AVERAGE && next_duration > AVERAGE) {
          packet = packet << 1;
          bitClear(packet, 0);
        }
  }
#ifdef DEBUG
      Serial.print("|0x");
      Serial.println((long) packet, HEX);
#endif

}
Пример #14
0
 /* Read from AX bus */
 void setAX_RD(){
     int i;
     // Need to wait for last byte to be sent before turning the bus around.
     // Check the Transmit complete flag
     while (bit_is_clear(UCSR2A, UDRE2));
     for(i=0; i<UBRR2L*20; i++)    
         asm("nop");
   #ifdef SERVO_STIK
     PORTC = 0x40;
   #else
     PORTG = ( (PORTG&0xE7) | 0x08 );
   #endif
     asm("nop");
     asm("nop");
     asm("nop");
     //bitClear(UCSR1B, TXEN1);
     bitSet(UCSR2B, RXEN2);
     ax_rx_int_Pointer = 0;
     ax_rx_Pointer = 0;
 }
Пример #15
0
	uint16_t phy_sendCMD (uint16_t command) {
		// Change spi speed - see https://www.arduino.cc/en/Tutorial/SPIEEPROM
		#if F_CPU > 10000000
    		bitSet(SPCR, SPR0);
		#endif
	
    	phy_enableRF(); // Chip select (activate SPI)
    
    	// Send first 8 bytes and read first 8 bytes reply - then the next 8 bytes
    	uint16_t response = phy_sendCMDByte(command >> 8) << 8;
    	response |= phy_sendCMDByte(command);
    
    	phy_disableRF(); // Chip select (deactivate SPI)
    	
    	#if F_CPU > 10000000
    		bitClear(SPCR, SPR0);
		#endif
    	
    	return response;
	}
Пример #16
0
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
	LEDs_Init();
	USB_Init();

    // enable pull-up on the RX pin to prevent spurious signal.
    bitClear(DDRD,2);
    bitSet( PORTD,2);

	/* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */
	TCCR0B = (1 << CS02);
}
Пример #17
0
/*-----------------------------------------------------------------------------
    Name        : taskResumesAll
    Description : Resumes all previously unpaused tasks.
    Inputs      : void
    Outputs     : Copies pause save bit into paused bit.
    Return      : void
    Note        : It is up to the calling party to ensure that the next call to
                    taskExecuteAllPending() does not try to execute all the task
                    ticks which would have happended while the tasks were paused.
----------------------------------------------------------------------------*/
void taskResumeAll(void)
{
    sdword index;

    taskInitCheck();
    for (index = 0; index < taskMaxTask; index++)           //for all tasks
    {
        if (taskData[index] != NULL)                        //if task active
        {
            if (bitTest(taskData[index]->flags, TF_PauseSave)) //save the pause bit
            {
                bitSet(taskData[index]->flags, TF_Paused);
            }
            else
            {
                bitClear(taskData[index]->flags, TF_Paused);
            }
        }
    }
}
Пример #18
0
/* ******************************************************************** *
 * public: jump to an item of this menu if exists
 * @param
 *		item name (uint8)
 * @return
 * ******************************************************************** */
void		LCDMenuLib::jumpToElement(uint8_t p_element)
/* ******************************************************************** */
{	
	// check if function is active
	if(function == p_element) {
		return;
	}
	Button_quit();
	function = _LCDML_NO_FUNC;	
	goRoot();		
	
	bitSet(control, _LCDML_control_disable_hidden);
	if(selectElementDirect(*rootMenu, p_element)) { //search element
		//open this element
		goEnter();
		//Button_enter();
	}
	bitClear(control, _LCDML_control_disable_hidden);
	bitClear(control, _LCDML_control_search_display);
}
Пример #19
0
// System commands
int8_t ModbusProcess_FC100()
{
    _u8BufferSize = 10;
    _lastCommand = _au8Buffer[COM_COM_ID];
    switch(_lastCommand)
    {
        case MB_COMMAND_RESET:
            #asm
                RESET; 
            #endasm
            break;
        case MB_COMMAND_SET_ADDRESS:
            _u8id = _au8Buffer[COM_DATA];
            eeprom_write(EE_MODBUS_ID, _u8id);
            while(WR)
                continue;
            ModbusSetExceptionStatusBit(MB_EXCEPTION_LAST_COMMAND_STATE, true);
            break;  
        case MB_COMMAND_SET_TIME:
            SetHourMin(&(_au8Buffer[COM_ADD1_HI]), &(_au8Buffer[COM_ADD1_LO]), &(_au8Buffer[COM_ADD2_LO]));
            
            //----------------
            struct tm newTime;
            newTime.tm_year = _au8Buffer[COM_ADD3_LO] + 100; // since 1900
            newTime.tm_mon = _au8Buffer[COM_ADD3_HI];
            newTime.tm_mday = _au8Buffer[COM_ADD2_HI];
            newTime.tm_hour = _au8Buffer[COM_ADD1_HI];
            newTime.tm_min = _au8Buffer[COM_ADD1_LO];
            newTime.tm_sec = _au8Buffer[COM_ADD2_LO];
            time_t newRawTime = mktime(&newTime);
            SetTime(&newRawTime);
            //----------------
            bitSet(_deviceStatus, INPUT_TIME_SET);
            ModbusSetExceptionStatusBit(MB_EXCEPTION_LAST_COMMAND_STATE, true);
            break;
    }
    uint8_t u8CopyBufferSize = _u8BufferSize + 2;
    ModbusSendTxBuffer();

    return u8CopyBufferSize;
}
Пример #20
0
unsigned char PS2X::_gamepad_shiftinout (char byte) {
   unsigned char tmp = 0;
   for(unsigned char i=0;i<8;i++) {
      if(CHK(byte,i)) CMD_SET();
      else CMD_CLR();
	  
      CLK_CLR();
      delayMicroseconds(CTRL_CLK);

      //if(DAT_CHK()) SET(tmp,i);
      if(DAT_CHK()) bitSet(tmp,i);

      CLK_SET();
#if CTRL_CLK_HIGH
      delayMicroseconds(CTRL_CLK_HIGH);
#endif
   }
   CMD_SET();
   delayMicroseconds(CTRL_BYTE_DELAY);
   return tmp;
}
Пример #21
0
bool DefenseFighterSpecialActivate(Ship *ship)
{
    DefenseFighterSpec *spec = (DefenseFighterSpec *)ship->ShipSpecifics;

    if(bitTest(ship->dontrotateever,1))
    {
        //Turn off Special Ops
        spec->DefenseFighterCanNowRotate = FALSE;       //signifies we need to re-charge for a bit
        bitClear(ship->dontrotateever,1);
    }
    else
    {
        //turn on special ops
        if(spec->DefenseFighterCanNowRotate)
        {
            //only turn on if we can rotate now...
            bitSet(ship->dontrotateever,1);
        }
    }
    return TRUE;
}
Пример #22
0
/*-----------------------------------------------------------------------------
    Name        : taskSavePauseStatus
    Description :
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void taskSavePauseStatus(void)
{
    sdword index;

    taskInitCheck();
    for (index = 0; index < taskMaxTask; index++)           //for all tasks
    {
        if (taskData[index] != NULL)                        //if task active
        {
            if (bitTest(taskData[index]->flags, TF_Paused)) //save the pause bit
            {
                bitSet(taskData[index]->flags, TF_PauseSave);
            }
            else
            {
                bitClear(taskData[index]->flags, TF_PauseSave);
            }
            // deliberately do not pause task, just make sure TF_PauseSave gets set correctly
        }
    }
}
Пример #23
0
void AX12::setRX () {
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328P__)
    bitClear(UCSR0B, TXEN0);   // deshabilita la trasmisión
    bitSet(UCSR0B, RXEN0);     // habilita la recepción
    bitSet(UCSR0B, RXCIE0);    // habilita la interrupción de recepción
#elif defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)    
    bitClear(UCSR1B, TXEN1);   // deshabilita la trasmisión
    bitSet(UCSR1B, RXEN1);     // habilita la recepción
    bitSet(UCSR1B, RXCIE1);    // habilita la interrupción de recepción
#elif defined (__AVR_ATmega8__)
    bitClear(UCSRB, TXEN);   // deshabilita la trasmisión
    bitSet(UCSRB, RXEN);     // habilita la recepción
    bitSet(UCSRB, RXCIE);    // habilita la interrupción de recepción 
#endif    
    ax_rx_Pointer = 0;         // resetea el puntero del buffer
}
Пример #24
0
/* ******************************************************************** *
 * public: display the current menu
 * @param
 * @return
 * ******************************************************************** */
void	LCDMenuLib::display()
/* ******************************************************************** */
{
	//declaration
	LCDMenu * tmp;
	uint8_t i = scroll;
	uint8_t maxi = (rows + scroll);
	char buffer[_LCDML_DISP_cfg_max_string_length];

	child_cnt = countChilds();	
	//check children
	if ((tmp = curMenu->getChild(i))) {
		if (!bitRead(control, _LCDML_control_search_display)) {
			//clear lcd
			display_clear();			
			//show menu structure
			do
			{				
				if (bitRead(group_en, tmp->disp)) {	
					#if defined ( ESP8266 ) || defined ( ESP32 )
						strcpy_P(content[i-scroll], (char*)(flash_table[tmp->name]));
					#else
						strcpy_P(content[i-scroll], (char*)pgm_read_word(&(flash_table[tmp->name])));
					#endif
					content_id[i-scroll] = tmp->name;
					i++;					
				}

			} while ((tmp = tmp->getSibling(1)) != NULL && i<maxi);
			bitSet(control, _LCDML_control_disp_update);			
		}
	}
	else { // no children
		goBack();
		// function can run ...		
		
	}
	setCursor();	
}
Пример #25
0
/*-----------------------------------------------------------------------------
    Name        : aihSwarmerEmptyFuelHandler
    Description : Sets the swarmers to SOF_Crazy when they are out of fuel.
                  NOTE: Need to somehow blow those ships up as well...
    Inputs      : team - the team with the ship that has no fuel
    Outputs     : Kills a ship
    Return      : void
----------------------------------------------------------------------------*/
void aihSwarmerEmptyFuelHandler(AITeam *team)
{
    sdword i, numShips = team->shipList.selection->numShips;
    ShipPtr ship;

    for (i = 0; i < numShips; i++)
    {
        ship = team->shipList.selection->ShipPtr[i];

        if (!bitTest(ship->flags, SOF_Crazy) &&
            (100.0 * ship->fuel / ship->staticinfo->maxfuel
                  < team->curMove->events.fuelLow.watchPercentage))
        {
            bitSet(ship->flags, SOF_Crazy);
            ship->deathtime = universe.totaltimeelapsed + frandyrandombetween(RAN_AIPlayer, 14.0, 20.0);
            ApplyCareenRotationDirectly(ship);
            ship->rotinfo.rotspeed.x *= 1.5;
            ship->rotinfo.rotspeed.y *= 1.5;
            ship->rotinfo.rotspeed.z *= 1.5;
        }
    }
}
Пример #26
0
/*-----------------------------------------------------------------------------
    Name        : aioCreateHarass
    Description : Creates the moves for a team to perform the harass order
    Inputs      : team - the team to do the harassing
    Outputs     : Creates a whole bunch of moves for the team
    Return      : void
----------------------------------------------------------------------------*/
void aioCreateHarass(AITeam *team)
{
    vector destination, origin = ORIGIN_VECTOR;
    AlternativeShips alternatives;
    AITeamMove *move;

    aiplayerLog((aiIndex, "%x Issuing Harass Order", team));

    bitSet(team->teamFlags, HARASS_TEAM);

    destination = aiuFindEnemyMothershipCoords(aiCurrentAIPlayer->player);
    destination = aiuFindRangeStandoffPoint(destination, origin, HARASS_STANDOFF_DISTANCE);

    SetNumAlternativesFlags(alternatives,6,ALTERNATIVE_RANDOM);
    SetAlternative(alternatives,0,HeavyInterceptor,HARASS_HEAVYINT_EQUIVNUM);
    SetAlternative(alternatives,1,HeavyInterceptor,HARASS_HEAVYINT_EQUIVNUM);
    SetAlternative(alternatives,2,AttackBomber,HARASS_BOMBER_EQUIVNUM);
    SetAlternative(alternatives,3,AttackBomber,HARASS_BOMBER_EQUIVNUM);
    SetAlternative(alternatives,4,CloakedFighter,10);
    SetAlternative(alternatives,5,CloakedFighter,10);

    aimCreateFancyGetShips(team, LightInterceptor, HARASS_LIGHTINT_INITNUM, &alternatives, REQUESTSHIPS_HIPRI, TRUE, FALSE);

    move = aimCreateMoveTeam(team, destination, AIO_HARASS_INITIAL_MOVE_FORMATION, TRUE, FALSE);
    aieHandlerSetFuelLow(move, AIO_HARASS_FUEL_LOW, TRUE, TRUE, aihGenericFuelLowHandler);
    aieHandlerSetNumbersLow(move, AIO_HARASS_NUMBERS_LOW, 0, TRUE, aihHarassNumbersLowHandler);
    aieHandlerSetGettingRocked(move, FALSE, aihGenericGettingRockedHandler);
    aieHandlerSetTeamDied(move, aihHarassTeamDiedHandler);

//    aimCreateFormation(team, CLAW_FORMATION, FALSE, FALSE);

    move = aimCreateHarassAttack(team, TRUE, FALSE);
    aieHandlerSetFuelLow(move, AIO_HARASS_FUEL_LOW, TRUE, TRUE, aihGenericFuelLowHandler);
    aieHandlerSetNumbersLow(move, AIO_HARASS_NUMBERS_LOW, 0, TRUE, aihHarassNumbersLowHandler);
    aieHandlerSetGettingRocked(move, FALSE, aihGenericGettingRockedHandler);
    aieHandlerSetTeamDied(move, aihHarassTeamDiedHandler);

    aimCreateMoveDone(team, FALSE, FALSE);
}
Пример #27
0
void CarrierDied(Ship *ship)
{
    CarrierSpec *spec = (CarrierSpec *)ship->ShipSpecifics;
    sdword i;
    for(i=0;i<MAX_NUM_DROP;i++)
    {

        if(spec->droptarget[i] != NULL)
        {
            if(spec->droptarget[i]->objtype == OBJ_ShipType)
            {
                //undisabled and make selectable
                if(!bitTest(((Ship *)spec->droptarget[i])->specialFlags2,SPECIAL_2_DisabledForever))
                {
                    bitClear(spec->droptarget[i]->flags,SOF_Disabled);
                    bitClear(spec->droptarget[i]->specialFlags,SPECIAL_SalvagedTargetGoingIntoDockWithShip);
                    bitSet(spec->droptarget[i]->flags,SOF_Selectable);
                }
            }

        }
    }
}
Пример #28
0
// timer in CTC mode
// Set the OCR for the given timer,
// set the toggle count,
// then turn on the interrupts
// OCR2A = ocr;
void Timer2Init(uint32_t TimerFreq)
{

    static const uint16_t pscLst_alt[] = {0, 1, 8, 32, 64, 128, 256, 1024};

    //Set frequency of timer2
    //setting the waveform generation mode
    uint8_t wgm = 2;
    TCCR2A = 0;
    TCCR2B = 0;
    TCCR2A = (TCCR2A & B11111100) | (wgm & 3);
    TCCR2B = (TCCR2B & B11110111) | ((wgm & 12) << 1);

    uint16_t multiplier = F_CPU / 2 / TimerFreq / 256;
    byte iterate = 0;
    while(multiplier > pscLst_alt[++iterate]);
    multiplier = pscLst_alt[iterate];
    OCR2A = F_CPU/2/TimerFreq/ multiplier-1;
    TCCR2B = (TCCR2B & ~7) | (iterate & 7);

    //enable interrupt
    bitSet(TIMSK2, OCIE2B);
}
Пример #29
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
    
    bitSet(DDRC,7); // HACK DEBUG
    
	SetupHardware();

	/* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
	CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);

	GlobalInterruptEnable();

	for (;;)
	{
		process_bytes();
		
		/*if(do_charge_test){
			charging_test();
		}*/
		
		CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
		USB_USBTask();
	}
}
Пример #30
0
void AX12::setRX () {
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328P__)
    //bitClear(TIMSK0, TOIE0);   // deshabilita la interrupción del timer0 (nota: esto es sólo para entornos Arduino)
    bitClear(UCSR0B, TXEN0);   // deshabilita la trasmisión
    bitSet(UCSR0B, RXEN0);     // habilita la recepción
    bitSet(UCSR0B, RXCIE0);    // habilita la interrupción de recepción
#elif defined (__AVR_ATmega1280__) || defined (__AVR_ATmega128__) || defined (__AVR_ATmega2560__)
    //bitClear(TIMSK0, TOIE0);   // deshabilita la interrupción del timer0 (nota: esto es sólo para entornos Arduino)
    bitClear(UCSR1B, TXEN1);   // deshabilita la trasmisión
    bitSet(UCSR1B, RXEN1);     // habilita la recepción
    bitSet(UCSR1B, RXCIE1);    // habilita la interrupción de recepción
#elif defined (__AVR_ATmega8__)
    //bitClear(TIMSK0, TOIE0); // deshabilita la interrupción del timer0 (nota: esto es sólo para entornos Arduino)
    bitClear(UCSRB, TXEN);   // deshabilita la trasmisión
    bitSet(UCSRB, RXEN);     // habilita la recepción
    bitSet(UCSRB, RXCIE);    // habilita la interrupción de recepción 
#endif    
    ax_rx_Pointer = 0;         // resetea el puntero del buffer
}