Browse Source

ssd1327: Added new lcd module.

Signed-off-by: Kiveisha Yevgeniy <yevgeniy.kiveisha@intel.com>
Kiveisha Yevgeniy 10 years ago
parent
commit
557f63edf6
7 changed files with 595 additions and 1 deletions
  1. 2
    0
      examples/CMakeLists.txt
  2. 126
    0
      examples/oled-1327.cxx
  3. 1
    1
      src/lcd/CMakeLists.txt
  4. 7
    0
      src/lcd/jsupm_ssd1327.i
  5. 8
    0
      src/lcd/pyupm_ssd1327.i
  6. 276
    0
      src/lcd/ssd1327.cxx
  7. 175
    0
      src/lcd/ssd1327.h

+ 2
- 0
examples/CMakeLists.txt View File

@@ -11,6 +11,7 @@ add_executable (nrf_receiver nrf_receiver.cxx)
11 11
 add_executable (es08a es08a.cxx)
12 12
 add_executable (son-hcsr04 hcsr04.cxx)
13 13
 add_executable (oled-1308 oled-1308.cxx)
14
+add_executable (oled-1327 oled-1327.cxx)
14 15
 
15 16
 include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
16 17
 include_directories (${PROJECT_SOURCE_DIR}/src/grove)
@@ -35,3 +36,4 @@ target_link_libraries (nrf_receiver nrf24l01 ${CMAKE_THREAD_LIBS_INIT})
35 36
 target_link_libraries (es08a servo ${CMAKE_THREAD_LIBS_INIT})
36 37
 target_link_libraries (son-hcsr04 hcsr04 ${CMAKE_THREAD_LIBS_INIT})
37 38
 target_link_libraries (oled-1308 i2clcd ${CMAKE_THREAD_LIBS_INIT})
39
+target_link_libraries (oled-1327 i2clcd ${CMAKE_THREAD_LIBS_INIT})

+ 126
- 0
examples/oled-1327.cxx View File

