Use Font for S7735R LCD using ESP32 - c

I'm working on ESP32. With ESP32 MCU interface S7735 LCD and I'm use ESP_IDF as an IDE.
I use " https://github.com/loboris/ESP32_TFT_library " for TFT_LCD and there are given fonts I use.I'm tried given font and its working fine and if you want to use your custom font then simply put font file in spiffs/fonts folder and flash into the ESP32.
Above this steps I follow but not reflect any font style if I flash custom font in .ttf . I also try to convert .ttf to .fon font but .fon format is for Window/Dos. and for LCD I need a .fon (binary).
I did not get which font extension I use for this given particular file. Kindly suggest compatible font extension and link also where I will be download easily.
static const char *file_fonts[3] = {"/spiffs/fonts/DotMatrix_M.fon", "/spiffs/fonts/Ubuntu.fon", "/spiffs/fonts/Grotesk24x48.fon"};
from main/tft_demo.c there are given above line and that font use from given path.
I need a solution for font file which is compatible with my driver.
Kindly suggest me flow for new custom font use.

The font format is proprietary and simple bit-maps. The file name extension .fon is generic and tells you nothing about the actual format.
The /tools folder of the library you linked includes a tool for converting TTF fonts to bitmaps generated as C code data arrays that you simply link to your project to add fonts.
From the read-me file:
Program to convert any ttf font to c source file that can be includes
in ESP32 tft library.
This is a windows program, but can be used under Linux with wine:
Usage:
ttf2c_vc2003.exe <point-size> <input-file> <output-file> [<start_char> <end_char>]
or, under Linux:
wine ./ttf2c_vc2003.exe <point-size> <input-file> <output-file> [<start_char> <end_char>]
There is more in the read-me file - a couple of manual edits that need to be made. The folder includes examples for Vera and DejaVu Sans.

Related

uboot using FIT to upgrade

I am using a custom embedded rtos and booting with uboot via a FIT image. "bootm" works very nicely with this .itb container.
I would like to include in the Sha signed image .itb file upgrades to my filesystem. That way uboot (via scripts) can upgrade files in the flash fat filesystem. The docs file update_uboot.its gives a hint as to what I need with:
update#1 {
description = "U-Boot binary";
data = /incbin/("./u-boot.bin");
compression = "none";
type = "firmware";
load = <FFFC0000>;
hash#1 {
algo = "sha1";
};
};
Where presumably this is a packaged binary upgrade for u-boot. And I can generate the image file with mkimage. However I cannot find any directions of how to use this or flash this, etc.
And generically there are several very interesting FIT types like "filesystem" which imply there is a way to package up a complete filesystem. That is very close to what I want, but I cannot find any way to extract and flash the filesystem from u-boot scripts.
I tried to do a "cp $loadaddr:update#1 0x90000000 10" but cp does not copy the data from the itb file. And from the source it looks like do_mem_cp does not do any special FIT syntax handling.
I am using a fairly recent TI Sitara uboot (u-boot-2016.05+gitAUTOINC+2f757e5b2c-g2f757e5b2c), do I need to modify the source to do what I want?
Thanks, Steve
You're looking for the imxtract command to extract parts of a FIT image in memory.

Displaying Text with SDL_ttf without font file hard code

I have code in C LANGUAGE to display text on screen using SDL_ttf library in linux.
TTF_Font *font;
font = TTF_OpenFont("FreeSans.ttf", 20);
But in this I don't want to give file name as hard coded or file path. so when I execute this programme on other Linux machine it should run fine. I don't want to keep always this font file with my executable.
Is there any way to write portable code for TTF_OpenFont ?
or i can use something else that can solve my problem ?
To avoid hardcoding fonts you need to integrate SFL_TTF with fontconfig.
Or use fontconfig through a higher-level framework like pango http://sdlpango.sourceforge.net/

Is there a MIME type for C# (.cs) files?

