|
@@ -36,96 +36,92 @@ SSD1327::SSD1327(int bus_in, int addr_in) : I2CLcd(bus_in, addr_in)
|
36
|
36
|
{
|
37
|
37
|
mraa_result_t error = MRAA_SUCCESS;
|
38
|
38
|
usleep(INIT_SLEEP);
|
39
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xFD, LCD_CMD); // Unlock OLED driver IC MCU
|
40
|
|
- // interface from entering command.
|
41
|
|
- // i.e: Accept commands
|
|
39
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0xFD); // Unlock OLED driver IC MCU
|
|
40
|
+ // interface from entering command.
|
|
41
|
+ // i.e: Accept commands
|
42
|
42
|
usleep(INIT_SLEEP);
|
43
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x12, LCD_CMD);
|
|
43
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x12);
|
44
|
44
|
usleep(INIT_SLEEP);
|
45
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xAE, LCD_CMD); // Set display off
|
|
45
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xAE); // Set display off
|
46
|
46
|
usleep(INIT_SLEEP);
|
47
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA8, LCD_CMD); // set multiplex ratio
|
|
47
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0xA8); // set multiplex ratio
|
48
|
48
|
usleep(INIT_SLEEP);
|
49
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x5F, LCD_CMD); // 96
|
|
49
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x5F); // 96
|
50
|
50
|
usleep(INIT_SLEEP);
|
51
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA1, LCD_CMD); // set display start line
|
|
51
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xA1); // set display start line
|
52
|
52
|
usleep(INIT_SLEEP);
|
53
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00, LCD_CMD); //
|
|
53
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x00); //
|
54
|
54
|
usleep(INIT_SLEEP);
|
55
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA2, LCD_CMD); // set display offset
|
|
55
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xA2); // set display offset
|
56
|
56
|
usleep(INIT_SLEEP);
|
57
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x60, LCD_CMD);
|
|
57
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x60);
|
58
|
58
|
usleep(INIT_SLEEP);
|
59
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA0, LCD_CMD); // set remap
|
|
59
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xA0); // set remap
|
60
|
60
|
usleep(INIT_SLEEP);
|
61
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x46, LCD_CMD);
|
|
61
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x46);
|
62
|
62
|
usleep(INIT_SLEEP);
|
63
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xAB, LCD_CMD); // set vdd internal
|
|
63
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xAB); // set vdd internal
|
64
|
64
|
usleep(INIT_SLEEP);
|
65
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x01, LCD_CMD); //
|
|
65
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x01); //
|
66
|
66
|
usleep(INIT_SLEEP);
|
67
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x81, LCD_CMD); // set contrasr
|
|
67
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x81); // set contrasr
|
68
|
68
|
usleep(INIT_SLEEP);
|
69
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x53, LCD_CMD); // 100 nit
|
|
69
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x53); // 100 nit
|
70
|
70
|
usleep(INIT_SLEEP);
|
71
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xB1, LCD_CMD); // Set Phase Length
|
|
71
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xB1); // Set Phase Length
|
72
|
72
|
usleep(INIT_SLEEP);
|
73
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0X51, LCD_CMD); //
|
|
73
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0X51); //
|
74
|
74
|
usleep(INIT_SLEEP);
|
75
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
76
|
|
- 0xB3,
|
77
|
|
- LCD_CMD); // Set Display Clock Divide Ratio/Oscillator
|
78
|
|
- // Frequency
|
|
75
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xB3); // Set Display Clock Divide Ratio/Oscillator
|
|
76
|
+ // Frequency
|
79
|
77
|
usleep(INIT_SLEEP);
|
80
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x01, LCD_CMD); //
|
|
78
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x01); //
|
81
|
79
|
usleep(INIT_SLEEP);
|
82
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xB9, LCD_CMD); //
|
|
80
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xB9); //
|
83
|
81
|
usleep(INIT_SLEEP);
|
84
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xBC, LCD_CMD); // set pre_charge
|
85
|
|
- // voltage/VCOMH
|
|
82
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xBC); // set pre_charge
|
|
83
|
+ // voltage/VCOMH
|
86
|
84
|
usleep(INIT_SLEEP);
|
87
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08, LCD_CMD); // (0x08);
|
|
85
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x08); // (0x08);
|
88
|
86
|
usleep(INIT_SLEEP);
|
89
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xBE, LCD_CMD); // set VCOMH
|
|
87
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xBE); // set VCOMH
|
90
|
88
|
usleep(INIT_SLEEP);
|
91
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0X07, LCD_CMD); // (0x07);
|
|
89
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0X07); // (0x07);
|
92
|
90
|
usleep(INIT_SLEEP);
|
93
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xB6, LCD_CMD); // Set second pre-charge
|
94
|
|
- // period
|
|
91
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xB6); // Set second pre-charge
|
|
92
|
+ // period
|
95
|
93
|
usleep(INIT_SLEEP);
|
96
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x01, LCD_CMD); //
|
|
94
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x01); //
|
97
|
95
|
usleep(INIT_SLEEP);
|
98
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
99
|
|
- 0xD5,
|
100
|
|
- LCD_CMD); // enable second precharge and enternal vsl
|
|
96
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xD5); // enable second precharge and enternal vsl
|
101
|
97
|
usleep(INIT_SLEEP);
|
102
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0X62, LCD_CMD); // (0x62);
|
|
98
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0X62); // (0x62);
|
103
|
99
|
usleep(INIT_SLEEP);
|
104
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA4, LCD_CMD); // Set Normal Display Mode
|
|
100
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xA4); // Set Normal Display Mode
|
105
|
101
|
usleep(INIT_SLEEP);
|
106
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x2E, LCD_CMD); // Deactivate Scroll
|
|
102
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x2E); // Deactivate Scroll
|
107
|
103
|
usleep(INIT_SLEEP);
|
108
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xAF, LCD_CMD); // Switch on display
|
|
104
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0xAF); // Switch on display
|
109
|
105
|
usleep(INIT_SLEEP);
|
110
|
106
|
|
111
|
107
|
// Row Address
|
112
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x75, LCD_CMD); // Set Row Address
|
|
108
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x75); // Set Row Address
|
113
|
109
|
usleep(INIT_SLEEP);
|
114
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00, LCD_CMD); // Start 0
|
|
110
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x00); // Start 0
|
115
|
111
|
usleep(INIT_SLEEP);
|
116
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x5f, LCD_CMD); // End 95
|
|
112
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x5f); // End 95
|
117
|
113
|
usleep(INIT_SLEEP);
|
118
|
114
|
|
119
|
115
|
// Column Address
|
120
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x15, LCD_CMD); // Set Column Address
|
|
116
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x15); // Set Column Address
|
121
|
117
|
usleep(INIT_SLEEP);
|
122
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08, LCD_CMD); // Start from 8th Column of
|
123
|
|
- // driver IC. This is 0th
|
124
|
|
- // Column for OLED
|
|
118
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x08); // Start from 8th Column of
|
|
119
|
+ // driver IC. This is 0th
|
|
120
|
+ // Column for OLED
|
125
|
121
|
usleep(INIT_SLEEP);
|
126
|
|
- error = mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x37, LCD_CMD); // End at (8 + 47)th
|
127
|
|
- // column. Each Column has 2
|
128
|
|
- // pixels(segments)
|
|
122
|
+ error = m_i2c_lcd_control.writeReg(LCD_CMD, 0x37); // End at (8 + 47)th
|
|
123
|
+ // column. Each Column has 2
|
|
124
|
+ // pixels(segments)
|
129
|
125
|
usleep(INIT_SLEEP);
|
130
|
126
|
|
131
|
127
|
clear();
|
|
@@ -153,7 +149,7 @@ SSD1327::draw(uint8_t* data, int bytes)
|
153
|
149
|
value |= (bitOne) ? grayHigh : 0x00;
|
154
|
150
|
value |= (bitTwo) ? grayLow : 0x00;
|
155
|
151
|
|
156
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, value, LCD_DATA);
|
|
152
|
+ m_i2c_lcd_control.writeReg(LCD_DATA, value);
|
157
|
153
|
usleep(CMD_SLEEP - 2000);
|
158
|
154
|
}
|
159
|
155
|
}
|
|
@@ -185,19 +181,19 @@ SSD1327::setCursor(int row, int column)
|
185
|
181
|
mraa_result_t error = MRAA_SUCCESS;
|
186
|
182
|
|
187
|
183
|
// Column Address
|
188
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x15, LCD_CMD); /* Set Column Address */
|
|
184
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x15); /* Set Column Address */
|
189
|
185
|
usleep(CMD_SLEEP);
|
190
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08 + (column * 4), LCD_CMD); /* Start Column:
|
|
186
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x08 + (column * 4)); /* Start Column:
|
191
|
187
|
Start from 8 */
|
192
|
188
|
usleep(CMD_SLEEP);
|
193
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x37, LCD_CMD); /* End Column */
|
|
189
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x37); /* End Column */
|
194
|
190
|
usleep(CMD_SLEEP);
|
195
|
191
|
// Row Address
|
196
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x75, LCD_CMD); /* Set Row Address */
|
|
192
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x75); /* Set Row Address */
|
197
|
193
|
usleep(CMD_SLEEP);
|
198
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00 + (row * 8), LCD_CMD); /* Start Row*/
|
|
194
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x00 + (row * 8)); /* Start Row*/
|
199
|
195
|
usleep(CMD_SLEEP);
|
200
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x07 + (row * 8), LCD_CMD); /* End Row*/
|
|
196
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x07 + (row * 8)); /* End Row*/
|
201
|
197
|
usleep(CMD_SLEEP);
|
202
|
198
|
|
203
|
199
|
return error;
|
|
@@ -254,7 +250,7 @@ SSD1327::writeChar(uint8_t value)
|
254
|
250
|
data |= (bitOne) ? grayHigh : 0x00;
|
255
|
251
|
data |= (bitTwo) ? grayLow : 0x00;
|
256
|
252
|
|
257
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, data, LCD_DATA);
|
|
253
|
+ m_i2c_lcd_control.writeReg(LCD_DATA, data);
|
258
|
254
|
usleep(CMD_SLEEP - 2000);
|
259
|
255
|
}
|
260
|
256
|
}
|
|
@@ -263,43 +259,42 @@ SSD1327::writeChar(uint8_t value)
|
263
|
259
|
mraa_result_t
|
264
|
260
|
SSD1327::setNormalDisplay()
|
265
|
261
|
{
|
266
|
|
- return mraa_i2c_write_byte_data(m_i2c_lcd_control,
|
267
|
|
- DISPLAY_CMD_SET_NORMAL,
|
268
|
|
- LCD_CMD); // set to normal display '1' is ON
|
|
262
|
+ return m_i2c_lcd_control.writeReg(LCD_CMD,
|
|
263
|
+ DISPLAY_CMD_SET_NORMAL); // set to normal display '1' is ON
|
269
|
264
|
}
|
270
|
265
|
|
271
|
266
|
mraa_result_t
|
272
|
267
|
SSD1327::setHorizontalMode()
|
273
|
268
|
{
|
274
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA0, LCD_CMD); // remap to
|
|
269
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0xA0); // remap to
|
275
|
270
|
usleep(CMD_SLEEP);
|
276
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x42, LCD_CMD); // horizontal mode
|
|
271
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x42); // horizontal mode
|
277
|
272
|
usleep(CMD_SLEEP);
|
278
|
273
|
|
279
|
274
|
// Row Address
|
280
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x75, LCD_CMD); // Set Row Address
|
|
275
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x75); // Set Row Address
|
281
|
276
|
usleep(CMD_SLEEP);
|
282
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x00, LCD_CMD); // Start 0
|
|
277
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x00); // Start 0
|
283
|
278
|
usleep(CMD_SLEEP);
|
284
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x5f, LCD_CMD); // End 95
|
|
279
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x5f); // End 95
|
285
|
280
|
usleep(CMD_SLEEP);
|
286
|
281
|
|
287
|
282
|
// Column Address
|
288
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x15, LCD_CMD); // Set Column Address
|
|
283
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x15); // Set Column Address
|
289
|
284
|
usleep(CMD_SLEEP);
|
290
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x08, LCD_CMD); // Start from 8th Column of driver
|
291
|
|
- // IC. This is 0th Column for OLED
|
|
285
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x08); // Start from 8th Column of driver
|
|
286
|
+ // IC. This is 0th Column for OLED
|
292
|
287
|
usleep(CMD_SLEEP);
|
293
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x37, LCD_CMD); // End at (8 + 47)th column. Each
|
294
|
|
- // Column has 2 pixels(or segments)
|
|
288
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x37); // End at (8 + 47)th column. Each
|
|
289
|
+ // Column has 2 pixels(or segments)
|
295
|
290
|
usleep(CMD_SLEEP);
|
296
|
291
|
}
|
297
|
292
|
|
298
|
293
|
mraa_result_t
|
299
|
294
|
SSD1327::setVerticalMode()
|
300
|
295
|
{
|
301
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0xA0, LCD_CMD); // remap to
|
|
296
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0xA0); // remap to
|
302
|
297
|
usleep(CMD_SLEEP);
|
303
|
|
- mraa_i2c_write_byte_data(m_i2c_lcd_control, 0x46, LCD_CMD); // Vertical mode
|
|
298
|
+ m_i2c_lcd_control.writeReg(LCD_CMD, 0x46); // Vertical mode
|
304
|
299
|
usleep(CMD_SLEEP);
|
305
|
300
|
}
|