-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.c
74 lines (60 loc) · 1.93 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
LiquidCrystal Library - setCursor
Demonstrates the use of a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints to all the positions of the LCD using the
setCursor() method:
The circuit:
* LCD RS pin to PD8
* LCD R/W pin to PD9
* LCD En pin to PD10
* LCD D4 pin to PD11
* LCD D5 pin to PD12
* LCD D6 pin to PD13
* LCD D7 pin to PD14
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
library originated from Arduino, Adafruit and ported 12 Apr 2018
by S. Saeed Hosseini ([email protected])
example originated from Arduino, Adafruit and ported 13 Apr 2018
by S. Saeed Hosseini ([email protected])
This example code is in the public domain.
https://github.com/SayidHosseini/LiquidCrystal/tree/master/examples/setCursor
*/
#include "stm32f3xx_hal.h" // change this here and inside LiquidCrystal library accordingly
#include "LiquidCrystal.h"
const int numRows = 2;
const int numCols = 16;
// ISR Required by the library (for HAL_Delay)
void SysTick_Handler(void);
int main(void)
{
// Initializing SysTick - required by the library
HAL_Init();
// initialize the library by associating any needed LCD interface pin
LiquidCrystal(GPIOD, GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10, GPIO_PIN_11, GPIO_PIN_12, GPIO_PIN_13, GPIO_PIN_14);
while(1)
{
// loop from ASCII 'a' to ASCII 'z':
for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
// loop over the columns:
for (int thisRow = 0; thisRow < numRows; thisRow++) {
// loop over the rows:
for (int thisCol = 0; thisCol < numCols; thisCol++) {
// set the cursor position:
setCursor(thisCol, thisRow);
// print the letter:
write(thisLetter);
HAL_Delay(200);
}
}
}
}
}
void SysTick_Handler(void)
{
HAL_IncTick();
}