当前位置: 首页>>代码示例>>C++>>正文


C++ Ticker::attach方法代码示例

本文整理汇总了C++中Ticker::attach方法的典型用法代码示例。如果您正苦于以下问题:C++ Ticker::attach方法的具体用法?C++ Ticker::attach怎么用?C++ Ticker::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ticker的用法示例。


在下文中一共展示了Ticker::attach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {
    led1 = 0;
    led2 = 0;
    uint32_t initial_handler, final_handler;
    Counter c;

    // Test chaining inside Serial class
    flipper_1.attach(&flip_1, 1.0); // the address of the function to be attached (flip) and the interval (1 second)
    flipper_2.attach(&flip_2, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)

    // Test global chaining (InterruptManager)
    printf("Handler initially: %08X\n", initial_handler = NVIC_GetVector(TIMER_IRQ));
    InterruptManager *pManager = InterruptManager::get();
    pFunctionPointer_t ptm = pManager->add_handler(testme, TIMER_IRQ);
    pFunctionPointer_t pinc = pManager->add_handler_front(&c, &Counter::inc, TIMER_IRQ);
    printf("Handler after calling InterruptManager: %08X\n", NVIC_GetVector(TIMER_IRQ));

    wait(4.0);

    if (!pManager->remove_handler(ptm, TIMER_IRQ) || !pManager->remove_handler(pinc, TIMER_IRQ)) {
        printf ("remove handler failed.\n");
        notify_completion(false);
    }
    printf("Interrupt handler calls: %d\n", c.get_count());
    printf("Handler after removing previously added functions: %08X\n", final_handler = NVIC_GetVector(TIMER_IRQ));

    if (initial_handler != final_handler) {
        printf( "InteruptManager test failed.\n");
        notify_completion(false);
    }

    while(1);
}
开发者ID:1deus,项目名称:tmk_keyboard,代码行数:33,代码来源:main.cpp

示例2: app_start

void app_start(int, char**) {

	// setup the EthernetInterface
	eth.init();	// DHCP
	eth.connect();
	
	// initialize the ipv4 tcp/ip stack
	lwipv4_socket_init();

	// setup the M2MInterface
	srand(time(NULL));
	uint16_t port = rand() % 65535 + 12345;
	srv = M2MInterfaceFactory::create_interface(observer,endpoint,type,
		lifetime,port,domain,M2MInterface::UDP,M2MInterface::LwIP_IPv4,context_address);

	// setup the Security object		
	sec = M2MInterfaceFactory::create_security(M2MSecurity::M2MServer);
	sec->set_resource_value(M2MSecurity::M2MServerUri,address);
	sec->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::NoSecurity);

	// setup the Device object
	dev = M2MInterfaceFactory::create_device();
	dev->create_resource(M2MDevice::Manufacturer,"Freescale");
	dev->create_resource(M2MDevice::DeviceType,"frdm-k64f");
	dev->create_resource(M2MDevice::ModelNumber,"M64FN1MOVLL12");
	dev->create_resource(M2MDevice::SerialNumber,"EB1524XXXX");

	// setup the sensor objects
	obj = M2MInterfaceFactory::create_object("loc");
	M2MObjectInstance* ins = obj->create_object_instance();
	M2MResource* resx = ins->create_dynamic_resource("x","accel",M2MResourceInstance::INTEGER,true);
	resx->set_operation(M2MBase::GET_PUT_ALLOWED);
	resx->set_value((const uint8_t*)"0",1);
	M2MResource* resy = ins->create_dynamic_resource("y","accel",M2MResourceInstance::INTEGER,true);
	resy->set_operation(M2MBase::GET_PUT_ALLOWED);
	resy->set_value((const uint8_t*)"0",1);

	
	// Assemble the list of objects to register
	M2MObjectList list;
	list.push_back(dev);
	list.push_back(obj);

	// setup registration event
	Ticker timer;
	timer.attach(&reg,&Registrar::update,20);

	// enable accelerometer
	printf("Initializied accelerometer\r\n");
	accel.enable();
	Ticker sampler;
	sampler.attach(sample,5);

	// schedule 
	FunctionPointer1<void, M2MObjectList> fp(&reg, &Registrar::setup);
	minar::Scheduler::postCallback(fp.bind(list));
	minar::Scheduler::postCallback(sample).period(minar::milliseconds(10000));
	minar::Scheduler::start();
}
开发者ID:wotio,项目名称:mbedos-accel-frdm-k64f,代码行数:59,代码来源:app.cpp

示例3: main

int main() {
    led1 = 0;
    led2 = 0;
    flipper_1.attach(&flip_1, 1.0); // the address of the function to be attached (flip) and the interval (1 second)
    flipper_2.attach(&flip_2, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)

    while (true) {
        wait(1.0);
    }
}
开发者ID:Illuminux,项目名称:mbed,代码行数:10,代码来源:main.cpp

示例4: report_sample

