📄 console.c
字号:
/******************************************************************************************
Console.c (v1.0)
-------------------------------------------------------------------------------------
This code is from the book:
"Embedded Internet: TCP/IP Basics, Implementation and Applications" by Sergio Scaglia
[Pearson Education, 2006 - ISBN: 0-32-130638-4]
This code is copyright (c) 2006 by Sergio Scaglia, and it may only be used for educational
purposes. For commercial use, please contact me at sscaglia@intramarket.com.ar
For more information and updates, please visit www.embeddedinternet.org
******************************************************************************************/
#include "console.h"
#include "uart.h"
#include "app.h"
#include "ADC.h"
#include "Led.h"
#include <stdio.h>
#include <string.h>
void console_process(void) {
int c;
c=getchar(); // Scan the console's keyboard
if (c != -1) {
if (c == 'h') { // show the command help
printf("Available commands:\r\n\r\n");
printf("h - Show this help\r\n");
printf("----------------------------------------------------\r\n");
printf("s - Start the Application Process Cycle\r\n");
printf("p - Show the Application Process Parameters\r\n");
printf("c - Set/Clear the Cycle variable (cycle continuously)\r\n");
printf("l - Enable/Disable the Board Activity Led\r\n");
printf("\r\n");
printf("Enter a command:>\r\n");
}else if (c == 's') {
state = STARTED;
printf("App Process Cycle Started!\r\n");
}else if (c == 'p') {
printf("State %d V1: %d Heater: %d V2: %d Liquid: %d Temp: %d ADC: %d Cycle: %d\r\n",
state, valve1, heater, valve2, liquid, temp, ADC_Read(), cycle);
}else if (c == 'c') {
if (cycle) {
cycle = 0;
printf("Cycle variable cleared\r\n");
}else {
cycle = 1;
printf("Cycle variable set\r\n");
}
}else if (c == 'l') {
if (led_enable) {
led_enable = 0;
printf("Led disabled\r\n");
}else {
led_enable = 1;
printf("Led enabled\r\n");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -