Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
sif_ssd1681.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, Cascoda Ltd.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
36 #ifndef SIF_SIF_SSD1681_H
37 #define SIF_SIF_SSD1681_H
38 
39 #include <stdint.h>
40 #include "ca821x_error.h"
41 #include "cascoda_chili_config.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #ifndef CASCODA_CHILI2_CONFIG
48 #error CASCODA_CHILI2_CONFIG has to be defined! Please include the file "cascoda_chili_config.h"
49 #endif
50 
51 /***********************************************************/
52 /********************* Pin connections *********************/
53 /***********************************************************/
54 /*
55  Pin config for M2351:
56  |---+- BUSY - Pin 31 (GPIO PB.5)
57  |---+- RST - Pin 15 (GPIO PA.15) on Chili2D, Pin 5 (GPIO PB.12) on Devboard
58  |---+- DC - Pin 34 (GPIO PB.2)
59  |---+- CS - GND
60  |---+- CLK - Pin 33 (GPIO PB.3)
61  |---+- DIN - Pin 32 (GPIO PB.4)
62  |---+- GND - (Pins 3/14/16/18-25/27/30)
63  |---+- VCC - Pin 13
64 
65 */
66 
67 /* Pin configuration */
68 #define SIF_SSD1681_BUSY_PIN 31
69 
70 #if (CASCODA_CHILI2_CONFIG == 2)
71 #define SIF_SSD1681_RST_PIN 5
72 #else
73 #define SIF_SSD1681_RST_PIN 15
74 #endif
75 
76 #define SIF_SSD1681_DC_PIN 34
77 //#define SIF_SSD1681_CS_PIN 34
78 
79 /* BUSY Timeout in [ms] */
80 #define SIF_SSD1681_BUSY_TIMEOUT 5000
81 
82 /* Actual physical display resolution (in pixels) */
83 #define SIF_SSD1681_WIDTH_PHYSICAL 200
84 #define SIF_SSD1681_HEIGHT_PHYSICAL 200
85 
86 #ifdef EPAPER_FULL_RESOLUTION
87 #define SIF_SSD1681_WIDTH_WINDOW SIF_SSD1681_WIDTH_PHYSICAL
88 #define SIF_SSD1681_HEIGHT_WINDOW SIF_SSD1681_HEIGHT_PHYSICAL
89 
90 #define SIF_SSD1681_WIDTH SIF_SSD1681_WIDTH_PHYSICAL
91 #define SIF_SSD1681_HEIGHT SIF_SSD1681_HEIGHT_PHYSICAL
92 #else
93 // Display resolution that the window will be set to upon initialization
94 // Note: 192 was chosen because it is the closest number to 200, that is a
95 // multiple of 8 after having been divided by 2. (The problem with 200 is that
96 // 200/2 is 100, which is not divisible by 8).
97 #define SIF_SSD1681_WIDTH_WINDOW 192
98 #define SIF_SSD1681_HEIGHT_WINDOW 200
99 
100 // Display resolution that the image buffer will be set to. This
101 // is the actual display resolution that ends up being used.
102 // This is done to save memory (200x200 resolution requires an image buffer
103 // of 5000 bytes, whereas 96*100 only requires 1200).
104 #define SIF_SSD1681_WIDTH (SIF_SSD1681_WIDTH_WINDOW / 2)
105 #define SIF_SSD1681_HEIGHT (SIF_SSD1681_WIDTH_WINDOW / 2)
106 #endif // EPAPER_FULL_RESOLUTION
107 
108 /* QR code image array size */
109 #define ARRAY_SIZE (SIF_SSD1681_HEIGHT * SIF_SSD1681_WIDTH / 8)
110 
111 /* Display update mode */
112 typedef enum
113 {
117 
118 /* functions */
119 
120 /******************************************************************************/
121 /***************************************************************************/
127 bool SIF_SSD1681_IsAsleep(void);
128 
129 /******************************************************************************/
130 /***************************************************************************/
135 
136 /******************************************************************************/
137 /***************************************************************************/
141 void SIF_SSD1681_Deinitialise(void);
142 
143 /******************************************************************************/
144 /***************************************************************************/
148 void SIF_SSD1681_ClearDisplay(void);
149 
150 /******************************************************************************/
151 /***************************************************************************/
156 
157 /******************************************************************************/
158 /***************************************************************************/
162 void SIF_SSD1681_DeepSleep(void);
163 
164 /******************************************************************************/
165 /***************************************************************************/
176 ca_error SIF_SSD1681_overlay_qr_code(const char *text, uint8_t *image, uint8_t scale, uint8_t x, uint8_t y);
177 
178 /******************************************************************************/
179 /***************************************************************************/
190 void SIF_SSD1681_SetFrameMemory(const uint8_t *image, bool full_resolution);
191 
192 /******************************************************************************/
193 /***************************************************************************/
199 void SIF_SSD1681_SetFrameMemoryPartial(const uint8_t *image);
200 
201 /******************************************************************************/
202 /***************************************************************************/
207 void SIF_SSD1681_DisplayFrame(void);
208 
209 /******************************************************************************/
210 /***************************************************************************/
216 
217 /******************************************************************************/
218 /***************************************************************************/
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
235 #endif
236 // SIF_SIF_SSD1681_H
Global error declarations for use across the Cascoda SDK.
void SIF_SSD1681_Deinitialise(void)
EINK De-Initialisation.
Definition: sif_ssd1681.c:628
void SIF_SSD1681_DisplayFrame(void)
Causes the eink to display what is currently in its RAM, using the full update process.
Definition: sif_ssd1681.c:787
void SIF_SSD1681_ClearDisplay(void)
Clears the display.
Definition: sif_ssd1681.c:645
void SIF_SSD1681_SetFrameMemory(const uint8_t *image, bool full_resolution)
Copies the image into the eink display's RAM, for full update.
Definition: sif_ssd1681.c:714
bool SIF_SSD1681_IsAsleep(void)
Function which reports the sleep status of the eink display.
Definition: sif_ssd1681.c:587
void SIF_SSD1681_DeepSleep(void)
Enter deep sleep mode.
Definition: sif_ssd1681.c:688
void SIF_SSD1681_SetFrameMemoryPartial(const uint8_t *image)
Copies the image into the eink display's RAM, for partial update.
Definition: sif_ssd1681.c:751
void SIF_SSD1681_DisplayPartFrame(void)
Causes the eink to display what is currently in its RAM, using the partial update process.
Definition: sif_ssd1681.c:792
void SIF_SSD1681_DisplayPartBaseImageWhite(void)
Causes the eink to display a white image, to be used as a "base" image for subsequent partial updates...
Definition: sif_ssd1681.c:797
void SIF_SSD1681_StrongClearDisplay(void)
Clears the display many times to make sure there is no ghost image.
Definition: sif_ssd1681.c:681
ca_error SIF_SSD1681_overlay_qr_code(const char *text, uint8_t *image, uint8_t scale, uint8_t x, uint8_t y)
Creates a QR code and overlays it on top of a pre-existing image at the given coordinates.
Definition: sif_ssd1681.c:697
SIF_SSD1681_Update_Mode
Definition: sif_ssd1681.h:113
ca_error SIF_SSD1681_Initialise(void)
EINK Initialisation.
Definition: sif_ssd1681.c:592
@ PARTIAL_UPDATE
Definition: sif_ssd1681.h:115
@ FULL_UPDATE
Definition: sif_ssd1681.h:114
ca_error
Cascoda error type.
Definition: ca821x_error.h:51