/*
for reporting a sample that satisfies the reporting criteria and resetting the state machine
*/
int report_sample(sample s)
{
    if(send_notification(s)){  // sends current_sample if observing is on
        last_band = band(s); // limits state machine
        high_step = s + LWM2M_step; // reset floating band upper limit defined by step
        low_step = s - LWM2M_step; // reset floating band lower limit defined by step
        pmin_timer.detach();
        pmin_exceeded = false; // state machine to inhibit reporting at intervals < pmin
        pmin_timer.attach(&on_pmin, LWM2M_pmin);
        pmax_timer.detach();
        pmax_timer.attach(&on_pmax, LWM2M_pmax);
        return 1;
    }
    else return 0;
}
开发者ID:connectIOT,项目名称:lwm2m-objects,代码行数:18,代码来源:LWM2M_resource.cpp

示例5: pppDialing

void pppDialing(void const*) {
    HuaweiUSBCDMAModem modem(NC, true);

    NetLED_ticker.attach(&toggle_NetLed, 3);	//net is disconnect
    while (true) {
        osEvent evt = redial.get();
        char *ch;
        if (evt.status == osEventMessage) {
            ch = (char *)evt.value.p;
            INFO("Get redial osEventMessage value id is %d\n", *ch);
        }

        if (*ch == 1) {
            while(pppRedialingSuccessFlag == false) {
                // connect to redial cellular network
                if (modem.connect(MODEM_APN, MODEM_USERNAME, MODEM_PASSWORD) != OK) {
                    INFO("Could connect the mobile gprs server, please check the Huawei modem or sim card.");
                    Thread::wait(5000);
                }
            }
        } else {
            // connect to cellular network
            if (modem.connect(MODEM_APN, MODEM_USERNAME, MODEM_PASSWORD) != OK) {
                INFO("Could connect the mobile gprs server, please check the Huawei modem or sim card.");
            } else {
                pppDialingSuccessFlag = 1;
            }
        }
    }
}
开发者ID:HeydayGuan,项目名称:Nucleo_RemoteUpdate,代码行数:30,代码来源:main.cpp

示例6: main

int main (void) {
    GREENTEA_SETUP(20, "default_auto");

    Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE);
    Ticker ticker;
    ticker.attach(queue_isr, 1.0);
    int isr_puts_counter = 0;
    bool result = true;

    while (true) {
        osEvent evt = queue.get();
        if (evt.status != osEventMessage) {
            printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status);
            result = false;
            break;
        } else {
            printf("QUEUE_GET: Value(%u) ... [OK]\r\n", evt.value.v);
            if (evt.value.v == QUEUE_PUT_ISR_VALUE) {
                isr_puts_counter++;
            }
            if (isr_puts_counter >= QUEUE_SIZE) {
                break;
            }
        }
    }

    GREENTEA_TESTSUITE_RESULT(result);
    return 0;
}
开发者ID:dinau,项目名称:mbed,代码行数:29,代码来源:main.cpp

示例7: main

int main() {
  pc.printf("\r\nHi! Built with keil\r\n");
  
  //leftChannelA.rise(&leftGotPulse);
  //rightChannelA.rise(&rightGotPulse);
  
  bool pressed = false;
  int motorState = 0;
  speed = 0.0f;
  
  ticker.attach(&printStatus, 0.5);
  
  while(1){
    if (user_button == 0 && !pressed){
        pressed = true;
        
        
        switch (motorState){
            case 0: speed = 0.0f; break;
            case 1: speed = 0.1f; break;
            case 2: speed = 0.5f; break;
            case 3: speed = 1.0f; break;
            case 4: speed = 0.0f; break;
            case 5: speed = -0.1f; break;
            case 6: speed = -0.5f; break;
            case 7: speed = -1.0f; motorState = -1; break;
        }
        motorState++;
        drive(speed);
    }
    else if (user_button == 1){
        pressed = false;
    }
  }
}
开发者ID:austinxiao-ucsd,项目名称:falcon,代码行数:35,代码来源:main.cpp

示例8: main

int main() {
    DBG("start main !!\r\n");
    
    // output pwm value
    pwmu_p.period_us(PWM_T_TIME);
    pwmv_p.period_us(PWM_T_TIME);
    pwmw_p.period_us(PWM_T_TIME);
    
    pwmu_n.period_us(PWM_T_TIME);
    pwmv_n.period_us(PWM_T_TIME);
    pwmw_n.period_us(PWM_T_TIME);    

    // initialize 
    is_initialized = false;
    start_motor = false;
    hallonoff = false;
    dx = 1.0/(DX_LEN * freq);
    
    startup.fall(&initialize);
    frequp.fall(&pushUp);
    controller.attach(&bldcval, dx);

    while(1) {
        wait(1);
    }
}
开发者ID:hirotakaster,项目名称:hallsensor-bldc,代码行数:26,代码来源:test.cpp

示例9: Init

