Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example sketch #14

Merged
merged 1 commit into from
Feb 11, 2021
Merged

Add example sketch #14

merged 1 commit into from
Feb 11, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Mar 19, 2020

The example sketch uses the ArduinoGraphics library to draw ASCII art and print it to the Serial Monitor.

This is an alternative to #10

I wanted an example sketch that didn't require any additional display hardware. This is what I came up with.

It's not very beginner friendly code, but I don't think it's possible to avoid that without involving another library.

It's a bit hacky in that the r parameter is used to set the character to draw with and the g and b parameters are unused.

Copy link

@MisterAwesome23 MisterAwesome23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 51: char _canvasBuffer[canvasWidth][canvasHeight] = {0};
Should be changed to- char _canvasBuffer[canvasWidth][canvasHeight] = {{0}};
This would fix compilation issue of array must be initialized with a brace-enclosed initializer.

@per1234
Copy link
Contributor Author

per1234 commented Mar 27, 2020

Thanks for your input @MisterAwesome23!

I think it's a good idea to do this, but I am curious to learn more because the current code works fine for me, without even a compiler warning. I see lots of recommendations to use {0} or {} for zero-initializing multidimensional arrays, and more rarely mentions of {{0}}. Which board are you compiling for?

@MisterAwesome23
Copy link

MisterAwesome23 commented Mar 27, 2020

I was using an Adafruit Feather Huzzah ESP8266 while testing.

It's true, {{0}} is rare initialiser but has a larger code compilation coverage I guess.

Also, thank you so much collecting and forming this. I am working on an example for ArduinoGraphics under GSoC proposal demonstration and this has been a great resource for reference.

@per1234
Copy link
Contributor Author

per1234 commented Mar 28, 2020

I was using an Adafruit Feather Huzzah ESP8266 while testing.

Thanks for the information. I am able to reproduce the error and have now pushed your recommended fix.

thank you so much collecting and forming this

You're welcome. My primary motivation for writing this example was to allow compilation testing of this library. However, I have since seen that it has other uses. It's nice to be able to copy/paste some text from Serial Monitor to show exactly the the output I'm seeing without needing to take a picture of some display hardware.

I'm fortunate enough to own a MKR RGB Shield, so I can try the library out on some display hardware, but not all the contributors have a MKR RGB Shield. The size of the RGB matrix is also limiting to be used for testing and development of the library.

this has been a great resource for reference.

I would recommend that you also look at the Arduino_MKRRGB library, since that demonstrates a more complete application of this library:
https://github.com/arduino-libraries/Arduino_MKRRGB

@MisterAwesome23
Copy link

I'm fortunate enough to own a MKR RGB Shield

Oh that is so great! I hope to get one as well if ArduinoGraphics gets a part in GSoC2020 and I get selected :)
For now I'm working on an example with the serial monitor ASCII art itself.

The size of the RGB matrix is also limiting to be used for testing and development of the library.

Is it why you have chosen 61X27 canvas. If so, I'll make sure I use the same dimensions while formulating examples.

https://github.com/arduino-libraries/Arduino_MKRRGB

Thanks for recommending this, I am looking in to that to get more ideas.
Also, to someone reading this thread and want to contribute I'd suggest learning Processing- http://processing.org/
as it will help as well :)

@per1234
Copy link
Contributor Author

per1234 commented Mar 28, 2020

I'm working on an example with the serial monitor ASCII art itself.

Be sure to take note of this bug:
https://github.com/arduino-libraries/ArduinoGraphics/pull/13
It caused me some confusion while I was working on this example.

Is it why you have chosen 61X27 canvas.

No, the MKR RGB Shield is only a 12x7 matrix! 61x27 is just the space required to fit the "ARDUINO" text as well as some decorative borders that demonstrate the use of the background, rect, line, and point functions.

The example sketch uses the ArduinoGraphics library to draw ASCII art and print it to the Serial Monitor.
@aentinger aentinger merged commit 194a17b into arduino-libraries:master Feb 11, 2021
@per1234 per1234 deleted the add-example branch February 11, 2021 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants