The beginning of…….

Last year I bought a 64x16 red led matrix. Not a clue what to do with it but it was fun to play around with. It took me a few minutes to get is connected to my Arduino Uno and installing an example. That was easy, but what should I build?

It took some time and a lot more tweaking to get the display to dim and show a nice 16 dots character font which I found was useable. The diming was a nice feature since the idea of making a clock for the living room was born, but I do not need another “red” light source. Adding a LDR determining the minimum value and I had an automatically dimming display which could show the time when provided by the USB interface.  Since the internal clock is not really precise I started with adding a real-time clock with a back-up battery, but even that did not satisfy my wishes. That where I came along the ESP8266. A cool, tiny in size but big in power, little controller with WiFi build in. At first, I started playing around with the AT interface which it had installed by default but once I made an error and more or less corrupted its setting I discovered that you could easily program the controller with the Arduino platform. So, I wrote some software to make the ESP8266 work as a controller as well as a SNTP client to get the correct time once every hour. But the ESP8266 communicates with the Arduino Uno via a serial interface which is not really efficient in more ways. First the Arduino’s buffer is small and that thing is working as hard as it can to keep the display updated. Second, I now have to pieces of software to maintain. I later on also added a DHT22, temperature and humidity sensor. A friend of mine who also got excited hearing me talking about the project and seeing the progress, took me out shopping for a nice frame to bring the whole thing together. I ended up with a cool clock hanging in the living room over which I have some controller using an Android app that I wrote as well.

Beginning of this year I came across the ESP32 and that beast is really powerful for its size and could do even more. So, I ordered one and with my obsession with the led matrix displays I ordered a 64x32 Red/Green display. First, I played around with just writing some simple code and get used to the Free-RTOS which is totally different than the Arduino platform I was used to. Then a few weeks ago I connected the display to the ESP32. With the ESP being 3v3 and the display 5V I hoped that it was just enough for the display to operate. But whatever I did I got no predictable response. I even had the idea that I might have damaged the ESP32, which till the day of today I’m still not sure off. So writing a simple program to check every single output to see that some of them where not responding. After ordering level-shifters to be on the safe side and used the outputs of which I was sure that would still work, I got some result.

I started writing a component to control the display. It starts a hardware timer to update every scan. That worked ok but I wanted more. I wanted to be able to control the level of the both colors as well with 16 levels (4 bits per color). Pulls Code Modulation is the way to go, but that would require an extreme high frame rate and a lot of CPU power. That where I came across Bit Code Modulation. I thought I had that one working but still it didn’t seem totally correct. Well what the hell, I got some output on the display so let’s see if I can get the time from a SNTP server. That was extremely easy since there was already a library for that in the Free-RTOS. But now it had trouble connecting to WiFi from time to time. Apparently, my interrupt handler was taking too much time and called to frequently that it interfered with the WiFi stack. After a lot of tweaking the timer settings I got a more or less a result that was good enough, until that same friend saw my progress and asked if it comes with sunglasses. That triggered me to try and dim this display as well, I might use it in the living room as a replacement of my previous clock or even use it in the bedroom as an alarm clock. That’s where I came up with using a second hardware timer which is triggered by the first after updating the display. The second would be triggered 1/8, 1/4, 1/2 and 1 period of a full display cycle and do nothing more than turning the display off. Now I had the BCM working as a charm giving me the results I was hoping for, but even better it is also able to control the brightness of the whole display by simply shorting the cycle time of the second timer.


At the moment, the project is still in a “rough” state and there are some parts than can and most likely have to be optimized. One of the things to be optimized is using bitmap planes in memory to make the streaming less intensive for the CPU. There should also be the option to use the I2S interface in LCD modus to stream the 4 bits of data using internal hardware and direct memory access, but that one I still haven’t got working. 

Reacties

Populaire posts van deze blog

MQTT