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 :
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.
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 !
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
Post a Comment