-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlab1-2
More file actions
25 lines (23 loc) · 792 Bytes
/
lab1-2
File metadata and controls
25 lines (23 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "stm32f769xx.h"
#include<stdlib.h>
int main(void)
{ Sys_Init();
char key;
system("COLOR 16");// 0Black/1Blue/2Green/3Aqua/4Red/5Purple/6Yellow/7White/8Gray/9Light Blue/ALight Green/BLight Aqua
//CLight Red/DLight Purple/ELight YellowFBright White
//or use ANSI escape codes
while(1)
{
printf("\e[1B\e[23Center <ESC> or the combination ^[ to halt\r\n");
key = getchar();
if (isprint(key)) // printable character ASCII 33-125, isprint() return 1 if its printable, 0 otherwise
printf("\e[H\e[5B\e[2KThe Keyboard character is \e[31m%c\e[33m. \r\n", key);
else if (key == 27 || key == 123)
return 1; // return 0 or return 1?
else
{
printf("\e[12;24r");
printf("\a\e[5mThe Keyboard character $%X is \e[4m'not printable'\e[0m.\r\n", key);
}
}
}