components/u8g2/csrc/u8x8_d_pcf8812.c

changeset 0
88d965579617
equal deleted inserted replaced
-1:000000000000 0:88d965579617
1 /*
2
3 u8x8_d_pcf8812.c
4
5 pcf8812: 65x102
6 pcf8814: 65x96
7
8 Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
9
10 Copyright (c) 2017, olikraus@gmail.com
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without modification,
14 are permitted provided that the following conditions are met:
15
16 * Redistributions of source code must retain the above copyright notice, this list
17 of conditions and the following disclaimer.
18
19 * Redistributions in binary form must reproduce the above copyright notice, this
20 list of conditions and the following disclaimer in the documentation and/or other
21 materials provided with the distribution.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
28 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37 */
38
39
40 #include "u8x8.h"
41
42
43
44 static const uint8_t u8x8_d_pcf8812_96x65_init_seq[] = {
45
46 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
47
48 U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
49 U8X8_C(0x008), /* blank display */
50
51 U8X8_C(0x021), /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
52 U8X8_C(0x006), /* temp. control: b10 = 2 */
53 U8X8_C(0x013), /* bias system, 0x010..0x07 1:48 */
54 U8X8_C(0x09f), /* contrast setting, 0..127 */
55 //U8X8_CA(0x020 | 2, 0x080 | 0), /* contrast setting, pcf8814 */
56
57 U8X8_C(0x024), /* deactivate chip (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
58
59 U8X8_END_TRANSFER(), /* disable chip */
60 U8X8_END() /* end of sequence */
61 };
62
63 static const uint8_t u8x8_d_pcf8812_96x65_powersave0_seq[] = {
64 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
65 U8X8_C(0x020), /* power on */
66 U8X8_C(0x00c), /* display on */
67 U8X8_END_TRANSFER(), /* disable chip */
68 U8X8_END() /* end of sequence */
69 };
70
71 static const uint8_t u8x8_d_pcf8812_96x65_powersave1_seq[] = {
72 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
73 U8X8_C(0x020), /* power on */
74 U8X8_C(0x008), /* blank display */
75 U8X8_C(0x024), /* power down */
76 U8X8_END_TRANSFER(), /* disable chip */
77 U8X8_END() /* end of sequence */
78 };
79
80
81 static uint8_t u8x8_d_pcf8812_96x65_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
82 {
83 uint8_t x, c;
84 uint8_t *ptr;
85 switch(msg)
86 {
87 /* handled by the calling function
88 case U8X8_MSG_DISPLAY_SETUP_MEMORY:
89 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
90 break;
91 */
92 case U8X8_MSG_DISPLAY_INIT:
93 u8x8_d_helper_display_init(u8x8);
94 u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_init_seq);
95 break;
96 case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
97 if ( arg_int == 0 )
98 u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave0_seq);
99 else
100 u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave1_seq);
101 break;
102 /*
103 case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
104 if ( arg_int == 0 )
105 {
106 u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip0_seq);
107 u8x8->x_offset = u8x8->display_info->default_x_offset;
108 }
109 else
110 {
111 u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip1_seq);
112 u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
113 }
114 break;
115 */
116 #ifdef U8X8_WITH_SET_CONTRAST
117 case U8X8_MSG_DISPLAY_SET_CONTRAST:
118 u8x8_cad_StartTransfer(u8x8);
119 u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
120 u8x8_cad_SendArg(u8x8, (arg_int>>1)|0x80 ); /* 0..127 for contrast */
121 u8x8_cad_EndTransfer(u8x8);
122 break;
123 #endif
124 case U8X8_MSG_DISPLAY_DRAW_TILE:
125 u8x8_cad_StartTransfer(u8x8);
126 x = ((u8x8_tile_t *)arg_ptr)->x_pos;
127 x *= 8;
128 x += u8x8->x_offset;
129
130 u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
131 u8x8_cad_SendCmd(u8x8, 0x080 | x);
132 u8x8_cad_SendCmd(u8x8, 0x040 | ((u8x8_tile_t *)arg_ptr)->y_pos);
133
134 do
135 {
136 c = ((u8x8_tile_t *)arg_ptr)->cnt;
137 ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
138 u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
139 /*
140 do
141 {
142 u8x8_cad_SendData(u8x8, 8, ptr);
143 ptr += 8;
144 c--;
145 } while( c > 0 );
146 */
147 arg_int--;
148 } while( arg_int > 0 );
149
150 u8x8_cad_EndTransfer(u8x8);
151 break;
152 default:
153 return 0;
154 }
155 return 1;
156 }
157
158
159 static const u8x8_display_info_t u8x8_pcf8812_96x65_display_info =
160 {
161 /* chip_enable_level = */ 0,
162 /* chip_disable_level = */ 1,
163
164 /* post_chip_enable_wait_ns = */ 100,
165 /* pre_chip_disable_wait_ns = */ 100,
166 /* reset_pulse_width_ms = */ 100,
167 /* post_reset_wait_ms = */ 100,
168 /* sda_setup_time_ns = */ 100,
169 /* sck_pulse_width_ns = */ 100,
170 /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
171 /* spi_mode = */ 0, /* active high, rising edge */
172 /* i2c_bus_clock_100kHz = */ 4,
173 /* data_setup_time_ns = */ 40,
174 /* write_pulse_width_ns = */ 150,
175 /* tile_width = */ 12,
176 /* tile_hight = */ 9,
177 /* default_x_offset = */ 0,
178 /* flipmode_x_offset = */ 0,
179 /* pixel_width = */ 96,
180 /* pixel_height = */ 65
181 };
182
183 uint8_t u8x8_d_pcf8812_96x65(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
184 {
185 if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
186 {
187 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
188 return 1;
189 }
190 return u8x8_d_pcf8812_96x65_generic(u8x8, msg, arg_int, arg_ptr);
191 }
192
193

mercurial