Just wondering if there are any other fonts that can be used directly with the Arduino_H7_Video class other than the 4x6 or 5x7 which look Real small on these displays
So far, I have not found any... Could probably create some.
But in the meantime, I made a sub-class of Arduino_H7_Video, that added
a couple of logical methods for the text method, that allows the selected font
to be scaled. Like the Adafruit system allows for the system font.
Would be nice if ArduinoGraphics had it built in...
I currently have it as part of my Picture viewer sketch I mentioned in the post:
Where in the sketch I now have:
Display.beginDraw();
fillScreen(0, 0, 0xff, false);
Display.textFont(Font_5x7);
Display.textSize(5, 5);
Display.stroke(0xff, 0, 0);
Display.background(0, 0, 0xff);
Display.text("Waiting for SD or USB", 0, 0);
Display.endDraw();
The only really needed method is textSize... or could be textScaled or ...
The ::text(...) method was updated, for the increments, like:
if (c == '\n') {
y += _font->height * _yTextScale;
And I have it if the scales are not 1, call off to new method: scaledBitmap:
void Arduino_H7_Video_Plus::scaledBitmap(const uint8_t* data, int x, int y, int w, int h) {
if (!_stroke || !_xTextScale || !_yTextScale) {
return;
}
if ((data == nullptr) || ((x + (w * _xTextScale) < 0)) || ((y + (h * _yTextScale) < 0)) || (x > width()) || (y > height())) {
// offscreen
return;
}
int xStart = x;
for (int j = 0; j < h; j++) {
uint8_t b = data[j];
for (uint8_t ys = 0; ys < _yTextScale; 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 < _xTextScale; xs++) set(x++, y, _strokeR, _strokeG, _strokeB);
} else {
for (uint8_t xs = 0; xs < _xTextScale; xs++) set(x++, y, _backgroundR, _backgroundG, _backgroundB);
}
if (x >= width()) break;
}
y++;
}
}
}
Not pretty, but mostly works.
Also trying to figure out how to not have each write clear the rest of the screen.
I see that the beginWrite() does a dsi_lcdClear(0);
So makes sense that it clears.
and endDraw() does a dsi_drawCurrentFrameBuffer();
Which does the output. Looks like it keeps the same background color, but the other
line of text is cleared...
Now back to playing
Edit: I believe this is related to the issue opened like 5 years ago:
Add API to set font size · Issue #3 · arduino-libraries/ArduinoGraphics (github.com)
For what it is worth, I created a Pull request with code to allow you
to set the text scale size to use with the specified font:
Here is the output from the libraries only example, where I told it to
upsize the font to 3...
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+---------------------------------------------------------------------------------------------------------------------------------+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+-*****+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*****-+
+-*****+OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO+*****-+
+-*****+OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO+*****-+
+-*****+OOOOO @@@@@@ @@@@@@@@@ @@@@@@@@@ @@@ @@@ @@@@@@@@@ @@@ @@@ @@@@@@ OOOOO+*****-+
+-*****+OOOOO @@@@@@ @@@@@@@@@ @@@@@@@@@ @@@ @@@ @@@@@@@@@ @@@ @@@ @@@@@@ OOOOO+*****-+
+-*****+OOOOO @@@@@@ @@@@@@@@@ @@@@@@@@@ @@@ @@@ @@@@@@@@@ @@@ @@@ @@@@@@ OOOOO+*****-+
+-*****+OOOOO@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@ @@@ @@@ @@@ OOOOO+*****-+
+-*****+OOOOO@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@ @@@ @@@ @@@ OOOOO+*****-+
+-*****+OOOOO@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @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OOO----+-----------------------------------------------------------------------------------------------+----OOOOO+*****-+
+-*****+OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO+*****-+
+-*****+OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO+*****-+
+-*****+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*****-+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+-*******************************************************************************************************************************-+
+---------------------------------------------------------------------------------------------------------------------------------+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Not very exciting.
But not really sure how well any of this stuff works with the current
Arduino_H7_Video library.
In particular how one is supposed to use any of the graphic primitives in relationship with the beginDraw/endDraw.
As I mentioned in the previous post, the beginDraw appears to clear the complete contents of your frame buffer.
For example suppose here is my example sketch:
#include <elapsedMillis.h>
#include "Arduino_H7_Video.h"
#include "ArduinoGraphics.h"
REDIRECT_STDOUT_TO(Serial)
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
void fillScreen(uint8_t r, uint8_t g, uint8_t b, bool begin_end = true) {
if (begin_end) Display.beginDraw();
//Display.background(r, g, b);
for (int y = 0; y < Display.height(); y++) {
for (int x = 0; x < Display.width(); x++) {
Display.set(x, y, r, g, b);
}
}
if (begin_end) Display.endDraw();
}
//****************************************************************************
// Setup
//****************************************************************************
void setup(void) {
Serial.begin(115200);
while (!Serial && millis() < 3000)
Serial.println("*** start up display ***");
Display.begin();
//tft.setRotation(1);
fillScreen(0xff, 0, 0, true); // experiment going direct
//tft.fillScreen(RED);
delay(500);
fillScreen(0, 0xff, 0, true);
//tft.fillScreen(GREEN);
delay(500);
fillScreen(0, 0, 0xff, true);
//tft.fillScreen(BLUE);
delay(500);
Display.beginDraw();
fillScreen(0, 0, 0xff, false);
Display.textFont(Font_5x7);
//Display.textSize(5, 5);
Display.setTextSize(5);
Display.stroke(0xff, 0, 0);
Display.background(0, 0, 0xff);
Display.text("Waiting for SD or USB", 0, 0);
Display.endDraw();
delay(2000);
//Display.beginDraw();
Display.text("SD Started", 100, 100);
Display.endDraw();
delay(2000);
// Display.beginDraw();
Display.text("USB Started", 100, 200);
Display.endDraw();
delay(2000);
fillScreen(0xff, 0, 0, true);
Display.beginText(100, 300);
Display.print("Here is some Text");
Display.textScrollSpeed(100);
Display.endText(SCROLL_LEFT);
}
void loop() {
}
After it goes through cycle showing Red, Green and then Blue screens,
It draws a text line: Waiting for SD or USB
I then wait some time and display a second message: SD Started
If I call beginDraw before this, it shows up as the only thing on screen
with black background. If I don't call beginDraw, it shows the whole screen in Blue with only this new text.
If then wait some more time and draw the text: USB Started.
Again if I have beginDraw called, only it shows up with Black background,
BUT if I don't call beginDraw, the screen is in Blue, and it also shows
the first line of text but not the second?
And with the Scrolling text, each time the delay happens in the call for endText it does
if (scrollDirection == SCROLL_LEFT) {
int scrollLength = _textBuffer.length() * textFontWidth() + _textX;
for (int i = 0; i < scrollLength; i++) {
beginDraw();
int const text_x = _textX - i;
text(_textBuffer, text_x, _textY);
scaledBitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height, _textsize_x, _textsize_y);
endDraw();
delay(_textScrollSpeed);
}
So each delay it clears the entire display.
Wondering if I should create an issue against? Probably the Arduino_H7_library?
@ptillisch or others suggestions?