/////////////////////////////////////////////////////////////////////////
// Les actions élémentaires
/////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//Initialisation//
////////////////////////////////////////////////////////////////
void Init(void)
{
    son.MusicOff();
    scanShip.attach(&shipscan,0.2);
    giEvent = RIEN;
    giEtat = LCDPLAY;
    giStatelvl = LVL1;
    lcd.cls();        //efface LCD
    timemove.stop();
    timemove.reset(); //reset timer
    timemove.start();
    timetir.stop();
    timetir.reset();
    timetir.start();
    Scrolling.stop();
    Scrolling.reset();
    Chrono.stop();
    Chrono.reset();
    EndTime.stop();
    EndTime.reset();
    giH = giS = giM = giD = 0;
    ScIndice=-1;
    gilen=0;
    scl=0;
    IndicePseudo=0;
    lcd.printf("=>Jouer   Score");
    lcd.locate(0,1);
    lcd.printf("  Difficulte");
    T_MS1=500; //timer mouvement
    T_MS2=500; //timer tir
    //à 500ms dans le menu pour plus de précision
    //sinon T_MS1=100ms
    //      T_MS2=150ms
    space.menuAff();
}
开发者ID:HaenlinJason,项目名称:Info2-Projet-Game,代码行数:41,代码来源:Jeux.cpp

示例10: initializeSnake

void initializeSnake(LLRoot * master) {
    /* Start Snake at 3 in length
     * x, y, z:layer
     */ 
      
    //if(master != NULL)      // Uh oh, non-empty snake?
    //    freeListLL(master); // No matter
    
    initializeLL(master);
    __disable_irq();
    addToHeadLL(master, 0, 0, 0);
    __enable_irq();
    // BEAMMEUPSCOTTY
    myCube.plotPoint(0, 0, 0);
    master->direction = XPOS;
    //master->length = 1;
   
    generateFruit(master);
    
    // Note: What if fruit is generated on snake?
    // The user will not be able to see it until all snake nodes have gone
    // over it
    
    tick.attach(&setSnakeFlag, SPEED);
}
开发者ID:ahmedlogic,项目名称:LEDcube,代码行数:25,代码来源:main.cpp

示例11: main

int main (void) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(ISR (Queue));
    MBED_HOSTTEST_START("RTOS_8");

    Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE);
    Ticker ticker;
    ticker.attach(queue_isr, 1.0);
    int isr_puts_counter = 0;
    bool result = true;

    while (true) {
        osEvent evt = queue.get();
        if (evt.status != osEventMessage) {
            printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status);
            result = false;
            break;
        } else {
            printf("QUEUE_GET: Value(%u) ... [OK]\r\n", evt.value.v);
            if (evt.value.v == QUEUE_PUT_ISR_VALUE) {
                isr_puts_counter++;
            }
            if (isr_puts_counter >= QUEUE_SIZE) {
                break;
            }
        }
    }

    MBED_HOSTTEST_RESULT(result);
    return 0;
}
开发者ID:TemcoHeng,项目名称:mbed,代码行数:32,代码来源:main.cpp

示例12: main

int main(void)
{
    led1 = 1;
    Ticker ticker;
    ticker.attach(periodicCallback, 1); // blink LED every second

    BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE);
    ble.init(bleInitComplete);

    /* SpinWait for initialization to complete. This is necessary because the
     * BLE object is used in the main loop below. */
    while (ble.hasInitialized()  == false) { /* spin loop */ }

    // infinite loop
    while (1) {
        // check for trigger from periodicCallback()
        if (triggerSensorPolling && ble.getGapState().connected) {
            triggerSensorPolling = false;
        
            // Do blocking calls or whatever is necessary for sensor polling.
            // In our case, we simply update the HRM measurement.
            hrmCounter++;
            pc.printf("%d\n", hrmCounter);
            hrService->updateHeartRate(hrmCounter);
        } else {
            ble.waitForEvent(); // low power wait for event
        }
    }
}
开发者ID:rix1,项目名称:master-sensor-software,代码行数:29,代码来源:main.cpp

示例13: main

int main() {
    // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms)
    toggle_led_ticker.attach(&toggle_led, 0.1);
    while (true) {
        // Do other things...
    }
}
开发者ID:dotnfc,项目名称:arducleo,代码行数:7,代码来源:ticker_main.cpp

示例14: main

int main(void) {
    //setup zender
    zender.baud(115200);
    zender.attach(&newData);   
    
    //attach tickers
    blinker.attach(&blink, 0.5);
    updater.attach(&update, 0.1);
    
    //echo off
    state["echo"] = 0;
    
      
    while (1) {
        ;
    }
}
开发者ID:pd0wm,项目名称:flying-dutchman,代码行数:17,代码来源:main.cpp

示例15: pppSurfing

void pppSurfing(void const*) {
    while (pppDialingSuccessFlag == 0) {
        Thread::wait(500);
    }
    NetLED_ticker.detach();
    NetLED_ticker.attach(&toggle_NetLed, 0.5);	//net is connect
    startRemoteUpdate();
}
开发者ID:HeydayGuan,项目名称:Nucleo_RemoteUpdate,代码行数:8,代码来源:main.cpp


注:本文中的Ticker::attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。