Modified Bob Stone's code for ILI9341 QVGA TFT's without touch capability. Navigation is now done with rotary encoders - two for position, & one setting the maxiterations.

Dependencies:   SPI_TFT_ILI9341 TFT_fonts mbed

Fork of Mandelbrot by Bob Stone

Should have mentioned in the above: Encoder code is specific to the STM32F4, tested on Nucleo F401, should work on the Nucleo F411..

/media/uploads/gregeric/img_20150121_093103_744-1-.jpg /media/uploads/gregeric/img_20150121_093055_682-1-.jpg

Committer:
gregeric
Date:
Thu Jan 22 10:01:49 2015 +0000
Revision:
3:267e7130007d
Parent:
2:b1169b84a563
Increase debounce time, shown necessary after round of testing.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gregeric 2:b1169b84a563 1 #include "mbed.h"
gregeric 2:b1169b84a563 2
gregeric 2:b1169b84a563 3 void EncoderInit(TIM_Encoder_InitTypeDef encoder, TIM_HandleTypeDef timer, TIM_TypeDef *TIMx, uint32_t maxcount, uint32_t encmode)
gregeric 2:b1169b84a563 4 {
gregeric 2:b1169b84a563 5 timer.Instance = TIMx;
gregeric 2:b1169b84a563 6 timer.Init.Period = maxcount;
gregeric 2:b1169b84a563 7 timer.Init.CounterMode = TIM_COUNTERMODE_UP;
gregeric 2:b1169b84a563 8 timer.Init.Prescaler = 0;
gregeric 2:b1169b84a563 9 timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
gregeric 2:b1169b84a563 10
gregeric 2:b1169b84a563 11 encoder.EncoderMode = encmode;
gregeric 2:b1169b84a563 12
gregeric 2:b1169b84a563 13 encoder.IC1Filter = 0x0F;
gregeric 2:b1169b84a563 14 encoder.IC1Polarity = TIM_INPUTCHANNELPOLARITY_RISING;
gregeric 2:b1169b84a563 15 encoder.IC1Prescaler = TIM_ICPSC_DIV4;
gregeric 2:b1169b84a563 16 encoder.IC1Selection = TIM_ICSELECTION_DIRECTTI;
gregeric 2:b1169b84a563 17
gregeric 2:b1169b84a563 18 encoder.IC2Filter = 0x0F;
gregeric 2:b1169b84a563 19 encoder.IC2Polarity = TIM_INPUTCHANNELPOLARITY_FALLING;
gregeric 2:b1169b84a563 20 encoder.IC2Prescaler = TIM_ICPSC_DIV4;
gregeric 2:b1169b84a563 21 encoder.IC2Selection = TIM_ICSELECTION_DIRECTTI;
gregeric 2:b1169b84a563 22
gregeric 2:b1169b84a563 23
gregeric 2:b1169b84a563 24 if (HAL_TIM_Encoder_Init(&timer, &encoder) != HAL_OK) {
gregeric 2:b1169b84a563 25 printf("Couldn't Init Encoder\r\n");
gregeric 2:b1169b84a563 26 while (1) {}
gregeric 2:b1169b84a563 27 }
gregeric 2:b1169b84a563 28
gregeric 2:b1169b84a563 29 if(HAL_TIM_Encoder_Start(&timer,TIM_CHANNEL_1)!=HAL_OK) {
gregeric 2:b1169b84a563 30 printf("Couldn't Start Encoder\r\n");
gregeric 2:b1169b84a563 31 while (1) {}
gregeric 2:b1169b84a563 32 }
gregeric 2:b1169b84a563 33 }
gregeric 2:b1169b84a563 34