Go Down

Topic: Convert a .ttf file (Read 730 times) previous topic - next topic

Conces

Hey guys,

I would like to convert .ttf file to app.h to program my vidor. I tried to convert it to .bin and after that to .h. I used online web convertors, but I was't successful. Do you have some recommendations? Or do you know another way to convert it?

Thanks.

Conces


Limba

Did you use example repository as baseline?

If yes then there is build script that will create app.h.
You need also install go compiler for flash swap converter.

herrnamenlos123

#2
Aug 18, 2020, 04:04 pm Last Edit: Aug 24, 2020, 09:15 pm by herrnamenlos123
Actually converting a .ttf file to app.h file doesn't take more than renaming it. However, in the case of the Arduino this is not enough, as Quartus generates the bitstream bit-reversed, at least what we need it for. Because of that, you have to run it through a tool which reverses all bytes and then you can rename the output file to app.h.

You can find a tutorial on how to convert it here, in case you want to read through all of it:
https://systemes-embarques.fr/wp/archives/mkr-vidor-4000-programmation-du-fpga-partie-1/

Here's a direct download link for the converter tool:
https://systemes-embarques.fr/wp/wp-content/uploads/2018/10/ReverseByte_V2.zip

Unzip the archive, store the .class and .java files somewhere it won't be removed (like the user folder in "C:\Users\YourName\"). Now, when opening a command prompt in this directory you can type the command:


Code: [Select]
Java ReverseByte "YourTTF" "YourAPPH"
 

For making this easier, i wrote a simple batch script which you can use:

Code: [Select]

@echo off

set sourcePath=F:\Documents\CNC\RealTimeController_V2\projects\RealTimeController\output_files\MKRVIDOR4000.ttf
set targetPath=F:\Documents\Sketchbook\libraries\FPGA_Controller\FPGA_Bitstream.h

cd /D F:\Documents\CNC\ReverseByte

if exist tempStream.ttf (
del tempStream.ttf
)

echo Converting FPGA Bitstream...
java ReverseByte %sourcePath% tempStream.ttf

if not exist tempStream.ttf (
echo Error while converting!
Pause
exit
)

if exist %targetPath% (
del %targetPath%
)

copy tempStream.ttf %targetPath%

if not exist %targetPath% (
echo Error: Failed to replace bitstream!
Pause
exit
)

echo Successfully replaced bitstream!

timeout 1


The special characters are for coloring the console to make text green, and red if the script fails. The detection if ReverseByte fails is also the reason the script is so complex.

This script converts the file and replaces the target file, while it will also tell you if this process fails.

To use this script, just copy the content into a file named VidorUpload.bat or something similar. Save it somewhere it won't get removed and edit the three paths like the source file, target file and the cd command, which is the path to where you saved your ReverseByte.class files previously.

When those three paths are set up and java is installed (it is when you have the Arduino IDE installed) it is time to run the script.
And finally, you can create a Windows shortcut to this batch file, which you can drag anywhere and even change the icon to a microchip symbol or anything you like. When you edit the Windows shortcut from something like "F:/Desktop/Vidorupload.bat" to "explorer.exe F:/Desktop/Vidorupload.bat" you can even attach it to your taskbar.

Great, now you just need to click on your taskbar to copy the bitstream from a Quartus project directly to your Arduino sketch!


And lastly, I don't know if you already have a way to actually upload the sketch, but in case you don't,  you can take a look at my Github repo:
https://github.com/HerrNamenlos123/JTAG_Interface

This repo contains modules for uploading the bitstream and also for exchanging data with the FPGA at runtime. In case you're interested just read the ReadMe of the repository.

Hope this was helpful, have a nice day!

Go Up