-
Notifications
You must be signed in to change notification settings - Fork 23
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
Allow the fixed fonts to be scaled up. #45
Conversation
Memory usage change @ 6d1e09e
Click for full report table
Click for full report CSV
|
As I mentioned in the forum thread: I have run what tests I know of for this library. I believe there are integration issues between this library and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good!
Some adjustments for consistency:
_textsize_x, _textsize_y
->_textSizeX, _textSizeY
setTextSize()
->textSize()
- remove
scaledBitmap
function, and overloadbitmap
with default values
src/ArduinoGraphics.h
Outdated
@@ -114,6 +118,8 @@ class ArduinoGraphics : public Print { | |||
uint8_t _textR, _textG, _textB; | |||
int _textX; | |||
int _textY; | |||
uint8_t _textsize_x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8_t _textsize_x; | |
uint8_t _textSizeX; |
src/ArduinoGraphics.h
Outdated
@@ -114,6 +118,8 @@ class ArduinoGraphics : public Print { | |||
uint8_t _textR, _textG, _textB; | |||
int _textX; | |||
int _textY; | |||
uint8_t _textsize_x; | |||
uint8_t _textsize_y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8_t _textsize_y; | |
uint8_t _textSizeY; |
src/ArduinoGraphics.h
Outdated
@@ -92,6 +94,8 @@ class ArduinoGraphics : public Print { | |||
|
|||
protected: | |||
virtual void bitmap(const uint8_t* data, int x, int y, int width, int height); | |||
virtual void scaledBitmap(const uint8_t* data, int x, int y, int width, int height, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual void scaledBitmap(const uint8_t* data, int x, int y, int width, int height, |
src/ArduinoGraphics.h
Outdated
@@ -92,6 +94,8 @@ class ArduinoGraphics : public Print { | |||
|
|||
protected: | |||
virtual void bitmap(const uint8_t* data, int x, int y, int width, int height); | |||
virtual void scaledBitmap(const uint8_t* data, int x, int y, int width, int height, | |||
uint8_t scale_x, uint8_t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8_t scale_x, uint8_t); |
src/ArduinoGraphics.h
Outdated
@@ -92,6 +94,8 @@ class ArduinoGraphics : public Print { | |||
|
|||
protected: | |||
virtual void bitmap(const uint8_t* data, int x, int y, int width, int height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
src/ArduinoGraphics.cpp
Outdated
@@ -26,7 +26,9 @@ | |||
ArduinoGraphics::ArduinoGraphics(int width, int height) : | |||
_width(width), | |||
_height(height), | |||
_font(NULL) | |||
_font(NULL), | |||
_textsize_x(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_textsize_x(1), | |
_textSizeX(1), |
src/ArduinoGraphics.cpp
Outdated
_font(NULL) | ||
_font(NULL), | ||
_textsize_x(1), | ||
_textsize_y(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_textsize_y(1) | |
_textSizeY(1) |
examples/ASCIIDraw/ASCIIDraw.ino
Outdated
@@ -85,6 +86,7 @@ void setup() { | |||
ASCIIDraw.stroke('@', 0, 0); | |||
const char text[] = "ARDUINO"; | |||
ASCIIDraw.textFont(Font_5x7); | |||
ASCIIDraw.setTextSize(fontSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASCIIDraw.setTextSize(fontSize); | |
ASCIIDraw.textSize(fontSize); |
src/ArduinoGraphics.cpp
Outdated
// forward to scaled version | ||
scaledBitmap(data, x, y, width, height, 1, 1); | ||
} | ||
|
||
void ArduinoGraphics::scaledBitmap(const uint8_t* data, int x, int y, int w, int h, uint8_t scale_x, uint8_t scale_y) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// forward to scaled version | |
scaledBitmap(data, x, y, width, height, 1, 1); | |
} | |
void ArduinoGraphics::scaledBitmap(const uint8_t* data, int x, int y, int w, int h, uint8_t scale_x, uint8_t scale_y) { |
src/ArduinoGraphics.cpp
Outdated
_textsize_y = (sy > 0)? sy : 1; | ||
} | ||
|
||
|
||
void ArduinoGraphics::bitmap(const uint8_t* data, int x, int y, int width, int height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void ArduinoGraphics::bitmap(const uint8_t* data, int x, int y, int width, int height) | |
void ArduinoGraphics::bitmap(const uint8_t* data, int x, int y, int w, int h, uint8_t scale_x, uint8_t scale_y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I pushed up the changes that were requested.
First attempt forgot to update the example sketch.
Let me know if I missed anything.
Thank you for the changes! |
Memory usage change @ 7169c43
Click for full report table
Click for full report CSV
|
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
Pushed up changes and squashed all down to 1... |
Memory usage change @ 0ea3666
Click for full report table
Click for full report CSV
|
This hopefully addresses issue #3
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