Skip to content

Commit eaa47c8

Browse files
committed
0.1.4 ANSI
1 parent b7611de commit eaa47c8

File tree

15 files changed

+181
-37
lines changed

15 files changed

+181
-37
lines changed

libraries/ANSI/.arduino-ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ compile:
22
# Choosing to run compilation tests on 2 different Arduino platforms
33
platforms:
44
- uno
5-
- leonardo
6-
- due
7-
- zero
5+
# - due
6+
# - zero
7+
# - leonardo
8+
- m4
9+
- esp32
10+
# - esp8266
11+
# - mega2560

libraries/ANSI/.github/workflows/arduino_test_runner.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ name: Arduino CI
44
on: [push, pull_request]
55

66
jobs:
7-
arduino_ci:
7+
runTest:
88
runs-on: ubuntu-latest
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: Arduino-CI/action@master
13-
# Arduino-CI/[email protected]
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
- run: |
16+
gem install arduino_ci
17+
arduino_ci.rb

libraries/ANSI/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Rob Tillaart
3+
Copyright (c) 2020-2021 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libraries/ANSI/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
[![Arduino CI](https://github.com/RobTillaart/ANSI/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![Arduino-lint](https://github.com/RobTillaart/ANSI/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/ANSI/actions/workflows/arduino-lint.yml)
4+
[![JSON check](https://github.com/RobTillaart/ANSI/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/ANSI/actions/workflows/jsoncheck.yml)
35
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/ANSI/blob/master/LICENSE)
46
[![GitHub release](https://img.shields.io/github/release/RobTillaart/ANSI.svg?maxAge=3600)](https://github.com/RobTillaart/ANSI/releases)
57

@@ -11,25 +13,23 @@ Arduino library with basic ANSI display codes for terminal applications.
1113

1214
# Description
1315

14-
TODO
15-
16-
Ansi codes are special codes that are send to a terminal e.g. VT100 to add
16+
ANSI codes are special codes that are send to a terminal e.g. VT100 to add
1717
attributes to displayed characters.
18-
Typical examples are bold, blink or color.
18+
Typical examples are bold, blink or colour.
1919
Also known as escape codes the set of codes is large, however not
2020
all terminal types do support all codes.
2121

22-
Sending these ANSI codes to a simple terminal like the one in the Arduino
23-
IDE might result in garbage. SO use with care.
22+
Sending these ANSI codes to a simple ASCII only terminal like the one in the Arduino
23+
IDE might result in garbage. So use with care.
2424

2525

2626
## Terminals tested
2727

2828
Tests are done with
29-
- Teraterm 4.102 (vt100 mode)
29+
- TeraTerm 4.102 + 4.106 (VT100, VT202, VT525 mode)
3030
- Putty 0.71
3131

32-
Other terminal programma's exist so please let me know if yours is working too.
32+
Other terminal program's exist so please let me know if yours is working too.
3333
If not, please open an issue.
3434

3535
# Operation

libraries/ANSI/ansi.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
//
22
// FILE: ansi.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.3
4+
// VERSION: 0.1.4
55
// PURPOSE: Arduino library to send ANSI escape sequences
66
// DATE: 2020-04-28
77
// URL: https://github.com/RobTillaart/ANSI
88
//
9-
// 0.1.0 2020-04-28 initial version
10-
// 0.1.1 2020-05-27 update library.json
11-
// 0.1.2 2020-07-08 added clearLine + color support (thanks airbornemint)
12-
// 0.1.3 2020-12-11 added arduino-ci + unit test (minimal)
9+
// 0.1.0 2020-04-28 initial version
10+
// 0.1.1 2020-05-27 update library.json
11+
// 0.1.2 2020-07-08 added clearLine + color support (thanks airbornemint)
12+
// 0.1.3 2020-12-11 added Arduino-CI + unit test (minimal)
13+
// 0.1.4 2020-10-18 updated Arduino-CI (esp32) + examples
14+
1315

1416
#include "ansi.h"
1517

18+
1619
ANSI::ANSI(Stream * stream)
1720
{
1821
_stream = stream;
1922
}
2023

2124
int ANSI::available()
2225
{
23-
return _stream->available();
26+
return _stream->available();
2427
}
2528

2629
int ANSI::read()
2730
{
28-
return _stream->read();
31+
return _stream->read();
2932
}
3033

3134
int ANSI::peek()
3235
{
33-
return _stream->peek();
36+
return _stream->peek();
3437
}
3538

3639
void ANSI::clearScreen()

libraries/ANSI/ansi.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
//
33
// FILE: ansi.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.1.3
5+
// VERSION: 0.1.4
66
// PURPOSE: Arduino library to send ANSI escape sequences
77
// DATE: 2020-04-28
88
// URL: https://github.com/RobTillaart/ANSI
99
//
1010

11+
1112
#include "Arduino.h"
1213

14+
#define ANSI_LIB_VERSION (F("0.1.4"))
15+
16+
1317
class ANSI : public Stream
1418
{
1519
public:
@@ -21,14 +25,16 @@ class ANSI : public Stream
2125
int peek();
2226
void flush() { return; }; // placeholder to keep CI happy
2327

28+
2429
// CHAR MODES
2530
void normal() { print("\033[0m"); };
2631
void bold() { print("\033[1m"); };
2732
void low() { print("\033[2m"); };
2833
void underline() { print("\033[4m"); };
2934
void blink() { print("\033[5m"); };
3035
void reverse() { print("\033[7m"); };
31-
36+
37+
3238
// COLOR
3339
enum {
3440
black = 0,
@@ -62,7 +68,8 @@ class ANSI : public Stream
6268
// Convert RGB color to ANSI color in 4-bit colorspace
6369
// Pass in a RGB level from 0 (dark) to 255 (light)
6470
uint8_t rgb2color(uint8_t r, uint8_t g, uint8_t b);
65-
71+
72+
6673
// POSITIONING
6774
enum {
6875
toEnd = 0,
@@ -74,22 +81,23 @@ class ANSI : public Stream
7481
void clearLine(uint8_t clear = toEnd);
7582

7683
void home() { print("\033[H"); };
77-
84+
7885
void gotoXY(uint8_t x, uint8_t y);
7986
void cursorUp(uint8_t x);
8087
void cursorDown(uint8_t x);
8188
void cursorForward(uint8_t x);
8289
void cursorBack(uint8_t x);
8390

91+
8492
private:
8593
size_t write(uint8_t c);
8694
void color4(uint8_t base, uint8_t color);
8795
void color4_code(uint8_t base, uint8_t color);
8896
void colors4(uint8_t fgcolor, uint8_t bgcolor);
8997
void color8(uint8_t base, uint8_t color);
9098

91-
Stream * _stream;
92-
99+
Stream * _stream;
100+
93101
};
94102

95103
// -- END OF FILE --

libraries/ANSI/examples/ansiDemo01/ansiDemo01.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// (c) : MIT
99
//
1010

11+
1112
#include "ansi.h"
1213

1314
ANSI ansi(&Serial);
@@ -87,10 +88,13 @@ void setup()
8788

8889
delay(1000);
8990
ansi.normal();
91+
92+
ansi.println("\ndone...");
9093
}
9194

95+
9296
void loop()
9397
{
9498
}
9599

96-
// -- END OF FILE --
100+
// -- END OF FILE --

libraries/ANSI/examples/ansiDemo02/ansiDemo02.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// (c) : MIT
99
//
1010

11+
1112
#include "ansi.h"
1213

1314
ANSI ansi(&Serial);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//
2+
// FILE: ansi_IO.ino
3+
// AUTHOR: Rob Tillaart
4+
// VERSION: 0.1.0
5+
// PURPOSE: demo
6+
// DATE: 2021-10-18
7+
// URL: https://github.com/RobTillaart/ANSI
8+
// (c) : MIT
9+
//
10+
11+
12+
#include "ansi.h"
13+
14+
ANSI ansi(&Serial);
15+
16+
String user = "";
17+
String password = "";
18+
19+
void setup()
20+
{
21+
Serial.begin(115200);
22+
23+
ansi.clearScreen();
24+
25+
ansi.print("ANSI_LIB_VERSION: ");
26+
ansi.print(ANSI_LIB_VERSION);
27+
28+
ansi.gotoXY(4, 2);
29+
ansi.print("Username: ");
30+
char c = '\0';
31+
while (c != '\r')
32+
{
33+
if (ansi.available() )
34+
{
35+
c = ansi.read();
36+
if (c != '\r')
37+
{
38+
user += c;
39+
ansi.print(c);
40+
}
41+
}
42+
}
43+
44+
ansi.gotoXY(5, 2);
45+
ansi.print("Password: ");
46+
c = '\0';
47+
while (c != '\r')
48+
{
49+
if (ansi.available() )
50+
{
51+
c = ansi.read();
52+
if (c != '\r')
53+
{
54+
password += c;
55+
ansi.print('.');
56+
}
57+
}
58+
}
59+
60+
ansi.gotoXY(10, 2);
61+
ansi.print(user);
62+
ansi.print("\t\t");
63+
ansi.print(password);
64+
65+
ansi.println("\ndone...");
66+
}
67+
68+
69+
void loop()
70+
{
71+
}
72+
73+
// -- END OF FILE --
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// FILE: ansi_char_test.ino
3+
// AUTHOR: Rob Tillaart
4+
// VERSION: 0.1.0
5+
// PURPOSE: brute force char test
6+
// DATE: 2021-10-18
7+
// URL: https://github.com/RobTillaart/ANSI
8+
// (c) : MIT
9+
//
10+
11+
12+
#include "ansi.h"
13+
14+
ANSI ansi(&Serial);
15+
16+
17+
void setup()
18+
{
19+
Serial.begin(115200);
20+
21+
ansi.clearScreen();
22+
23+
for (int i = 0; i < 255; i++)
24+
{
25+
ansi.print((char)i);
26+
// if (isprint(i)) ansi.print((char)i);
27+
// else ansi.print('.');
28+
if (i % 16 == 0) ansi.println();
29+
}
30+
31+
ansi.println("\ndone...");
32+
}
33+
34+
35+
void loop()
36+
{
37+
}
38+
39+
// -- END OF FILE --

0 commit comments

Comments
 (0)