mirror of
https://github.com/avem-labs/Avem.git
synced 2023-09-01 15:18:49 +08:00
Merge from <feature-CLI>
This commit is contained in:
commit
51354cadb8
28
libs/include/cli.h
Normal file
28
libs/include/cli.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CLI_H
|
||||
#define CLI_H
|
||||
|
||||
#include "uart.h"
|
||||
|
||||
#define BLOCK_WIDTH 2
|
||||
#define BLOCK_HEIGHT 8
|
||||
#define WIDTH 40
|
||||
#define HEIGHT 40
|
||||
#define CACHE_WIDTH WIDTH/BLOCK_WIDTH
|
||||
#define CACHE_HEIGHT HEIGHT/BLOCK_HEIGHT
|
||||
|
||||
// ---
|
||||
// |0 3|
|
||||
// |1 4|
|
||||
// |2 5|
|
||||
// |6 7|
|
||||
// ---
|
||||
// #define BRAILLE_OFFSET 0x2800
|
||||
// #define PIX(x) (1<<(x))
|
||||
// #define MAP(bit) BRAILLE_OFFSET + (bit)
|
||||
|
||||
void cli_fresh();
|
||||
void cli_drawBlock(unsigned char *uni);
|
||||
void cli_drawSpot(unsigned char x, unsigned char y);
|
||||
|
||||
|
||||
#endif
|
@ -1,18 +0,0 @@
|
||||
#ifndef DRAWILLE_H
|
||||
#define DRAWILLE_H
|
||||
|
||||
#include "uart.h"
|
||||
|
||||
// ---
|
||||
// |0 3|
|
||||
// |1 4|
|
||||
// |2 5|
|
||||
// |6 7|
|
||||
// ---
|
||||
// #define BRAILLE_OFFSET 0x2800
|
||||
#define PIX(x) (1<<(x))
|
||||
// #define MAP(bit) BRAILLE_OFFSET + (bit)
|
||||
|
||||
void draw(unsigned char uni);
|
||||
|
||||
#endif
|
@ -11,5 +11,6 @@ void uart_sendStr(char * cmd);
|
||||
uart_sendData(0x0D);\
|
||||
uart_sendData(0x0A);\
|
||||
}
|
||||
#define UART_CLEAR() {uart_sendStr("\033[H\033[J");}
|
||||
|
||||
#endif
|
||||
|
44
libs/source/cli.c
Normal file
44
libs/source/cli.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include "cli.h"
|
||||
#include "tty.h"
|
||||
// Command Line Interface
|
||||
|
||||
// 1110 xxxx : 10xx xxxx : 10xx xxxx - UTF-8
|
||||
// 0x2800 - braille unicode offset
|
||||
// 0010 1000 : 0000 0000
|
||||
|
||||
const char cli_bitmap[BLOCK_HEIGHT][BLOCK_WIDTH] = {
|
||||
{0x01, 0x08},
|
||||
{0x02, 0x10},
|
||||
{0x04, 0x20},
|
||||
{0x40, 0x80}
|
||||
};
|
||||
|
||||
unsigned char cli_cache[CACHE_HEIGHT][CACHE_WIDTH] = {};
|
||||
|
||||
|
||||
void cli_fresh() {
|
||||
for(unsigned char x = 0; x < CACHE_WIDTH; x++) {
|
||||
for(unsigned char y = 0; y < CACHE_HEIGHT; y++) {
|
||||
cli_drawBlock(&cli_cache[y][x]);
|
||||
}
|
||||
UART_CR();
|
||||
}
|
||||
}
|
||||
|
||||
void cli_drawBlock(unsigned char *uni) { //unicode to UTF-8
|
||||
uart_sendData(0xE2); //First byte must be 0xE2
|
||||
uart_sendData(0xA0 | ((*uni>>6) & 0b00000011));
|
||||
uart_sendData(0x80 | (*uni & 0b00111111));
|
||||
}
|
||||
|
||||
void cli_drawSpot(unsigned char x, unsigned char y) {
|
||||
if((x < WIDTH)&&(y < HEIGHT)) {
|
||||
// Get offset of block
|
||||
unsigned char x_offset = x % BLOCK_WIDTH;
|
||||
unsigned char y_offset = y % BLOCK_HEIGHT;
|
||||
// Get position of block
|
||||
x /= BLOCK_WIDTH;
|
||||
y /= BLOCK_HEIGHT;
|
||||
cli_cache[y][x] |= cli_bitmap[y_offset][x_offset];
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#include "drawille.h"
|
||||
|
||||
// 1110 xxxx : 10xx xxxx : 10xx xxxx - UTF-8
|
||||
// 0x2800 - braille unicode offset
|
||||
// 0010 1000 : 0000 0000
|
||||
|
||||
const char bitmap[2][4] = {
|
||||
{0x01, 0x08},
|
||||
{0x02, 0x10},
|
||||
{0x04, 0x20},
|
||||
{0x40, 0x80}
|
||||
}
|
||||
|
||||
void draw(unsigned char uni) { //unicode to UTF-8
|
||||
uart_sendData(0xE2); //First byte must be 0xE2
|
||||
uart_sendData(0xA0 | ((uni>>6) & 0b00000011));
|
||||
uart_sendData(0x80 | (uni & 0b00111111));
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
#include "wifi.h"
|
||||
#include "pid.h"
|
||||
#include "tty.h"
|
||||
#include "drawille.h"
|
||||
#include "cli.h"
|
||||
|
||||
#define Kp 100.0f //比例增益支配率(常量)
|
||||
#define Ki 0.002f //积分增益支配率
|
||||
@ -185,7 +185,11 @@ void uart_debugPID() {
|
||||
|
||||
void drawille_task() {
|
||||
while(1) {
|
||||
draw((PIX(0)|PIX(1)|PIX(2)|PIX(3)|PIX(4)|PIX(5)|PIX(6)|PIX(7)));
|
||||
UART_CLEAR();
|
||||
for(unsigned char x = 0; x< WIDTH; x++) {
|
||||
cli_drawSpot(x,x);
|
||||
}
|
||||
cli_fresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user