@@ -0,0 +1,126 @@
1
+/*
2
+ * Author: Yevgeniy Kiveish <yevgeniy.kiveisha@intel.com>
3
+ * Copyright (c) 2014 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
+
25
+#include "ssd1327.h"
26
+
27
+#define DEVICE_ADDRESS    0x3C
28
+#define BUS_NUMBER        0x0
29
+
30
+static uint8_t SeeedLogo[] ={
31
+0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32
+0x00, 0x60, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00,
33
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
34
+0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35
+0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80,
36
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00,
37
+0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xC0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
38
+0x07, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0F, 0x80, 0x01, 0xE0,
39
+0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00,
40
+0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
41
+0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0,
42
+0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00,
43
+0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
44
+0x0F, 0x80, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0F, 0x80, 0x01, 0xE0,
45
+0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x0F, 0x80, 0x03, 0xE0, 0x78, 0x00, 0x00, 0x00,
46
+0x00, 0x00, 0x00, 0x1E, 0x07, 0x80, 0x03, 0xE0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
47
+0x07, 0x80, 0x03, 0xE0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x07, 0x80, 0x03, 0xC1,
48
+0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x87, 0xC0, 0x07, 0xC1, 0xF0, 0x00, 0x00, 0x00,
49
+0x00, 0x00, 0x00, 0x0F, 0x83, 0xC0, 0x07, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F,
50
+0xC3, 0xC0, 0x07, 0x87, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE1, 0xE0, 0x07, 0x0F,
51
+0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, 0xE0, 0x0F, 0x0F, 0x80, 0x00, 0x00, 0x00,
52
+0x00, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x0E, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
53
+0xF8, 0x70, 0x1C, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x30, 0x18, 0x7E,
54
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x18, 0x30, 0xFC, 0x00, 0x00, 0x00, 0x00,
55
+0x00, 0x00, 0x00, 0x00, 0x1F, 0x88, 0x21, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56
+0x0F, 0xC4, 0x47, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x0F, 0x80,
57
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
58
+0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61
+0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00,
62
+0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06,
63
+0x00, 0x00, 0x60, 0x00, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xDF, 0xE1, 0x9F, 0xEC, 0x7E,
64
+0xE6, 0x73, 0x9C, 0xE7, 0x39, 0xCE, 0x1C, 0xDF, 0xE1, 0xB9, 0xEC, 0xE7, 0xE0, 0x61, 0xD8, 0x66,
65
+0x1B, 0x86, 0x1C, 0x06, 0x61, 0xB0, 0x6D, 0xC3, 0x7C, 0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x0F, 0x86,
66
+0x61, 0xB0, 0x6D, 0x83, 0x3E, 0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x07, 0xC6, 0x61, 0xB0, 0x6D, 0x83,
67
+0xC3, 0x61, 0x18, 0x46, 0x03, 0x86, 0x18, 0x66, 0x61, 0xB0, 0x6D, 0xC3, 0xFE, 0x7F, 0x9F, 0xE7,
68
+0xF9, 0xFE, 0x1F, 0xE6, 0x3F, 0x9F, 0xEC, 0xFE, 0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xC6,
69
+0x3F, 0x9F, 0xEC, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
79
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
81
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
82
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
83
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00,
86
+0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x20, 0x82, 0x00,
87
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xF3, 0xCF, 0x70, 0x9E, 0x79, 0xE7, 0x80, 0x00, 0x00,
88
+0x00, 0x00, 0x7D, 0x9E, 0x68, 0x20, 0xB2, 0xC8, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x9E,
89
+0x6F, 0x20, 0xB2, 0xF9, 0xE7, 0x80, 0x00, 0x00, 0x00, 0x00, 0x46, 0x9A, 0x61, 0x20, 0xB2, 0xCB,
90
+0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xF3, 0xCF, 0x30, 0x9E, 0x79, 0xE7, 0x90, 0x00, 0x00,
91
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
92
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
94
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
95
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x02, 0x00, 0x00, 0x82, 0x60, 0x00, 0x00,
96
+0xF8, 0x00, 0x00, 0x40, 0x40, 0x02, 0x00, 0x00, 0x83, 0x60, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x40,
97
+0x60, 0xB7, 0x79, 0xE7, 0x81, 0xC7, 0x92, 0x70, 0x89, 0xE7, 0x9E, 0x78, 0x7C, 0xE2, 0xC9, 0x2C,
98
+0x81, 0xCC, 0xD2, 0x40, 0xFB, 0x21, 0xB2, 0x48, 0x40, 0x62, 0xF9, 0x2C, 0x80, 0x8C, 0xD2, 0x40,
99
+0x8B, 0xE7, 0xB0, 0x48, 0x40, 0xE2, 0xC9, 0x2C, 0x80, 0x84, 0xD2, 0x40, 0x8B, 0x2D, 0x92, 0x48,
100
+0x7D, 0xB3, 0x79, 0x27, 0x80, 0x87, 0x9E, 0x40, 0x8D, 0xE7, 0x9E, 0x48, 0x00, 0x00, 0x00, 0x00,
101
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
102
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
103
+};
104
+
105
+
106
+int
107
+main(int argc, char **argv)
108
+{
109
+    upm::SSD1327 *lcd = new upm::SSD1327 (BUS_NUMBER, 0x3C);
110
+
111
+    /*
112
+     * Simple print hello world
113
+     */
114
+    for(uint8_t i = 0; i < 12 ; i++) {
115
+        lcd->setCursor (i, 0);
116
+        lcd->setGrayLevel (i);
117
+        lcd->write ("Hello World");
118
+    }
119
+
120
+   /*
121
+     * Simple print hello world
122
+     */
123
+    lcd->draw (SeeedLogo, 96 * 96 / 8);
124
+
125
+    lcd->close ();
126
+}

+ 1
- 1
src/lcd/CMakeLists.txt View File

@@ -1,4 +1,4 @@
1 1
 set (libname "i2clcd")
2
-add_library (i2clcd SHARED iiclcd.cxx lcm1602.cxx jhd1313m1.cxx ssd1308.cxx)
2
+add_library (i2clcd SHARED iiclcd.cxx lcm1602.cxx jhd1313m1.cxx ssd1308.cxx ssd1327.cxx)
3 3
 include_directories (${MAA_INCLUDE_DIR})
4 4
 target_link_libraries (i2clcd ${MAA_LIBRARIES})

+ 7
- 0
src/lcd/jsupm_ssd1327.i View File

@@ -0,0 +1,7 @@
1
+%module jsupm_ssd1327
2
+
3
+%{
4
+    #include "ssd1327.h"
5
+%}
6
+
7
+%include "ssd1327.h"

