From afa4c53ac0fd4895f40515822040e8a16ea0cf33 Mon Sep 17 00:00:00 2001 From: Jeremy Mayeres Date: Sat, 22 Jul 2023 14:06:28 +0200 Subject: [PATCH 1/2] Add font customization Fixes #36 --- adafruit_max7219/matrices.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/adafruit_max7219/matrices.py b/adafruit_max7219/matrices.py index 1c969dc..6778873 100644 --- a/adafruit_max7219/matrices.py +++ b/adafruit_max7219/matrices.py @@ -52,7 +52,15 @@ def init_display(self) -> None: self.fill(0) self.show() - def text(self, strg: str, xpos: int, ypos: int, bit_value: int = 1) -> None: + def text( + self, + strg: str, + xpos: int, + ypos: int, + bit_value: int = 1, + *, + font_name: str = "font5x8.bin" + ) -> None: """ Draw text in the 8x8 matrix. @@ -60,8 +68,9 @@ def text(self, strg: str, xpos: int, ypos: int, bit_value: int = 1) -> None: :param int xpos: x position of LED in matrix :param int ypos: y position of LED in matrix :param int bit_value: > 1 sets the text, otherwise resets + :param str font_name: path to binary font file (default: "font5x8.bin") """ - self.framebuf.text(strg, xpos, ypos, bit_value) + self.framebuf.text(strg, xpos, ypos, bit_value, font_name=font_name) def clear_all(self) -> None: """ From 193593c7a8b5707f646987f93a3f6a04016459a8 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 4 Sep 2023 15:29:13 -0500 Subject: [PATCH 2/2] add note about font can only set once --- adafruit_max7219/matrices.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_max7219/matrices.py b/adafruit_max7219/matrices.py index 6778873..3294688 100644 --- a/adafruit_max7219/matrices.py +++ b/adafruit_max7219/matrices.py @@ -68,7 +68,9 @@ def text( :param int xpos: x position of LED in matrix :param int ypos: y position of LED in matrix :param int bit_value: > 1 sets the text, otherwise resets - :param str font_name: path to binary font file (default: "font5x8.bin") + :param str font_name: path to binary font file (default: "font5x8.bin"). + The font can only be set once, if you want a different font you must + re-initialize the matrix. """ self.framebuf.text(strg, xpos, ypos, bit_value, font_name=font_name)