Giter Club home page Giter Club logo

Comments (8)

Bodmer avatar Bodmer commented on August 13, 2024

The library supports the Adafruit free font format. Linux tools for this are in the fontconvert folder. I have not used these tools myself, they were created by Adafruit.
The library also includes Run Length ~Encoded fonts but these are difficult to create so it is best to stick with the Adafruit freefont style.

from tft_hx8357.

rafik73github avatar rafik73github commented on August 13, 2024

OK. Display the digit timer when using the enlarged font (tft.setTextFont(6); tft.setTextSize(1);), the text blinks. Is it normal?

from tft_hx8357.

rafik73github avatar rafik73github commented on August 13, 2024

This is my code:

#include <TFT_HX8357.h> // Hardware-specific library
TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library

int m=0;
int s=45;
int timerstat = 1;

void setup()
{

// Setup the LCD
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK); // Clear screen to black background
tft.setTextColor(TFT_GREEN,TFT_BLACK); //green
tft.setTextFont(8);
tft.setTextSize(2);
}

void timer()
{
if(m == 0 && s == 0) {timerstat = 0;}
if(timerstat == 0) //----------------------------------uptime
{
tft.setTextColor(TFT_RED,TFT_BLACK); //red
//delay(225);
s++;
if(s > 59)
{
m++;
s=0;
}
}
else //---------------------------------------------downtime
{
if(m == 0 && s < 31) // blink when 30 sec left...
{

tft.setTextColor(TFT_YELLOW,TFT_BLACK); //yellow

//delay(225);

s--;
if(s < 0)
{
m--;
s=59;
}

}
else
{
tft.setTextColor(TFT_GREEN,TFT_BLACK); //green
//delay(225);
s--;
if(s < 0)
{
m--;
s=59;
}
}
}
} // end void timer

void timerDisplay()
{
int m1 , m2 ,s1 , s2;
if (m > 9) {
m1 = (m - (m % 10)) / 10;
} else {
m1 = 0;
}
m2 = m % 10;

if (s > 9) {
s1 = (s - (s % 10)) / 10;
 } else {
s1 = 0;

}
s2 = s % 10;

tft.drawNumber(m1,5,70,8);

tft.drawNumber(m2,113,70,8);

tft.drawNumber(s1,253,70,8);

tft.drawNumber(s2,366,70,8);

} // end void timerDisplay

void loop()
{
timerDisplay();
timer();
delay(1000);
//tft.fillScreen(TFT_BLACK);
}

from tft_hx8357.

Bodmer avatar Bodmer commented on August 13, 2024

Yes, it is normal when a scaled font (x2 in this case) is used as there are so many pixels to draw and the character is blanked first.

The effect can be made less visually intrusive by only drawing characters when they change. For example declare global variables:

int om1 = 99, om2 = 99,os1 = 99;

Then is the code use a conditional test like this:
s2 = s % 10;
if (m1 != om1) tft.drawNumber(m1,5,70,8);
om1 = m1;
if (m2 != om2) tft.drawNumber(m2,113,70,8);
om2 = m2;
if (s1 != os1) tft.drawNumber(s1,253,70,8);
os1 = s1;
tft.drawNumber(s2,366,70,8);

You will also have to add conditional code when the colour changes too using the same approach, but these changes will let you see the improvement.

from tft_hx8357.

rafik73github avatar rafik73github commented on August 13, 2024

Thank you for your help. I tried to convert large font, but I can not deal with it. I do this on Fedora 23. I used the description on this page:
https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts.
But it does not work. I installed GNU and Freetype, type a command fontconvert parameters and displays a "command not found".

from tft_hx8357.

rafik73github avatar rafik73github commented on August 13, 2024

How to display a bitmap? I try this:
http://javl.github.io/image2cpp/
and my code:
const unsigned char myBitmap [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff,
0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x9f, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x0f, 0xf9, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x1f, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x3f, 0xe1, 0xff, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x7f, 0xc1, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf8, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x01, 0xff,
0x81, 0xff, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x01,
0xff, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x01, 0xff,
0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x01, 0xff, 0x00,
0x00, 0x00, 0x03, 0xfe, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x7f, 0xe0, 0x01, 0xff, 0x00, 0x00,
0x00, 0x07, 0xfc, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0xff, 0x80, 0x01, 0xff, 0x00, 0x00, 0x00,
0x1f, 0xf8, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x03, 0xff, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0xff, 0xc0,
0x00, 0x1f, 0xf0, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x01, 0xff, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00,
0x1f, 0xf0, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x01, 0xff, 0x00, 0x00, 0x07, 0xfe, 0x00, 0x00, 0x1f,
0xf0, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x01, 0xff, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x1f, 0xf0,
0x00, 0x01, 0xff, 0x80, 0x00, 0x01, 0xff, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x1f, 0xf0, 0x00,
0x03, 0xfe, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
void setup()
{
tft.drawBitmap(0,0,myBitmap,60,80,TFT_YELLOW);
}

displays artifacts and not graphics.

source image:
maybe.zip

from tft_hx8357.

Bodmer avatar Bodmer commented on August 13, 2024

The bitmap function in the library expects the bitmap array to be byte aligned, i.e a multiple of 8 bits wide to be compatible with the Adafruit_GFX library.

If you try this you will see that the bitmap is otherwise OK:

tft.drawBitmap(0,0,myBitmap,120,40,TFT_YELLOW);

120 is divisible by 8 so it works but you get two 4's side by side as each bitmap is actually 60 pixels wide.
You will have to write a new function if you wish the bitmap to be an arbitrary number of bits wide.

from tft_hx8357.

rafik73github avatar rafik73github commented on August 13, 2024

Thank you for help.I'll try this.

from tft_hx8357.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.