components/u8g2/csrc/u8x8_d_sbn1661.c

changeset 0
88d965579617
equal deleted inserted replaced
-1:000000000000 0:88d965579617
1 /*
2
3 u8x8_d_sbn1661.c
4
5 SED1520 / SBN1661 122x32 5V LCD
6
7 Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
8
9 Copyright (c) 2016, olikraus@gmail.com
10 All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without modification,
13 are permitted provided that the following conditions are met:
14
15 * Redistributions of source code must retain the above copyright notice, this list
16 of conditions and the following disclaimer.
17
18 * Redistributions in binary form must reproduce the above copyright notice, this
19 list of conditions and the following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
36
37 */
38 #include "u8x8.h"
39
40
41
42
43 static const uint8_t u8x8_d_sbn1661_init_seq[] = {
44 U8X8_C(0x0c0), /* display start at line 0 */
45 U8X8_C(0x0a0), /* a0: ADC forward, a1: ADC reverse */
46 U8X8_C(0x0a4), /* a4: normal driving, a5: power save */
47 U8X8_C(0x0a9), /* a8: 1/16, a9: 1/32 duty */
48
49 //U8X8_C(0x0af), /* display on */
50
51 U8X8_END() /* end of sequence */
52 };
53
54 static const uint8_t u8x8_d_sbn1661_powersave0_seq[] = {
55 U8X8_C(0x0af), /* display on */
56 U8X8_END() /* end of sequence */
57 };
58
59 static const uint8_t u8x8_d_sbn1661_powersave1_seq[] = {
60 U8X8_C(0x0ae), /* display off */
61 U8X8_END() /* end of sequence */
62 };
63
64
65 struct u8x8_sbn1661_vars
66 {
67 uint8_t *ptr;
68 uint8_t x;
69 uint8_t c;
70 uint8_t arg_int;
71 };
72
73 #ifdef NOT_USED
74 static void u8x8_sbn1661_out(u8x8_t *u8x8, struct u8x8_sbn1661_vars *v, void *arg_ptr)
75 {
76 uint8_t cnt;
77 u8x8_cad_SendCmd(u8x8, 0x000 | ((v->x << 3) & 63) );
78 u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
79
80 while( v->arg_int > 0 )
81 {
82 /* calculate tiles to next boundary (end or chip limit) */
83 cnt = v->x;
84 cnt += 8;
85 cnt &= 0x0f8;
86 cnt -= v->x;
87
88 if ( cnt > v->c )
89 cnt = v->c;
90
91 /* of course we still could use cnt=1 here... */
92 /* but setting cnt to 1 is not very efficient */
93 //cnt = 1;
94
95 v->x +=cnt;
96 v->c-=cnt;
97 cnt<<=3;
98 u8x8_cad_SendData(u8x8, cnt, v->ptr); /* note: SendData can not handle more than 255 bytes */
99 v->ptr += cnt;
100
101 if ( v->c == 0 )
102 {
103 v->ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
104 v->c = ((u8x8_tile_t *)arg_ptr)->cnt;
105 v->arg_int--;
106 }
107 if ( ((v->x) & 7) == 0 )
108 break;
109 }
110 }
111 #endif /* NOT_USED */
112
113
114 static const u8x8_display_info_t u8x8_sbn1661_122x32_display_info =
115 {
116 /* chip_enable_level = */ 0, /* sbn1661: Not used */
117 /* chip_disable_level = */ 1, /* sbn1661: Not used */
118
119 /* post_chip_enable_wait_ns = */ 100,
120 /* pre_chip_disable_wait_ns = */ 20,
121 /* reset_pulse_width_ms = */ 1,
122 /* post_reset_wait_ms = */ 6, /* */
123 /* sda_setup_time_ns = */ 12,
124 /* sck_pulse_width_ns = */ 75, /* sbn1661: Not used */
125 /* sck_clock_hz = */ 4000000UL, /* sbn1661: Not used */
126 /* spi_mode = */ 0, /* active high, rising edge */
127 /* i2c_bus_clock_100kHz = */ 4, /* sbn1661: Not used */
128 /* data_setup_time_ns = */ 200,
129 /* write_pulse_width_ns = */ 200, /* */
130 /* tile_width = */ 16, /* width of 16*8=128 pixel */
131 /* tile_hight = */ 4,
132 /* default_x_offset = */ 0,
133 /* flipmode_x_offset = */ 0,
134 /* pixel_width = */ 122,
135 /* pixel_height = */ 32
136 };
137
138 uint8_t u8x8_d_sbn1661_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
139 {
140 uint8_t *ptr;
141 //uint8_t x;
142 //uint8_t c;
143
144 switch(msg)
145 {
146 case U8X8_MSG_DISPLAY_SETUP_MEMORY:
147 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sbn1661_122x32_display_info);
148 break;
149 case U8X8_MSG_DISPLAY_INIT:
150 u8x8_d_helper_display_init(u8x8);
151
152 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
153 u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
154 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
155
156 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
157 u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
158 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
159 break;
160 case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
161
162 if ( arg_int == 0 )
163 {
164 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
165 u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
166 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
167
168 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
169 u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
170 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
171 }
172 else
173 {
174 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
175 u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
176 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
177
178 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
179 u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
180 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
181
182 }
183 break;
184 case U8X8_MSG_DISPLAY_DRAW_TILE:
185
186 ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
187 // x and c are ignored (u8g2 only)
188 //x = ((u8x8_tile_t *)arg_ptr)->x_pos;
189 //c = ((u8x8_tile_t *)arg_ptr)->cnt;
190
191 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
192 u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
193 u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
194 u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
195 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
196
197 ptr += 61;
198
199 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
200 u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
201 u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
202
203 u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
204 u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
205
206 break;
207 default:
208 return 0;
209 }
210 return 1;
211 }
212
213 uint8_t u8x8_d_sed1520_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
214 {
215 return u8x8_d_sbn1661_122x32(u8x8, msg, arg_int, arg_ptr);
216
217 }

mercurial