Skip to main content

First steps with a screen

I haven't written anything for months ! But lots of things happened.

First, I made my first steps with the STM32 and the KaRadio communication through serial. It ran into lots of trouble regarding the Arduino Code, and the limitations of writing with Arduino only. In order to get it working, I used the existing code from Jean-Pierre Cocatrix (the creator of KaRadio) for his own STM32 with full LCD screen and IR remote. As I read it, I slowly started to understand that he used special functions from the FreeRTOS implementation for STM32, which allowed him to use timers to schedule multiple functions to be run in parallel. I though it was brilliant, and since I had problems with the serial buffer size with regular programmation (sorry not to give more information about this, there is some on Facebook but I desactivated my account some time ago), I ended up adapting Jean-Pierre's code to use the FreeRTOS implementation of scheduled tasks for the different tasks of my program. It fixed the problem with reading and writing on serial, so I was happy with it.

I connected my LCD screen on the STM32 on PB6 and PB7, to use SDA and SCL for I2C communication. My LCD is connected with the address 0x3f. Because I wanted to be able to print easily something on a line that can be horizontally scrolled, or on multiple lines that can be vertically scrolled, I wrote several functions in the LiquidCrystal_I2C library for Arduino that I used previously. My modified library will be available, although I don't plan to use it as-is in the near future. The functions I've written are extensively using delays, so they're messing up with the division in tasks and they're blocking the whole STM32 so I will definitely re-write them in a better way. Still, I think they are a valuable piece of information for the future on how NOT to write code.

Concerning the hardware, I arranged some of my PCBs on a single board and soldered them so that their power supply is directly shared. It makes it easier to power the STM32, the ESP8266 and the VS1053 at once. You can see the result here :

The screen is nice !

I directly stole the functions to decode the UART and to create scheduled tasks from Jean-Pierre's STM32 code. I wrote just a bit of code to display things like artist and title, and the radio name, with my (poorly written) functions, and also to display time.
Time is first known through an NTP requets, and then it is counted on the STM32 itself. In order not to have too frequent NTP requests, I decided to schedule NTP requests every 2mn for the moment, and to count seconds with a scheduled task. For the moment, every second lasts 2 seconds (which is awfully bad I know :D) but I think it's because of my delays in the LCD print functions I build. As soon as they're re-built, I should be far better.

I decided to extract the speakers from their wooden frame, so that they would adapt on a future, newer frame.


Lots of parts are still connected with plug, allowing easy separations.

I am still unsure of how to design the final box. The more I think of it, the more I suspect that drilling holes in a wooden box will be a hassle and a tiring operation. So I am thinking of using wood (or agglomerated wood) for the whole box except the front face. For the front face, I can 3D print some plate I can design with SolidWorks. This way, I would have holes and openings all ready as soon as the face gets out of the printer. Assembling the two could be done by screws.

This is getting a bit more complicated since I'm decided for good to build some kind of alarm-clock with this webradio. I want it to be an alarm clock. So I may have to re-work how many buttons I should have, how they should work, how can I set the alarm time (I don't need to set the global time since it's NTP based, but I want to be able to set the alarm anytime), how to set it ON or OFF... and how to display time on every situation ! I will buy some 7-segments display , driven by a TM1637 chip just dedicated to that task.

For the moment, I didn't find a nice wooden case to put everything in yet. It's getting more and more complicated, but at least it's also getting more and more interesting.

The code is available here, it's dirty, ugly, but I think preserving it for history may be nice. So here it is. https://drive.google.com/open?id=1eXwoX-yZ6Oo6ycYR64UcktSgxkpoHvxl

Next time would be re-writing all my libs to make them faster and cleaner (and not use delays !). I want to try to add some buttons to add control through the STM32 to the KaRadio (I can already ask for NTP requests, I want to do more).
For hardware work, I need to organize my buttons and to prepare a real VCC-GND line for all the components that are not connected yet. This means the LCD screen, the PAM8403 amplifier, and the future TM1637 display. In the future, the LCD display would be able to be shut down to save power and not to be annoying at night time.

See you next time !

Comments

Popular posts from this blog

Flashing an STM32 "Blue Pill"

Flashing this STM32 "Blue Pill" board took me 5 hours. I finally recieved my microcontrollers. I have at disposal : A brand new WeMos D1 Mini (it's a smallish NodeMCU) An Arduino Pro Mini (it acts just like a Leonardo, but it lacks some interesting pins sadly :(  ) An STM32F103C8T6, I'll call this the Blue Pill for short. The Arduino Pro Mini has an Arduino bootloader out-of-the-box, so  I could play with it directly. It's nice ! Still, it lacks the double Serial of the original Leonardo, and most importantly, there's no A4 and A5 pins, so libraries for I2C won't work without modification. But the Blue Pill needs more work. Basically, I followed the instructions on this site : http://wiki.stm32duino.com/index.php?title=Installation Since it's quite complicated, consider the following as a tutorial to set up your Blue Pill. I tried different things, the following has worked for me. Before doing anything software-related, while reading the B...

KaRadio DVT-01

I packed everything in my little case. It's really a mess in there, with cables flying around and every card floating, not fixed on the inside. But it looks quite cool ! I removed the old radio antenna to use its hole to pass my USB cable. Here's how it looks ! As you can see, I let the rotary knob (it's a simple angular potentiometer, in fact) from the amplifier out. It holds with a little nut that was provided with it. The buttons you can see are all fakes, they belonged to the old radio and I forgot to remove them (in fact they're simply glued to the back).  Maybe I'll find some tools to make a nice-looking front panel when my stuff arrives. I'll ask people around me to lend me their tools...  In the end, the radio would have a 20x4 LCD screen to display artist + title and useful infos (like the IP or the volume when you change it from the website, maybe). I think I'll need two more buttons to change the station. I won't...

Start of a blog - KaRadio Project

Hello everyone ! I decided to start a blog to keep a track of my electronics stuff I want to build. I found the KaRadio Project, that aims to build a webradio - you know, the thing, not the stream. A real object that connects to the Wi-Fi and plays your favourite radios. Some useful links : KaRadio's GitHub :  https://github.com/karawin/Ka-Radio The Hackaday Page :  https://hackaday.io/project/11570-wifi-webradio-with-esp8266-and-vs1053 The KaRadio Group on Facebook (very active !) :  https://www.facebook.com/groups/162949914181385/ As I tried a first prototype, I was really amazed what the main chip, the ESP8266, was capable of. So I decided to buy second-hand stuff in flea market to build a nice little webradio. For the moment, I have my prototype working, but most of the work lies ahead : adding control through a second microcontroller (MCU for short), adding buttons, pushing everything into a case, adding energy support... heh, I'm hyped ! Nonethele...