-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.c
82 lines (68 loc) · 1.95 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
75
76
77
78
79
80
81
82
/*
LiquidCrystal Library - TextDirection
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 demonstrates how to use leftToRight() and rightToLeft()
to move the cursor.
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/TextDirection
*/
#include "stm32f3xx_hal.h" // change this here and inside LiquidCrystal library accordingly
#include "LiquidCrystal.h"
int thisChar = 'a';
// 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)
{
// reverse directions at 'm':
if (thisChar == 'm') {
// go right for the next letter
rightToLeft();
}
// reverse again at 's':
if (thisChar == 's') {
// go left for the next letter
leftToRight();
}
// reset at 'z':
if (thisChar > 'z') {
// go to (0,0):
home();
// start again at 0
thisChar = 'a';
}
// print the character
write(thisChar);
// wait a second:
HAL_Delay(1000);
// increment the letter:
thisChar++;
}
}
void SysTick_Handler(void)
{
HAL_IncTick();
}