adafruit / micropython-adafruit-bitmap-font

Text rendering module to write messages with simple bitmap fonts on any pixel-based display.
MIT License
34 stars 8 forks source link

MicroPython text font & printing support for Adafruit Feather ESP8266 & FeatherWing ILI9341 TFT combo #2

Closed randmor closed 5 years ago

randmor commented 7 years ago

Hi Tony.

I seem to recall in one of your videos you referred us here for text graphic support for the FeatherWing ILI9341 TFT Board. While there are examples for LED matix displays, I don't see something for the 240x320 pixel FeatherWing TFT display. Are you planning to do a port? Or are you leaving this for to us to figure out?

randmor commented 7 years ago

Trying to zero in on the problem. Seems we need to write a "display_pixel(x,y, color)" function for the ILI9341 TFT display. Piecing the story together from what Tony writes here:

https://cdn-learn.adafruit.com/downloads/pdf/micropython-displays-drawing-text.pdf

we should be able to code the rest of it up as follows:

import machine spi = machine.SPI(1, baudrate=32000000)

import ili9341 display = ili9341.ILI9341(spi, cs=machine.Pin(0), dc=machine.Pin(15)) display.fill(0) # Clear screen by filling it with black pixels.

def display_pixel(x,y,color): # This is the function that has to be developed. #

#

import bitmapfont bf = bitmapfont.BitmapFont(240, 320, display_pixel) bf.init() bf.text('Hello, World!', 0, 0, ili9341.color565(255,0,255)) # Print 'Hello, World!' in magenta bf.deinit()

randmor commented 7 years ago

Well, seems using GitHub is another learning curve I'll need to conquer.

gampam2000 commented 7 years ago

You need only convert the color. The following did work for me:


def ili_pixel(x,y,color):
    display.pixel(x,y,ili9341.color565(color[0], color[1], color[2]))

import bitmapfont
bf = bitmapfont.BitmapFont(240, 320, ili_pixel)
bf.init()
bf.text('Test Test Test', 0, 0, (255, 0, 255))
peterowcarz commented 6 years ago

Hello Guys, I have same problem as @randmor . I try @gampam2000 code and still have issue with display text on my lcd.

`import machine import ili9341 import gfx import bitmapfont import rgb import rgb_text

spi = machine.SPI(1, baudrate=32000000) display = ili9341.ILI9341(spi, cs=machine.Pin(4), dc=machine.Pin(5))

color = [255,255,0] display.fill(0)

display.fill_rectangle(10, 10, 100, 100, ili9341.color565(255,255,0))

def ili_pixel(x,y,color): display.pixel(x,y,ili9341.color565(color[0], color[1], color[2]))

color = [255,255,0]

bf = bitmapfont.BitmapFont(240, 320, ili_pixel) bf.init() bf.draw_char('Test Test Test', 0, 0, color)`

What can i do to repair tihs?

ladyada commented 5 years ago

hiya, we'll be archiving this repo, we're not supporting micropython code.

we've integrated a bunch of this font stuff into our soft framebuf implementation for circuitpython https://github.com/adafruit/Adafruit_CircuitPython_framebuf

we will be adding ili9341 support to circuitpython's displayio via https://github.com/adafruit/Adafruit_CircuitPython_BitmapFont