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
Should have mentioned in the above: Encoder code is specific to the STM32F4, tested on Nucleo F401, should work on the Nucleo F411..
Encoder/EncoderMspInitL0.cpp@3:267e7130007d, 2015-01-22 (annotated)
- 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?
User | Revision | Line number | New 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_STM32L0 |
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 == TIM2) { //PA0 PA1 = Nucleo A0 A1 |
gregeric | 2:b1169b84a563 | 18 | __TIM2_CLK_ENABLE(); |
gregeric | 2:b1169b84a563 | 19 | __GPIOA_CLK_ENABLE(); |
gregeric | 2:b1169b84a563 | 20 | GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1; |
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_TIM2; |
gregeric | 2:b1169b84a563 | 25 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
gregeric | 2:b1169b84a563 | 26 | } |
gregeric | 2:b1169b84a563 | 27 | } |
gregeric | 2:b1169b84a563 | 28 | #endif |