本文整理汇总了C++中HardwareTimer::startOnce方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwareTimer::startOnce方法的具体用法?C++ HardwareTimer::startOnce怎么用?C++ HardwareTimer::startOnce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareTimer
的用法示例。
在下文中一共展示了HardwareTimer::startOnce方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StepperTimerInt
void IRAM_ATTR StepperTimerInt() {
hardwareTimer.initializeUs(deltat, StepperTimerInt);
hardwareTimer.startOnce();
if (steppersOn) {
uint32_t pin_mask_steppers = 0;
//set direction pins
for (int i = 0; i < 4; i++) {
if (curPos[i] != nextPos[i]) {
int8_t sign = -1;
if (nextPos[i] > curPos[i])
sign = 1;
if (sign > 0)
digitalWrite(dir[i], false);
else
digitalWrite(dir[i], true);
curPos[i] = curPos[i] + sign;
pin_mask_steppers = pin_mask_steppers | (1 << step[i]);
}
}
delayMicroseconds(3);
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pin_mask_steppers);
delayMicroseconds(5);
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pin_mask_steppers); // Set pin a and b low
delayMicroseconds(5);
}
}
示例2: connectOk
void connectOk(IPAddress ip, IPAddress mask, IPAddress gateway) {
//void connectOk() {
String ipString = WifiStation.getIP().toString();
Serial.println("I'm CONNECTED to AP_SSID=" + wifi_sid.get(currWifiIndex) + " IP: " + ipString);
//String ipString = ip.toString();
Serial.println("IP: " + ipString);
startWebServer();
if (ipString.equals("192.168.1.115") || ipString.equals("192.168.1.110")) {
// distance sensor
Serial.println("MODE: LEUZE Distance sensor");
udp.listen(udpServerPort);
Serial.begin(57600);
deltat = 100000;
system_uart_swap();
delegateDemoClass.begin();
reportTimer.initializeMs(100, reportAnalogue).start();
} else if (ipString.equals("192.168.1.113") || ipString.equals("192.168.1.112") || ipString.equals("192.168.1.21")
|| ipString.equals("192.168.43.154")) { //
// 4 axis stepper driver
Serial.setCallback(serialCallBack);
Serial.println("MODE: 4 Axis Stepper driver");
Serial.println("Init ended.");
Serial.println("Type 'help' and press enter for instructions.");
Serial.println();
deltat = 2000;
if (ipString.equals("192.168.1.112"))
parseGcode("reassign x=0 y=3 e=1 z=2");
else if (ipString.equals("192.168.1.113"))
parseGcode("reassign x=0 y=1 e=3 z=2");
reportTimer.initializeMs(300, reportStatus).start();
hardwareTimer.initializeUs(deltat, StepperTimerInt);
hardwareTimer.startOnce();
} else if (ipString.equals("192.168.1.116")) {
Serial.println("MODE: Encoder driver");
pinMode(encoder0PinA, INPUT);
digitalWrite(encoder0PinA, HIGH); // turn on pullup resistor
pinMode(encoder0PinB, INPUT);
digitalWrite(encoder0PinB, HIGH); // turn on pullup resistor
attachInterrupt(encoder0PinA, doEncoderA, GPIO_PIN_INTR_ANYEDGE);
attachInterrupt(encoder0PinB, doEncoderB, GPIO_PIN_INTR_ANYEDGE);
reportTimer.initializeMs(100, reportEncoderPosition).start();
} else if (ipString.equals("192.168.1.117")) {
Ltc2400Spi = new SPISoft(PIN_DO, PIN_DI, PIN_CK, PIN_SS);
Ltc2400Spi->begin();
reportTimer.initializeMs(300, readFromLTC2400).startOnce();
}
else
{
Serial.setCallback(serialCallBack);
}
}