Skip to content

Commit 6b6d1ea

Browse files
committed
Printf fixing and Prepairing of new display types, driver itselfs needs to be tweaked,
The new higher resolution is too high for the RAM, so needs some different driving overall
1 parent 7fb07b0 commit 6b6d1ea

File tree

11 files changed

+603
-10
lines changed

11 files changed

+603
-10
lines changed

Firmware/ATC_Paper.bin

484 Bytes
Binary file not shown.

Firmware/components/application/print/u_printf.c

+2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@
5252

5353
#include "drivers.h"
5454
extern int putchar(int c);
55+
extern int putchar_custom(int c);
5556
static void printchar(char **str, int c) {
5657
if (str) {
5758
**str = c;
5859
++(*str);
5960
} else
6061
(void) putchar(c);
62+
(void) putchar_custom(c);
6163
}
6264

6365
#define PAD_RIGHT 1

Firmware/src/epd.c

+26-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "epd_spi.h"
66
#include "epd_bw_213.h"
77
#include "epd_bwr_213.h"
8+
#include "epd_bwr_350.h"
9+
#include "epd_bwy_350.h"
810
#include "epd_bw_213_ice.h"
911
#include "epd_bwr_154.h"
1012
#include "drivers.h"
@@ -20,8 +22,8 @@ extern const uint8_t ucMirror[];
2022
#include "font16.h"
2123
#include "font30.h"
2224

23-
RAM uint8_t epd_model = 0; // 0 = Undetected, 1 = BW213, 2 = BWR213, 3 = BWR154, 4 = BW213ICE
24-
const char *epd_model_string[] = {"NC", "BW213", "BWR213", "BWR154", "213ICE"};
25+
RAM uint8_t epd_model = 0; // 0 = Undetected, 1 = BW213, 2 = BWR213, 3 = BWR154, 4 = BW213ICE, 5 = BWR350
26+
const char *epd_model_string[] = {"NC", "BW213", "BWR213", "BWR154", "213ICE", "BWR350", "BWY350"};
2527
RAM uint8_t epd_update_state = 0;
2628

2729
const char *BLE_conn_string[] = {"", "B"};
@@ -100,6 +102,10 @@ _attribute_ram_code_ uint8_t EPD_read_temp(void)
100102
epd_temperature = EPD_BWR_154_read_temp();
101103
else if (epd_model == 4)
102104
epd_temperature = EPD_BW_213_ice_read_temp();
105+
else if (epd_model == 5)
106+
epd_temperature = EPD_BWR_350_read_temp();
107+
else if (epd_model == 6)
108+
epd_temperature = EPD_BWY_350_read_temp();
103109

104110
EPD_POWER_OFF();
105111

