Classwork
Classwork
Skeleton code
Remember to add the function prototypes in main.c for the declaration of the functions, as follow:
/* main.c */
/* USER CODE BEGIN PFP */
void gpio_classwork(void);
void tft_classwork(void);
/* USER CODE END PFP */Task 1 :GPIO
When
BTN1is held,LED1should be on. (@1)When
BTN2is held,LED2should be flashing (toggle in 50ms).(@1)When both
BTN1andBTN2are held, the following sequence is conducted:(@2)LED1andLED3are on whileLED2are flashing.After 1 second,
LED1andLED3are flashing whileLED2are on.After 1 second, repeat from step 1.
Keyword: Finite State Machine

LED1 RED
LED2 GREEN
LED3 BLUE
BTN1 RED one
BTN2 GREEN one
Order: BTN2 -> BTN1 -> BTN1 & BTN2
Task 2 :TFT
Print the time elapsed with the format of
mm:ss:sssZwheresssZmeans millisecond. e.g.00:23:109(@2)Print a 50px * 50px square directly under the elapsed time where its color changes when 1 second passed.(@2)
Keywords:
HAL_GetTickHints:
Integer division
1 min = 60 second, 1 second = 1000 milliseconds
Read the function prototypes in Core/Inc/lcd/lcd.h for more tft_print functions that you can use.

The actual size of square printed on TFT should be larger than this one
⚠️ Don't use
__forceinline static void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)as it seems to cause error
Last updated