upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
hd44780_bits.h
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 // This file contains bit definitions for the HD44780 and compatible
27 // LCD controllers. It is used primarily my the lcm1602 driver and
28 // it's derivatives.
29 //
30 // Those values (DATA, CMD) are specific to the implementation of the
31 // i2C expander in use, so may not be appropriate for inclusion into
32 // this file. But for now, we will leave them here.
33 
34 #include <stdint.h>
35 
36 // commands
37 const uint8_t HD44780_CLEARDISPLAY = 0x01;
38 const uint8_t HD44780_RETURNHOME = 0x02;
39 const uint8_t HD44780_ENTRYMODESET = 0x04;
40 const uint8_t HD44780_DISPLAYCONTROL = 0x08;
41 const uint8_t HD44780_CURSORSHIFT = 0x10;
42 const uint8_t HD44780_FUNCTIONSET = 0x20;
43 
44 // flags for display entry mode
45 const uint8_t HD44780_ENTRYRIGHT = 0x00;
46 const uint8_t HD44780_ENTRYLEFT = 0x02;
47 const uint8_t HD44780_ENTRYSHIFTINCREMENT = 0x01;
48 const uint8_t HD44780_ENTRYSHIFTDECREMENT = 0x00;
49 
50 // flags for display on/off control
51 const uint8_t HD44780_DISPLAYON = 0x04;
52 const uint8_t HD44780_DISPLAYOFF = 0x00;
53 const uint8_t HD44780_CURSORON = 0x02;
54 const uint8_t HD44780_CURSOROFF = 0x00;
55 const uint8_t HD44780_BLINKON = 0x01;
56 const uint8_t HD44780_BLINKOFF = 0x00;
57 
58 // flags for display/cursor shift
59 const uint8_t HD44780_DISPLAYMOVE = 0x08;
60 const uint8_t HD44780_MOVERIGHT = 0x04;
61 const uint8_t HD44780_MOVELEFT = 0x00;
62 
63 // flags for function set
64 const uint8_t HD44780_8BITMODE = 0x10;
65 const uint8_t HD44780_4BITMODE = 0x00;
66 const uint8_t HD44780_2LINE = 0x08;
67 const uint8_t HD44780_1LINE = 0x00;
68 const uint8_t HD44780_5x10DOTS = 0x04;
69 const uint8_t HD44780_5x8DOTS = 0x00;
70 
71 // flags for CGRAM
72 const uint8_t HD44780_SETCGRAMADDR = 0x40;
73 
74 // may be implementation specific
75 const uint8_t HD44780_EN = 0x04; // Enable bit
76 const uint8_t HD44780_RW = 0x02; // Read/Write bit
77 const uint8_t HD44780_RS = 0x01; // Register select bit
78 const uint8_t HD44780_DATA = 0x40;
79 const uint8_t HD44780_CMD = 0x80;
80 
81 const uint8_t HD44780_BACKLIGHT = 0x08;
82 const uint8_t HD44780_NOBACKLIGHT = 0x00;