Five in a row is a relatively easy game for two players. The aim is to get five of one's pieces in a row (horizontal, vertical, or diagonal). Below is a simple algorithm in C to find the winner.
Encoding in Base64 (C Source Code)
Base64 encoding schemes are generally used when there is a need to encode binary information that needs to be stored and transferred over media that are developed to deal with textual information. This guarantees that the data stays unchanged without modification during transfer. Base64 is generally used in a number of applications including electronic mail via MIME, and keeping complex...
Convert a char array of HEX to ASCII in C
This function solves the case when we have a message which is represented as sequence of bytes in hex format in a string and we want to convert it back.
STM32L4 Sleep mode using FreeRTOS
A useful functionality in low-powered applications is to set the microcontroller in sleep mode for a specific time. This will reduce the overall consumption of the system, and depending on the application it can dramatically improve the battery life. However, using FreeRTOS, the activation of this mode is a bit tricky due to the fact that you have to take into account several other parameters. In...
STM32 UART – Receive unknown size data using DMA and FreeRTOS
There are several situations where we need to use a UART/Serial interface to connect our microcontroller with an external device. However, a common issue is that in most of those cases we do not know in advance the size of the messages thus, our final application needs to use either per character interrupt or a more advanced way like DMAs. Each method has it’s own pros/cons. As you can...
HowTo: STM32 Custom Bootloader/Application
It is a common practice in embedded system these days to use a bootloader-application architecture. The following source code snippets will help you to build you own bootloader/application project providing by the minimum code that is required to jump from one to the other. The example also works with FreeRTOS. First we need to understand 2 simple things. Each binary will be placed in different...
STM32L0xx HAL – DMA register callback issue
This is a simple bugfix of the HAL library (unfortunately ST does not allow external commits). If you have any issues regarding the function HAL_DMA_RegisterCallback(...) using the option HAL_DMA_XFER_ALL_CB_ID
WPF useful Extension methods
It is quite common the need of several extension methods in WPF which could help you develop faster and better apps without strange workarounds. Below I list some of them that are where quite important for me during the years.
All-around function to find mins/maxs, in order, distinct elements in array
It this post you can find a function in C which is a able to find X minimum or maximum elements in a given array, order the output either ascended or descended and get either distinct elements or duplications. Of course this function is far away from optimal solutions as it is better to use specific algorithms depending on your needs, however for fast experimentation it is useful. You can use...
C# WPF Canvas – Move shapes around
Recently, I needed to support dragging shapes and some other elements on a Canvas in WPF. However, looking online I found several implementations that were more complex than needed and/or not well functioning and I just wanted something very simple and solid. For that reason, below you will find a simple, yet useful implementation which can be easily adapted according to you needs. Step 1: Create...