can you check this version with 7 fonts added ?
how to add fonts :
First, all fonts must be in directory : Arduino/libraries/Adafruit_GFX_Library/Fonts
*****************************************************************
after, to install fonts in wrapper, you have to modify rILI9488.h
*****************************************************************
below we have example for 7 fonts
=> here we have 7 fontsB4X://******************************************** //fonts addition Phase 1 => add one line #include for each font to add //fonts must be in "Arduino/libraries/Adafruit_GFX_Library/Fonts" directory //******************************************** #include <Fonts/FreeMono9pt7b.h> #include <Fonts/FreeSans9pt7b.h> #include <Fonts/FreeSerif9pt7b.h> #include <Fonts/FreeMonoBold9pt7b.h> #include <Fonts/FreeMonoBoldOblique9pt7b.h> #include <Fonts/FreeMonoOblique9pt7b.h> #include <Fonts/FreeSansBold9pt7b.h> //********************************************
=> we have to indicate number of fonts in first line and name of each font afterB4X://**************************************************** //fonts addition Phase 2 => add each font in an array //**************************************************** const GFXfont * myfonts[7]= { // number of fonts &FreeMono9pt7b, // => setfont(00) &FreeSans9pt7b, // => setfont(01) &FreeSerif9pt7b, // => setfont(02) &FreeMonoBold9pt7b, // => setfont(03) &FreeMonoBoldOblique9pt7b, // => setfont(04) &FreeMonoOblique9pt7b, // => setfont(05) &FreeSansBold9pt7b // => setfont(06) }; //****************************************************
=> we have also to indicate fonts for B4R interfaceB4X://******************************************** //fonts addition Phase 3 => a #define is added for each font available on B4R interface //******************************************** #define /*byte FreeMono9pt7b;*/ BAR_FreeMono9pt7b 00 // setfont(tft.FreeMono9pt7b) <=> setfont(00) #define /*byte FreeSans9pt7b;*/ BAR_FreeSans9pt7b 01 // setfont(tft.FreeSans9pt7b) <=> setfont(01) #define /*byte FreeSerif9pt7b;*/ BAR_FreeSerif9pt7b 02 // setfont(tft.FreeSerif9pt7b) <=> setfont(02) #define /*byte FreeMonoBold9pt7b;*/ BAR_FreeMonoBold9pt7b 03 // setfont(tft.FreeMonoBold9pt7b) <=> setfont(03) #define /*byte FreeMonoBoldOblique9pt7b;*/ BAR_FreeMonoBoldOblique9pt7b 04 // setfont(tft.FreeMonoBoldOblique9pt7b) <=> setfont(04) #define /*byte FreeMonoOblique9pt7b;*/ BAR_FreeMonoOblique9pt7b 05 // setfont(tft.FreeMonoOblique9pt7b) <=> setfont(05) #define /*byte FreeSansBold9pt7b;*/ BAR_FreeSansBold9pt7b 06 // setfont(tft.FreeSansBold9pt7b) <=> setfont(06) //********************************************
***************************************************************
at end of rILI9488.xml, we have to add fonts for B4R interface
***************************************************************
here we have configuration in rILI9488.xml for 7 fonts
B4X:<field> <name DefineMethod="true" DesignerName="FreeMono9pt7b">BAR_FreeMono9pt7b</name> <returntype>byte</returntype> </field> <field> <name DefineMethod="true" DesignerName="FreeSans9pt7b">BAR_FreeSans9pt7b</name> <returntype>byte</returntype> </field> <field> <name DefineMethod="true" DesignerName="FreeSerif9pt7b">BAR_FreeSerif9pt7b</name> <returntype>byte</returntype> </field> <field> <name DefineMethod="true" DesignerName="FreeMonoBold9pt7b">BAR_FreeMonoBold9pt7b</name> <returntype>byte</returntype> </field> <field> <name DefineMethod="true" DesignerName="FreeMonoBoldOblique9pt7b">BAR_FreeMonoBoldOblique9pt7b</name> <returntype>byte</returntype> </field> <field> <name DefineMethod="true" DesignerName="FreeMonoOblique9pt7b">BAR_FreeMonoOblique9pt7b</name> <returntype>byte</returntype> </field> <field> <name DefineMethod="true" DesignerName="FreeSansBold9pt7b">BAR_FreeSansBold9pt7b</name> <returntype>byte</returntype> </field>
#if C
#define fonts true
#include <Fonts/FreeMono9pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSerif9pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBoldOblique9pt7b.h>
#include <Fonts/FreeMonoOblique9pt7b.h>
#include <Fonts/FreeSansBold9pt7b.h>
const GFXfont * B4R::B4RILI9488::myfonts[7]= {
&FreeMono9pt7b, // => setfont(00)
&FreeSans9pt7b, // => setfont(01)
&FreeSerif9pt7b, // => setfont(02)
&FreeMonoBold9pt7b, // => setfont(03)
&FreeMonoBoldOblique9pt7b, // => setfont(04)
&FreeMonoOblique9pt7b, // => setfont(05)
&FreeSansBold9pt7b // => setfont(06)
};
#End If
tft.begin
tft.setTextSize(4)
tft.setTextColor(tft.ILI9488_CYAN)
tft.setFont(00)
tft.println("Font 0")
Delay(2000)
tft.setFont(01)
tft.println("Font 1")
Delay(2000)
tft.setFont(02)
tft.println("Font 2")
Delay(2000)
tft.setFont(03)
tft.println("Font 3")
Delay(2000)
tft.setFont(04)
tft.println("Font 4")
Delay(2000)
tft.setFont(05)
tft.println("Font 5")
Delay(2000)
tft.setFont(06)
tft.println("Font 6")
Delay(2000)
Hican you share inline C added ?
if pointer to font is "nullptr" or if "fonts"is "not define", nothing is done.
and can you make tests with wrapper below? some traces are added on "setfont" function
#if C
#define fonts true
#include <Fonts/FreeMono9pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSerif9pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBoldOblique9pt7b.h>
#include <Fonts/FreeMonoOblique9pt7b.h>
#include <Fonts/FreeSansBold9pt7b.h>
const GFXfont * B4R::B4RILI9488::myfonts[7]= {
&FreeMono9pt7b, // => setfont(00)
&FreeSans9pt7b, // => setfont(01)
&FreeSerif9pt7b, // => setfont(02)
&FreeMonoBold9pt7b, // => setfont(03)
&FreeMonoBoldOblique9pt7b, // => setfont(04)
&FreeMonoOblique9pt7b, // => setfont(05)
&FreeSansBold9pt7b // => setfont(06)
};
#End If
DEBUG StatusLogger Stopped XmlConfiguration[location=jar:file:/C:/Program%20Files%20(x86)/Arduino/lib/pde.jar!/log4j2.xml] OK
DEBUG StatusLogger Stopped LoggerContext[name=1e6f5c3, org.apache.logging.log4j.core.LoggerContext@1f72f5] with status true
********************* PROGRAM STARTING ****************
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
AppStart
ILI9488 Test!
start_setfont
start_setfont
start_setfont
start_setfont
start_setfont
start_setfont
start_setfont
Display Power Mode: 0x0000
MADCTL Mode: 0x0000
Pixel Format: 0x0000
Image Format: 0x0000
Self Diagnostic: 0x0000
Benchmark Time16208558
Screen fill 2942685
Text 80377
Lines 1563034
Horiz/Vert Lines 239447
Rectangles (outline) 2676
Rectangles (filled) 7173729
Circles (filled) 716216
Circles (outline) 669131
Triangles (outline) 310397
Triangles (filled) 2303285
Rounded rects (outline) 281104
Rounded rects (filled) 7126844
Done!
#if C
#define fonts true
#include <Fonts/FreeMono9pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSerif9pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBoldOblique9pt7b.h>
#include <Fonts/FreeMonoOblique9pt7b.h>
#include <Fonts/FreeSansBold9pt7b.h>
const GFXfont * B4R::B4RILI9488::myfonts[7]= {
&FreeMono9pt7b, // => setfont(00)
&FreeSans9pt7b, // => setfont(01)
&FreeSerif9pt7b, // => setfont(02)
&FreeMonoBold9pt7b, // => setfont(03)
&FreeMonoBoldOblique9pt7b, // => setfont(04)
&FreeMonoOblique9pt7b, // => setfont(05)
&FreeSansBold9pt7b // => setfont(06) };
#End If
#if C
#include <Fonts/FreeMono9pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSerif9pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBoldOblique9pt7b.h>
#include <Fonts/FreeMonoOblique9pt7b.h>
#include <Fonts/FreeSansBold9pt7b.h>
const GFXfont * B4R::B4RILI9488::myfonts[7]= {
&FreeMono9pt7b, // => setfont(00)
&FreeSans9pt7b, // => setfont(01)
&FreeSerif9pt7b, // => setfont(02)
&FreeMonoBold9pt7b, // => setfont(03)
&FreeMonoBoldOblique9pt7b, // => setfont(04)
&FreeMonoOblique9pt7b, // => setfont(05)
&FreeSansBold9pt7b // => setfont(06)
};
#End If
Hican you test wrapper attached with inline C below ? it should work with font 00<06
please to make setfont() only on existing fonts or you will have crash...
B4X:#if C #include <Fonts/FreeMono9pt7b.h> #include <Fonts/FreeSans9pt7b.h> #include <Fonts/FreeSerif9pt7b.h> #include <Fonts/FreeMonoBold9pt7b.h> #include <Fonts/FreeMonoBoldOblique9pt7b.h> #include <Fonts/FreeMonoOblique9pt7b.h> #include <Fonts/FreeSansBold9pt7b.h> const GFXfont * B4R::B4RILI9488::myfonts[7]= { &FreeMono9pt7b, // => setfont(00) &FreeSans9pt7b, // => setfont(01) &FreeSerif9pt7b, // => setfont(02) &FreeMonoBold9pt7b, // => setfont(03) &FreeMonoBoldOblique9pt7b, // => setfont(04) &FreeMonoOblique9pt7b, // => setfont(05) &FreeSansBold9pt7b // => setfont(06) }; #End If
HiHi
I have tried the above and all seems great! I have substituted other fonts and all seems ok.
I must thank you very much for your help. I could not have done it myself.
Thanks
Len
tft.begin
tft.setTextColor(tft.ILI9488_WHITE)
tft.fillScreen(tft.ILI9488_BLACK)
tft.setFont(5)
tft.setTextColor(tft.ILI9488_RED)
tft.setTextSize(2)
Dim n As UInt
Do Until n=1350
n=n+1
tft.drawRect(49,4,202,87,tft.ILI9488_WHITE)
tft.fillRect(50,5,200,85,tft.ILI9488_BLACK)
tft.setCursor(50,80)
tft.print(n)
Log(n)
Delay(400)
Loop
Log("Cont")
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
Do Until n=1350
n=n+1
callsubplus("printvalue",400,0)
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
Loop
sub printvalue
tft.drawRect(49,4,202,87,tft.ILI9488_WHITE)
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
tft.fillRect(50,5,200,85,tft.ILI9488_BLACK)
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
tft.setCursor(50,80
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM))
tft.print(n)
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
Log(n)
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
end sub
Hican you add line below at several points of your project, just to see where buffer is increasing ?
before and after "setfont"
and after each line in the loop
also, can you make same test with an other font ? or only with standard font ? (to check if issue is due to new font.)B4X:Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
on my part, i will clean wrapper to remove all traces added on "setfont()"[/code]
GFXfont found / Ptr: 1061165796
buffer: 0memory: 367724
buffer: 0memory: 367724
buffer: 0memory: 367724
buffer: 0memory: 367724
buffer: 0memory: 367724
buffer: 0memory: 367724
buffer: 0memory: 367724
buffer: 0memory: 367724
before tft.print(n)
buffer: 0memory: 367724
after tft.print(n)
buffer: 10memory: 367724
1
buffer: 10memory: 367724
buffer: 10memory: 367724
buffer: 10memory: 367724
buffer: 10memory: 367724
buffer: 10memory: 367724
before tft.print(n)
buffer: 10memory: 367724
after tft.print(n)
buffer: 22memory: 367724
2
buffer: 22memory: 367724
buffer: 22memory: 367724
buffer: 22memory: 367724
buffer: 22memory: 367724
buffer: 22memory: 367724
before tft.print(n)
buffer: 22memory: 367724
after tft.print(n)
buffer: 34memory: 367724
3
buffer: 34memory: 367724
buffer: 34memory: 367724
buffer: 34memory: 367724
buffer: 34memory: 367724
buffer: 34memory: 367724
before tft.print(n)
buffer: 34memory: 367724
after tft.print(n)
If I just put the printing code in a sub and then call sub it does not work. You have to call the sub with ato use "tft.print" in a sub will avoid buffer issue.
tft.begin
tft.setTextColor(tft.ILI9488_WHITE)
tft.fillScreen(tft.ILI9488_BLACK)
tft.setTextColor(tft.ILI9488_WHITE)
tft.fillScreen(tft.ILI9488_BLACK)
tft.setFont(5)
tft.setTextColor(tft.ILI9488_RED)
tft.setTextSize(2)
Dim n As UInt
Do Until n=1350
n=n+1
num=n
tft.drawRect(49,4,202,87,tft.ILI9488_WHITE)
tft.fillRect(50,5,200,85,tft.ILI9488_BLACK)
tft.setCursor(50,80)
tft.print("*") 'Sending a string is OK
PrintToTft(n)
'tft.print(n) 'Sending a byte or Uint causes the problem
Log(n)
Log("buffer: ",StackBufferUsage, "memory: ",AvailableRAM)
Delay(400)
Loop
Log("Cont")
End Sub
Sub PrintToTft(TxtNum As UInt) 'Print(txt as String)' Requests a string
'******** Defining TxtNum as Uint where 'print() requests a string 'print(txt as String) As Uint'
Dim testnum As UInt=TxtNum
tft.print(testnum) 'works fine
tft.print(num) 'printing a Global Uint in sub is OK
tft.print(TxtNum) 'print(txt as String) As Uint
End Sub
Sub lLoop
Dim rotation As Byte
For rotation = 0 To 3 '<4
tft.setRotation(rotation)
testText
Delay(1000)
Next
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?