Meteor M-N2 Images

Tuesday 17 January 2017

VLF/LF Receiver implemented in microprocessor - Rotary encoder control and LCD (Part 4 of n)


The rotary encoder control works by switching between screen buttons on each push of the encoder button. The button that is activated is highlighted in blue when active, non-buttons that have actions are highlighted in red. Turning the encoder clockwise or anti-clockwise will change the option and activate it immediately. When the station name is red you can tune manually (the station name will change to 'User' after the frequency has been changed).

Having reviewed my code it is difficult to describe in detail exactly which changes need to be made to add rotary encoder control. However, as far as I am aware I have put a comment including the word 'rotary' in every place where I have added code for this reason. 

If you want to backport the rotary encoder code to the STM32F4 board I suggest you search all the code for the word 'rotary' - grep -r rotary * - and take it from there.

There are three main additions of code to support the rotary encoder. There is a:

  • new routine in SDR_initPeriphs.c called  initEncoder()
  • new routine in main.c called ManageEncoder()
  • new routine in stm32f7xx_hal_msp.c called HAL_TIM_Encoder_MspInit()
  • an additional section in the HAL_GPIO_EXTI_Callback routine in stm32f7xx_it.c
  • Elsewhere various variables are defined in main.h and Globals.h.


Adding the external LCD involved a lot of digging around in low level LCD controller code. It must have affected my brain because now I cannot see what I changed to make it work. There's some pin definitions for the LCD in main.h, maybe that's all it needs but I am sure the STemWin GUI controller is defined somewhere. If you want to look into this area then the file LCD_X_8080_8.h would be a good place to start. 

A video of the rotary encoder/LCD combination will be posted here shortly.

The code is available on github link



No comments:

Post a Comment