+ 8
- 0
src/lcd/pyupm_ssd1327.i View File

@@ -0,0 +1,8 @@
1
+%module pyupm_ssd1327
2
+
3
+%feature("autodoc", "3");
4
+
5
+%include "ssd1327.h"
6
+%{
7
+    #include "ssd1327.h"
8
+%}

+ 276
- 0
src/lcd/ssd1327.cxx View File

@@ -0,0 +1,276 @@
1
+/*
2
+ * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3
+ * Copyright (c) 2014 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
+
25
+#include <string>
26
+#include <unistd.h>
27
+
28
+#include "ssd1327.h"
29
+
30
+using namespace upm;
31
+
32
+#define INIT_SLEEP 50000
33
+#define CMD_SLEEP  10000
34
+
35
+SSD1327::SSD1327 (int bus_in, int addr_in) : IICLcd (bus_in, addr_in) {
36
+    maa_result_t error  = MAA_SUCCESS;
37
+    usleep (INIT_SLEEP);
38
+    i2Cmd (m_i2c_lcd_control, 0xFD); // Unlock OLED driver IC MCU interface from entering command. i.e: Accept commands
39
+    usleep (INIT_SLEEP);
40
+    i2Cmd (m_i2c_lcd_control, 0x12);
41
+    usleep (INIT_SLEEP);
42
+    error = i2Cmd (m_i2c_lcd_control, 0xAE); // Set display off
43
+    usleep (INIT_SLEEP);
44
+    i2Cmd (m_i2c_lcd_control, 0xA8); // set multiplex ratio
45
+    usleep (INIT_SLEEP);
46
+    error = i2Cmd (m_i2c_lcd_control, 0x5F); // 96
47
+    usleep (INIT_SLEEP);
48
+    error = i2Cmd (m_i2c_lcd_control, 0xA1); // set display start line
49
+    usleep (INIT_SLEEP);
50
+    error = i2Cmd (m_i2c_lcd_control, 0x00); //
51
+    usleep (INIT_SLEEP);
52
+    error = i2Cmd (m_i2c_lcd_control, 0xA2); // set display offset
53
+    usleep (INIT_SLEEP);
54
+    error = i2Cmd (m_i2c_lcd_control, 0x60);
55
+    usleep (INIT_SLEEP);
56
+    error = i2Cmd (m_i2c_lcd_control, 0xA0); // set remap
57
+    usleep (INIT_SLEEP);
58
+    error = i2Cmd (m_i2c_lcd_control, 0x46);
59
+    usleep (INIT_SLEEP);
60
+    error = i2Cmd (m_i2c_lcd_control, 0xAB); // set vdd internal
61
+    usleep (INIT_SLEEP);
62
+    error = i2Cmd (m_i2c_lcd_control, 0x01); //
63
+    usleep (INIT_SLEEP);
64
+    error = i2Cmd (m_i2c_lcd_control, 0x81); // set contrasr
65
+    usleep (INIT_SLEEP);
66
+    error = i2Cmd (m_i2c_lcd_control, 0x53); // 100 nit
67
+    usleep (INIT_SLEEP);
68
+    error = i2Cmd (m_i2c_lcd_control, 0xB1); // Set Phase Length
69
+    usleep (INIT_SLEEP);
70
+    error = i2Cmd (m_i2c_lcd_control, 0X51); //
71
+    usleep (INIT_SLEEP);
72
+    error = i2Cmd (m_i2c_lcd_control, 0xB3); // Set Display Clock Divide Ratio/Oscillator Frequency
73
+    usleep (INIT_SLEEP);
74
+    error = i2Cmd (m_i2c_lcd_control, 0x01); //
75
+    usleep (INIT_SLEEP);
76
+    error = i2Cmd (m_i2c_lcd_control, 0xB9); //
77
+    usleep (INIT_SLEEP);
78
+    error = i2Cmd (m_i2c_lcd_control, 0xBC); // set pre_charge voltage/VCOMH
79
+    usleep (INIT_SLEEP);
80
+    error = i2Cmd (m_i2c_lcd_control, 0x08); // (0x08);
81
+    usleep (INIT_SLEEP);
82
+    error = i2Cmd (m_i2c_lcd_control, 0xBE); // set VCOMH
83
+    usleep (INIT_SLEEP);
84
+    error = i2Cmd (m_i2c_lcd_control, 0X07); // (0x07);
85
+    usleep (INIT_SLEEP);
86
+    error = i2Cmd (m_i2c_lcd_control, 0xB6); // Set second pre-charge period
87
+    usleep (INIT_SLEEP);
88
+    error = i2Cmd (m_i2c_lcd_control, 0x01); //
89
+    usleep (INIT_SLEEP);
90
+    error = i2Cmd (m_i2c_lcd_control, 0xD5); // enable second precharge and enternal vsl
91
+    usleep (INIT_SLEEP);
92
+    error = i2Cmd (m_i2c_lcd_control, 0X62); // (0x62);
93
+    usleep (INIT_SLEEP);
94
+    error = i2Cmd (m_i2c_lcd_control, 0xA4); // Set Normal Display Mode
95
+    usleep (INIT_SLEEP);
96
+    error = i2Cmd (m_i2c_lcd_control, 0x2E); // Deactivate Scroll
97
+    usleep (INIT_SLEEP);
98
+    error = i2Cmd (m_i2c_lcd_control, 0xAF); // Switch on display
99
+    usleep (INIT_SLEEP);
100
+
101
+    // Row Address
102
+    error = i2Cmd (m_i2c_lcd_control, 0x75); // Set Row Address
103
+    usleep (INIT_SLEEP);
104
+    error = i2Cmd (m_i2c_lcd_control, 0x00); // Start 0
105
+    usleep (INIT_SLEEP);
106
+    error = i2Cmd (m_i2c_lcd_control, 0x5f); // End 95
107
+    usleep (INIT_SLEEP);
108
+
109
+    // Column Address
110
+    error = i2Cmd (m_i2c_lcd_control, 0x15); // Set Column Address
111
+    usleep (INIT_SLEEP);
112
+    error = i2Cmd (m_i2c_lcd_control, 0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
113
+    usleep (INIT_SLEEP);
114
+    error = i2Cmd (m_i2c_lcd_control, 0x37); // End at  (8 + 47)th column. Each Column has 2 pixels(segments)
115
+    usleep (INIT_SLEEP);
116
+
117
+    clear ();
118
+    setNormalDisplay ();
119
+    setVerticalMode ();
120
+}
121
+
122
+SSD1327::~SSD1327 () {
123
+
124
+}
125
+
126
+maa_result_t
127
+SSD1327::draw (uint8_t *data, int bytes) {
128
+    maa_result_t error = MAA_SUCCESS;
129
+
130
+    setHorizontalMode ();
131
+    for (int row = 0; row < bytes; row++) {
132
+        for (uint8_t col = 0; col < 8; col+=2) {
133
+            uint8_t value = 0x0;
134
+
135
+            uint8_t bitOne = (data[row] << col) & 0x80;
136
+            uint8_t bitTwo = (data[row] << (col + 1)) & 0x80;
137
+
138
+            value |= (bitOne) ? grayHigh : 0x00;
139
+            value |= (bitTwo) ? grayLow : 0x00;
140
+
141
+            i2cData (m_i2c_lcd_control, value);
142
+            usleep (CMD_SLEEP - 2000);
143
+        }
144
+    }
145
+
146
+    return error;
147
+}
148
+
149
+/*
150
+ * **************
151
+ *  virtual area
152
+ * **************
153
+ */
154
+maa_result_t
155
+SSD1327::write (std::string msg) {
156
+    maa_result_t error = MAA_SUCCESS;
157
+
158
+    setVerticalMode ();
159
+    for (std::string::size_type i = 0; i < msg.size(); ++i) {
160
+        writeChar (m_i2c_lcd_control, msg[i]);
161
+    }
162
+
163
+    return error;
164
+}
165
+
166
+maa_result_t
167
+SSD1327::setCursor (int row, int column) {
168
+    maa_result_t error = MAA_SUCCESS;
169
+
170
+    //Column Address
171
+    i2Cmd (m_i2c_lcd_control, 0x15);                /* Set Column Address */
172
+    usleep (CMD_SLEEP);
173
+    i2Cmd (m_i2c_lcd_control, 0x08 + (column * 4));  /* Start Column: Start from 8 */
174
+    usleep (CMD_SLEEP);
175
+    i2Cmd (m_i2c_lcd_control, 0x37);                /* End Column */
176
+    usleep (CMD_SLEEP);
177
+    // Row Address
178
+    i2Cmd (m_i2c_lcd_control, 0x75);                /* Set Row Address */
179
+    usleep (CMD_SLEEP);
180
+    i2Cmd (m_i2c_lcd_control, 0x00 + (row * 8));     /* Start Row*/
181
+    usleep (CMD_SLEEP);
182
+    i2Cmd (m_i2c_lcd_control, 0x07 + (row * 8));     /* End Row*/
183
+    usleep (CMD_SLEEP);
184
+
185
+    return error;
186
+}
187
+
188
+maa_result_t
189
+SSD1327::clear () {
190
+    maa_result_t error = MAA_SUCCESS;
191
+    uint8_t columnIdx, rowIdx;
192
+
193
+    for(rowIdx = 0; rowIdx < 12; rowIdx++) {
194
+        // clear all columns
195
+        for(columnIdx = 0; columnIdx < 12; columnIdx++) {
196
+            writeChar (m_i2c_lcd_control, ' ');
197
+        }
198
+    }
199
+
200
+    return MAA_SUCCESS;
201
+}
202
+
203
+maa_result_t
204
+SSD1327::home () {
205
+    return setCursor (0, 0);
206
+}
207
+
208
+maa_result_t
209
+SSD1327::setGrayLevel (uint8_t level) {
210
+    grayHigh = (level << 4) & 0xF0;
211
+    grayLow  =  level & 0x0F;
212
+}
213
+
214
+/*
215
+ * **************
216
+ *  private area
217
+ * **************
218
+ */
219
+maa_result_t
220
+SSD1327::writeChar (maa_i2c_context ctx, uint8_t value) {
221
+    if (value < 0x20 || value > 0x7F) {
222
+        value = 0x20; // space
223
+    }
224
+
225
+    for (uint8_t row = 0; row < 8; row=row+2) {
226
+        for (uint8_t col = 0; col < 8; col++) {
227
+            uint8_t data = 0x0;
228
+
229
+            uint8_t bitOne = ((BasicFont[value - 32][row]) >> col) & 0x1;
230
+            uint8_t bitTwo = ((BasicFont[value - 32][row + 1]) >> col) & 0x1;
231
+
232
+            data |= (bitOne) ? grayHigh : 0x00;
233
+            data |= (bitTwo) ? grayLow : 0x00;
234
+
235
+            i2cData (m_i2c_lcd_control, data);
236
+            usleep (CMD_SLEEP - 2000);
237
+        }
238
+    }
239
+}
240
+
241
+maa_result_t
242
+SSD1327::setNormalDisplay () {
243
+    return i2Cmd (m_i2c_lcd_control, DISPLAY_CMD_SET_NORMAL);    // set to normal display '1' is ON
244
+}
245
+
246
+maa_result_t
247
+SSD1327::setHorizontalMode () {
248
+    i2Cmd (m_i2c_lcd_control, 0xA0); // remap to
249
+    usleep (CMD_SLEEP);
250
+    i2Cmd (m_i2c_lcd_control, 0x42); // horizontal mode
251
+    usleep (CMD_SLEEP);
252
+
253
+    // Row Address
254
+    i2Cmd (m_i2c_lcd_control, 0x75); // Set Row Address
255
+    usleep (CMD_SLEEP);
256
+    i2Cmd (m_i2c_lcd_control, 0x00); // Start 0
257
+    usleep (CMD_SLEEP);
258
+    i2Cmd (m_i2c_lcd_control, 0x5f); // End 95
259
+    usleep (CMD_SLEEP);
260
+
261
+    // Column Address
262
+    i2Cmd (m_i2c_lcd_control, 0x15); // Set Column Address
263
+    usleep (CMD_SLEEP);
264
+    i2Cmd (m_i2c_lcd_control, 0x08); // Start from 8th Column of driver IC. This is 0th Column for OLED
265
+    usleep (CMD_SLEEP);
266
+    i2Cmd (m_i2c_lcd_control, 0x37); // End at  (8 + 47)th column. Each Column has 2 pixels(or segments)
267
+    usleep (CMD_SLEEP);
268
+}
269
+
270
+maa_result_t
271
+SSD1327::setVerticalMode () {
272
+    i2Cmd (m_i2c_lcd_control, 0xA0); // remap to
273
+    usleep (CMD_SLEEP);
274
+    i2Cmd (m_i2c_lcd_control, 0x46); // Vertical mode
275
+    usleep (CMD_SLEEP);
276
+}

