コード例 #1
0
ファイル: ial.c プロジェクト: fkolacek/FIT-VUT
void symbolTableInit(tSymbolTable* symbolTable){
    btInit(&(symbolTable->mainFunc.symbols));
    initList(&(symbolTable->mainFunc.constants));
    initList(&(symbolTable->mainFunc.instructions));
    btInit(&(symbolTable->functions));
    symbolTable->mainFunc.called=0;
    symbolTable->currentFunc=&(symbolTable->mainFunc);
}
コード例 #2
0
int main(void)
{
    SPI_MasterInit();
    btInit();
    interruptINT1_init();
    sei();
    btTransmit(0);
    //moveRobot(ACTIVATE_HIT);
    while(1)
    {
        BT_SensorValues();
        getSensorValues();
        setVariables();

        dataValues[LIFE] = lifeCount;

        //Start of AI program that should keep the robot within the boundaries of the tape track
        moveRobot(LED | lifeCount);

        if(!lifeCount) {
            sensorControlDead();
            if(TapeFlag >= 0x03 && counting == 0) {
                counting = 1;
                timerValue = TIMER_1A_SECOND;
                timer_init();
            } else if(counting == 2) {
                while(1) {
                    moveRobot(STOP);
                }
            }


        } else {

            if(hit == 0) {
                activateHitFlag = 0;
                hitFlag = 1;
            }

            if (hit == 1 && activateHitFlag)
            {
                moveRobot(IR_ON);
                moveRobot(ACTIVATE_HIT);
            }

            else if(hit == 1 && hitFlag == 1) {
                hitFlag = 0;
                lifeCount = lifeCount >> 1;
                timer0_init();
            }

            else if (hit == 1 && !activateHitFlag) {
                moveRobot(IR_OFF);
            }


            if(!sprayPray) {
                idle();
            }
        }
コード例 #3
0
ファイル: menu_general.cpp プロジェクト: 4408/opentx
void menuGeneralHardware(uint8_t event)
{
  MENU(STR_HARDWARE, menuTabDiag, e_Hardware, ITEM_SETUP_HW_MAX+1, {0, 0, (uint8_t)-1, 0, 0, 0, 0, IF_BLUETOOTH(0)});

  uint8_t sub = m_posVert - 1;

  for (uint8_t i=0; i<LCD_LINES-1; i++) {
    uint8_t y = 1 + 1*FH + i*FH;
    uint8_t k = i+s_pgOfs;
    uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
    uint8_t attr = (sub == k ? blink : 0);

    switch(k) {
      case ITEM_SETUP_HW_OPTREX_DISPLAY:
        g_eeGeneral.optrexDisplay = selectMenuItem(GENERAL_HW_PARAM_OFS, y, STR_LCD, STR_VLCD, g_eeGeneral.optrexDisplay, 0, 1, attr, event);
        break;

      case ITEM_SETUP_HW_STICKS_GAINS_LABELS:
        lcd_putsLeft(y, PSTR("Sticks"));
        break;

      case ITEM_SETUP_HW_STICK_LV_GAIN:
      case ITEM_SETUP_HW_STICK_LH_GAIN:
      case ITEM_SETUP_HW_STICK_RV_GAIN:
      case ITEM_SETUP_HW_STICK_RH_GAIN:
      {
        lcd_putsiAtt(INDENT_WIDTH, y, PSTR("\002LVLHRVRH"), k-ITEM_SETUP_HW_STICK_LV_GAIN, 0);
        lcd_puts(INDENT_WIDTH+3*FW, y, PSTR("Gain"));
        uint8_t mask = (1<<(k-ITEM_SETUP_HW_STICK_LV_GAIN));
        uint8_t val = (g_eeGeneral.sticksGain & mask ? 1 : 0);
        lcd_putcAtt(GENERAL_HW_PARAM_OFS, y, val ? '2' : '1', attr);
        if (attr) {
          CHECK_INCDEC_GENVAR(event, val, 0, 1);
          if (checkIncDec_Ret) {
            g_eeGeneral.sticksGain ^= mask;
            setSticksGain(g_eeGeneral.sticksGain);
          }
        }
        break;
      }

      case ITEM_SETUP_HW_ROTARY_ENCODER:
        g_eeGeneral.rotarySteps = selectMenuItem(GENERAL_HW_PARAM_OFS, y, PSTR("Rotary Encoder"), PSTR("\0062steps4steps"), g_eeGeneral.rotarySteps, 0, 1, attr, event);
        break;

#if defined(BLUETOOTH)
      case ITEM_SETUP_HW_BT_BAUDRATE:
        g_eeGeneral.btBaudrate = selectMenuItem(GENERAL_HW_PARAM_OFS, y, STR_BAUDRATE, PSTR("\005115k 9600 19200"), g_eeGeneral.btBaudrate, 0, 2, attr, event);
        if (attr && checkIncDec_Ret) {
          btInit();
        }
        break;
#endif

    }
  }
}
コード例 #4
0
ファイル: ial.c プロジェクト: fkolacek/FIT-VUT
E_CODE symbolTableInsertFunction(tSymbolTable* symbolTable, tString functionName){
    tFunction *func=mmuMalloc(sizeof(tFunction));
    strCopyString(&functionName,&(func->name)); // jmeno fce
    btInit(&(func->symbols)); // symboly
    initList(&(func->instructions)); // instrukce
    initList(&(func->constants));
    func->called=1;
    E_CODE err=BTInsert(&(symbolTable->functions),&(func->name),func);
    if (err!=ERROR_OK){strFree(&(func->name));mmuFree(func);}
    return err;
}
コード例 #5
0
ファイル: ADK.cpp プロジェクト: CyrilleSavy/BluetoothDevMob
void adkInit(void){

    //bt init
    static const BtFuncs myBtFuncs = {this, btVerboseScanCbkF, btConnReqF, btConnStartF, btConnEndF, btPinRequestF, btLinkKeyRequest, btLinkKeyCreated, btAclDataRxF, btSspShowF};
    btInit(&myBtFuncs);              //BT UART & HCI driver
    btSdpRegisterL2capService();     //SDP daemon
    btRfcommRegisterL2capService();  //RFCOMM framework

    uint8_t mac[BT_MAC_SIZE];

    if(btLocalMac(mac)) dbgPrintf("BT MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);

}
コード例 #6
0
ファイル: bluetooth.c プロジェクト: Surebu/Projekt
int main(void)
{
	btInit();
	sei();
	
	val = 'A'; //0x41;
	//PORTB = ~val; // set PORTB
	
	while(1)
	{
		btTransmit(val);
		_delay_ms(250);
	}
};
コード例 #7
0
ファイル: ADK.c プロジェクト: CyrilleSavy/BluetoothDevMob
void adkInit(void){

    //Create the BT functions structure
    static const BtFuncs myBtFuncs = {0, btVerboseScanCbkF, btConnReqF, btConnStartF, btConnEndF, btPinRequestF, btLinkKeyRequest, btLinkKeyCreated, btAclDataRxF, btSspShowF};

    //Bluetooth initialisation
    btInit(&myBtFuncs);

    //Start the listener service
    btSdpRegisterL2capService();     //SDP daemon
    btRfcommRegisterL2capService();  //RFCOMM framework

    //Configuration is Event controlled
    // Initiate the configuration processe by reset the dongle
    btReset_hci();

}
コード例 #8
0
ファイル: binary_tree-test.c プロジェクト: fkolacek/FIT-VUT
int main()
{
    tBTree *T;
    tBTNode N;

    mmuInit();
    T=mmuMalloc(sizeof(tBTree));
    btInit(T);
    tString str,str1,str2,str3;
    void *nic=NULL;
    str=strCreate("ahoj");
    str1=strCreate("nazdar");
    str2=strCreate("valhala");
    str3=strCreate("abcd");
    if(strCmp(&str1,&str1)!=0)printf("chyba strCmp");
    //printf("%s\n",str.data);
    BTInsert(T,&str,nic);
    BTInsert(T,&str1,nic);
    BTInsert(T,&str2,nic);
    BTInsert(T,&str3,nic);
    printf("%d\n",T->root->height);
    printf("%s\n",T->root->left->key->data);
    printf("%s\n",T->root->right->key->data);
    printf("%s\n",T->root->right->right->key->data);
    printf("%s\n",T->root->key->data);
    N=btFind(T,&str1);
    //BTInsert(T,&str2,nic);
    if(N!=NULL)printf("%s\n",N->key->data);
    else printf("nic se nenaslo\n");
    if(T->root->left==NULL && T->root->right==NULL) printf("chyba\n");
    int cmp=strCmp(&str1,&str);
    printf("%d\n",cmp);
    //btFree(T);
    mmuGlobalFree();
    return 0;
}
コード例 #9
0
ファイル: ial.c プロジェクト: fkolacek/FIT-VUT
void btFree(tBTree *T){
    deleteNodes(T->root);
    btInit(T);
}
コード例 #10
0
ファイル: bluetooth.cpp プロジェクト: adriano65/opentx-2.0.14
void btTask(void* pdata)
{
  uint8_t byte;

  btFlag = CoCreateFlag(true, false);
  btTx.size = 0;

  // Look for BT module baudrate, try 115200, and 9600
  // Already initialised to g_eeGeneral.bt_baudrate
  // 0 : 115200, 1 : 9600, 2 : 19200

  uint32_t x = g_eeGeneral.btBaudrate;

  btStatus = btPollDevice() ;              // Do we get a response?

  for (int y=0; y<2; y++) {
    if (btStatus == 0) {
      x += 1 ;
      if (x > 2) {
        x = 0 ;
      }
      btSetBaudrate(x) ;
      CoTickDelay(1) ;                                        // 2mS
      btStatus = btPollDevice() ;              // Do we get a response?
    }
  }

  if (btStatus) {
    btStatus = x + 1 ;
    if ( x != g_eeGeneral.btBaudrate ) {
      x = g_eeGeneral.btBaudrate ;
      // Need to change Bt Baudrate
      btChangeBaudrate( x ) ;
      btStatus += (x+1) * 10 ;
      btSetBaudrate( x ) ;
    }
  }
  else {
    btInit();
  }

  CoTickDelay(1) ;

  btPollDevice(); // Do we get a response?

  while (1) {
    uint32_t x = CoWaitForSingleFlag(btFlag, 10); // Wait for data in Fifo
    if (x == E_OK) {
      // We have some data in the Fifo
      while (btTxFifo.pop(byte)) {
        btTxBuffer[btTx.size++] = byte;
        if (btTx.size > 31) {
          btSendBuffer();
        }
      }
    }
    else if (btTx.size) {
      btSendBuffer();
    }
  }
}