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


C++ Console::clear方法代码示例

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


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

示例1: show_welcome

	void show_welcome() {
		while(m_usb.isConnected()) {
			m_con.clear();
			m_con << "****************************************" << endl;
			m_con << "*     Welcome to Self-Balance Robot    *" << endl;
			m_con << "*                 " VERSION "               *" << endl;
			m_con << "****************************************" << endl;
			m_con << "[1] Calibrations" << endl;
			m_con << "[2] PID Control tuning" << endl;
			m_con << "[3] Save changed" << endl;
			m_con << "[4] Load Default" << endl;
			m_con << "[5] Dashboard" << endl;
			switch(m_con.getc()) {
			case '1' :
				show_mpu6050();
				break;
			case '2' :
				show_pid();
				break;
			case '3' :
				saveConfigure();
				break;
			case '4' :
				setDefault();
				break;
			case '5':
				dashboard();
				break;
			case 'H':
				m_con.printf("High-Water Mark:%d\n", getStackHighWaterMark());
				m_con.getc();
				break;
			}
		}
开发者ID:eastWillow,项目名称:self_balance_robot,代码行数:34,代码来源:main.cpp

示例2: dashboard

	void dashboard() {
		while(m_usb.isConnected() ) {
			m_con.clear();
			m_con << "SetPoint Patch   Roll    PWM\%" << endl;
			m_con.printf("%0.3f\t %0.3f\t %0.3f\t%0.3f", m_robot->m_setpoint, m_robot->m_pitch, m_robot->m_roll, m_robot->m_output);
			if ( m_usb.available() ) {
				if ( m_con.getc()==0x1B ) return;
			}
			sleep(250);
		}
开发者ID:eastWillow,项目名称:self_balance_robot,代码行数:10,代码来源:main.cpp

示例3: show_pid

	void show_pid() {
		while( m_usb.isConnected() ) {
			m_con.clear();
			m_con << "****************************************" << endl;
			m_con << "*          PID Control tuning          *" << endl;
			m_con << "****************************************" << endl;
			m_con.printf("[1] Kp (%0.3f)\n", config.kp);
			m_con.printf("[2] Ki (%0.3f)\n", config.ki);
			m_con.printf("[3] Kd (%0.3f)\n", config.kd);
			m_con.printf("[4] Min. PWM (%0.2f)\n", config.pwm_min);
			m_con.printf("[5] Max. PWM (%0.2f)\n", config.pwm_max);
			m_con.printf("[6] Skip Interval (%0.4f)\n", config.skip_interval);
			m_con << "[ESC] Return" << endl;
			switch(m_con.getc()) {
			case '1':
				m_con << "Input Kp:" << flush;
				config.kp = m_usb.parseFloat(true);
				m_robot->tuings(config.kp, config.ki, config.kd);
				break;
			case '2':
				m_con << "Input Ki:" << flush;
				config.ki = m_usb.parseFloat(true);
				m_robot->tuings(config.kp, config.ki, config.kd);
				break;
			case '3':
				m_con << "Input Kd:" << flush;
				config.kd = m_usb.parseFloat(true);
				m_robot->tuings(config.kp, config.ki, config.kd);
				break;
			case '4':
				m_con << "Input Min. PWM:" << flush;
				config.pwm_min = m_usb.parseFloat(true);
				break;
			case '5':
				m_con << "Input Max. PWM:" << flush;
				config.pwm_max = m_usb.parseFloat(true);
				break;
			case '6':
				m_con << "Input Skip Interval:" << flush;
				config.skip_interval = m_usb.parseFloat(true);
				break;
			case 0x1B:
				return;
			}
		}
开发者ID:eastWillow,项目名称:self_balance_robot,代码行数:45,代码来源:main.cpp

示例4: angle

	void show_mpu6050() {
		while( m_usb.isConnected() ) {
			m_con.clear();
			m_con << "****************************************" << endl;
			m_con << "*            Calibrations              *" << endl;
			m_con << "****************************************" << endl;
#if USE_AUTO_TUNING
			m_con.printf("[1] Set roll angle (%0.4f)\n", config.roll_offset);
#else
			m_con.printf("[1] Set roll offset (%0.4f)\n", config.roll_offset);
#endif
			m_con.printf("[2] Set left motor power (%0.2f)\n", config.left_power);
			m_con.printf("[3] Set right motor power (%0.2f)\n", config.right_power);
			m_con << "[ESC] Return" << endl;

			switch( m_con.getc() ) {
			case '1':
#if USE_AUTO_TUNING
				m_con << "Input roll angle:" << flush;
#else
				m_con << "Input roll offset:" << flush;
#endif
				config.roll_offset = m_usb.parseFloat(true);
				break;
			case '2':
				m_con << "Input left power:" << flush;
				config.left_power = m_usb.parseFloat(true);
				break;
			case '3':
				m_con << "Input right power:" << flush;
				config.right_power = m_usb.parseFloat(true);
				break;
			case 0x1B:
				return;
			}
		}
开发者ID:eastWillow,项目名称:self_balance_robot,代码行数:36,代码来源:main.cpp

示例5: activate

void UserSortState::activate() {
	Console* console = Console::getInstance();
	SortWrapper sortFascade;
	srand(time(NULL));

	bool exit = false;
	while (!exit) {
		string input = "";
		console->clear();
		console->put("[run] run a sort");
		console->put("[back] return to main screen");
		console->put("please enter your desired option: ");
		input = console->get();
		if (input == "back") {
			exit = true;
		}
		else if (input == "run") {
			int n = 0;
			console->put("how many elements would you like to sort: ");
			n = console->str_to_int(console->get());
			vector<int> vectorToSort;
			for (int i = 0; i < n; i++) {
				vectorToSort.push_back(rand() % RAND_MAX);
			}

			string ascendingInput = "";
			while (ascendingInput != "asc" && ascendingInput != "des") {
				console->put("[asc]ending or [des]cending: ");
				ascendingInput = console->get();
			}
			bool ascending = (ascendingInput == "asc");

			string typeInput = "";
			while (typeInput != "sel" && typeInput != "ins" && typeInput != "she" && typeInput != "qui" && typeInput != "mer" && typeInput != "hm" && typeInput != "hq") {
				console->put("which type of sort?");
				console->put("[sel]ection, [ins]ertion, [she]ll, [mer]ge, [qui]ck, [hm]-hybrid merge, or [hq]-hybrid quick: ");
				typeInput = console->get();
			}
			SortType sortType;
			if (typeInput == "sel") {
				sortType = SELECTION;
			}
			else if (typeInput == "ins") {
				sortType = INSERTION;
			}
			else if (typeInput == "she") {
				sortType = SHELL;
			}
			else if (typeInput == "mer") {
				sortType = MERGE;
			}
			else if (typeInput == "qui") {
				sortType = QUICK;
			}
			else if (typeInput == "hm") {
				sortType = HYBRID_MERGE;
			}
			else if (typeInput == "hq") {
				sortType = HYBRID_QUICK;
			}

			int hybridThreshold = 0;
			if (sortType == HYBRID_MERGE || sortType == HYBRID_QUICK) {
				console->put("how large do you want the hybrid threshold to be: ");
				hybridThreshold = console->str_to_int(console->get());
			}

			SortParams params;
			params.ascending = ascending;
			params.sortType = sortType;
			params.hybridThreshold = hybridThreshold;
			console->put("running sort, depending on how many elements you chose this may take some time");

			int memBefore = MemoryTracker::get_current_memory();
			int ticksBefore = clock();
			sortFascade.sort(vectorToSort, params);
			int ticksAfter = clock();
			int timeElapsed = (ticksAfter - ticksBefore)/(CLOCKS_PER_SEC/1000);
			int memUsed = MemoryTracker::get_saved_memory() - memBefore;

			bool success = true;
			for (vector<int>::iterator sortedIt = vectorToSort.begin(); sortedIt != vectorToSort.end(); sortedIt++) {
				vector<int>::iterator next = sortedIt + 1;
				if (next != vectorToSort.end()) {
					if (params.ascending) {
						if (*next < *sortedIt) {
							success = false;
							break;
						}
					}
					else {
						if (*next > *sortedIt) {
							success = false;
							break;
						}
					}
				}
			}

			string successString = (success) ? ("successfull") : ("not successfull");
//.........这里部分代码省略.........
开发者ID:barryWarnock,项目名称:SortHomework,代码行数:101,代码来源:UserSortState.cpp


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