本文整理汇总了C++中Ticker类的典型用法代码示例。如果您正苦于以下问题:C++ Ticker类的具体用法?C++ Ticker怎么用?C++ Ticker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ticker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
// Instantiate security manager now so that it doesn't need to be done from an ISR later.
nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getSecurityManager();
/* 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++;
if (hrmCounter == 175) { // 100 <= HRM bps <=175
hrmCounter = 100;
}
hrService->updateHeartRate(hrmCounter);
} else {
ble.waitForEvent(); // low power wait for event
}
}
}
示例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(®,&Registrar::update,20);
// enable accelerometer
printf("Initializied accelerometer\r\n");
accel.enable();
Ticker sampler;
sampler.attach(sample,5);
// schedule
FunctionPointer1<void, M2MObjectList> fp(®, &Registrar::setup);
minar::Scheduler::postCallback(fp.bind(list));
minar::Scheduler::postCallback(sample).period(minar::milliseconds(10000));
minar::Scheduler::start();
}
示例3: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Ticker w;
w.setText(QString(QObject::tr("***人的孤独********!")));
w.show();
return a.exec();
}
示例4: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ticker ticker;
ticker.setWindowTitle(QObject::tr("Ticker"));
ticker.setText(QObject::tr("How long it lasted was impossible to "
"say ++ "));
ticker.show();
return app.exec();
}
示例5: equeue_tick_init
static void equeue_tick_init() {
MBED_STATIC_ASSERT(sizeof(equeue_timer) >= sizeof(Timer),
"The equeue_timer buffer must fit the class Timer");
MBED_STATIC_ASSERT(sizeof(equeue_ticker) >= sizeof(Ticker),
"The equeue_ticker buffer must fit the class Ticker");
Timer *timer = new (equeue_timer) Timer;
Ticker *ticker = new (equeue_ticker) Ticker;
equeue_minutes = 0;
timer->start();
ticker->attach_us(equeue_tick_update, 1000 << 16);
equeue_tick_inited = true;
}
示例6: main
int main (void) {
Thread thread(queue_thread);
Ticker ticker;
ticker.attach(queue_isr, 1.0);
while (true) {
osEvent evt = queue.get();
if (evt.status != osEventMessage) {
printf("queue->get() returned %02x status\n\r", evt.status);
} else {
printf("queue->get() returned %d\n\r", evt.value.v);
}
}
}
示例7: main
int main()
{
Ticker blinky;
blinky.attach(blink, 0.4f);
printf("NetworkSocketAPI Example\r\n");
eth.connect();
const char *ip = eth.get_ip_address();
const char *mac = eth.get_mac_address();
printf("IP address is: %s\r\n", ip ? ip : "No IP");
printf("MAC address is: %s\r\n", mac ? mac : "No MAC");
SocketAddress addr(ð, "mbed.org");
printf("mbed.org resolved to: %s\r\n", addr.get_ip_address());
TCPSocket ipv4socket(ð);
ipv4socket.connect("4.ifcfg.me", 23);
ipv4socket.set_blocking(false);
ipv4socket.attach(network_callback);
TCPSocket ipv6socket(ð);
ipv6socket.connect("6.ifcfg.me", 23);
ipv6socket.set_blocking(false);
ipv6socket.attach(network_callback);
// Tries to get both an IPv4 and IPv6 address
while (network_sem.wait(2500) > 0) {
int count;
char buffer[64];
count = ipv4socket.recv(buffer, sizeof buffer);
if (count >= 0) {
printf("public IPv4 address is: %.15s\r\n", &buffer[15]);
}
count = ipv6socket.recv(buffer, sizeof buffer);
if (count >= 0) {
printf("public IPv6 address is: %.39s\r\n", &buffer[15]);
}
}
ipv4socket.close();
ipv6socket.close();
eth.disconnect();
printf("Done\r\n");
}
示例8: 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();
}
示例9: 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);
}
}
示例10: pushUp
void pushUp(){
freq += FREQ_SIZE;
if (freq >= MAX_FREQ) freq = MAX_FREQ;
dx = 1.0/(DX_LEN * freq);
controller.detach();
controller.attach(&bldcval, dx);
DBG("freq = %d\r\n", freq);
}
示例11: debounce_handler
void debounce_handler() {
if (debounce.read_ms() >= 500) {
debounce.reset();
training_mode = !training_mode;
if (training_mode) tcontrol.attach(checkTimers, 1);
else tcontrol.detach();
led4 = !led4;
turnoffgreen();
greenlightact();
}
}
示例12: update
inline void update(FT mFT) override
{
tlShoot.update(mFT);
if(tckShoot.getCurrent() > shootDelay / 1.5f &&
tckShoot.getCurrent() < shootDelay)
game.createPCharge(1, cPhys.getPosPx(), 20);
if(tckShoot.update(mFT))
{
tlShoot.reset();
tlShoot.start();
}
}
示例13: 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;
}
示例14: kickExternalWatchdog
void kickExternalWatchdog(void) {
static bool locked = false;
static bool wdog_state = false;
static bool wdog_configured = false;
if (!wdog_configured) {
pinMode(WATCHDOG_WOUT_PIN, OUTPUT);
kickAllSoftwareWatchdogs();
SWWatchdog.attach_ms(300, softwareWatchdog); // Check for stuck tasks and kick external Watchdog
// The external wdog trips after 1.6s, but the timing is sloppy for the ESP8266, need this as 300ms.
wdog_configured = true;
startedTime = millis();
Serial.println(F("Software watchdog initialized."));
}
if (!locked) {
locked = true;
pinMode(WATCHDOG_WOUT_PIN, OUTPUT);
if (wdog_state) {
digitalWrite(WATCHDOG_WOUT_PIN, HIGH);
wdog_state = false;
}
else {
digitalWrite(WATCHDOG_WOUT_PIN, LOW);
wdog_state = true;
}
locked = false;
}
}
示例15: 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;
}
}
}