本文整理汇总了C++中USART::getch方法的典型用法代码示例。如果您正苦于以下问题:C++ USART::getch方法的具体用法?C++ USART::getch怎么用?C++ USART::getch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USART
的用法示例。
在下文中一共展示了USART::getch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
imu.start();
out.printf("Battery: %f cell\n", batmon.getCellVoltage());
out.print("Waiting for remote signal\n");
while (!vex.getSynced()) { Task::sleep(100); }
out.print("Arming\n");
motors.arm();
float heading = imu.getYaw();
buzzer.buzz(300);
while (true) {
control.start();
Logger logger(eeprom, 0);
bool logging = false;
while (true) {
bool up = false;
if (!vex.getSynced()) {
control.stop();
motors.off();
while (!vex.getSynced()) { Task::sleep(100); }
control.start();
sensors.centerGyros();
heading = imu.getYaw();
buzzer.buzz(300);
}
VexRC::Channels chans = vex.getChannels();
if (chans.right != VexRC::NONE)
break;
if (chans.left == VexRC::UP)
logging = true;
else if (chans.left == VexRC::DOWN)
logging = false;
float throttle = chans.analogs[1] / 50.0;
if (throttle < 0)
throttle = 0;
float rollsetpoint = (-chans.analogs[3] / 50.0) * 0.3;
float pitchsetpoint = (-chans.analogs[2] / 50.0) * 0.3;
heading += (chans.analogs[0] / 50.0) * (M_PI / 4) * .005;
control.setControlPoints(throttle, rollsetpoint, pitchsetpoint, heading);
if (!up) {
if (throttle > 0.4)
up = true;
else
control.clearIntegrals();
}
if (logging) {
LogEntry entry = { sensors.getReadings(), imu.getState(), throttle };
logger.write((uint8_t *)&entry, sizeof(entry));
}
IMU::State state = imu.getState();
IMU::State velstate = imu.getVelocityState();
out.printf("%f %f\n", control.getRollCorrection(), control.getPitchCorrection());
Task::sleep(25);
}
control.stop();
motors.off();
out.print("Push enter\n");
while (out.getch() != '\r') { }
out.print("Press y to dump log");
if (out.getch() == 'y') {
out.print("\nLog dump:");
LogReader reader(eeprom, 0);
struct LogEntry entry;
while (reader.read((uint8_t *)&entry, sizeof(entry)) == sizeof(entry)) {
int i;
for (i=0;i<6;i++) {
out.printf("%.3f ", entry.analogs.array[i]);
}
out.printf("%.3f %.3f %.3f ", entry.state.roll, entry.state.pitch, entry.state.yaw);
out.printf("%.3f\n", entry.throttle);
}
}
docalibrate("Roll", &controlconfig.roll_config);
docalibrate("Pitch", &controlconfig.pitch_config);
docalibrate("Yaw", &controlconfig.yaw_config);
out.printf("Current stick values: %f %f\n", controlconfig.rollpitch_stickfactor, controlconfig.yaw_stickfactor);
out.printf("Stick: ");
static char buf[50];
out.getline(buf, sizeof(buf));
sscanf(buf, "%f %f", &controlconfig.rollpitch_stickfactor, &controlconfig.yaw_stickfactor);
}
}
示例2: loop
/* ----------------------------------------------------------------------------
* メインループ
* ---------------------------------------------------------------------------- */
void loop() {
int i;
int j;
// 1秒毎の処理
if(interruptCount > 999) {
// 時計モード
if(userDataTimerCount == 0) {
rtc.get();
// 年月日表示か時刻表示かの判定
if(displayDateIntervalCount <= displayDateIntervalValue) {
// 時分秒表示
// カンマをクリア
for(int i = 0; i < 8; i++) {
IN12Com[i] = 0;
}
// 6桁フォーマット 999999
if(dispTimeFormat == 0) {
IN12Num[0] = 0x0F;
if(hour12_24format == 1) {
IN12Num[1] = rtc.hourHigh;
IN12Num[2] = rtc.hourLow;
} else {
IN12Num[1] = rtc.hourHigh12;
IN12Num[2] = rtc.hourLow12;
}
IN12Num[3] = rtc.minutesHigh;
IN12Num[4] = rtc.minutesLow;
IN12Num[5] = rtc.secondsHigh;
IN12Num[6] = rtc.secondsLow;
IN12Num[7] = 0x0F;
}
// 8桁フォーマット 99, 99, 99
if(dispTimeFormat == 1) {
if(hour12_24format == 1) {
IN12Num[0] = rtc.hourHigh;
IN12Num[1] = rtc.hourLow;
} else {
IN12Num[0] = rtc.hourHigh12;
IN12Num[1] = rtc.hourLow12;
}
IN12Num[2] = 0x0F;
IN12Num[3] = rtc.minutesHigh;
IN12Num[4] = rtc.minutesLow;
IN12Num[5] = 0x0F;
IN12Num[6] = rtc.secondsHigh;
IN12Num[7] = rtc.secondsLow;
IN12Com[2] = 1;
IN12Com[5] = 1;
}
} else {
// 年月日表示
// カンマクリア
for(int i = 0; i < 8; i++) {
IN12Com[i] = 0;
}
IN12Num[0] = 2;
IN12Num[1] = 0;
IN12Num[2] = rtc.yearHigh;
IN12Num[3] = rtc.yearLow;
IN12Num[4] = rtc.monthHigh;
IN12Num[5] = rtc.monthLow;
IN12Num[6] = rtc.dayHigh;
IN12Num[7] = rtc.dayLow;
if(displayDateIntervalCount >= ( displayDateIntervalValue + displayDateSecondsValue)) {
displayDateIntervalCount = 0;
}
}
displayDateIntervalCount++;
}
// ユーザーデータ表示中
if(userDataTimerCount > 0) {
userDataTimerCount--;
}
// LED 点滅
if(led == false) {
led = true;
PORTC |= (1<<LED);
} else {
led = false;
PORTC &= ~(1<<LED);
}
interruptCount = 0;
}
// シリアル1 受信処理
while(Serial1.available()) {
char ch = Serial1.getch();
serial0String[serial0StringIdx] = ch;
Serial1.putch(ch);
if(serial0String[serial0StringIdx] == '\r') {
Serial1.putch('\n');
serial0String[serial0StringIdx] = 0;
serial0StringComplete = true;
}
serial0StringIdx++;
if(serial0StringIdx >= SERIALBUF_LEN) {
//.........这里部分代码省略.........