0.1.7 ANSI

This commit is contained in:
rob tillaart 2022-10-29 12:44:27 +02:00
parent 6bd0bef1c0
commit 3ced6ab10e
7 changed files with 56 additions and 54 deletions

View File

@ -1,3 +1,18 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
@ -7,5 +22,7 @@ compile:
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560
- esp8266
# - mega2560
- rpipico

View File

@ -1,4 +1,4 @@
# Change Log bitHelpers
# Change Log ANSI
All notable changes to this project will be documented in this file.
@ -6,57 +6,39 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.6] - 2022-04-11
## [0.1.7] - 2022-110-28
- add RP2040 to build-CI
- minor edits
- start simplifying changelog
- minor change unit test
### Added
## [0.1.6] - 2022-04-11
- add CHANGELOG.md
- add **int deviceType()**
### Changed
- edit README.md
### Fixed
## [0.1.5] - 2021-12-13
### Added
- add write(array, length)
### Changed
- update library.json, license, minor edits
## [0.1.4] - 2021-10-18
### Changed
- update build-CI (e.g. ESP32)
- update examples
## [0.1.3] - 2020-12-11
### Added
- add Arduino-CI
- add unit test (minimal)
## [0.1.2] - 2020-07-08
### Added
- add clearLine
= add color support (thanks to airbornemint)
## [0.1.1] - 2020-05-27
### Changed
- update library.json
## [0.1.0] - 2020-04-28
### Added
- initial release

View File

@ -1,7 +1,7 @@
//
// FILE: ansi.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.6
// VERSION: 0.1.7
// PURPOSE: Arduino library to send ANSI escape sequences
// DATE: 2020-04-28
// URL: https://github.com/RobTillaart/ANSI
@ -50,9 +50,9 @@ void ANSI::clearLine(uint8_t clear)
}
// ANSI has three different color spaces: 4-bit color, 8-bit color, and 24-bit color
// The are rendered with SGR 30-37,90-97/40-47,100-107, SGR 38;5/48;5, and SGR 38;2/48;2, respectively
// The 4-bit color space is the most widely compatible and the most compactly transmitted
// ANSI has three different color spaces: 4-bit color, 8-bit color, and 24-bit color
// These are rendered with SGR 30-37,90-97/40-47,100-107, SGR 38;5/48;5, and SGR 38;2/48;2, respectively
// The 4-bit color space is the most widely compatible and the most compactly transmitted
enum {
fg_normal = 30,
bg_normal = 40,
@ -147,7 +147,7 @@ void ANSI::cursorBack(uint8_t x)
int ANSI::deviceType(uint32_t timeout)
{
int type = -1; // -1 = unknown
int type = -1; // -1 = unknown
print("\033[0c");
uint32_t start = millis();
@ -174,7 +174,7 @@ int ANSI::deviceType(uint32_t timeout)
//
size_t ANSI::write(uint8_t c)
{
// TODO add line buffer? - interference with write(array, length) !?
// TODO add line buffer? - interference with write(array, length) !?
return _stream->write(c);
}
@ -221,5 +221,6 @@ void ANSI::color8(uint8_t base, uint8_t color) {
print("m");
}
// -- END OF FILE --

View File

@ -2,7 +2,7 @@
//
// FILE: ansi.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.6
// VERSION: 0.1.7
// PURPOSE: Arduino library to send ANSI escape sequences
// DATE: 2020-04-28
// URL: https://github.com/RobTillaart/ANSI
@ -11,7 +11,7 @@
#include "Arduino.h"
#define ANSI_LIB_VERSION (F("0.1.6"))
#define ANSI_LIB_VERSION (F("0.1.7"))
class ANSI : public Stream
@ -23,7 +23,7 @@ public:
int available();
int read();
int peek();
void flush() { return; }; // placeholder to keep CI happy
void flush() { return; }; // placeholder to keep CI happy
// CHAR MODES
@ -45,28 +45,29 @@ public:
magenta,
cyan,
white,
bright, // Add this to any of the previous 8 to get a bright color
bright, // Add this to any of the previous 8 to get a bright color
};
// foreground, background, and color accept one of the following colors:
// * color name from above: ANSI::red
// * bright color name from above: ANSI::red + ANSI::bright
// * gray color: ANSI::gray2color(gray)
// * RGB color: ANSI::rgb2color(r, g, b)
// foreground, background, and color accept one of the following colors:
// * color name from above: ANSI::red
// * bright color name from above: ANSI::red + ANSI::bright
// * gray color: ANSI::gray2color(gray)
// * RGB color: ANSI::rgb2color(r, g, b)
// Set foreground color
// Set foreground color
void foreground(uint8_t fgcolor);
// Set background color
// Set background color
void background(uint8_t bgcolor);
// Set foreground and background color (for named colors, this is 25% faster than setting one then the other)
// Set foreground and background color
// (for named colors, this is 25% faster than setting one then the other)
void color(uint8_t fgcolor, uint8_t bgcolor);
// Convert gray to ANSI 24-level gray in 4-bit colorspace
// Pass in a gray level from 0 (black) to 255 (white)
// Convert gray to ANSI 24-level gray in 4-bit colorspace
// Pass in a gray level from 0 (black) to 255 (white)
uint8_t gray2color(uint8_t gray) { return 232 + uint16_t(gray) * 24 / 256; }
uint8_t grey2color(uint8_t grey) { return this->gray2color(grey); }
// Convert RGB color to ANSI color in 4-bit colorspace
// Pass in a RGB level from 0 (dark) to 255 (light)
// Convert RGB color to ANSI color in 4-bit colorspace
// Pass in a RGB level from 0 (dark) to 255 (light)
uint8_t rgb2color(uint8_t r, uint8_t g, uint8_t b);
@ -136,4 +137,6 @@ private:
};
// -- END OF FILE --

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ANSI.git"
},
"version": "0.1.6",
"version": "0.1.7",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=ANSI
version=0.1.6
version=0.1.7
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library to send ANSI escape sequences

View File

@ -27,6 +27,7 @@
unittest_setup()
{
fprintf(stderr, "ANSI_LIB_VERSION: %s\n", (char *) ANSI_LIB_VERSION);
}
@ -38,7 +39,6 @@ unittest_teardown()
unittest(test_constructor)
{
ANSI ansi(&Serial);
fprintf(stderr, "ANSI_LIB_VERSION: %s\n", (char *) ANSI_LIB_VERSION);
assertEqual(12, ansi.println("1234567890") );
}
@ -47,7 +47,6 @@ unittest(test_constructor)
unittest(test_gray2color)
{
ANSI ansi(&Serial);
fprintf(stderr, "ANSI_LIB_VERSION: %s\n", (char *) ANSI_LIB_VERSION);
for (int gray = 0; gray < 255; gray += 31)
{