Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Proportional Fonts for GLCDs + TrueType Converter
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Tue Nov 14, 2017 7:49 pm    Post subject: Reply with quote

Embarrassing, link is fixed now Smile

Thank you! I'm glad it works with one easy change without debugging Wink

The registers saved here are the ones needed by the font library, I've pushed them all to avoid conflicts with unknown Pixel-routines. If the Pixel routine doesn't use them or takes care of them itself, you could omit the register saving for speed reasons. Thank you for pointing this out, I'll add it to the wiki page!

br

edit: Quickly tested the update function, when starting V1.2, the update notification pops up about 1 sec later and update works aswell, maybe some firewall issue (it's a http request)?

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
daro

Bascom Member



Joined: 15 Nov 2010
Posts: 25

blank.gif
PostPosted: Wed May 29, 2019 8:45 pm    Post subject: Reply with quote

I have problem with this lib...no text is displayed on LCD SSD1963 900x400 and ATmega1280 (16MHz).

See on picture...should be ABCD1234, but ABCD is not displayed, only numbers like on picture....any suggestions?

I used this set pixel sub and font like attachement.

Code:
'-------------------------------------------------------------------------------
' Set Pixel
'-------------------------------------------------------------------------------
Sub Lcd_set_pixel(byval X1 As Word , Byval Y1 As Word , Byval Color As Word)
Rgb16_ssd1963 = Color : Temp_x_ssd1963 = X1 : Temp_y_ssd1963 = Y1
#if Portrait = 0
   Data_disp_low = &H2B
#else
   Data_disp_low = &H2A
#endif
Send_com                                                    '------ Y
Data_disp_low = Temp_y_ssd1963_h : Send_data
Data_disp_low = Temp_y_ssd1963_l : Send
#if Portrait = 0
   Data_disp_low = 1 : Send : Data_disp_low = &HDF : Send
#else
   Data_disp_low = 3 : Send : Data_disp_low = &H1F : Send
#endif
#if Portrait = 0
   Data_disp_low = &H2A
#else
   Data_disp_low = &H2B
#endif
Send_com                                                    '------ X
Data_disp_low = Temp_x_ssd1963_h : Send_data
Data_disp_low = Temp_x_ssd1963_l : Send
#if Portrait = 0
  Data_disp_low = 3 : Send : Data_disp_low = &H1F : Send
#else
  Data_disp_low = 1 : Send : Data_disp_low = &HDF : Send
#endif
Data_disp_low = &H2C : Send_com
Data_disp_high = Rgb16_ssd1963_high : Data_disp_low = Rgb16_ssd1963_low
Send_data
#if Portrait = 0
   Ssd1963_write_reg &H36 , Landscape_mode                  'Normal X/Y order
#else
   Ssd1963_write_reg &H36 , Portrait_mode
#endif
End Sub


After testing...Fonts where char have maximum 40px width are displayed correctly. So any char above 40pixels make error.
Another problem is then char "Space" " " don't clear a pixel data.
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Sat Jun 01, 2019 11:41 pm    Post subject: Reply with quote

The problem was the data size of some characters exceeded 256 bytes which was not handled correctly by the converter/library.
Although I do not have your font, I could recreate (and then solve) the problem using Arial Black 72pt.
The big font must be exportet again using the new version, existing older font files remain compatible.

New in Version 1.4
    * Added support for big character fonts (character data size > 256)
    * Small performance improvements


The FontConverter update function should work, download is on the wiki page.

When overwriting previous text, space characters (or any other character) don't work, because only the set pixels are drawn, background is left out intentionally (to write text over non-uniform backgrounds).
If you want to clear the area containing the text, you could use the function Lcd_tt_width("Text") to get the width of the text in pixels and then draw a rectangle over it, I've added a small example to the wiki page.

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
daro

Bascom Member



Joined: 15 Nov 2010
Posts: 25

blank.gif
PostPosted: Wed Apr 29, 2020 11:23 am    Post subject: Reply with quote

Thanks for new version, but I still have some problems in new LCD 4,3 inch. See pictures. A parts of letters are broken, and in other places.


Using library from this post: https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=12505&postdays=0&postorder=asc&start=0 (plus modify touch init and tests)
I place also all my codes for this lcd.

When i change font for Montserrat_20pt_b.inc (packed witch all source codes) is better, and broken letters is when 'o' 'i' 'h' is displayed. I don't understand why.


Can You see what is going wrong?
Back to top
View user's profile
daro

Bascom Member



Joined: 15 Nov 2010
Posts: 25

blank.gif
PostPosted: Thu Apr 30, 2020 12:34 pm    Post subject: Reply with quote

I observed then if is a problem, then problem is repeated with the same letters.
So if letter 'i' is broken then all 'i' letters is broken. If 'o' then always 'o' is broken, if '7' is boken thay all '7' become broken in all strings.
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Thu Apr 30, 2020 4:10 pm    Post subject: Reply with quote

Hello,

I did not found anything obvious, I will investigate further on the long weekend!

br

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Sat May 02, 2020 12:19 am    Post subject: Reply with quote

As a test, move that Font File to a different location in your program code.

For example:

Code:

$regfile xxx
$crystal ccc
$etc.

Goto jumpover
Include ffffonts
Jumpover:

'Rest of code
 


E
Back to top
View user's profile
daro

Bascom Member



Joined: 15 Nov 2010
Posts: 25

blank.gif
PostPosted: Sat May 02, 2020 9:12 am    Post subject: Reply with quote

This generate
Code:
 Error : 228   Line :   209   DATA line must be placed after the END statement  , in File : ...


What is strange to me, when I add some new codes, then other letters start to broken (previously broken are displayed ok), and if broken then always the same letters.
So is possible then is some problem with data alocation in memory.
Back to top
View user's profile
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Sat May 02, 2020 12:46 pm    Post subject: Reply with quote

Yes, that's what I was trying to fix.

The character pointer to the Font table is getting corrupted or is wrong Dimension.

Try to move the Font files to just after the Main Progam End statement.

E
Back to top
View user's profile
daro

Bascom Member



Joined: 15 Nov 2010
Posts: 25

blank.gif
PostPosted: Sat May 02, 2020 12:52 pm    Post subject: Reply with quote

I try this after Your first post, but no effect, still problem exist.
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Mon May 04, 2020 5:59 pm    Post subject: Reply with quote

small update:
we are also in contact per mail, we ruled out a 64K boundary crossing (and I fixed this bug already) and trashed registers by the pixel draw call.
I could not reproduce the error on my platform (Atxmega128A1 Xplained & ILI9341 320x240), daro is sending me his hardware (Mega2560 & SSD1963 800x480) to test further.

br

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
daro

Bascom Member



Joined: 15 Nov 2010
Posts: 25

blank.gif
PostPosted: Tue May 05, 2020 8:48 am    Post subject: Reply with quote

Yes, the package has already been packed and will leave today to You.

I change Your code only in main loop to display all chars:
Code:
   Call Lcd_clear(black)
   Lcd_tt_text "+,-./0123456789" , 1 , 1 , Red
   Lcd_tt_text "ABCDEFGHIJKLM" , 1 , 50 , Green
   Lcd_tt_text "NOPQRSTUVWXYZ" , 1 , 100 , Blue
   Lcd_tt_text "abcdefghijklmno" , 1 , 150 , White
   Lcd_tt_text "pqrstuvwxyz{|}~" , 1 , 200 , Gray
   Wait 2




Now 5, F, K, h is broken, but any new code change broken chars to other.
Back to top
View user's profile
daro

Bascom Member



Joined: 15 Nov 2010
Posts: 25

blank.gif
PostPosted: Wed May 13, 2020 8:12 am    Post subject: Reply with quote

I think then this is some problem with compiler, or ATmega2560. Temporary I start display numbers as BGC files.

I using that sub:
Code:
Sub Numbers_40px(byval Text_to_lcd As String , Byval X As Word , Byval Y As Word )       ' wyświetla dużą cyfrową czcionke
   Local Text As String * 16
   Local Txt As String * 1
   Local Position As Byte
   Local Length As Byte

   Length = Len(text_to_lcd)
   Text = Mid(text_to_lcd , 1 , Length)
   Length = Len(text)

   For Position = 1 To Length
      Txt = Mid(text , Position , 1)

      Select Case Txt
      Case "0" : Restore 0_32x40
      Case "1" : Restore 1_32x40
      Case "2" : Restore 2_32x40
      Case "3" : Restore 3_32x40
      Case "4" : Restore 4_32x40
      Case "5" : Restore 5_32x40
      Case "6" : Restore 6_32x40
      Case "7" : Restore 7_32x40
      Case "8" : Restore 8_32x40
      Case "9" : Restore 9_32x40
      Case " " : Restore Space_32x40
      Case "!"
         Restore Mbar_112x40
         X = X - 2
      End Select

      Call Lcd_show_bgc(x , Y )

      X = X + 34
   Next
End Sub


All pictures are saved in flash memory.
Code:
0_32x40:
$bgf "Montserrat_40px_b\0_32x40.bgc"
1_32x40:
$bgf "Montserrat_40px_b\1_32x40.bgc"
2_32x40:
$bgf "Montserrat_40px_b\2_32x40.bgc"
3_32x40:
$bgf "Montserrat_40px_b\3_32x40.bgc"
4_32x40:
$bgf "Montserrat_40px_b\4_32x40.bgc"
5_32x40:
$bgf "Montserrat_40px_b\5_32x40.bgc"
6_32x40:
$bgf "Montserrat_40px_b\6_32x40.bgc"
7_32x40:
$bgf "Montserrat_40px_b\7_32x40.bgc"
8_32x40:
$bgf "Montserrat_40px_b\8_32x40.bgc"
9_32x40:
$bgf "Montserrat_40px_b\9_32x40.bgc"


So when I add some other pictures or new code to flash memory then this picutures stop displayed correctly (for example number 7 is'n displayed correctly).

Same situation is with ProportionalFont. So new code or more pictures in flash (some move in memories) generate problems.
Back to top
View user's profile
mariosm

Bascom Member



Joined: 12 Oct 2005
Posts: 48
Location: Thessaloniki

greece.gif
PostPosted: Wed May 26, 2021 3:18 pm    Post subject: Reply with quote

I use a samble code for testing ST7735 128x160 color display.


Code:
$regfile = "m644pdef.dat"
$crystal = 20000000
$hwstack = 250
$swstack = 250
$framesize = 300
Config Graphlcd = Color , Cs1 = Porta.3 , Rst = Porta.4 , A0 = Porta.5 , Si = Porta.6 , Sclk = Porta.7
Cls
$include "ProportionalFont.inc"

Restore Timesnewroman_10pt
Lcd_tt_loadfont
Lcd_tt_text "ABCDEFGHIJKL" , 0 , 0 , &HFFFF
Wait 2

Lcd_tt_text "ABB1234567890" , 1 , 40 , &HFFFF
Wait 2

Lcd_tt_text " 12345678901234567890" , 1 , 60 , &HFFFF
Wait 2


 Do

Loop


$include "TimesNewRoman_10pt.inc"




This code have two errors after compiling .

Error : 97 Line : 42 SUB or FUNCTION must be DECLARED first [LCD_TT_LOADFONT] , in File : ProportionalFont.inc
Error : 93 Line : 46 Variable not dimensioned [___READRAMPZ] , in File : ProportionalFont.inc

Version of ProportionalFont.inc is 1.4

I don't know why ProportionalFont.inc don't work.

_________________
Bascom AVR ver 2.0.8.5 full version
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Wed May 26, 2021 5:19 pm    Post subject: Reply with quote

Hello,

you need to use
Code:
Config Submode = New
$include "ProportionalFont.inc"

or declare the subs before including:
Code:
Declare Sub Lcd_tt_loadfont()
Declare Sub Lcd_tt_text(byval Text As String * 50 , Byval X As Word , Byval Y As Word , Byval Forecolor As Word)
Declare Function Lcd_tt_textwidth(byval Text As String) As Word
$include "ProportionalFont.inc"


Then it boils down (up) to the ___readrampz-error and a bunch of errors from the Config Graphlcd= line.
I guess, since ___readrampz does indeed exist in the compiler report (which has been generated despite the errors?), this error might go away after the others have been fixed.

Do you have a working basic sample without using the proportional fonts library?

br

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum