📜 ⬆️ ⬇️

Arduino, Nokia 5110 LCD and Cyrillic Module



It took me, for a small project on the Arduino, to display some information, of course, on the screen, and not to the console. I bought a couple of LCD modules a la Nokia 5110 with a resolution of 84 x 48 pixels. I decided to use the library from Adafruit , more precisely two Adafruit-PCD8544-Nokia-5110-LCD-library and Adafruit-GFX-Library . If someone is not familiar with them, they allow you to display text on the screen (six lines of 14 characters each), display images prepared in advance, draw (lines, rectangles, circles, etc.), and draw pixel-by-pixel. The pcdtest sketch worked fine, and I started writing my project bike . This is where the adventures began ...

It turned out that there are no Russian characters in the font, but I wanted to. On the very first link in Google, he found like-minded people , in comment # 35 a certain Droni shared the font editor and the font he made. In fact, the editor turned out to be crooked - did not display the last (256) character, and the font itself was not brought to mind - not only was the cp866 encoding not yet completed - the symbol was missed in pseudographics (the error came from the original adafruit font ), there are not enough characters "" and "". At first I tried to modify the font in the Droni editor, but when I found out that the 256 character is not displayed - my patience is exhausted and I decided to write my own editor with blackjack and .... Editor and font encoded in cp1251 . Brief instruction: the editor has two working fields - in the left we edit the selected character (click the color of the pixel by clicking the color), the right displays all the characters of the font, separated by a red line on ASCII (from 0 to 127) and national (from 128 to 255) selected the symbol is surrounded by a blue frame; the index of the selected symbol in the decimal and hexadecimal systems is displayed below. Everything is simple - we open the finished font, see what you don’t like in it and want to change, edit and save. Please note - the fonts are 5x7 pixels, in fact 5x8, the bottom row of pixels is used, but only in such characters as “D”, “C”, “U”, and in fact, it is a separator between the lines. On the screen, each character is 6x8, that is, an interval of one pixel is used between the characters.

Next, I discovered unexpected Wiring behavior. The editor encoding is utf-8 itself, but if preproc.substitute_unicode = false is set in the preferences file, then when compiling it is converted to system encoding, i.e. in cp1251. It turns out that by turning off the "unicode replacement" we enable the conversion of encodings. Simply put - you can write directly to the IDE in Cyrillic and, after loading the sketch into the board, see the normal Russian text on the screen.
')
I also needed to display a couple of icons. Adafruit proposes to use the Img2Code converter , but somehow I didn’t really like to draw in GIMP pixel-by-pixel, I was too lazy to look for a free editor for pixel art and I decided to make an icon editor in addition to the font editor. The editor turned out to be sad, I tried to draw small icons, so it was quite convenient, but it would probably be completely uncomfortable to draw a full-sized picture (84x48).

A sketch showing the output of Cyrillic on the screen (photo at the beginning of the article) and icons (based on the picture from this article ). Naturally, the sketch should be used with a ready-made font and the correct Wiring settings.
Editors screenshots



In conclusion, editors are written in Python 2, no third-party libraries are required, because the interface to Tkinter, well, I suppose the editors are cross-platform. Editors are meant for sighted people - I work on a netbook with a 10 ”screen, so the interface elements are very small. I am honestly very ashamed of the code, so it's better not to watch it.

PS: The irony of fate - in my project, I ended up abandoning the Cyrillic alphabet and icons.

Source: https://habr.com/ru/post/242957/


All Articles