Skip to content

Commit

Permalink
Add color and sl example
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Han committed Aug 24, 2019
1 parent 68a186f commit 32d47b4
Show file tree
Hide file tree
Showing 10 changed files with 565 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf
.vscode/
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## VT-100

RT-Thread 的终端 msh 一直是一个非常受大家欢迎的组件,但是终端只能打印基本的字符未免有些单调了,于是我封装了 ANSI Escape 标准,这样就可以在 msh 里实现更加丰富的图形界面了,例如动画和游戏开发。

### 奔跑的小火车

![](./doc/sl.gif)

小火车还有不同类型

![](./doc/sl_c.png)

### 实时控制台

![](./doc/monitor.png)



### 绘制色条矩形

![](./doc/color.png)



## 联系方式

- 维护:Wu Han
- 主页:http://wuhanstudio.cc
- 邮箱:wuhanstudio@hust.edu.cn
Binary file added doc/color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/monitor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/sl.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/sl_c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions examples/vt_color.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* @Description: VT100 Color demo
* @Author: Wu Han
* @Date: 2019-08-24 21:02:52
* @LastEditTime: 2019-08-24 21:34:44
* @LastEditors: Please set LastEditors
*/

#include <rtthread.h>
#include <stdio.h>

#include "vt100.h"

void vt_color(int argc, char* argv[])
{
vt_hide_cursor();
vt_clear();

// 1. Corlor Bar
for (int i = 0; i < 8; i++)
{
if(i == 0)
{
vt_set_font_color(VT_F_WHITE);
}
else
{
vt_set_font_color(VT_F_BLACK + i - 1 );
}
vt_set_bg_color(VT_B_BLACK + i);
vt_draw_hline(i, 0, 80, ' ');
vt_draw_str_at(i, 31, "Put your text here");
}

// 2. Boxes
vt_set_font_color(VT_F_WHITE);
vt_set_bg_color(VT_B_BLACK);
for (int i = 0; i < 7; i++)
{
vt_draw_box(8 + i, 0, 16 - i * 2, 40 - i * 2, '-', '|', '+');
}

// 3. Logo
char rt_str[30];
vt_draw_str_at(14, 40, " \\ | /");
vt_draw_str_at(15, 40, "- RT - Thread Operating System\n");
sprintf(rt_str, " / | \\ %d.%d.%d build %s\n", RT_VERSION, RT_SUBVERSION, RT_REVISION, __DATE__);
vt_draw_str_at(16, 40, rt_str);
vt_draw_str_at(17, 40, " 2006 - 2019 Copyright by rt-thread team\n");

// 4. Fill box
for (int i = 0; i < 6; i++)
{
vt_set_bg_color(VT_B_RED + i);
vt_fill_box(9, 43 + i * 6, 4, 4, ' ');
}

for (int i = 5; i >= 0; i--)
{
vt_set_bg_color(VT_B_WHITE - i);
vt_fill_box(19, 43 + i * 6, 4, 4, ' ');
}

vt_set_bg_color(VT_B_BLACK);
vt_move_to(23, 0);
printf("\n");

vt_clear_attr();
vt_show_cursor();

}
MSH_CMD_EXPORT(vt_color, vt color demo)
Loading

0 comments on commit 32d47b4

Please sign in to comment.