PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33
Started by LeonJ, Feb 21, 2021, 01:58 PM
$define ST7735_PrintChar(pChar) ' WREG = pChar ' _ST7735_PrintChar()#ifSym __SYSCOM_GLCD_PRINT_REQ_ ' Has the compiler's Print command been used in the main program?__Print_:Sub _ST7735_PrintChar() ST_bSaveChar = WREG ' Save the character value ST_wSaveTblPtr = ST_wTblPtr ' Save the contents of TBLPTRL\H'' Locate the character's image data from flash memory tables'WREG = ST_bSaveChar ' Leonj added this. It now prints the correct characters. WREG = WREG - 32 ' Remove the ASCII offset WREG = WREG * 2 ' Offsets are 2 bytes each (words)
QuoteIf you only have a font creator that produces Y axis font data, rotate the window that is needed before the font is sent to the display and the pixels will move in the Y direction within it for every write of a pixels. Then send the command to rotate it back when the character is printed. This also helps if the whole display is rotated in use, because the font will always remain in the correct orientation to it. With a brief look at the ST7565R datasheet, it seems to be pixel writes instead of byte writes, so it should have a window mechanism.See this article I created and it may give you some clues to creating a library for graphic LCDs. It also has a font generator link within it. proton-experimenters-notebook/st7735-160x128-graphic-lcd-libraryThe problem with a lot of graphic LCD libraries is that they do not state, exactly, what Font Generator was used to create the bitmap images in flash memory of the characters, or the library code is quite old, so the font generator has long been removed from sites. This has been a problem from day one of graphic LCDs being available for users. :-) That is why I "never" trust the internet and whenever possible download full sites and store them on external drives, so even when the user who created items cannot be bothered to maintian and keep them, I still have them! This has come in very handy many times in the past. Just look at this site and there are so many files that have been removed or mishandled so they are now gone, which is such a shame. :-(
Movffl TBLPTRL, ST_wSaveTblPtr ' Save the contents of TBLPTRL Movffl TBLPTRH, ST_wSaveTblPtrH ' Save the contents of TBLPTRH
Quote from: top204 on Feb 22, 2021, 03:16 PMI had forgotten about the 18FxxK42 devices that have their SFRs above the address 4095, so the compiler uses a smaller method of access to them instead of the Movffl mnemonic whenever possible, because Movffl takes more clock cyles and more flash memory usage. In the smaller RAM devices, the compiler uses the Movff mnemonic which does not disturb the WREG or any of the STATUS flags. However, the compiler's method to counter-act Movffl uses the WREG, so its contents will be over-written. i.e. volatile.
MenuLine[textctr] = MenuArray[index] ' produces a wrong result textchar = MenuArray[index] ' this workaround produces the correct result MenuLine[textctr] = textchar