LCD in JointJS

Goodbye to another great week, with the highlight of watching The Walk with our boss. I thought the movie was great and inspiring, until I googled about Phillipe Petit (and the things he did).

So.. my recent work is all about the LCD which I talked slightly about last week. I think the basic model is almost complete now, with the LCD now being able to print string! Though I must say it was achieved with some hardship and some help from my dear Peter.

Creating the LCD Screen and generating characters.

First, the LCD is created by editing its markup. A simple <rect> and <text> appended to it would create the screen and also the text position. After that, a means to edit the text was needed. I tried using the “set” attribute function in jointJS to edit the text. However, it was not responsive and needed a few page refreshes for the characters to show. Finally, I just used document.querySelectorAll to search for the LCD characters and change its innerHTML.

As of the LCD library, it is now occupied with a few basic functions :-

write(int char) – displays a character on the screen.

command(int command) – runs a command, only clear screen is done for now.

I was required to interface it with the controller and simulate the LCD as close to an actual model. For example, if one of the data pins are not connected, the displayed characters would be wrong. I previously thought I could make out something like the jointJS logic circuit example, with the elements (controller ports) broadcasting the signal through the links and to the modules. However, the ports are not jointJS elements as they are already created in the SVG file by previous intern. I decided to use another approach to complete the interface, which uses bit masking. In brief, the connected ports are AND-ed with the LCD data register (obtained when the user ‘writes’ or ‘commands’). The result would then be processed to determine the output in LCD.

Negative addresses generated in simulator addresses

While getting print string in LCD to work, I faced some problem while using strlen() function, where the value returned was wrong. This troubled me for one whole day until Dr. Shawn told me to check through each assembly instruction and figure out what is happening. I logged all the registers using RISCV.gen_reg[]. For my case, the argument registers are the ones of interest. Finally, I found the line, which was an ANDI instruction at the start of strlen(). It was trying to AND a register with negative address. This negative address is caused by the simulator which was ported from 64bit to 32bit. The addresses had to be converted back to positive before instruction are executed and finally, it works!


 

Watching the LCD slowly come together piece by piece is really exciting. The great thing is that now, I can make the LCD talk to me at times when I feel lonely in the office and occasionally display some data.

Attached here is a screenshot of the evolved LCD.

Screenshot - 10232015 - 07_01_16 PM

You may also like...

Leave a Reply