+ 175
- 0
src/lcd/ssd1327.h View File

@@ -0,0 +1,175 @@
1
+/*
2
+ * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3
+ * Copyright (c) 2014 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
+
25
+#pragma once
26
+
27
+#include <string>
28
+#include "iiclcd.h"
29
+
30
+namespace upm {
31
+/*
32
+#define DISPLAY_CMD_OFF             0xAE
33
+#define DISPLAY_CMD_ON              0xAF
34
+
35
+#define BASE_LOW_COLUMN_ADDR        0x00
36
+#define BASE_HIGH_COLUMN_ADDR       0x10
37
+#define BASE_PAGE_START_ADDR        0xB0
38
+#define DISPLAY_CMD_MEM_ADDR_MODE   0x20
39
+*/
40
+#define DISPLAY_CMD_SET_NORMAL      0xA4
41
+
42
+const uint8_t BasicFont[][8] =
43
+{
44
+  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
45
+  {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
46
+  {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
47
+  {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
48
+  {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
49
+  {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
50
+  {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
51
+  {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
52
+  {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
53
+  {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
54
+  {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
55
+  {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
56
+  {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
57
+  {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
58
+  {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
59
+  {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
60
+  {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
61
+  {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
62
+  {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
63
+  {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
64
+  {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
65
+  {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
66
+  {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
67
+  {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
68
+  {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
69
+  {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
70
+  {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
71
+  {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
72
+  {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
73
+  {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
74
+  {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
75
+  {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
76
+  {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
77
+  {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
78
+  {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
79
+  {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
80
+  {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
81
+  {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
82
+  {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
83
+  {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
84
+  {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
85
+  {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
86
+  {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
87
+  {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
88
+  {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
89
+  {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
90
+  {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
91
+  {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
92
+  {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
93
+  {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
94
+  {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
95
+  {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
96
+  {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
97
+  {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
98
+  {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
99
+  {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
100
+  {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
101
+  {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
102
+  {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
103
+  {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
104
+  {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
105
+  {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
106
+  {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
107
+  {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
108
+  {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
109
+  {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
110
+  {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
111
+  {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
112
+  {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
113
+  {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
114
+  {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
115
+  {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
116
+  {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
117
+  {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
118
+  {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
119
+  {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
120
+  {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
121
+  {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
122
+  {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
123
+  {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
124
+  {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
125
+  {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
126
+  {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
127
+  {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
128
+  {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
129
+  {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
130
+  {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
131
+  {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
132
+  {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
133
+  {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
134
+  {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
135
+  {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
136
+  {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
137
+  {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
138
+  {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
139
+  {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
140
+};
141
+
142
+typedef enum {
143
+    HORIZONTAL    =  0,
144
+    VERTICAL      =  1,
145
+    PAGE          =  2
146
+} displayAddressingMode;
147
+
148
+class SSD1327 : public IICLcd {
149
+    public:
150
+        /** SSD1308 Constructor.
151
+         * Calls MAA initialisation functions.
152
+         * @param bus i2c bus to use
153
+         * @param address the slave address the lcd is registered on.
154
+         */
155
+        SSD1327 (int bus, int address);
156
+        ~SSD1327 ();
157
+        maa_result_t draw(uint8_t *data, int bytes);
158
+
159
+        // virtual methods
160
+        maa_result_t write (std::string msg);
161
+        maa_result_t setCursor (int row, int column);
162
+        maa_result_t clear ();
163
+        maa_result_t home ();
164
+        maa_result_t setGrayLevel (uint8_t level);
165
+
166
+    private:
167
+        maa_result_t writeChar (maa_i2c_context ctx, uint8_t value);
168
+        maa_result_t setNormalDisplay ();
169
+        maa_result_t setHorizontalMode ();
170
+        maa_result_t setVerticalMode ();
171
+
172
+        uint8_t grayHigh;
173
+        uint8_t grayLow;
174
+    };
175
+}