Standard UNIX tools (file command) return text/x-c++. This is not the greatest result possible.
On Windows urlmon.dll/FindMimeFromData returns text/plain. Looks like Windows never got any decent file type recognition library.
Is there something more precise than text/plain?
I was looking for the same thing on Ubuntu 20.04 - open .CS files in Code and other text files in the default editor.
I copied the line form the /usr/share/applications/defaults.list
text/plain=org.gnome.gedit.desktop
and added the .cs extension like so
text/plain.cs=code
Now my CS files open in VS Code and all other plain text files open in the default editor

a lib that loads bmp files on a gnome-based system in C

This is a project that our university is asking us to go through (asking for help on third places is not restricted)
We have to build a 3D scene in which objects are mapped with textures.
I'm stuck where I need to load a BMP file's data into the program.
We have to use a library that is already present in the system (forbidden to code it).
My request is :
Using fedora (gnome environment), is there a pre-built library into which a function that loads BMP files and returns a pointer to the payload is existent ?
EDIT : We are forbidden to install any additional libs, the lib must be a pre-built lib of Fedora.
Take a look at the GDK library and the funcion gdk_pixbuf_new_from_file. As you can see in the API you can use:
GdkPixbuf *bmp_pixbuf;
GError *error = NULL;
bmp_pixbuf = gdk_pixbuf_new_from_file ("/tmp/myfile.bmp", &error);
if (bmp_pixbuf == NULL) {
/* Error codes are GDK_PIXBUF_ERROR and G_FILE_ERROR */
}
It's important to check first the BMP support in GDK using:
$ gdk-pixbuf-query-loaders-64 | grep bmp
You need a library like libpixbufloader-bmp.so.
I don't know what library are you using to create the 3D scene, but you can get the raw pixels after load the pixbuf with gdk_pixbuf_get_pixels and then load into a surface.
Hope this help.
freeimage is the package name which does have method to upload bmp image. From online documentation at freeimage project page I can see the API:
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char
*filename, int flags FI_DEFAULT(0));
You can
yum install freeimage-devel
on fedora for development. Use this method and link to the library.
I'll reuse a previous answer:
Sean Barrett's stb_image.c is a stand-alone single-file public domain image loader for JPEG, PNG, BMP, TGA, PSD, GIF, HDR and PIC files.

Xcode change/remove comment template

Recently I've been learning how to program C. For most of the time, I have been using the C version of Eclipse. Recently, I tried out Xcode. I am using a Mac running Mac OS X Lion - Xcode version 4.1.
There is one grievance I have: at the top of every file that I create, there is this little section of comments that I wish to remove or better yet, change.
When I create a file, something like this is put at the top of the file by default:
//
// FILE.c
// PROJECT NAME
//
// Created by Martin Tuskevicius on DATE.
// Copyright YEAR ORGANIZATION (my school name for some reason). All rights reserved.
//
Obviously the things in capitals would be replaced with an actual value. For those of you have use, or have used Xcode, for programming C - do you know a way of how to change or remove these default comments?
I really appreciate any help.
Thanks!
UPDATE:
According to #Michael Dautermann 's comment below, change templates in Xcode.app bundle is not a good way. Check https://stackoverflow.com/a/33743/380774 for more information.
You can remove or change the header in File Templates, I'm using Xcode 4.3, and the File Templates is in /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates.
Please do not edit files inside Xcode, that will break the application signature and will cause Xcode to refuse to start up after the next restart or so.
Create an IDETemplateMacros.plist file containing a dictionary with a FILEHEADER key (string) instead.
You can put the file in
for all users on a single project by dropping it in your project's or workspace's xcshareddata folder (e.g. MyAppWorkspace.xcworkspace/xcshareddata/IDETemplateMacros.plist)
for yourself for a single project by copying it into e.g MyAppWorkspace.xcworkspace/xcuserdata/YOURNAMEHERE.xcuserdatad
global for all projects that you open in your account by dropping the file in ~/Library/Developer/Xcode/UserData/
You can change it in Xcode project File.
This is my image for tutorial :D
Very easy!!!

Resources