From b6f05dd14f516a3a94dced71ed11b04a6d939739 Mon Sep 17 00:00:00 2001 From: 8bitkick <8bitkick@users.noreply.github.com> Date: Wed, 10 Apr 2019 21:08:06 -0700 Subject: [PATCH 01/21] RGB16 red masked to 5 bits Prevents high green bits overlapping to low red. --- src/ArduinoGraphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArduinoGraphics.cpp b/src/ArduinoGraphics.cpp index e80e4b3..bedd1a7 100644 --- a/src/ArduinoGraphics.cpp +++ b/src/ArduinoGraphics.cpp @@ -298,7 +298,7 @@ void ArduinoGraphics::imageRGB16(const Image& img, int x, int y, int width, int for (int i = 0; i < width; i++) { uint16_t pixel = *data++; - set(x + i, y + j, (pixel >> 8), ((pixel >> 3) & 0xfc), (pixel << 3) & 0xf8); + set(x + i, y + j, ((pixel >> 8) & 0xf8), ((pixel >> 3) & 0xfc), (pixel << 3) & 0xf8); } data += (img.width() - width); From 7c0ecdd297033ab92a7ddd1b39ca156e3041dfd0 Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Mon, 7 Oct 2019 17:22:37 -0400 Subject: [PATCH 02/21] Add Github workflows for compiling examples and spell checking --- .github/workflows/compile-examples.yml | 19 +++++++++++++++++++ .github/workflows/spell-check.yml | 11 +++++++++++ README.adoc | 2 ++ 3 files changed, 32 insertions(+) create mode 100644 .github/workflows/compile-examples.yml create mode 100644 .github/workflows/spell-check.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..93357ec --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,19 @@ +name: Compile Examples +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + fqbn: [ + "arduino:samd:mkrzero" + ] + + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - uses: arduino/actions/libraries/compile-examples@master + with: + fqbn: ${{ matrix.fqbn }} diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..7b45d77 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,11 @@ +name: Spell Check +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - uses: arduino/actions/libraries/spell-check@master diff --git a/README.adoc b/README.adoc index 38c6684..135197f 100644 --- a/README.adoc +++ b/README.adoc @@ -1,5 +1,7 @@ = ArduinoGraphics Library for Arduino = +image:https://github.com/arduino-libraries/ArduinoGraphics/workflows/Compile%20Examples/badge.svg["Compile Examples Status", link="https://github.com/arduino-libraries/ArduinoGraphics/actions?workflow=Compile+Examples"] image:https://github.com/arduino-libraries/ArduinoGraphics/workflows/Spell%20Check/badge.svg["Spell Check Status", link="https://github.com/arduino-libraries/ArduinoGraphics/actions?workflow=Spell+Check"] + Core graphics library for Arduino. Based on the Processing API. For more information about this library please visit us at https://www.arduino.cc/en/Reference/ArduinoGraphics From e9880f03503a43b74fb2f746b6cad5504f6c15f7 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 19 Mar 2020 08:06:37 -0700 Subject: [PATCH 03/21] Add example sketch The example sketch uses the ArduinoGraphics library to draw ASCII art and print it to the Serial Monitor. --- examples/ASCIIDraw/ASCIIDraw.ino | 107 +++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 examples/ASCIIDraw/ASCIIDraw.ino diff --git a/examples/ASCIIDraw/ASCIIDraw.ino b/examples/ASCIIDraw/ASCIIDraw.ino new file mode 100644 index 0000000..398a40d --- /dev/null +++ b/examples/ASCIIDraw/ASCIIDraw.ino @@ -0,0 +1,107 @@ +/* + ASCIIDraw + + Use the ArduinoGraphics library to draw ASCII art on the Serial Monitor. + + This is intended primarily to allow testing of the library. + See the Arduino_MKRRGB library for a more useful demonstration of the ArduinoGraphics library. + + The circuit: + - Arduino board + + This example code is in the public domain. +*/ + +#include + +const byte canvasWidth = 61; +const byte canvasHeight = 27; + +class ASCIIDrawClass : public ArduinoGraphics { + public: + // can be used with an object of any class that inherits from the Print class + ASCIIDrawClass(Print &printObject = (Print &)Serial) : + ArduinoGraphics(canvasWidth, canvasHeight), + _printObject(&printObject) {} + + // this function is called by the ArduinoGraphics library's functions + virtual void set(int x, int y, uint8_t r, uint8_t g, uint8_t b) { + // the r parameter is (mis)used to set the character to draw with + _canvasBuffer[x][y] = r; + // cast unused parameters to void to fix "unused parameter" warning + (void)g; + (void)b; + } + + // display the drawing + void endDraw() { + ArduinoGraphics::endDraw(); + + for (byte row = 0; row < canvasHeight; row++) { + for (byte column = 0; column < canvasWidth; column++) { + // handle unset parts of buffer + if (_canvasBuffer[column][row] == 0) { + _canvasBuffer[column][row] = ' '; + } + _printObject->print(_canvasBuffer[column][row]); + } + _printObject->println(); + } + } + + private: + Print *_printObject; + char _canvasBuffer[canvasWidth][canvasHeight] = {{0}}; +}; + +ASCIIDrawClass ASCIIDraw; + +void setup() { + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + ASCIIDraw.beginDraw(); + + // configure the character used to fill the background. The second and third parameters are ignored + ASCIIDraw.background('+', 0, 0); + ASCIIDraw.clear(); + + // add the outer border + ASCIIDraw.stroke('-', 0, 0); + ASCIIDraw.fill('*', 0, 0); + const byte outerBorderThickness = 1; + ASCIIDraw.rect(outerBorderThickness, outerBorderThickness, canvasWidth - outerBorderThickness * 2, canvasHeight - outerBorderThickness * 2); + + // add the inner border + ASCIIDraw.stroke('+', 0, 0); + ASCIIDraw.fill('O', 0, 0); + const byte borderThickness = outerBorderThickness + 6; + ASCIIDraw.rect(borderThickness, borderThickness, canvasWidth - borderThickness * 2, canvasHeight - borderThickness * 2); + + // add the text + ASCIIDraw.background(' ', 0, 0); + ASCIIDraw.stroke('@', 0, 0); + const char text[] = "ARDUINO"; + ASCIIDraw.textFont(Font_5x7); + const byte textWidth = strlen(text) * ASCIIDraw.textFontWidth(); + const byte textHeight = ASCIIDraw.textFontHeight(); + const byte textX = (canvasWidth - textWidth) / 2; + const byte textY = (canvasHeight - textHeight) / 2; + ASCIIDraw.text(text, textX, textY); + + // underline the text + ASCIIDraw.stroke('-', 0, 0); + ASCIIDraw.line(textX, textY + textHeight - 1, textX + textWidth - 1, textY + textHeight - 1); + + // add some accents to the underline + ASCIIDraw.stroke('+', 0, 0); + ASCIIDraw.point(textX + 4, textY + textHeight - 1); + ASCIIDraw.point(textX + textWidth - 1 - 4, textY + textHeight - 1); + + // print the drawing to the Serial Monitor + ASCIIDraw.endDraw(); +} + +void loop() {} From ba36c7c3b82d34a607510e47213ad620ca0905e2 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 19 Mar 2020 07:58:10 -0700 Subject: [PATCH 04/21] Fix bug that caused bitmap to not display when y > height Use of incorrect variable name caused the bitmap to not display when the y position was greater than the bitmap height. --- src/ArduinoGraphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArduinoGraphics.cpp b/src/ArduinoGraphics.cpp index bedd1a7..6e15198 100644 --- a/src/ArduinoGraphics.cpp +++ b/src/ArduinoGraphics.cpp @@ -236,7 +236,7 @@ void ArduinoGraphics::bitmap(const uint8_t* data, int x, int y, int width, int h return; } - if ((data == NULL) || ((x + width) < 0) || ((y + height) < 0) || (x > _width) || (y > height)) { + if ((data == NULL) || ((x + width) < 0) || ((y + height) < 0) || (x > _width) || (y > _height)) { // offscreen return; } From 3b5dc25e6d75050455c23f0fbf2470165e8091d9 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 20 Apr 2021 06:35:57 -0700 Subject: [PATCH 05/21] Configure Dependabot to check for outdated actions used in workflows Dependabot will periodically check the versions of all actions used in the repository's workflows. If any are found to be outdated, it will submit a pull request to update them. NOTE: Dependabot's PRs will sometimes try to pin to the patch version of the action (e.g., updating `uses: foo/bar@v1` to `uses: foo/bar@v2.3.4`). When the action author has provided a major version ref, use that instead (e.g., `uses: foo/bar@v2`). Dependabot will automatically close its PR once the workflow has been updated. More information: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot --- .github/dependabot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..03600dd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file +version: 2 + +updates: + # Configure check for outdated GitHub Actions actions in workflows. + # See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot + - package-ecosystem: github-actions + directory: / # Check the repository's workflows under /.github/workflows/ + schedule: + interval: daily From 2c1a336c7a51ba1b7d5913324e7fef161753f3f3 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 20 Apr 2021 06:38:09 -0700 Subject: [PATCH 06/21] Update "smoke test" examples compilation CI workflow On every push or pull request that affects library source or example files, and periodically, compile all example sketches for the specified boards. --- .github/workflows/compile-examples.yml | 71 ++++++++++++++++++++------ README.adoc | 7 ++- 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 93357ec..96652c0 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -1,19 +1,60 @@ name: Compile Examples -on: [push, pull_request] + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-examples.yml" + - "library.properties" + - "examples/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/compile-examples.yml" + - "library.properties" + - "examples/**" + - "src/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + jobs: - build: - runs-on: ubuntu-latest + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:samd:arduino_zero_edbg + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrzero + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:nano_33_iot + platforms: | + - name: arduino:samd + + steps: + - name: Checkout repository + uses: actions/checkout@v2 - strategy: - matrix: - fqbn: [ - "arduino:samd:mkrzero" - ] + - name: Compile examples + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + # Install the library from the local path. + - source-path: ./ + # Additional library dependencies can be listed here. + # See: https://github.com/arduino/compile-sketches#libraries + sketch-paths: | + - examples - steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 1 - - uses: arduino/actions/libraries/compile-examples@master - with: - fqbn: ${{ matrix.fqbn }} diff --git a/README.adoc b/README.adoc index 135197f..0b944a5 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,9 @@ -= ArduinoGraphics Library for Arduino = +:repository-owner: arduino-libraries +:repository-name: ArduinoGraphics -image:https://github.com/arduino-libraries/ArduinoGraphics/workflows/Compile%20Examples/badge.svg["Compile Examples Status", link="https://github.com/arduino-libraries/ArduinoGraphics/actions?workflow=Compile+Examples"] image:https://github.com/arduino-libraries/ArduinoGraphics/workflows/Spell%20Check/badge.svg["Spell Check Status", link="https://github.com/arduino-libraries/ArduinoGraphics/actions?workflow=Spell+Check"] += {repository-name} Library for Arduino = + +image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml/badge.svg["Compile Examples status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml"] Core graphics library for Arduino. Based on the Processing API. From e7d75fef4d7d6d81a3564a702eb7c3c15bc9ee97 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 20 Apr 2021 06:38:56 -0700 Subject: [PATCH 07/21] Report changes in memory usage that would result from merging a PR On creation or commit to a pull request, a report of the resulting change in memory usage of the examples will be commented to the PR thread. --- .github/workflows/compile-examples.yml | 11 +++++++++++ .github/workflows/report-size-deltas.yml | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/report-size-deltas.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 96652c0..811e7bd 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -25,6 +25,9 @@ jobs: name: ${{ matrix.board.fqbn }} runs-on: ubuntu-latest + env: + SKETCHES_REPORTS_PATH: sketches-reports + strategy: fail-fast: false @@ -57,4 +60,12 @@ jobs: # See: https://github.com/arduino/compile-sketches#libraries sketch-paths: | - examples + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..652be5d --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,24 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.yml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # The name of the workflow artifact created by the sketch compilation workflow + sketches-reports-source: sketches-reports From c1cd7905b6bf736f68ad3288c3b0849b66344dfb Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 20 Apr 2021 06:39:19 -0700 Subject: [PATCH 08/21] Update CI workflow to check for commonly misspelled words On every push, pull request, and periodically, use the codespell-project/actions-codespell action to check for commonly misspelled words. In the event of a false positive, the problematic word should be added, in all lowercase, to the ignore-words-list field of ./.codespellrc. Regardless of the case of the word in the false positive, it must be in all lowercase in the ignore list. The ignore list is comma-separated with no spaces. --- .codespellrc | 7 +++++++ .github/workflows/spell-check.yml | 29 ++++++++++++++++++++--------- README.adoc | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..101edae --- /dev/null +++ b/.codespellrc @@ -0,0 +1,7 @@ +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: +ignore-words-list = , +check-filenames = +check-hidden = +skip = ./.git diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 7b45d77..01bee87 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -1,11 +1,22 @@ name: Spell Check -on: [push, pull_request] + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 1 - - uses: arduino/actions/libraries/spell-check@master + spellcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Spell check + uses: codespell-project/actions-codespell@master diff --git a/README.adoc b/README.adoc index 0b944a5..3f9d65c 100644 --- a/README.adoc +++ b/README.adoc @@ -4,6 +4,7 @@ = {repository-name} Library for Arduino = image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml/badge.svg["Compile Examples status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml"] +image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml/badge.svg["Spell Check status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml"] Core graphics library for Arduino. Based on the Processing API. From 322f187c4999007ce95e1a85f33ce35ba0649a25 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 20 Apr 2021 06:39:46 -0700 Subject: [PATCH 09/21] Add CI workflow to do Arduino project-specific linting On every push, pull request, and periodically, run Arduino Lint to check for common problems not related to the project code. --- .github/workflows/check-arduino.yml | 28 ++++++++++++++++++++++++++++ README.adoc | 1 + 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/check-arduino.yml diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml new file mode 100644 index 0000000..0d969f6 --- /dev/null +++ b/.github/workflows/check-arduino.yml @@ -0,0 +1,28 @@ +name: Check Arduino + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Arduino Lint + uses: arduino/arduino-lint-action@v1 + with: + compliance: specification + library-manager: update + # Always use this setting for official repositories. Remove for 3rd party projects. + official: true + project-type: library diff --git a/README.adoc b/README.adoc index 3f9d65c..a77a80e 100644 --- a/README.adoc +++ b/README.adoc @@ -3,6 +3,7 @@ = {repository-name} Library for Arduino = +image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml/badge.svg["Check Arduino status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-arduino.yml"] image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml/badge.svg["Compile Examples status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/compile-examples.yml"] image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml/badge.svg["Spell Check status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check.yml"] From ea0d71a1c2b5549b92afb5c36d0924d5c451d0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Wed, 30 Jun 2021 12:15:12 +0200 Subject: [PATCH 10/21] Add docs folder --- docs/api.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/readme.md | 13 +++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 docs/api.md create mode 100644 docs/readme.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..b9f3b87 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,52 @@ +# ArduinoGraphics Library + +## Methods + +### `begin()` + +Description +Initializes the graphics device. + +#### Syntax + +`YourScreen.begin()` + +#### Parameters + +None + +#### Returns + +1 for success, 0 on failure. + +#### Example + +```arduino +if (!YourScreen.begin() { + Serial.println(“Failed to initialize the display!”); + while (1); +} +``` + +### `end()` + +Description +Stops the graphics device. + +#### Syntax + +`YourScreen.end()` + +#### Parameters + +None + +#### Returns + +Nothing + +#### Example + +```arduino +YourScreen.end(); +``` diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 0000000..92ff8db --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,13 @@ +# 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. + +To use this library + +``` +#include +``` + +To let you easily understand the usage of the graphics primitives, we are using a dummy screen object named YourScreen that should be substituted with the real one, Eg. MATRIX, OLED, TFT and so on. Refer to the hardware interfacing library of your screen to get more details. + +The style and syntax of this library is inspired by [Processing 3](https://processing.org/) and we believe that learning Processing is very helpful to develop complex applications that combine the versatility of Arduino driven hardware with the power of a pc based graphical interface. \ No newline at end of file From 486e46cd0e42c8eb0af411a0f388cf65b06f0de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Mon, 26 Jul 2021 09:54:50 +0200 Subject: [PATCH 11/21] Update api.md --- docs/api.md | 789 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 782 insertions(+), 7 deletions(-) diff --git a/docs/api.md b/docs/api.md index b9f3b87..491bb9c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,15 +1,20 @@ -# ArduinoGraphics Library +# Arduino Graphics Library ## Methods ### `begin()` -Description +#### Description + + Initializes the graphics device. #### Syntax -`YourScreen.begin()` +``` +YourScreen.begin() +``` + #### Parameters @@ -21,32 +26,802 @@ None #### Example -```arduino +``` if (!YourScreen.begin() { Serial.println(“Failed to initialize the display!”); while (1); } ``` + + ### `end()` -Description +#### Description + Stops the graphics device. #### Syntax -`YourScreen.end()` +``` +YourScreen.end() + +``` + #### Parameters + None + #### Returns Nothing #### Example -```arduino +``` YourScreen.end(); ``` + + + +### `width()` + +#### Description + + +Returns the pixel width of the graphics device. + +#### Syntax + +``` +YourScreen.width() + +``` + + +#### Parameters + + +None + +#### Returns + +Returns the pixel width of the graphics device. + +#### Example + +``` +int w = YourScreen.width(); +``` + + +### `height()` + +#### Description + + +Returns the pixel height of the graphics device. + +#### Syntax + +``` +YourScreen.height() + +``` + + +#### Parameters + + +None + +#### Returns + +Returns the pixel height of the graphics device. + +#### Example + +``` +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 + +#### Example + +``` +YourScreen.beginDraw(); +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 + +``` +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) +- color: 24-bit RGB color, 0xrrggbb + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.background(255, 0, 0); +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 + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.background(255, 0, 0); +YourScreen.clear(); +YourScreen.endDraw(); +``` + + + +### `fill()` + +#### Description + + +Set the fill color of drawing operations. + +#### Syntax + +``` +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) +- color: 24-bit RGB color, 0xrrggbb + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.noStroke(); +YourScreen.fill(255, 255, 0); +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 + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.stroke(255, 0, 255); +YourScreen.noFill(); +YourScreen.rect(0, 0, YourScreen.width(), YourScreen.height()); +YourScreen.endDraw(); +``` + + +### `stroke()` + +#### Description + + +Set the stroke color of drawing operations. + +#### Syntax + +``` +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) +- color: 24-bit RGB color, 0xrrggbb + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.stroke(255, 0, 255); +YourScreen.noFill(); +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 + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.noStroke(); +YourScreen.fill(255, 255, 0); +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 +- y2: y position of the end point of the line + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.stroke(0, 0, 255); +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 + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.stroke(0, 255, 0); +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 +- height: height of the rectangle + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.noStroke(); +YourScreen.fill(255, 255, 0); +YourScreen.rect(0, 0, YourScreen.width(), YourScreen.height()); +YourScreen.endDraw(); +``` + + +### `text()` + +#### Description + + +Draw some text, uses the stroke color set in stroke() and the background color set in background(). + +#### Syntax + +``` +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 + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.stroke(255, 255, 255); +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 + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.stroke(255, 255, 255); +YourScreen.textFont(Font_5x7); +YourScreen.text("abc", 0, 1); +YourScreen.endDraw(); +``` + + +### `textFontWidth()` + +#### Description + + +Returns the width, in pixels, of the current font. + +#### Syntax + +``` +YourScreen.textFontWidth() + +``` + + +#### Parameters + + +None + + +#### Returns + +Nothing + +#### Example + +``` +int w = YourScreen.textFontWidth(); +``` + + +### `textFontHeight()` + +#### Description + + +Returns the height, in pixels, of the current font. + +#### Syntax + +``` +YourScreen.textFontHeight() + +``` + + +#### Parameters + + +None + + +#### Returns + +Nothing + +#### Example + +``` +int h = YourScreen.textFontHeight(); +``` + + +### `set()` + +#### Description + + +Set a pixel’s color value. + +#### Syntax + +``` +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) +g: green color value (0 - 255) +b: blue color value (0 - 255) +color: 24-bit RGB color, 0xrrggbb + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +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 + +``` +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) +g: green color value (0 - 255) +b: blue color value (0 - 255) +color: 24-bit RGB color, 0xrrggbb + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginText(0, 0, 127, 0, 0); +YourScreen.print("Hi"); +YourScreen.endText(); +``` + + +### `endText()` + +#### Description + + +End the process of displaying and optionally scrolling text. + +#### Syntax + +``` +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 + +Nothing + +#### Example + +``` +YourScreen.beginText(0, 0, 127, 0, 0); +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 + +#### Example + +``` +YourScreen.beginText(0, 0, 127, 0, 0); +YourScreen.textScrollSpeed(500); +YourScreen.print("Hello There!"); +YourScreen.endText(true); +``` + From b2168e6d059e69747ee8694d95487ff2f86e4847 Mon Sep 17 00:00:00 2001 From: Elena Marzi Tornblad Date: Sat, 13 Nov 2021 21:55:08 +0100 Subject: [PATCH 12/21] Fix color bug in clear() method The green and blue components of the background were switched in the clear() method. --- src/ArduinoGraphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArduinoGraphics.cpp b/src/ArduinoGraphics.cpp index 6e15198..5aeff55 100644 --- a/src/ArduinoGraphics.cpp +++ b/src/ArduinoGraphics.cpp @@ -83,7 +83,7 @@ void ArduinoGraphics::clear() { for (int x = 0; x < _width; x++) { for (int y = 0; y < _height; y++) { - set(x, y, _backgroundR, _backgroundB, _backgroundG); + set(x, y, _backgroundR, _backgroundG, _backgroundB); } } } From 3835c7250a00621d002692845c35f6b4063cfba2 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 10 Jan 2022 01:06:03 -0800 Subject: [PATCH 13/21] Add GitHub Actions workflow to synchronize with shared repository labels (#23) On every push that changes relevant files, and periodically, configure the repository's issue and pull request labels according to the universal, shared, and local label configuration files. --- .github/dependabot.yml | 2 + .github/workflows/sync-labels.yml | 138 ++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 .github/workflows/sync-labels.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 03600dd..fa738ec 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,3 +8,5 @@ updates: directory: / # Check the repository's workflows under /.github/workflows/ schedule: interval: daily + labels: + - "topic: infrastructure" diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..3ee6feb --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,138 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md +name: Sync Labels + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + pull_request: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + schedule: + # Run daily at 8 AM UTC to sync with changes to shared label configurations. + - cron: "0 8 * * *" + workflow_dispatch: + repository_dispatch: + +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT: label-configuration-files + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download JSON schema for labels configuration file + id: download-schema + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json + location: ${{ runner.temp }}/label-configuration-schema + + - name: Install JSON schema validator + run: | + sudo npm install \ + --global \ + ajv-cli \ + ajv-formats + + - name: Validate local labels configuration + run: | + # See: https://github.com/ajv-validator/ajv-cli#readme + ajv validate \ + --all-errors \ + -c ajv-formats \ + -s "${{ steps.download-schema.outputs.file-path }}" \ + -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" + + download: + needs: check + runs-on: ubuntu-latest + + strategy: + matrix: + filename: + # Filenames of the shared configurations to apply to the repository in addition to the local configuration. + # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels + - universal.yml + + steps: + - name: Download + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} + + - name: Pass configuration files to next job via workflow artifact + uses: actions/upload-artifact@v2 + with: + path: | + *.yaml + *.yml + if-no-files-found: error + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + sync: + needs: download + runs-on: ubuntu-latest + + steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" + + - name: Determine whether to dry run + id: dry-run + if: > + github.event_name == 'pull_request' || + ( + ( + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' + ) && + github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + ) + run: | + # Use of this flag in the github-label-sync command will cause it to only check the validity of the + # configuration. + echo "::set-output name=flag::--dry-run" + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download configuration files artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + path: ${{ env.CONFIGURATIONS_FOLDER }} + + - name: Remove unneeded artifact + uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + - name: Merge label configuration files + run: | + # Merge all configuration files + shopt -s extglob + cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" + + - name: Install github-label-sync + run: sudo npm install --global github-label-sync + + - name: Sync labels + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # See: https://github.com/Financial-Times/github-label-sync + github-label-sync \ + --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ + ${{ steps.dry-run.outputs.flag }} \ + ${{ github.repository }} From cc97d209d077acc86e1013421c75cd0884054153 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Mar 2022 02:14:57 +0000 Subject: [PATCH 14/21] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/check-arduino.yml | 2 +- .github/workflows/compile-examples.yml | 2 +- .github/workflows/spell-check.yml | 2 +- .github/workflows/sync-labels.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml index 0d969f6..3e0d26c 100644 --- a/.github/workflows/check-arduino.yml +++ b/.github/workflows/check-arduino.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Arduino Lint uses: arduino/arduino-lint-action@v1 diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 811e7bd..e73871a 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Compile examples uses: arduino/compile-sketches@v1 diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 01bee87..3f6b03f 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Spell check uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 3ee6feb..4ea5755 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download JSON schema for labels configuration file id: download-schema @@ -105,7 +105,7 @@ jobs: echo "::set-output name=flag::--dry-run" - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download configuration files artifact uses: actions/download-artifact@v2 From aca891474ff0cfec76a7423ed132d106669918d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 02:12:16 +0000 Subject: [PATCH 15/21] Bump actions/upload-artifact from 2 to 3 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/compile-examples.yml | 2 +- .github/workflows/sync-labels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index e73871a..326b00a 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -64,7 +64,7 @@ jobs: sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} - name: Save sketches report as workflow artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 4ea5755..1d969d5 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -70,7 +70,7 @@ jobs: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} - name: Pass configuration files to next job via workflow artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: path: | *.yaml From 15ebb22f4c1490e6b42655b6a3e6a08b495a4025 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 02:12:18 +0000 Subject: [PATCH 16/21] Bump actions/download-artifact from 2 to 3 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .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 4ea5755..e84e803 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -108,7 +108,7 @@ jobs: uses: actions/checkout@v3 - name: Download configuration files artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} path: ${{ env.CONFIGURATIONS_FOLDER }} From 71ed5d909a5a1e5ffa13e4c992951eb624090d29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 02:12:11 +0000 Subject: [PATCH 17/21] Bump geekyeggo/delete-artifact from 1 to 2 Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 1 to 2. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v1...v2) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .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 986bda6..10abaea 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@v1 + uses: geekyeggo/delete-artifact@v2 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From c213ff9617a25191593defac8709cdb712237aac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Oct 2022 02:12:22 +0000 Subject: [PATCH 18/21] Bump carlosperate/download-file-action from 1 to 2 Bumps [carlosperate/download-file-action](https://github.com/carlosperate/download-file-action) from 1 to 2. - [Release notes](https://github.com/carlosperate/download-file-action/releases) - [Commits](https://github.com/carlosperate/download-file-action/compare/v1...v2) --- updated-dependencies: - dependency-name: carlosperate/download-file-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/sync-labels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 10abaea..94938f3 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -31,7 +31,7 @@ jobs: - name: Download JSON schema for labels configuration file id: download-schema - uses: carlosperate/download-file-action@v1 + uses: carlosperate/download-file-action@v2 with: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json location: ${{ runner.temp }}/label-configuration-schema @@ -65,7 +65,7 @@ jobs: steps: - name: Download - uses: carlosperate/download-file-action@v1 + uses: carlosperate/download-file-action@v2 with: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} From 001f35ce87d064f9df7253aac9d03ea64e93c3ed Mon Sep 17 00:00:00 2001 From: Leonardo Cavagnis Date: Fri, 14 Apr 2023 15:47:33 +0200 Subject: [PATCH 19/21] adding circle and ellipse drawing functions --- docs/api.md | 77 +++++++++++++++++++++++++++++++++++++++++ keywords.txt | 2 ++ src/ArduinoGraphics.cpp | 47 +++++++++++++++++++++++++ src/ArduinoGraphics.h | 4 ++- 4 files changed, 129 insertions(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 491bb9c..a870920 100644 --- a/docs/api.md +++ b/docs/api.md @@ -539,6 +539,83 @@ 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 + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.noStroke(); +YourScreen.fill(255, 255, 0); +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 +- height: height of the ellipse + +#### Returns + +Nothing + +#### Example + +``` +YourScreen.beginDraw(); +YourScreen.clear(); +YourScreen.noStroke(); +YourScreen.fill(255, 255, 0); +YourScreen.ellipse(YourScreen.width()/2, YourScreen.height()/2, YourScreen.width(), YourScreen.height()); +YourScreen.endDraw(); +``` + + ### `text()` #### Description diff --git a/keywords.txt b/keywords.txt index 5c7d60b..ce07cc7 100644 --- a/keywords.txt +++ b/keywords.txt @@ -33,6 +33,8 @@ line KEYWORD2 point KEYWORD2 quad KEYWORD2 rect KEYWORD2 +circle KEYWORD2 +ellipse KEYWORD2 text KEYWORD2 textFont KEYWORD2 diff --git a/src/ArduinoGraphics.cpp b/src/ArduinoGraphics.cpp index 5aeff55..15fe1ad 100644 --- a/src/ArduinoGraphics.cpp +++ b/src/ArduinoGraphics.cpp @@ -59,6 +59,12 @@ int ArduinoGraphics::height() return _height; } +uint32_t ArduinoGraphics::background() +{ + uint32_t bg = (uint32_t)((uint32_t)(_backgroundR << 16) | (uint32_t)(_backgroundG << 8) | (uint32_t)(_backgroundB << 0)); + return bg; +} + void ArduinoGraphics::beginDraw() { } @@ -124,6 +130,47 @@ void ArduinoGraphics::noStroke() _stroke = false; } +void ArduinoGraphics::circle(int x, int y, int diameter) +{ + ellipse(x, y, diameter, diameter); +} + +void ArduinoGraphics::ellipse(int x, int y, int width, int height) +{ + if (!_stroke && !_fill) { + return; + } + + int32_t a = width / 2; + int32_t b = height / 2; + int64_t a2 = a * a; + int64_t b2 = b * b; + int64_t i, j; + + if (_fill) { + for (j = -b; j <= b; j++) { + for (i = -a; i <= a; i++) { + if (i*i*b2 + j*j*a2 <= a2*b2) { + set(x + i, y + j, _fillR, _fillG, _fillB); + } + } + } + } + if (_stroke) { + int x_val, y_val; + for (i = -a; i <= a; i++) { + y_val = b * sqrt(1 - (double)i*i / a2); + set(x + i, y + y_val, _strokeR, _strokeG, _strokeB); + set(x + i, y - y_val, _strokeR, _strokeG, _strokeB); + } + for (j = -b; j <= b; j++) { + x_val = a * sqrt(1 - (double)j*j / b2); + set(x + x_val, y + j, _strokeR, _strokeG, _strokeB); + set(x - x_val, y + j, _strokeR, _strokeG, _strokeB); + } + } +} + void ArduinoGraphics::line(int x1, int y1, int x2, int y2) { if (!_stroke) { diff --git a/src/ArduinoGraphics.h b/src/ArduinoGraphics.h index f5468b0..1f1c914 100644 --- a/src/ArduinoGraphics.h +++ b/src/ArduinoGraphics.h @@ -43,6 +43,7 @@ class ArduinoGraphics : public Print { int width(); int height(); + uint32_t background(); virtual void beginDraw(); virtual void endDraw(); @@ -58,7 +59,8 @@ class ArduinoGraphics : public Print { void noStroke(); //virtual void arc(int x, int y, int width, int height, int start, int stop); - //virtual void ellipse(int x, int y, int width, int height); + virtual void circle(int x, int y, int diameter); + virtual void ellipse(int x, int y, int width, int height); virtual void line(int x1, int y1, int x2, int y2); virtual void point(int x, int y); //virtual void quad(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); From feeb5fc56dfa6f1dd7d3aa116f10dafd45b713e9 Mon Sep 17 00:00:00 2001 From: Leonardo Cavagnis Date: Wed, 24 May 2023 17:16:02 +0200 Subject: [PATCH 20/21] add HasIncludeArduinoGraphics.h file --- src/HasIncludeArduinoGraphics.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/HasIncludeArduinoGraphics.h diff --git a/src/HasIncludeArduinoGraphics.h b/src/HasIncludeArduinoGraphics.h new file mode 100644 index 0000000..cc27970 --- /dev/null +++ b/src/HasIncludeArduinoGraphics.h @@ -0,0 +1,4 @@ +/* +This file is intentionally left blank. +Do not remove this comment. +*/ \ No newline at end of file From e018025634a9a825c4f78c153a98e9f0b2c5d30f Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 26 May 2023 17:14:34 +0200 Subject: [PATCH 21/21] Publish 1.1.0 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 2494df5..7933150 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ArduinoGraphics -version=1.0.0 +version=1.1.0 author=Arduino maintainer=Arduino sentence=Core graphics library for Arduino.