News:

Let's find out together what makes a PIC Tick!

Main Menu

www.picgraphic.com

Started by trastikata, Nov 12, 2024, 10:44 PM

Previous topic - Next topic

Mapo

fantastic work trastikata

Stephen Moss

Quote from: trastikata on Nov 19, 2025, 07:35 PMI am not sure if the library is actually being used by other people, but here's a sneaky preview of the new Version 2 that I am working on
I have not had time to do much PIC stuff recently or anything requiring graphics to date, but if I do it looks like it could be very useful, nice work.

JonW

Great work, it takes such a long time to produce these kinds of tools. 

Craig

Beautiful Trastikata Well done!

basparky

Awesome work! many thanks for sharing!

trastikata

#85

Dog.png Bug.png

Sneaky preview ...

"Bug" picture (RGB565 BMP), stored in FLASH as HEX data is overlay on RGB565 BMP "dog" background printed from SD card with addition of some text and the bug is moved around while rotated and applied transparency layer and background blending.

This is done on a 8b MCU - PIC18F67K22  :). How the actual user code looks like without the underlying library code:

Proc LoopVertical()
    wTempX = wOldPositionW
    wTempY = wOldPositionH
    Select bOrientation
        Case 0,1,7
            While wTempY < wNewPositionH  
                SptBmpOverSpt(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                    'Print bug
                SptReadTft(wTempX,wTempY + bSpriteHeight, bSpriteWidth,1, BufferIn,0,0,0)   'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 0,0,1,1, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, 0,bSpriteHeight - 1, 0,0,0)                'Copy over first line from BufferIn to BufferBug
                Inc wTempY                                                                  'Increment Y coordinate
            Wend
        Case 3,4,5
            While wTempY > wNewPositionH
                SptBmpOverSpt180(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                 'Print bug
                SptReadTft(wTempX,wTempY - 1, bSpriteWidth,1, BufferIn,0,0,0)               'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 0,0,0,1, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, 0,0, 0,0,0)                                'Copy over first line from BufferIn to BufferBug
                Dec wTempY                                                                  'Increment Y coordinate
            Wend
    EndSelect
    wOldPositionH = wNewPositionH
EndProc

Proc LoopHorizontal()
    wTempX = wOldPositionW
    wTempY = wOldPositionH
    Select bOrientation
        Case 1,2,3
            While wTempX < wNewPositionW 
                SptBmpOverSpt270(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                 'Print bug
                SptReadTft(wTempX + bSpriteWidth,wTempY, 1,bSpriteHeight, BufferIn,0,0,0)   'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 1,1,0,0, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, bSpriteWidth - 1,0, 0,0,0)                 'Copy over first line from BufferIn to BufferBug
                Inc wTempX                                                                  'Increment X coordinate
            Wend
        Case 5,6,7
            While wTempX > wNewPositionW 
                SptBmpOverSpt90(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                  'Print bug
                SptReadTft(wTempX - 1,wTempY, 1,bSpriteHeight, BufferIn,0,0,0)              'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 0,1,0,0, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, 0,0, 0,0,0)                                'Copy over first line from BufferIn to BufferBug
                Dec wTempX                                                                  'Increment X coordinate
            Wend
    EndSelect
    wOldPositionW = wNewPositionW
EndProc   

trastikata

Hello all,

Just a quick note to let you know that TFT Graphic Library 2 is now available at:

www.picgraphic.com

I hope it will be useful to fellow Positron users.
 

top204

That coding is incredible Dyanko, and many thanks.

The web site is excellent, and I really like the images and videos and demo code listing.

Best regards
Les

Frizie

Must be a lot of work Dyanko!  :o
Ohm sweet Ohm | www.picbasic.nl

Craig

Really a Beautiful Job Dyanko many thanks!

Abdullah

Quote from: trastikata on Feb 08, 2026, 06:13 PM

Dog.png Bug.png

Sneaky preview ...

"Bug" picture (RGB565 BMP), stored in FLASH as HEX data is overlay on RGB565 BMP "dog" background printed from SD card with addition of some text and the bug is moved around while rotated and applied transparency layer and background blending.

This is done on a 8b MCU - PIC18F67K22  :). How the actual user code looks like without the underlying library code:

Proc LoopVertical()
    wTempX = wOldPositionW
    wTempY = wOldPositionH
    Select bOrientation
        Case 0,1,7
            While wTempY < wNewPositionH   
                SptBmpOverSpt(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                    'Print bug
                SptReadTft(wTempX,wTempY + bSpriteHeight, bSpriteWidth,1, BufferIn,0,0,0)   'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 0,0,1,1, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, 0,bSpriteHeight - 1, 0,0,0)                'Copy over first line from BufferIn to BufferBug
                Inc wTempY                                                                  'Increment Y coordinate
            Wend
        Case 3,4,5
            While wTempY > wNewPositionH
                SptBmpOverSpt180(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                 'Print bug
                SptReadTft(wTempX,wTempY - 1, bSpriteWidth,1, BufferIn,0,0,0)               'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 0,0,0,1, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, 0,0, 0,0,0)                                'Copy over first line from BufferIn to BufferBug
                Dec wTempY                                                                  'Increment Y coordinate
            Wend
    EndSelect
    wOldPositionH = wNewPositionH
EndProc

Proc LoopHorizontal()
    wTempX = wOldPositionW
    wTempY = wOldPositionH
    Select bOrientation
        Case 1,2,3
            While wTempX < wNewPositionW 
                SptBmpOverSpt270(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                 'Print bug
                SptReadTft(wTempX + bSpriteWidth,wTempY, 1,bSpriteHeight, BufferIn,0,0,0)   'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 1,1,0,0, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, bSpriteWidth - 1,0, 0,0,0)                 'Copy over first line from BufferIn to BufferBug
                Inc wTempX                                                                  'Increment X coordinate
            Wend
        Case 5,6,7
            While wTempX > wNewPositionW 
                SptBmpOverSpt90(Bug,BufferBug, wTempX,wTempY, 1,BLACK,0,9)                  'Print bug
                SptReadTft(wTempX - 1,wTempY, 1,bSpriteHeight, BufferIn,0,0,0)              'Copy next line to Spt BufferIn
                SptShiftOut(BufferBug, 0,1,0,0, BLACK)                                      'Shift out lower line in BufferBug
                SptMergeOver(BufferIn,BufferBug, 0,0, 0,0,0)                                'Copy over first line from BufferIn to BufferBug
                Dec wTempX                                                                  'Increment X coordinate
            Wend
    EndSelect
    wOldPositionW = wNewPositionW
EndProc   

Hello sir
It's very beautiful good luck
Abdullah

trastikata

#91
Here's a guide how to use the SD section only of the TFT Library:

The PIC TFT Library is a library for TFT screens and the SD support is only part of the Library. You can download the entire library from the link at the top of the home page here.

- After downloading and unzipping it, the main folder "TftLib" should be in the main project folder. You can remove the font files from the font folders to reduce the total folder size, but keep the folders because the set-up tool will complain if those are missing, however it will still work.

TFT_LIB_SD_SETUP2.jpg

- In the main folder "TftLib" you can find the set-up tool "TFT_Graphic_Lib.exe", start it.
-- select the type of MCU being used i.e. 8b or 16b
-- select which sections you'd like to use i.e. "SD Card"
-- select "FAT System" to FAT16/32
-- select the communication method i.e. hardware SPI (SPI1 or SPI2) or software SPI
-- fill the required pin fields

TFT_LIB_SD_SETUP1.jpg

This will generate the required includes, which you can copy and paste at the top of the program listing after the "Declare" statements.

TFT_LIB_SD_SETUP3.jpg

After that you can use it as you have used the original FileSys24, and this library version supports 8b MCU too - note that hardware SPI is supported only for the older 8b devices, adding HW SPI for the newer 8b devices is on the "to do list", until then you can use the SD part in Software SPI mode when used with newer 8b PICs.

At the Library website you can find help how to use each command with some explanation. Here's an example listing file.

SD_Demo.zip


Frizie

Very nice Trastikata!
What a lot of work this must have been.  :o
I do not use TFT screens (yet), but I am adding this to my Favorites.
Ohm sweet Ohm | www.picbasic.nl

trastikata

#93
New demo, showing 8-bit PIC and touch/mouse screen pointer with double click.

Video quality is low because I broke my camera tripod and had to look the camera and the screen at the same time, so I couldn't always hit the buttons :)


RGV250

Hi,
It looks great and I have a display project coming up so am going to download and have a go.
Is the display set up the same as the screen shots for the SD card.

Regards,
Bob

trastikata

Hi Bob,

can you elaborate what do you mean by "same set-up". If you can share some basic information about what you need in your project as visualization and what MCU and display you plan to use, I can give more specific guidelines what can and can't be done and some thoughts on design, at least the part relevant to visualization.

Kind regards.

RGV250

Hi,
By same setup I am referring to the screenshots in post 92 for SD card.
I am in the pub at the moment so no idea on which device but basically I would like to show the speed of my lathe.
The display interface will most likely be parallel and the device will be 18 series.
It will probably just have an arc and digital display.
It looks very comprehensive so I think it is just the initial configuration I an concerned about.

Regards,
Bob

trastikata

#97
Bob,

Here are few thoughts:

- First check if the intended TFT panel/module driver - com port combination is supported by the library in case you think of using it.
- Parallel interface displays are usually 320x480 size, if you need it for faster transfers - dedicated hardware SPI line is as fast as the parallel interface but saves a lot of MCU pins.
- 320x480 SPI panels exist but they are 18b RGB, which mean they are slower because software RGB666 to RGB565 conversion is needed for every pixel.
- Parallel interface would take one or two full 8b ports, unless a pin-mapped parallel port is emulated, which is much slower.
- So I'd recommend a dedicated hardware SPI port for the display - most MCU's have at least two hardware SPI ports. The library supports only SPI1 and SPI2 ports.
- Do you need touch screen function? Only resistive touch (most common and least expensive option) is supported.
- If you are thinking of displaying some information only and you don't need visual effects then you don't need high com speeds and some lag is OK.
- Just graphic layout, shapes + fonts require about 300-700 bytes of RAM. Additional library modules can add more to these requirements.

I'd suggest you start by determining first:

1. What type of information will be displayed
2. Fonts to be used - scaled up fonts don't look as good as true size fonts
3. How you would like to display information - do you need effects etc.
4. Do you need other library modules - touch function, SD card, FLASH memory storage
5. What TFT panel/module size you'd like to use
6. Depending on this I can advise on minimum pin/RAM/FLASH requirements for the MCU
7. From there and your main program requirements you can look for suitable MCU families and models.

RGV250

hi,
I am not having a lot of luck here,
The one I would like to use is an Open Smart 3.2" which uses HX8352B driver (not supported).
I then dug another one which I have no idea what driver it uses, it works with an Arduino library but it has a white line on it so faulty.
I then found an ITEAD ITDB02 2.8" which uses ILI9325D (not supported), this one is SPI.

Regards the questions,
1/ Just a graphical dial and digital value for lathe speed.
2/ It does not matter but a medium to large size.
3/ No effects.
4/ None needed.
5/ See above, I will probably have to find another type.
6/ Hopefully 18F25K20 or 22 depending on voltage.

I have other displays, I will have to have a tidy up to try to find them.

Regards,
Bob

RGV250

#99
Hi,
I have downloaded it and started to have a look, I am sure I have an ILI9341 somewhere so compiling for that.
I was a bit confused as the SD example below (post 92) says it should be installed in the main project folder, I have installed it in the Library folder
C:\Users\Bob\PDS\Library\TftLib which seems to work.

In the fonts example you have used PortC.5 for both MISO & MOSI, is this correct or does it matter if I declare separate pins.

I have cut most of the fonts out as it would not fit in the 18F25K20, in my first project I will only be using numbers so is there a way of only including numbers to save space or does it have to have the whole character set.

One suggestion for the site, I copied and pasted the Fonts example and it added extra lines in between the others when I pasted it. I wonder if the examples could be added to the downloads section or am I looking in the wrong place.

Regards,
Bob