Strona 1 z 1

Kolorowy terminal rs232 prosta bibloteka

: czwartek 19 sty 2017, 06:03
autor: foreste
Witam
mam okazje zaprezentować bibliotekę kolorowego terminala rs232 dla mbed.
Biblioteka uzupełnia działanie w mbed Serial w opcje takie jak kolor terminala , kolor czcionki czy czyszczenie ekranu z zawartości

biblioteka

Kod: Zaznacz cały

#ifndef rs232_vt100_h
#define rs232_vt100_h

string clear             = "\x1b[2j";
string home              = "\x1b[H";
// font_ color
string font_black          = "\x1b[30m";
string font_red             = "\x1b[31m";
string font_green          = "\x1b[32m";
string font_yellow          = "\x1b[33m";
string font_blue          = "\x1b[34m";
string font_magenta          = "\x1b[35m";
string font_cyan          = "\x1b[36m";
string font_white          = "\x1b[37m";
string font_default          = "\x1b[39m";

//color backround

string background_black       = "\x1b[40m";
string background_red      = "\x1b[41m";
string background_green      = "\x1b[42m";
string background_yellow      = "\x1b[43m";
string background_blue      = "\x1b[44m";
string background_magenta   = "\x1b[45m";
string background_cyan      = "\x1b[46m";
string background_white      = "\x1b[47m";
string background_default      = "\x1b[49m";
#endif


Przykład użycia biblioteki


Kod: Zaznacz cały

#include "mbed.h"
#include "rs232_vt100.h"
#include <string>
Serial pc(USBTX, USBRX);
int main()
{

    pc.printf("%s", font_blue);
    wait(1);
    pc.printf("%s", background_red);
    wait(1);
    while(1) {

        pc.printf("Hello World !\n");
        wait(2);
    }
}

Re: Kolorowy terminal rs232 prosta bibloteka

: czwartek 19 sty 2017, 06:58
autor: SuperGość
Przykład, ze tak powiem z "użycia" i uzyskanego efektu pokażesz?

Re: Kolorowy terminal rs232 prosta bibloteka

: czwartek 19 sty 2017, 13:59
autor: Antystatyczny
W zasadzie można by upchnąć te stringi sterujące do flasha.