Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
gfx_library.h
Go to the documentation of this file.
1 /*********************************************************************
2 This is a header file for the gfx library
3 
4 Copyright 2023 Cascoda LTD.
5 *********************************************************************/
6 #ifndef GFX_LIBRARY_H
7 #define GFX_LIBRARY_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /****** Function Declarations for gfx library ******/
14 
28 void display_drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
29 
41 void display_drawRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
42 
54 void display_fillRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
55 
66 void display_drawCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color);
67 
78 void display_fillCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color);
79 
85 void display_setCursor(uint16_t x, uint16_t y);
86 
91 void display_setTextSize(uint8_t s);
92 
98 void display_setTextColor(uint16_t c, uint16_t b);
99 
106 void display_putc(uint8_t c);
107 
116 void display_puts(const uint8_t *s);
117 
134 void display_puts_max_n(const uint8_t *s, uint8_t n);
135 
143 void display_double(char *text, int text_size, double v, int decimalDigits);
144 
150 void display_setRotation(uint16_t rotation);
151 
156 uint16_t getCursorX(void);
157 
162 uint16_t getCursorY(void);
163 
168 uint16_t display_getWidth();
169 
174 uint16_t display_getHeight();
175 
180 void display_clear(void);
181 
182 /* GENERAL NOTES ON USAGE, and differences between using the 2.9inch (and MIKROE 1.54inch) vs
183 1.54inch (waveshare) functions:
184 - It is simple to do any kind of displaying with the 2.9inch eink display. Simply call the
185 `display_render()` function, with the arguments of your choice. E.g.
186  . To display the frame buffer using full update, with a clear happening before displaying,
187  call `display_render(FULL_UPDATE, WITH_CLEAR)`.
188  . For partial update, without clear, call `display_render(PARTIAL_UPDATE, WITHOUT_CLEAR)`.
189  That is all that is required.
190 - However, if using the 1.54inch display:
191  . To do a full update (always preceded with a clear), simply call the function `display_render_full()`.
192  . To do a partial update, call the function `display_render_partial()`, with `true` or `false` as the argument depending
193  on whether you want the eink display to be put in Deep Sleep mode after the update is done.
194 */
195 #if (defined EPAPER_2_9_INCH || defined EPAPER_MIKROE_1_54_INCH)
196 
197 #ifdef EPAPER_MIKROE_1_54_INCH
202 ca_error display_initialise(void);
203 
211 ca_error display_deinitialise(void);
212 #endif
213 
223 void display_render(
224 #ifdef EPAPER_2_9_INCH
225  SIF_IL3820_Update_Mode updt_mode,
226  SIF_IL3820_Clear_Mode clr_mode);
227 #elif defined EPAPER_MIKROE_1_54_INCH
228  SIF_SSD1608_Update_Mode updt_mode,
229  SIF_SSD1608_Clear_Mode clr_mode);
230 #endif
231 
232 #ifdef EPAPER_MIKROE_1_54_INCH
233 
238 void display_render_nowait(SIF_SSD1608_Update_Mode updt_mode, SIF_SSD1608_Clear_Mode clr_mode);
239 
240 #endif
241 
242 #elif defined EPAPER_WAVESHARE_1_54_INCH
243 
247 void display_render_full(void);
248 
254 void display_render_partial(bool sleep_when_done);
255 
256 #endif
257 
262 void display_fixed_image(const uint8_t *image);
263 
264 #ifdef EPAPER_MIKROE_1_54_INCH
265 
270 void display_fixed_image_nowait(const uint8_t *image);
271 
272 #endif
273 
274 // not documented
275 //void display_setTextWrap(bool w);
276 void display_drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
277 void display_fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
278 void display_drawRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color);
279 void display_fillRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color);
280 
281 void display_drawBitmapV1(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color);
282 void display_drawBitmapV1_bg(uint16_t x,
283  uint16_t y,
284  const uint8_t *bitmap,
285  uint16_t w,
286  uint16_t h,
287  uint16_t color,
288  uint16_t bg);
289 void display_drawBitmapV2(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color);
290 void display_drawBitmapV2_bg(uint16_t x,
291  uint16_t y,
292  const uint8_t *bitmap,
293  uint16_t w,
294  uint16_t h,
295  uint16_t color,
296  uint16_t bg);
297 void display_drawPixel(int16_t x, int16_t y, uint16_t color);
298 
299 uint8_t display_getRotation();
300 
301 void display_customChar(const uint8_t *c);
302 void display_drawChar(uint16_t x, uint16_t y, uint8_t c, uint16_t color, uint16_t bg, uint8_t size);
303 
304 void display_setContrast(uint32_t contrast);
305 void display_slider(int x, int y, int length, int value);
306 void display_progressbar(int x, int y, int length, int value);
307 
308 #ifdef __cplusplus
309 }
310 #endif
311 
312 #endif
void display_putc(uint8_t c)
Print one byte/character of data.
Definition: gfx_library.c:861
void display_setTextSize(uint8_t s)
Set text 'magnification' size.
Definition: gfx_library.c:1077
void display_double(char *text, int text_size, double v, int decimalDigits)
convert a float to a string
Definition: gfx_library.c:1287
uint16_t display_getHeight()
Get display Height.
Definition: gfx_library.c:1134
void display_drawCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color)
draw circle
Definition: gfx_library.c:501
void display_drawBitmapV1_bg(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color, uint16_t bg)
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground (for ...
Definition: gfx_library.c:1194
void display_puts_max_n(const uint8_t *s, uint8_t n)
Print a maximum of (n - 1) characters from the input string to the display and put "....
Definition: gfx_library.c:928
uint16_t getCursorY(void)
Get text cursor Y location.
void display_fillRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
draw filled rectangle
Definition: gfx_library.c:285
void display_drawPixel(int16_t x, int16_t y, uint16_t color)
Definition: gfx_library.c:142
void display_setTextColor(uint16_t c, uint16_t b)
Set text font color with custom background color.
Definition: gfx_library.c:1089
void display_clear(void)
clears the frame buffer intializes the background on white.
Definition: gfx_library.c:148
void display_drawRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
draw rectangle
Definition: gfx_library.c:674
void display_drawRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color)
Draw a rounded rectangle with no fill color.
Definition: gfx_library.c:693
void display_drawChar(uint16_t x, uint16_t y, uint8_t c, uint16_t color, uint16_t bg, uint8_t size)
Draw a single character.
Definition: gfx_library.c:1019
void display_slider(int x, int y, int length, int value)
Definition: gfx_library.c:1313
uint8_t display_getRotation()
Get rotation setting for display.
Definition: gfx_library.c:1112
void display_drawBitmapV1(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color)
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground color...
Definition: gfx_library.c:1168
void display_customChar(const uint8_t *c)
Definition: gfx_library.c:961
void display_fixed_image(const uint8_t *image)
Displays the image provided, using full update (slow).
void display_drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a triangle with no fill color.
Definition: gfx_library.c:746
void display_setCursor(uint16_t x, uint16_t y)
Set text cursor location.
Definition: gfx_library.c:1043
void display_drawBitmapV2_bg(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color, uint16_t bg)
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground (for ...
Definition: gfx_library.c:1260
void display_setContrast(uint32_t contrast)
void display_progressbar(int x, int y, int length, int value)
Definition: gfx_library.c:1322
void display_fillRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color)
Draw a rounded rectangle with fill color.
Definition: gfx_library.c:721
void display_setRotation(uint16_t rotation)
set the rotation prints starting at the cursor position.
Definition: gfx_library.c:277
void display_fillCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color)
draw a filled circle
Definition: gfx_library.c:598
void display_fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a triangle with color-fill.
Definition: gfx_library.c:765
void display_drawBitmapV2(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color)
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground color...
Definition: gfx_library.c:1227
void display_puts(const uint8_t *s)
Print a string to the display.
Definition: gfx_library.c:922
void display_drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color)
draw line
Definition: gfx_library.c:471
uint16_t getCursorX(void)
Get text cursor X location.
uint16_t display_getWidth()
Get display Width.
Definition: gfx_library.c:1123
SIF_IL3820_Clear_Mode
Definition: sif_il3820.h:98
SIF_IL3820_Update_Mode
Definition: sif_il3820.h:91
SIF_SSD1608_Update_Mode
Definition: sif_ssd1608.h:108
SIF_SSD1608_Clear_Mode
Definition: sif_ssd1608.h:115
ca_error
Cascoda error type.
Definition: ca821x_error.h:51