From e0928dab86af9feeaa91448093b3650766c3a013 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:47:56 +0100 Subject: [PATCH 01/10] Bump geekyeggo/delete-artifact from 4 to 5 (#43) Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 4 to 5. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Changelog](https://github.com/GeekyEggo/delete-artifact/blob/main/CHANGELOG.md) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 47ac50a..53a9f54 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -114,7 +114,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v4 + uses: geekyeggo/delete-artifact@v5 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From bdfd5040817575e5f46399be34b4ac3616443aa6 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 28 May 2024 02:26:51 -0700 Subject: [PATCH 02/10] Remove superfluous blank lines from documentation Previously, the documentation contained a large number of unnecessary blank lines. Since these serve no purpose and give the source content an unprofessional and sloppy appearance, they are removed. --- docs/api.md | 137 ---------------------------------------------------- 1 file changed, 137 deletions(-) diff --git a/docs/api.md b/docs/api.md index a870920..6940ae4 100644 --- a/docs/api.md +++ b/docs/api.md @@ -6,7 +6,6 @@ #### Description - Initializes the graphics device. #### Syntax @@ -15,7 +14,6 @@ Initializes the graphics device. YourScreen.begin() ``` - #### Parameters None @@ -33,8 +31,6 @@ if (!YourScreen.begin() { } ``` - - ### `end()` #### Description @@ -45,16 +41,12 @@ Stops the graphics device. ``` YourScreen.end() - ``` - #### Parameters - None - #### Returns Nothing @@ -65,26 +57,20 @@ Nothing YourScreen.end(); ``` - - ### `width()` #### Description - Returns the pixel width of the graphics device. #### Syntax ``` YourScreen.width() - ``` - #### Parameters - None #### Returns @@ -97,25 +83,20 @@ Returns the pixel width of the graphics device. int w = YourScreen.width(); ``` - ### `height()` #### Description - Returns the pixel height of the graphics device. #### Syntax ``` YourScreen.height() - ``` - #### Parameters - None #### Returns @@ -128,62 +109,48 @@ Returns the pixel height of the graphics device. int h = YourScreen.height(); ``` - ### `beginDraw()` #### Description - Begins a drawing operation. #### Syntax ``` YourScreen.beginDraw() - ``` - #### Parameters - None - #### Returns Nothing #### Example - YourScreen.beginDraw(); YourScreen.set(0, 0, 255, 0, 0); YourScreen.endDraw(); - - ### `endDraw()` #### Description - Ends a drawing operation, any drawing operations after beginDraw() is called will be displayed to the screen. #### Syntax ``` YourScreen.endDraw() - ``` - #### Parameters - None - #### Returns Nothing @@ -196,12 +163,10 @@ YourScreen.set(0, 0, 255, 0, 0); YourScreen.endDraw(); ``` - ### `background()` #### Description - Set the background color of drawing operations. Used when calling clear() or drawing text. #### Syntax @@ -209,13 +174,10 @@ Set the background color of drawing operations. Used when calling clear() or dra ``` YourScreen.background(r, g, b) YourScreen.background(color) - ``` - #### Parameters - - r: red color value (0 - 255) - g: green color value (0 - 255) - b: blue color value (0 - 255) @@ -234,28 +196,22 @@ YourScreen.clear(); YourScreen.endDraw(); ``` - ### `clear()` #### Description - Set clear the screen contents, uses the background colour set in background(). #### Syntax ``` YourScreen.clear() - ``` - #### Parameters - None - #### Returns Nothing @@ -269,13 +225,10 @@ YourScreen.clear(); YourScreen.endDraw(); ``` - - ### `fill()` #### Description - Set the fill color of drawing operations. #### Syntax @@ -283,13 +236,10 @@ Set the fill color of drawing operations. ``` YourScreen.fill(r, g, b) YourScreen.fill(color) - ``` - #### Parameters - - r: red color value (0 - 255) - g: green color value (0 - 255) - b: blue color value (0 - 255) @@ -310,28 +260,22 @@ YourScreen.rect(0, 0, YourScreen.width(), YourScreen.height()); YourScreen.endDraw(); ``` - ### `noFill()` #### Description - Clears the fill color of drawing operations. #### Syntax ``` YourScreen.noFill() - ``` - #### Parameters - None - #### Returns Nothing @@ -347,12 +291,10 @@ YourScreen.rect(0, 0, YourScreen.width(), YourScreen.height()); YourScreen.endDraw(); ``` - ### `stroke()` #### Description - Set the stroke color of drawing operations. #### Syntax @@ -360,13 +302,10 @@ Set the stroke color of drawing operations. ``` YourScreen.stroke(r, g, b) YourScreen.stroke(color) - ``` - #### Parameters - - r: red color value (0 - 255) - g: green color value (0 - 255) - b: blue color value (0 - 255) @@ -387,29 +326,22 @@ YourScreen.rect(0, 0, YourScreen.width(), YourScreen.height()); YourScreen.endDraw(); ``` - - ### `noStroke()` #### Description - Clears the stroke color of drawing operations. #### Syntax ``` YourScreen.noStroke() - ``` - #### Parameters - None - #### Returns Nothing @@ -425,25 +357,20 @@ YourScreen.rect(0, 0, YourScreen.width(), YourScreen.height()); YourScreen.endDraw(); ``` - ### `line()` #### Description - Stroke a line, uses the stroke color set in stroke(). #### Syntax ``` YourScreen.line(x1, y1, x2, y2) - ``` - #### Parameters - - x1: x position of the starting point of the line - y1: y position of the starting point of the line - x2: x position of the end point of the line @@ -463,25 +390,20 @@ YourScreen.line(0, 0, YourScreen.width() - 1, YourScreen.height() - 1); YourScreen.endDraw(); ``` - ### `point()` #### Description - Stroke a point, uses the stroke color set in stroke(). #### Syntax ``` YourScreen.point(x, y) - ``` - #### Parameters - x: x position of the point y: y position of the point @@ -499,25 +421,20 @@ YourScreen.point(1, 1); YourScreen.endDraw(); ``` - ### `rect()` #### Description - Stroke and fill a rectangle, uses the stroke color set in stroke() and the fill color set in fill(). #### Syntax ``` YourScreen.rect(x, y, width, height) - ``` - #### Parameters - - x: x position of the rectangle - y: y position of the rectangle - width: width of the rectangle @@ -538,25 +455,20 @@ YourScreen.rect(0, 0, YourScreen.width(), YourScreen.height()); YourScreen.endDraw(); ``` - ### `circle()` #### Description - Stroke and fill a circle, uses the stroke color set in stroke() and the fill color set in fill(). #### Syntax ``` YourScreen.circle(x, y, diameter) - ``` - #### Parameters - - x: x center position of the circle - y: y center position of the circle - diameter: diameter of the circle @@ -576,25 +488,20 @@ YourScreen.circle(YourScreen.width()/2, YourScreen.height()/2, YourScreen.height YourScreen.endDraw(); ``` - ### `ellipse()` #### Description - Stroke and fill an ellipse, uses the stroke color set in stroke() and the fill color set in fill(). #### Syntax ``` YourScreen.ellipse(x, y, width, height) - ``` - #### Parameters - - x: x center position of the ellipse - y: y center position of the ellipse - width: width of the ellipse @@ -615,12 +522,10 @@ YourScreen.ellipse(YourScreen.width()/2, YourScreen.height()/2, YourScreen.width YourScreen.endDraw(); ``` - ### `text()` #### Description - Draw some text, uses the stroke color set in stroke() and the background color set in background(). #### Syntax @@ -628,13 +533,10 @@ Draw some text, uses the stroke color set in stroke() and the background color s ``` YourScreen.text(string) YourScreen.text(string, x, y) - ``` - #### Parameters - - string: string to draw - x: x position for the start of the text - y: y position for the start of the text @@ -653,28 +555,22 @@ YourScreen.text("abc", 0, 1); YourScreen.endDraw(); ``` - ### `textFont()` #### Description - Sets the font uses for text. The library current has the Font_4x6 and Font_5x7 built in. #### Syntax ``` YourScreen.textFont(font) - ``` - #### Parameters - font: font to set - #### Returns Nothing @@ -690,12 +586,10 @@ YourScreen.text("abc", 0, 1); YourScreen.endDraw(); ``` - ### `textFontWidth()` #### Description - Returns the width, in pixels, of the current font. #### Syntax @@ -705,13 +599,10 @@ YourScreen.textFontWidth() ``` - #### Parameters - None - #### Returns Nothing @@ -722,28 +613,22 @@ Nothing int w = YourScreen.textFontWidth(); ``` - ### `textFontHeight()` #### Description - Returns the height, in pixels, of the current font. #### Syntax ``` YourScreen.textFontHeight() - ``` - #### Parameters - None - #### Returns Nothing @@ -754,12 +639,10 @@ Nothing int h = YourScreen.textFontHeight(); ``` - ### `set()` #### Description - Set a pixel’s color value. #### Syntax @@ -767,13 +650,10 @@ Set a pixel’s color value. ``` YourScreen.set(x, y, r, g, b) YourScreen.set(x, y, color) - ``` - #### Parameters - x: x position of the pixel y: y position of the pixel r: red color value (0 - 255) @@ -793,12 +673,10 @@ YourScreen.point(1, 1, 0, 255, 0); YourScreen.endDraw(); ``` - ### `beginText()` #### Description - Start the process of displaying and optionally scrolling text. The Print interface can be used to set the text. #### Syntax @@ -807,13 +685,10 @@ Start the process of displaying and optionally scrolling text. The Print interfa YourScreen.beginText() YourScreen.beginText(x, y, r, g, b) YourScreen.beginText(x, y, color) - ``` - #### Parameters - x: x position of the text y: y position of the text r: red color value (0 - 255) @@ -833,12 +708,10 @@ YourScreen.print("Hi"); YourScreen.endText(); ``` - ### `endText()` #### Description - End the process of displaying and optionally scrolling text. #### Syntax @@ -846,13 +719,10 @@ End the process of displaying and optionally scrolling text. ``` YourScreen.endText() YourScreen.endText(scrollDirection) - ``` - #### Parameters - scrollDirection: (optional) the direction to scroll, defaults to NO_SCROLL if not provided. Valid options are NO_SCROLL, SCROLL_LEFT, SCROLL_RIGHT, SCROLL_UP, SCROLL_DOWN #### Returns @@ -867,28 +737,22 @@ YourScreen.print("Hi"); YourScreen.endText(); ``` - ### `textScrollSpeed()` #### Description - Sets the text scrolling speed, the speed controls the delay in milliseconds between scrolling each pixel. #### Syntax ``` YourScreen.textScrollSpeed(speed) - ``` - #### Parameters - speed: scroll speed - #### Returns Nothing @@ -901,4 +765,3 @@ YourScreen.textScrollSpeed(500); YourScreen.print("Hello There!"); YourScreen.endText(true); ``` - From df7a773e51f43ff8c39929b0e268cfc60c46a8f7 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 28 May 2024 02:28:38 -0700 Subject: [PATCH 03/10] Correct syntax errors in documentation code snippet --- docs/api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 6940ae4..f4d9b59 100644 --- a/docs/api.md +++ b/docs/api.md @@ -25,8 +25,8 @@ None #### Example ``` -if (!YourScreen.begin() { - Serial.println(“Failed to initialize the display!”); +if (!YourScreen.begin()) { + Serial.println("Failed to initialize the display!"); while (1); } ``` From 96b58bb28fc38e68e6c2cde76687642e82c20269 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 28 May 2024 02:35:13 -0700 Subject: [PATCH 04/10] Add missing markup to API documentation --- docs/api.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api.md b/docs/api.md index f4d9b59..cc2e698 100644 --- a/docs/api.md +++ b/docs/api.md @@ -131,9 +131,11 @@ Nothing #### Example +``` YourScreen.beginDraw(); YourScreen.set(0, 0, 255, 0, 0); YourScreen.endDraw(); +``` ### `endDraw()` From a3e7f1eb86f15b1e6aa090a8ee2c15e2305d8cdf Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 28 May 2024 02:35:45 -0700 Subject: [PATCH 05/10] Fix typos in documentation --- README.adoc | 2 +- docs/api.md | 4 ++-- docs/readme.md | 2 +- extras/generate_font.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.adoc b/README.adoc index eeee79b..83baac9 100644 --- a/README.adoc +++ b/README.adoc @@ -32,6 +32,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA == How-to generate bitmaps from the fonts == [source,bash] ---- -cd extra +cd extras ./generate_font.py 5x7.bdf Font_5x7.c Font_5x7 ---- diff --git a/docs/api.md b/docs/api.md index cc2e698..db063a3 100644 --- a/docs/api.md +++ b/docs/api.md @@ -202,7 +202,7 @@ YourScreen.endDraw(); #### Description -Set clear the screen contents, uses the background colour set in background(). +Clear the screen contents, uses the background colour set in background(). #### Syntax @@ -561,7 +561,7 @@ YourScreen.endDraw(); #### Description -Sets the font uses for text. The library current has the Font_4x6 and Font_5x7 built in. +Sets the font used for text. The library current has the Font_4x6 and Font_5x7 built in. #### Syntax diff --git a/docs/readme.md b/docs/readme.md index 92ff8db..4260bca 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -1,6 +1,6 @@ # Arduino Graphics Library -This is a library that allows you to draw and write on screens with graphical primitives; it requires a specific hardware interfacce library to drive the screen you are using, therefore every screen type should have its own hardware specific library. +This is a library that allows you to draw and write on screens with graphical primitives; it requires a specific hardware interface library to drive the screen you are using, therefore every screen type should have its own hardware specific library. To use this library diff --git a/extras/generate_font.py b/extras/generate_font.py index 016f634..48efb84 100755 --- a/extras/generate_font.py +++ b/extras/generate_font.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# This file is part of the MKRRGBMatrix library. +# This file is part of the ArduinoGraphics library. # Copyright (c) 2018 Arduino SA. All rights reserved. # # This library is free software; you can redistribute it and/or From 0ea3666b05e5573ad9ae8148050dc62b560716eb Mon Sep 17 00:00:00 2001 From: kurte Date: Sun, 11 Aug 2024 16:58:55 -0700 Subject: [PATCH 06/10] Allow the fixed fonts to be scaled up. On larger displays, the two built in fonts are almost invisible. One possible solution is to supply some larger fonts. Another approach is to do, like several TFT display drivers do and allow you to scale the system fixed fonts up to a larger size. Decided this was the easiest approach, and did a quick implementation of it. Like the Adafruit displays, I allowed you to set different scale factors for X and Y. I added a scaledBitmap function which is a modified version of the current bitmap function. I also changed all of the text functions to use it. I left the unscalled version of the API, although I have it simply call the scaled version with scales 1 and 1, as since these methods are virtual, potentially some other subclasses might use and/or implement their own version. Updated the textFontWidth and textFontHeight to multiply the height * the scale as the one example sketch here needs it. I also updated the sketch to scale the canvas to take the font size into account. This appears to work with the changes and I have not used or tested the scroll code. Its sizing should be updated teh same way the test sketch was with the changes with the textFontWidth and textFontHeight changes Update api.md Forgot to update the AsciiDraw example sketch Code Review requested changes _textsize_x -> _textSizeX (ditto for y) setTextSize() -> textSize() scaledBitmap -> bitmap with the extra parameters with defaults --- docs/api.md | 35 ++++++++++++++++++++ examples/ASCIIDraw/ASCIIDraw.ino | 6 ++-- src/ArduinoGraphics.cpp | 57 ++++++++++++++++++++------------ src/ArduinoGraphics.h | 7 +++- 4 files changed, 81 insertions(+), 24 deletions(-) diff --git a/docs/api.md b/docs/api.md index db063a3..8827301 100644 --- a/docs/api.md +++ b/docs/api.md @@ -641,6 +641,41 @@ Nothing int h = YourScreen.textFontHeight(); ``` +### `textSize()` + +#### Description + +Set a text scale factor + +#### Syntax + +``` +YourScreen.textSize(scale) +YourScreen.textSize(scaleX, scaleY) +``` + +#### Parameters + +scale: scale factor used for both x and y +scaleX: x scale factor +scaleY: y scale factor + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.stroke(255, 255, 255); +YourScreen.textFont(Font_5x7); +YourScreen.textSize(5); +YourScreen.text("abc", 0, 1); +YourScreen.endDraw(); +``` + ### `set()` #### Description diff --git a/examples/ASCIIDraw/ASCIIDraw.ino b/examples/ASCIIDraw/ASCIIDraw.ino index 398a40d..dfb6bb3 100644 --- a/examples/ASCIIDraw/ASCIIDraw.ino +++ b/examples/ASCIIDraw/ASCIIDraw.ino @@ -14,8 +14,9 @@ #include -const byte canvasWidth = 61; -const byte canvasHeight = 27; +const byte fontSize = 3; +const byte canvasWidth = fontSize * (5 * 7) + 26; +const byte canvasHeight = fontSize * 7 + 20; class ASCIIDrawClass : public ArduinoGraphics { public: @@ -85,6 +86,7 @@ void setup() { ASCIIDraw.stroke('@', 0, 0); const char text[] = "ARDUINO"; ASCIIDraw.textFont(Font_5x7); + ASCIIDraw.textSize(fontSize); const byte textWidth = strlen(text) * ASCIIDraw.textFontWidth(); const byte textHeight = ASCIIDraw.textFontHeight(); const byte textX = (canvasWidth - textWidth) / 2; diff --git a/src/ArduinoGraphics.cpp b/src/ArduinoGraphics.cpp index b47c2b5..8ed68a0 100644 --- a/src/ArduinoGraphics.cpp +++ b/src/ArduinoGraphics.cpp @@ -26,7 +26,9 @@ ArduinoGraphics::ArduinoGraphics(int width, int height) : _width(width), _height(height), - _font(NULL) + _font(NULL), + _textSizeX(1), + _textSizeY(1) { } @@ -241,7 +243,7 @@ void ArduinoGraphics::text(const char* str, int x, int y) uint8_t const c = (uint8_t)*str++; if (c == '\n') { - y += _font->height; + y += _font->height * _textSizeY; } else if (c == '\r') { x = 0; } else if (c == 0xc2 || c == 0xc3) { @@ -254,10 +256,10 @@ void ArduinoGraphics::text(const char* str, int x, int y) } if (b) { - bitmap(b, x, y, _font->width, _font->height); + bitmap(b, x, y, _font->width, _font->height, _textSizeX, _textSizeY); } - x += _font->width; + x += _font->width * _textSizeX; } } } @@ -269,38 +271,51 @@ void ArduinoGraphics::textFont(const Font& which) int ArduinoGraphics::textFontWidth() const { - return (_font ? _font->width : 0); + return (_font ? _font->width * _textSizeX : 0); } int ArduinoGraphics::textFontHeight() const { - return (_font ? _font->height : 0); + return (_font ? _font->height* _textSizeY : 0); } -void ArduinoGraphics::bitmap(const uint8_t* data, int x, int y, int width, int height) +void ArduinoGraphics::textSize(uint8_t sx, uint8_t sy) { - if (!_stroke) { + _textSizeX = (sx > 0)? sx : 1; + _textSizeY = (sy > 0)? sy : 1; +} + + +void ArduinoGraphics::bitmap(const uint8_t* data, int x, int y, int w, int h, uint8_t scale_x, uint8_t scale_y) { + if (!_stroke || !scale_x || !scale_y) { return; } - if ((data == NULL) || ((x + width) < 0) || ((y + height) < 0) || (x > _width) || (y > _height)) { + if ((data == nullptr) || ((x + (w * scale_x) < 0)) || ((y + (h * scale_y) < 0)) || (x > _width) || (y > _height)) { // offscreen return; } - for (int j = 0; j < height; j++) { + int xStart = x; + for (int j = 0; j < h; j++) { uint8_t b = data[j]; - - for (int i = 0; i < width; i++) { - if (b & (1 << (7 - i))) { - set(x + i, y + j, _strokeR, _strokeG, _strokeB); - } else { - set(x + i, y + j, _backgroundR, _backgroundG, _backgroundB); + for (uint8_t ys = 0; ys < scale_y; ys++) { + if (ys >= _height) return; + x = xStart; // reset for each row + for (int i = 0; i < w; i++) { + if (b & (1 << (7 - i))) { + for (uint8_t xs = 0; xs < scale_x; xs++) set(x++, y, _strokeR, _strokeG, _strokeB); + } else { + for (uint8_t xs = 0; xs < scale_x; xs++) set(x++, y, _backgroundR, _backgroundG, _backgroundB); + } + if (x >= _width) break; } + y++; } } } + void ArduinoGraphics::imageRGB(const Image& img, int x, int y, int width, int height) { const uint8_t* data = img.data(); @@ -359,7 +374,7 @@ void ArduinoGraphics::image(const Image& img, int x, int y) void ArduinoGraphics::image(const Image& img, int x, int y, int width, int height) { - if (!img || ((x + width) < 0) || ((y + height) < 0) || (x > _width) || (y > height)) { + if (!img || ((x + width) < 0) || ((y + height) < 0) || (x > _width) || (y > _height)) { // offscreen return; } @@ -438,7 +453,7 @@ void ArduinoGraphics::endText(int scrollDirection) beginDraw(); int const text_x = _textX - i; text(_textBuffer, text_x, _textY); - bitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height); + bitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height, _textSizeX, _textSizeY); endDraw(); delay(_textScrollSpeed); @@ -450,7 +465,7 @@ void ArduinoGraphics::endText(int scrollDirection) beginDraw(); int const text_x = _textX - (scrollLength - i - 1); text(_textBuffer, text_x, _textY); - bitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height); + bitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height, _textSizeX, _textSizeY); endDraw(); delay(_textScrollSpeed); @@ -462,7 +477,7 @@ void ArduinoGraphics::endText(int scrollDirection) beginDraw(); int const text_y = _textY - i; text(_textBuffer, _textX, text_y); - bitmap(_font->data[0x20], _textX, text_y - 1, _font->width, 1); + bitmap(_font->data[0x20], _textX, text_y - 1, _font->width, 1, _textSizeX, _textSizeY); endDraw(); delay(_textScrollSpeed); @@ -474,7 +489,7 @@ void ArduinoGraphics::endText(int scrollDirection) beginDraw(); int const text_y = _textY - (scrollLength - i - 1); text(_textBuffer, _textX, text_y); - bitmap(_font->data[0x20], _textX, text_y - 1, _font->width, 1); + bitmap(_font->data[0x20], _textX, text_y - 1, _font->width, 1, _textSizeX, _textSizeY); endDraw(); delay(_textScrollSpeed); diff --git a/src/ArduinoGraphics.h b/src/ArduinoGraphics.h index 1f1c914..3386dfa 100644 --- a/src/ArduinoGraphics.h +++ b/src/ArduinoGraphics.h @@ -70,6 +70,8 @@ class ArduinoGraphics : public Print { virtual void text(const char* str, int x = 0, int y = 0); virtual void text(const String& str, int x = 0, int y = 0) { text(str.c_str(), x, y); } virtual void textFont(const Font& which); + virtual void textSize(uint8_t s) {textSize(s, s);} + virtual void textSize(uint8_t sx, uint8_t sy); virtual int textFontWidth() const; virtual int textFontHeight() const; @@ -91,7 +93,8 @@ class ArduinoGraphics : public Print { virtual void textScrollSpeed(unsigned long speed = 150); protected: - virtual void bitmap(const uint8_t* data, int x, int y, int width, int height); + virtual void bitmap(const uint8_t* data, int x, int y, int w, int h, uint8_t scale_x = 1, + uint8_t scale_y = 1); virtual void imageRGB(const Image& img, int x, int y, int width, int height); virtual void imageRGB24(const Image& img, int x, int y, int width, int height); virtual void imageRGB16(const Image& img, int x, int y, int width, int height); @@ -114,6 +117,8 @@ class ArduinoGraphics : public Print { uint8_t _textR, _textG, _textB; int _textX; int _textY; + uint8_t _textSizeX; + uint8_t _textSizeY; unsigned long _textScrollSpeed; }; From 676f83ca7a9a766d246a98be7d8d2f232a259d8e Mon Sep 17 00:00:00 2001 From: Omar Ali Hassan <36759605+OmarAli3@users.noreply.github.com> Date: Mon, 30 Mar 2020 12:17:59 +0200 Subject: [PATCH 07/10] add function to clear specific point --- src/ArduinoGraphics.cpp | 5 +++++ src/ArduinoGraphics.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/ArduinoGraphics.cpp b/src/ArduinoGraphics.cpp index 8ed68a0..852c273 100644 --- a/src/ArduinoGraphics.cpp +++ b/src/ArduinoGraphics.cpp @@ -96,6 +96,11 @@ void ArduinoGraphics::clear() } } +void ArduinoGraphics::clear(int x, int y) +{ + set(x, y, _backgroundR, _backgroundB, _backgroundG); +} + void ArduinoGraphics::fill(uint8_t r, uint8_t g, uint8_t b) { _fill = true; diff --git a/src/ArduinoGraphics.h b/src/ArduinoGraphics.h index 3386dfa..69166e6 100644 --- a/src/ArduinoGraphics.h +++ b/src/ArduinoGraphics.h @@ -51,6 +51,7 @@ class ArduinoGraphics : public Print { void background(uint8_t r, uint8_t g, uint8_t b); void background(uint32_t color); void clear(); + void clear(int x, int y); //clear specific point void fill(uint8_t r, uint8_t g, uint8_t b); void fill(uint32_t color); void noFill(); From 04aa61b5a337a6a13143fe1d8af1b5c36acb1e20 Mon Sep 17 00:00:00 2001 From: Omar Ali Hassan Date: Wed, 4 Sep 2024 09:38:09 -0700 Subject: [PATCH 08/10] Update src/ArduinoGraphics.h to remove unnecessary comment Co-authored-by: Leonardo Cavagnis <45899760+leonardocavagnis@users.noreply.github.com> --- src/ArduinoGraphics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArduinoGraphics.h b/src/ArduinoGraphics.h index 69166e6..6776f86 100644 --- a/src/ArduinoGraphics.h +++ b/src/ArduinoGraphics.h @@ -51,7 +51,7 @@ class ArduinoGraphics : public Print { void background(uint8_t r, uint8_t g, uint8_t b); void background(uint32_t color); void clear(); - void clear(int x, int y); //clear specific point + void clear(int x, int y); void fill(uint8_t r, uint8_t g, uint8_t b); void fill(uint32_t color); void noFill(); From 4572a10257e34de1e5e60b2ea306336e23212eaf Mon Sep 17 00:00:00 2001 From: Omar Ali Date: Wed, 4 Sep 2024 20:00:52 +0300 Subject: [PATCH 09/10] Update API documentation for clear() method --- docs/api.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 8827301..004b2b6 100644 --- a/docs/api.md +++ b/docs/api.md @@ -202,17 +202,19 @@ YourScreen.endDraw(); #### Description -Clear the screen contents, uses the background colour set in background(). +Clear the screen contents or a specific pixel, uses the background colour set in background(). #### Syntax ``` YourScreen.clear() +YourScreen.clear(x, y) ``` #### Parameters -None +- x: x position of the pixel to clear +- y: y position of the pixel to clear #### Returns From 5696697fabd30e2d60679d1c2856180ff8911864 Mon Sep 17 00:00:00 2001 From: Leonardo Cavagnis <45899760+leonardocavagnis@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:37:29 +0200 Subject: [PATCH 10/10] Update library.properties Release v1.1.3. --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 3ee6369..8378e06 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ArduinoGraphics -version=1.1.2 +version=1.1.3 author=Arduino maintainer=Arduino sentence=Core graphics library for Arduino.