Change to a new font

Description

Change current font to a different.

Fonts are stored in 4 places:

  1. 7 preloaded fonts saved in the MCU with code, the index numbers are:0,6,10,18,51,120,123
  2. 4 designated user fonts can be stored in MCU or Flash memory(if flash installed).The index numbers are:200,201,202,203
  3. Unlimited fonts can be stored in Flash memory at any address(if flash installed)
  4. Up to 254 fonts can be stored as files in Flash memory(if flash installed and firmware version is V7.0 and above)

Note:the structure of font's is u8g compatible, so can use all u8g fonts

Or use Digole font tool to build self fonts.

Usage:

Direct:

"SFn", for fonts in places 1 and 2
"SFFa", for fonts in place 3

"SFffile", for fonts in place 4

Arduino:

void setFont(uint8_t n); //use a internal font, availale: 0, 6,10,18,51,120,123, user font: 200-203

void setFlashFont(uint32_t a); //use a font in flash memory

void setFileFont(const char * file); //use a font file in flash memory(V7 only)

C:

void setFont(uint8_t n); //use a internal font, availale: 6,10,18,51,120,123, user font: 200-203

void setFlashFont(uint24_t a); //use a font in flash memory

void setFileFont(const char * file); //use a font file in flash memory(V7 only)

Parameters:

n

  The internal font's number. There are 7 preloaded fonts. The value are:0, 6, 10, 18, 51, 120, 123. Also can use the ASCII value of '0'~'6', so setFont(10) is same with setFont('2').

  The displays also provide some flash space for 4 designated user fonts: 3584B/per-font if no flash chip, or 12KB/per-font if has flash chip on board. The lower number of user font can take over the higher's space, this means the 200 user font can use 201,202,203's flash space.

  To use a designated user font, use number 200,201,202 and 203.

  To save designated user font data to display, use "SUF" command.

a

The font's address in flash memory chip. 3 bytes format, MSB first. Use "FLMWR" command to save font's data to anywhere in flash memory.

file

The font's file name in flash memory chip. Available in V7 firmware only. Use "fSAVE" command save font's data to mini-file system in flash memory.

Return:

none

Example (Arduino):

//use preloaded internal fonts
const unsigned char[] myfont={......}; //define a user font
mydisp.setFont
('3'); //use preloaded internal font:18
mydisp.setFont(18); //use preloaded internal font:18

//use designated user font
mydisp.downloadUserFont(sizeof(myfont), myfont, 200); //save font:myfont to designated user font's space
mydisp.setFont(200); //use the new font
mydisp.print("Hello you!");

//use font saved in flash memory
mydisp.flashWrite(10000,sizeof(myfont),myfont); //write myfont to address @10000 in flash memory
delay(1000);
mydisp.setFlashFont(10000); //use the font in flash memory @10000
mydisp.print("Hello you!");

//use font in a file in flash memory (V7 only)
mydisp.saveFile("myfont1",sizeof(myfont); //write myfont data to file name:myfont1
mydisp.setFileFont("myfont1"); //use the font file
mydisp.print("Hello you!"); //set cursor position to pixel(150,300)

Example(direct)

//use preloaded internal fonts
Serial.writeString("SF3"); //use preloaded internal font:18
Serial.writeString("TTHello you\x00"); //display: "Hello you" by using font 18

//use font saved in flash memory, font's data already save in flash @10000
Serial.writeString("SFF\x00\x27\x10"); //uint24_t 10000 is 0x00,0x27,0x10
Serial.writeString("TTHello you\x00"); //display: "Hello you" by using font 18

 

//use font in a file in flash memory, if font's file:myfont1 already saved (V7 only)
Serial.writeString
("SFfmyfont1 "); //use font file:myfont1
Serial.writeString
("TTHello you\x00"); //display: "Hello you" by using font 18
 
//more font's commands reffer to Arduino functions 

Changelog

Version Description
V7.0 "SFffile"use font in a file

See Also

Download designated user font

Save data to flash memory address

Save data to file in flash memory