@@ -131,6 +137,10 @@ _attribute_ram_code_ void EPD_Display(unsigned char *image, int size, uint8_t fu
131137
epd_temperature = EPD_BWR_154_Display(image, size, full_or_partial);
132138
else if (epd_model == 4)
133139
epd_temperature = EPD_BW_213_ice_Display(image, size, full_or_partial);
140+
else if (epd_model == 5)
141+
epd_temperature = EPD_BWR_350_Display(image, size, full_or_partial);
142+
else if (epd_model == 6)
143+
epd_temperature = EPD_BWY_350_Display(image, size, full_or_partial);
134144

135145
epd_temperature_is_read = 1;
136146
epd_update_state = 1;
@@ -149,6 +159,10 @@ _attribute_ram_code_ void epd_set_sleep(void)
149159
EPD_BWR_154_set_sleep();
150160
else if (epd_model == 4)
151161
EPD_BW_213_ice_set_sleep();
162+
else if (epd_model == 5)
163+
EPD_BWR_350_set_sleep();
164+
else if (epd_model == 6)
165+
EPD_BWY_350_set_sleep();
152166

153167
EPD_POWER_OFF();
154168
epd_update_state = 0;
@@ -262,6 +276,16 @@ _attribute_ram_code_ void epd_display(uint32_t time_is, uint16_t battery_mv, int
262276
resolution_w = 212;
263277
resolution_h = 104;
264278
}
279+
else if (epd_model == 5)
280+
{// Just as placeholder right now, needs a complete different driving because of RAM limits
281+
resolution_w = 250;
282+
resolution_h = 128; // 122 real pixel, but needed to have a full byte
283+
}
284+
else if (epd_model == 6)
285+
{// Just as placeholder right now, needs a complete different driving because of RAM limits
286+
resolution_w = 250;
287+
resolution_h = 128; // 122 real pixel, but needed to have a full byte
288+
}
265289

266290
obdCreateVirtualDisplay(&obd, resolution_w, resolution_h, epd_temp);
267291
obdFill(&obd, 0, 0); // fill with white

Firmware/src/epd_bwr_350.c

+277
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
#include <stdint.h>
2+
#include "tl_common.h"
3+
#include "main.h"
4+
#include "epd.h"
5+
#include "epd_spi.h"
6+
#include "epd_bwr_350.h"
7+
#include "drivers.h"
8+
#include "stack/ble/ble.h"
9+
10+
// SSD1675 mixed with SSD1680 EPD Controller
11+
12+
#define BWR_350_Len 50
13+
uint8_t LUT_bwr_350_part[] = {
14+
15+
0x01, 0x10, 0x18, 0x01, 0x32, 0x02, 0x01, 0x10, 0x08, 0x01, 0x03, 0x02,
16+
0x01, 0x01, 0x01, 0x0A, 0x05, 0x0A, 0x0F, 0x01, 0x01, 0x01, 0x14, 0x0F,
17+
0x02, 0x02, 0x01, 0x14, 0x01, 0x02, 0x02, 0x04, 0x02, 0x14, 0x12, 0x01,
18+
0x0A, 0x0F, 0x01, 0x02, 0x01, 0x01, 0x07, 0x05, 0x00, 0x22, 0x02, 0x01,
19+
0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x50, 0x18, 0x01,
20+
0x72, 0x02, 0x01, 0x10, 0x88, 0x01, 0x43,
21+
0x02, 0x01, 0x01, 0x01, 0x4A, 0x85, 0x4A,
22+
0x8F, 0x01, 0x01, 0x01, 0x94, 0x8F, 0x82,
23+
0x42, 0x01, 0x14, 0x01, 0x82, 0x42, 0x84,
24+
0x42, 0x14, 0x12, 0x01, 0x4A, 0x4F, 0x01,
25+
0x02, 0x01, 0x01, 0x07, 0x85, 0x00, 0xE2,
26+
0x02, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
27+
0x01, 0x01, 0x01, 0x01, 0x50, 0x58, 0x81,
28+
0x72, 0x02, 0x01, 0x10, 0x88, 0x01, 0x43,
29+
0x42, 0x01, 0x01, 0x01, 0x4A, 0x85, 0x4A,
30+
0x8F, 0x01, 0x01, 0x01, 0x94, 0x8F, 0x82,
31+
0x42, 0x01, 0x14, 0x01, 0x82, 0x42, 0x84,
32+
0x42, 0x14, 0x12, 0x01, 0x4A, 0x4F, 0x01,
33+
0x02, 0x01, 0x01, 0x07, 0x85, 0x00, 0x22,
34+
0x02, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
35+
0x01, 0x01, 0x01, 0x01, 0x50, 0x58, 0x01,
36+
0x72, 0x02, 0x01, 0x10, 0x88, 0x81, 0x43,
37+
0x02, 0x01, 0x01, 0x01, 0x4A, 0x85, 0x4A,
38+
0x8F, 0x01, 0x01, 0x01, 0x94, 0x8F, 0x82,
39+
0x42, 0x01, 0x14, 0x01, 0x82, 0x42, 0x84,
40+
0x42, 0x14, 0x12, 0x01, 0x4A, 0x4F, 0x01,
41+
0x82, 0x01, 0x01, 0x07, 0x05, 0x00, 0x22,
42+
0x42, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
43+
0x01, 0x01, 0x01,
44+
0x02, 0x00, 0x00,
45+
0x22, 0x17, 0x41, 0xA8, 0x32, 0x50
46+
};
47+
48+
#define EPD_BWR_350_test_pattern 0xA5
49+
_attribute_ram_code_ uint8_t EPD_BWR_350_detect(void)
50+
{
51+
// SW Reset
52+
EPD_WriteCmd(0x12);
53+
WaitMs(10);
54+
55+
EPD_WriteCmd(0x32);
56+
int i;
57+
for (i = 0; i < 153; i++)// This model has a 159 bytes LUT storage so we test for that
58+
{
59+
EPD_WriteData(EPD_BWR_350_test_pattern);
60+
}
61+
EPD_WriteCmd(0x33);
62+
for (i = 0; i < 153; i++)
63+
{
64+
if(EPD_SPI_read() != EPD_BWR_350_test_pattern)
65+
return 0;
66+
}
67+
return 1;
68+
}
69+
70+
_attribute_ram_code_ uint8_t EPD_BWR_350_read_temp(void)
71+
{
72+
uint8_t epd_temperature = 0 ;
73+
74+
// SW Reset
75+
EPD_WriteCmd(0x12);
76+
77+
EPD_CheckStatus_inverted(100);
78+
79+
// Set Analog Block control
80+
EPD_WriteCmd(0x74);
81+
EPD_WriteData(0x54);
82+
// Set Digital Block control
83+
EPD_WriteCmd(0x7E);
84+
EPD_WriteData(0x3B);
85+
86+
// Booster soft start
87+
EPD_WriteCmd(0x0C);
88+
EPD_WriteData(0x8B);
89+
EPD_WriteData(0x9C);
90+
EPD_WriteData(0x96);
91+
EPD_WriteData(0x0F);
92+
93+
// Driver output control
94+
EPD_WriteCmd(0x01);
95+
EPD_WriteData(0x28);
96+
EPD_WriteData(0x01);
97+
EPD_WriteData(0x01);
98+
99+
// Data entry mode setting
100+
EPD_WriteCmd(0x11);
101+
EPD_WriteData(0x01);
102+
103+
// Set RAM X- Address Start/End
104+
EPD_WriteCmd(0x44);
105+
EPD_WriteData(0x00);
106+
EPD_WriteData(0x0F);
107+
108+
// Set RAM Y- Address Start/End
109+
EPD_WriteCmd(0x45);
110+
EPD_WriteData(0x28);
111+
EPD_WriteData(0x01);
112+
EPD_WriteData(0x2E);
113+
EPD_WriteData(0x00);
114+
115+
// Border waveform control
116+
EPD_WriteCmd(0x3C);
117+
EPD_WriteData(0x05);
118+
119+
// Display update control
120+
EPD_WriteCmd(0x21);
121+
EPD_WriteData(0x00);
122+
EPD_WriteData(0x80);
123+
124+
// Temperature sensor control
125+
EPD_WriteCmd(0x18);
126+
EPD_WriteData(0x80);
127+
128+
// Display update control
129+
EPD_WriteCmd(0x22);
130+
EPD_WriteData(0xB1);
131+
132+
// Master Activation
133+
EPD_WriteCmd(0x20);
134+
135+
EPD_CheckStatus_inverted(100);
136+
137+
// Temperature sensor read from register
138+
EPD_WriteCmd(0x1B);
139+
epd_temperature = EPD_SPI_read();
140+
EPD_SPI_read();
141+
142+
WaitMs(5);
143+
144+
// deep sleep
145+
EPD_WriteCmd(0x10);
146+
EPD_WriteData(0x01);
147+
148+
return epd_temperature;
149+
}
150+
151+
_attribute_ram_code_ uint8_t EPD_BWR_350_Display(unsigned char *image, int size, uint8_t full_or_partial)
152+
{
153+
uint8_t epd_temperature = 0 ;
154+
155+
// SW Reset
156+
EPD_WriteCmd(0x12);
157+
158+
EPD_CheckStatus_inverted(100);
159+
160+
// Set Analog Block control
161+
EPD_WriteCmd(0x74);
162+
EPD_WriteData(0x54);
163+
// Set Digital Block control
164+
EPD_WriteCmd(0x7E);
165+
EPD_WriteData(0x3B);
166+
167+
// Booster soft start
168+
EPD_WriteCmd(0x0C);
169+
EPD_WriteData(0x8B);
170+
EPD_WriteData(0x9C);
171+
EPD_WriteData(0x96);
172+
EPD_WriteData(0x0F);
173+
174+
// Driver output control
175+
EPD_WriteCmd(0x01);
176+
EPD_WriteData(0x28);
177+
EPD_WriteData(0x01);
178+
EPD_WriteData(0x01);
179+
180+
// Data entry mode setting
181+
EPD_WriteCmd(0x11);
182+
EPD_WriteData(0x01);
183+
184+
// Set RAM X- Address Start/End
185+
EPD_WriteCmd(0x44);
186+
EPD_WriteData(0x00);
187+
EPD_WriteData(0x0F);
188+
189+
// Set RAM Y- Address Start/End
190+
EPD_WriteCmd(0x45);
191+
EPD_WriteData(0x28);
192+
EPD_WriteData(0x01);
193+
EPD_WriteData(0x2E);
194+
EPD_WriteData(0x00);
195+
196+
// Border waveform control
197+
EPD_WriteCmd(0x3C);
198+
EPD_WriteData(0x05);
199+
200+
// Display update control
201+
EPD_WriteCmd(0x21);
202+
EPD_WriteData(0x00);
203+
EPD_WriteData(0x80);
204+
205+
// Temperature sensor control
206+
EPD_WriteCmd(0x18);
207+
EPD_WriteData(0x80);
208+
209+
// Display update control
210+
EPD_WriteCmd(0x22);
211+
EPD_WriteData(0xB1);
212+
213+
// Master Activation
214+
EPD_WriteCmd(0x20);
215+
216+
EPD_CheckStatus_inverted(100);
217+
218+
// Temperature sensor read from register
219+
EPD_WriteCmd(0x1B);
220+
epd_temperature = EPD_SPI_read();
221+
EPD_SPI_read();
222+
223+
WaitMs(5);
224+
225+
// Set RAM X address
226+
EPD_WriteCmd(0x4E);
227+
EPD_WriteData(0x00);
228+
229+
// Set RAM Y address
230+
EPD_WriteCmd(0x4F);
231+
EPD_WriteData(0x28);
232+
EPD_WriteData(0x01);
233+
234+
EPD_LoadImage(image, size, 0x24);
235+
236+
// Set RAM X address
237+
EPD_WriteCmd(0x4E);
238+
EPD_WriteData(0x00);
239+
240+
// Set RAM Y address
241+
EPD_WriteCmd(0x4F);
242+
EPD_WriteData(0x28);
243+
EPD_WriteData(0x01);
244+
245+
EPD_WriteCmd(0x26);// RED Color TODO make something out of it :)
246+
int i;
247+
for (i = 0; i < size; i++)
248+
{
249+
EPD_WriteData(0x00);
250+
}
251+
252+
if (!full_or_partial)
253+
{
254+
EPD_WriteCmd(0x32);
255+
for (i = 0; i < sizeof(LUT_bwr_350_part); i++)
256+
{
257+
EPD_WriteData(LUT_bwr_350_part[i]);
258+
}
259+
}
260+
261+
// Display update control
262+
EPD_WriteCmd(0x22);
263+
EPD_WriteData(0xC7);
264+
265+
// Master Activation
266+
EPD_WriteCmd(0x20);
267+
268+
return epd_temperature;
269+
}
270+
271+
_attribute_ram_code_ void EPD_BWR_350_set_sleep(void)
272+
{
273+
// deep sleep
274+
EPD_WriteCmd(0x10);
275+
EPD_WriteData(0x01);
276+
277+
}

Firmware/src/epd_bwr_350.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
uint8_t EPD_BWR_350_detect(void);
4+
uint8_t EPD_BWR_350_read_temp(void);
5+
uint8_t EPD_BWR_350_Display(unsigned char *image, int size, uint8_t full_or_partial);
6+
void EPD_BWR_350_set_sleep(void);

0 commit comments

Comments
 (0)