9. April 2017

How to edit font for OLED display SD1306

In the previous article, I’ve described how to generate custom font for OLED display like SD1306.

Meanwhile, I’ve discovered that number eight and number zero are hard to distinguish when reading from a distance, because of the dot inside the number zero.

I decided to remove the dot from number zero in order to make the font more readable. But how to do it?

Font generated from Squix’s generator is stored in form of source code. That makes it possible to edit. Just the stream of hexadecimal numbers is not very readable for a human.

Here is a small trick. Open the file in Vim in a terminal window. Search for string 0x00 which represents an area with no pixels. Vim should highlight all the occurences of 0x00. If you can’t see the highlight type command:

:set hlsearch

Start shrinking the window of the terminal and you should see that pattern begins to emerge.

When you hit the correct length of a line you should see the number clearly.

Numbers could be rotated, like number seven:

Change the font rebuild the code and the result looks like this:

23. November 2013

Cppcheck – How to open source code at problematic line in Vim

Cppcheck is useful tool for assesment of C++ code quality. It can diagnose many potential problems.

It’s quite easy to configure Cppcheck to open files at problematic location in your favorite editor.

Here is example how to connect Cppcheck and Vim.

Open Edit – Preferences, select Applications tab, click Add

cppcheck-vim-01

Fill following form.

Name: gvim

Executable (point it to your installation of Vim): C:\Program Files (x86)\Vim\vim74\gvim.exe

Parameters: -f +(line) (file)

Click Ok.

cppcheck-vim-02

Set gvim as default application. Select gvim line and click Set as default.

cppcheck-vim-03

Double click any warning or error message and Vim should open at problematic line.

cppcheck-vim-04

8. May 2013

Vim mode in Cloud9 IDE

Cloud9 IDE is cloud base IDE for NodeJS, Python, Ruby or PHP projects.

The cool thing about this IDE is that code editor has support for Vim mode (it also supports Emacs) 🙂

vim-cloud9

Go to View, Keyboard Mode and select Vim.

Voila you can use many Vim features, like indentation by >> or many others.

Here is offical video from Cloud9 Youtube channel:

18. November 2012

Vim – How to edit Unicode files produced by PowerShell

It’s possible to redirect output of PowerShell command into file. E.g.:

Get-ChildItem -Recurse  | Select-Object -ExpandProperty FullName >file-list.txt

If you want to open this file-list.txt by vim you may be little bit surprised by unreadable text:

If you open the same file in notepad, then everything is perfectly readable.

There is simple fix for vim suggested by Tony Mechelynck. Just open .vimrc in your home directory and add following lines:

if has('multi_byte')                   " multibyte features compiled-in 
  if &encoding !~? '^u'                " the OS locale is not Unicode 
    if &termencoding == ''             " empty means 'use &enc' 
      let &termencoding = &encoding    " avoid clobbering keyboard codes 
    endif 
    set encoding=utf-8 " we can do it, now that the kb is taken care of 
  endif 
  set fileencodings=ucs-bom,utf-8,latin1 " heuristics for existing files 
  setglobal bomb fileencoding=latin1   " defaults for new files 
                     " 'bomb' doesn't apply to latin1 
                     " it applies when 'fenc' is manually set to Unicode 
endif

Result: