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:
Tue Jan 20 15:10:25 2015 +0000
Revision:
2:b1169b84a563
Modified Bob Stone's code for QVGA TFT's without touch capability. Navigation is now done with rotary encoders - two for position, one setting the maxiterations.

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 * HAL_TIM_Encoder_MspInit()
gregeric 2:b1169b84a563 4 * Overrides the __weak function stub in stm32f4xx_hal_tim.h
gregeric 2:b1169b84a563 5 *
gregeric 2:b1169b84a563 6 * Edit the below for your preferred pin wiring & pullup/down
gregeric 2:b1169b84a563 7 * I have encoder common at 3V3, using GPIO_PULLDOWN on inputs.
gregeric 2:b1169b84a563 8 * Encoder A&B outputs connected directly to GPIOs.
gregeric 2:b1169b84a563 9 *
gregeric 2:b1169b84a563 10 */
gregeric 2:b1169b84a563 11
gregeric 2:b1169b84a563 12 #ifdef TARGET_STM32F4
gregeric 2:b1169b84a563 13 void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim)
gregeric 2:b1169b84a563 14 {
gregeric 2:b1169b84a563 15 GPIO_InitTypeDef GPIO_InitStruct;
gregeric 2:b1169b84a563 16
gregeric 2:b1169b84a563 17 if (htim->Instance == TIM1) { //PA8 PA9 = Nucleo D7 D8, poss PB0 PB1 usable too (complementary?)
gregeric 2:b1169b84a563 18 __TIM1_CLK_ENABLE();
gregeric 2:b1169b84a563 19 __GPIOA_CLK_ENABLE();
gregeric 2:b1169b84a563 20 GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
gregeric 2:b1169b84a563 21 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
gregeric 2:b1169b84a563 22 GPIO_InitStruct.Pull = GPIO_PULLDOWN;
gregeric 2:b1169b84a563 23 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
gregeric 2:b1169b84a563 24 GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
gregeric 2:b1169b84a563 25 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
gregeric 2:b1169b84a563 26 }
gregeric 2:b1169b84a563 27 else if (htim->Instance == TIM2) { //PA0 PA1 = Nucleo A0 A1, PA5 PB3 = D13 D3 poss too
gregeric 2:b1169b84a563 28 __TIM2_CLK_ENABLE();
gregeric 2:b1169b84a563 29 __GPIOA_CLK_ENABLE();
gregeric 2:b1169b84a563 30 GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1;
gregeric 2:b1169b84a563 31 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
gregeric 2:b1169b84a563 32 GPIO_InitStruct.Pull = GPIO_PULLDOWN;
gregeric 2:b1169b84a563 33 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
gregeric 2:b1169b84a563 34 GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
gregeric 2:b1169b84a563 35 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
gregeric 2:b1169b84a563 36 }
gregeric 2:b1169b84a563 37 else if (htim->Instance == TIM3) { //PB4 PB5 = Nucleo D5 D4, PA6 PA7 & PC6 PC7 also an option for Nucleo
gregeric 2:b1169b84a563 38 __TIM3_CLK_ENABLE();
gregeric 2:b1169b84a563 39 __GPIOB_CLK_ENABLE();
gregeric 2:b1169b84a563 40 GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5;
gregeric 2:b1169b84a563 41 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
gregeric 2:b1169b84a563 42 GPIO_InitStruct.Pull = GPIO_PULLDOWN;
gregeric 2:b1169b84a563 43 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
gregeric 2:b1169b84a563 44 GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
gregeric 2:b1169b84a563 45 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
gregeric 2:b1169b84a563 46 }
gregeric 2:b1169b84a563 47 else if (htim->Instance == TIM4) { // PB6 PB7 = Nucleo D10 MORPHO_PB7
gregeric 2:b1169b84a563 48 __TIM4_CLK_ENABLE();
gregeric 2:b1169b84a563 49 __GPIOB_CLK_ENABLE();
gregeric 2:b1169b84a563 50 GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_7;
gregeric 2:b1169b84a563 51 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
gregeric 2:b1169b84a563 52 GPIO_InitStruct.Pull = GPIO_PULLDOWN;
gregeric 2:b1169b84a563 53 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
gregeric 2:b1169b84a563 54 GPIO_InitStruct.Alternate = GPIO_AF2_TIM4;
gregeric 2:b1169b84a563 55 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
gregeric 2:b1169b84a563 56 }
gregeric 2:b1169b84a563 57 else if (htim->Instance == TIM5) { // here for completeness, mbed sytem timer uses this
gregeric 2:b1169b84a563 58 __TIM5_CLK_ENABLE();
gregeric 2:b1169b84a563 59 __GPIOA_CLK_ENABLE();
gregeric 2:b1169b84a563 60 GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1;
gregeric 2:b1169b84a563 61 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
gregeric 2:b1169b84a563 62 GPIO_InitStruct.Pull = GPIO_PULLDOWN;
gregeric 2:b1169b84a563 63 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
gregeric 2:b1169b84a563 64 GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
gregeric 2:b1169b84a563 65 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
gregeric 2:b1169b84a563 66 }
gregeric 2:b1169b84a563 67 }
gregeric 2:b1169b84a563 68 #endif