Zephyr API 3.6.99
Loading...
Searching...
No Matches
auxdisplay.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022-2023 Jamie McCrae
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_AUXDISPLAY_H_
13#define ZEPHYR_INCLUDE_DRIVERS_AUXDISPLAY_H_
14
24#include <stdint.h>
25#include <stddef.h>
26#include <zephyr/kernel.h>
27#include <zephyr/device.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
34#define AUXDISPLAY_LIGHT_NOT_SUPPORTED 0
35
38
56
67
78
105
117
135
147typedef int (*auxdisplay_display_on_t)(const struct device *dev);
148
154typedef int (*auxdisplay_display_off_t)(const struct device *dev);
155
161typedef int (*auxdisplay_cursor_set_enabled_t)(const struct device *dev, bool enabled);
162
168typedef int (*auxdisplay_position_blinking_set_enabled_t)(const struct device *dev,
169 bool enabled);
170
176typedef int (*auxdisplay_cursor_shift_set_t)(const struct device *dev, uint8_t direction,
177 bool display_shift);
178
184typedef int (*auxdisplay_cursor_position_set_t)(const struct device *dev,
185 enum auxdisplay_position type,
186 int16_t x, int16_t y);
187
193typedef int (*auxdisplay_cursor_position_get_t)(const struct device *dev, int16_t *x,
194 int16_t *y);
195
201typedef int (*auxdisplay_display_position_set_t)(const struct device *dev,
202 enum auxdisplay_position type,
203 int16_t x, int16_t y);
204
210typedef int (*auxdisplay_display_position_get_t)(const struct device *dev, int16_t *x,
211 int16_t *y);
212
218typedef int (*auxdisplay_capabilities_get_t)(const struct device *dev,
219 struct auxdisplay_capabilities *capabilities);
220
226typedef int (*auxdisplay_clear_t)(const struct device *dev);
227
234typedef int (*auxdisplay_brightness_get_t)(const struct device *dev, uint8_t *brightness);
235
241typedef int (*auxdisplay_brightness_set_t)(const struct device *dev, uint8_t brightness);
242
249typedef int (*auxdisplay_backlight_get_t)(const struct device *dev, uint8_t *backlight);
250
256typedef int (*auxdisplay_backlight_set_t)(const struct device *dev, uint8_t backlight);
257
263typedef int (*auxdisplay_is_busy_t)(const struct device *dev);
264
270typedef int (*auxdisplay_custom_character_set_t)(const struct device *dev,
271 struct auxdisplay_character *character);
272
278typedef int (*auxdisplay_write_t)(const struct device *dev, const uint8_t *data, uint16_t len);
279
285typedef int (*auxdisplay_custom_command_t)(const struct device *dev,
286 struct auxdisplay_custom_data *command);
287
288__subsystem struct auxdisplay_driver_api {
289 auxdisplay_display_on_t display_on;
290 auxdisplay_display_off_t display_off;
291 auxdisplay_cursor_set_enabled_t cursor_set_enabled;
292 auxdisplay_position_blinking_set_enabled_t position_blinking_set_enabled;
293 auxdisplay_cursor_shift_set_t cursor_shift_set;
294 auxdisplay_cursor_position_set_t cursor_position_set;
295 auxdisplay_cursor_position_get_t cursor_position_get;
296 auxdisplay_display_position_set_t display_position_set;
297 auxdisplay_display_position_get_t display_position_get;
298 auxdisplay_capabilities_get_t capabilities_get;
299 auxdisplay_clear_t clear;
300 auxdisplay_brightness_get_t brightness_get;
301 auxdisplay_brightness_set_t brightness_set;
302 auxdisplay_backlight_get_t backlight_get;
303 auxdisplay_backlight_set_t backlight_set;
304 auxdisplay_is_busy_t is_busy;
305 auxdisplay_custom_character_set_t custom_character_set;
306 auxdisplay_write_t write;
307 auxdisplay_custom_command_t custom_command;
308};
309
323__syscall int auxdisplay_display_on(const struct device *dev);
324
325static inline int z_impl_auxdisplay_display_on(const struct device *dev)
326{
327 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
328
329 if (!api->display_on) {
330 return -ENOSYS;
331 }
332
333 return api->display_on(dev);
334}
335
345__syscall int auxdisplay_display_off(const struct device *dev);
346
347static inline int z_impl_auxdisplay_display_off(const struct device *dev)
348{
349 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
350
351 if (!api->display_off) {
352 return -ENOSYS;
353 }
354
355 return api->display_off(dev);
356}
357
368__syscall int auxdisplay_cursor_set_enabled(const struct device *dev,
369 bool enabled);
370
371static inline int z_impl_auxdisplay_cursor_set_enabled(const struct device *dev,
372 bool enabled)
373{
374 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
375
376 if (!api->cursor_set_enabled) {
377 return -ENOSYS;
378 }
379
380 return api->cursor_set_enabled(dev, enabled);
381}
382
393__syscall int auxdisplay_position_blinking_set_enabled(const struct device *dev,
394 bool enabled);
395
396static inline int z_impl_auxdisplay_position_blinking_set_enabled(const struct device *dev,
397 bool enabled)
398{
399 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
400
401 if (!api->position_blinking_set_enabled) {
402 return -ENOSYS;
403 }
404
405 return api->position_blinking_set_enabled(dev, enabled);
406}
407
421__syscall int auxdisplay_cursor_shift_set(const struct device *dev,
422 uint8_t direction, bool display_shift);
423
424static inline int z_impl_auxdisplay_cursor_shift_set(const struct device *dev,
425 uint8_t direction,
426 bool display_shift)
427{
428 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
429
430 if (!api->cursor_shift_set) {
431 return -ENOSYS;
432 }
433
434 if (direction >= AUXDISPLAY_DIRECTION_COUNT) {
435 return -EINVAL;
436 }
437
438 return api->cursor_shift_set(dev, direction, display_shift);
439}
440
454__syscall int auxdisplay_cursor_position_set(const struct device *dev,
455 enum auxdisplay_position type,
456 int16_t x, int16_t y);
457
458static inline int z_impl_auxdisplay_cursor_position_set(const struct device *dev,
459 enum auxdisplay_position type,
460 int16_t x, int16_t y)
461{
462 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
463
464 if (!api->cursor_position_set) {
465 return -ENOSYS;
466 } else if (type >= AUXDISPLAY_POSITION_COUNT) {
467 return -EINVAL;
468 } else if (type == AUXDISPLAY_POSITION_ABSOLUTE && (x < 0 || y < 0)) {
469 return -EINVAL;
470 }
471
472 return api->cursor_position_set(dev, type, x, y);
473}
474
487__syscall int auxdisplay_cursor_position_get(const struct device *dev,
488 int16_t *x, int16_t *y);
489
490static inline int z_impl_auxdisplay_cursor_position_get(const struct device *dev,
491 int16_t *x, int16_t *y)
492{
493 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
494
495 if (!api->cursor_position_get) {
496 return -ENOSYS;
497 }
498
499 return api->cursor_position_get(dev, x, y);
500}
501
515__syscall int auxdisplay_display_position_set(const struct device *dev,
516 enum auxdisplay_position type,
517 int16_t x, int16_t y);
518
519static inline int z_impl_auxdisplay_display_position_set(const struct device *dev,
520 enum auxdisplay_position type,
521 int16_t x, int16_t y)
522{
523 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
524
525 if (!api->display_position_set) {
526 return -ENOSYS;
527 } else if (type >= AUXDISPLAY_POSITION_COUNT) {
528 return -EINVAL;
529 } else if (type == AUXDISPLAY_POSITION_ABSOLUTE && (x < 0 || y < 0)) {
530 return -EINVAL;
531 }
532
533 return api->display_position_set(dev, type, x, y);
534}
535
548__syscall int auxdisplay_display_position_get(const struct device *dev,
549 int16_t *x, int16_t *y);
550
551static inline int z_impl_auxdisplay_display_position_get(const struct device *dev,
552 int16_t *x, int16_t *y)
553{
554 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
555
556 if (!api->display_position_get) {
557 return -ENOSYS;
558 }
559
560 return api->display_position_get(dev, x, y);
561}
562
572__syscall int auxdisplay_capabilities_get(const struct device *dev,
573 struct auxdisplay_capabilities *capabilities);
574
575static inline int z_impl_auxdisplay_capabilities_get(const struct device *dev,
576 struct auxdisplay_capabilities *capabilities)
577{
578 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
579
580 return api->capabilities_get(dev, capabilities);
581}
582
593__syscall int auxdisplay_clear(const struct device *dev);
594
595static inline int z_impl_auxdisplay_clear(const struct device *dev)
596{
597 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
598
599 return api->clear(dev);
600}
601
612__syscall int auxdisplay_brightness_get(const struct device *dev,
613 uint8_t *brightness);
614
615static inline int z_impl_auxdisplay_brightness_get(const struct device *dev,
616 uint8_t *brightness)
617{
618 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
619
620 if (!api->brightness_get) {
621 return -ENOSYS;
622 }
623
624 return api->brightness_get(dev, brightness);
625}
626
638__syscall int auxdisplay_brightness_set(const struct device *dev,
639 uint8_t brightness);
640
641static inline int z_impl_auxdisplay_brightness_set(const struct device *dev,
642 uint8_t brightness)
643{
644 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
645
646 if (!api->brightness_set) {
647 return -ENOSYS;
648 }
649
650 return api->brightness_set(dev, brightness);
651}
652
663__syscall int auxdisplay_backlight_get(const struct device *dev,
664 uint8_t *backlight);
665
666static inline int z_impl_auxdisplay_backlight_get(const struct device *dev,
667 uint8_t *backlight)
668{
669 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
670
671 if (!api->backlight_get) {
672 return -ENOSYS;
673 }
674
675 return api->backlight_get(dev, backlight);
676}
677
689__syscall int auxdisplay_backlight_set(const struct device *dev,
690 uint8_t backlight);
691
692static inline int z_impl_auxdisplay_backlight_set(const struct device *dev,
693 uint8_t backlight)
694{
695 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
696
697 if (!api->backlight_set) {
698 return -ENOSYS;
699 }
700
701 return api->backlight_set(dev, backlight);
702}
703
714__syscall int auxdisplay_is_busy(const struct device *dev);
715
716static inline int z_impl_auxdisplay_is_busy(const struct device *dev)
717{
718 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
719
720 if (!api->is_busy) {
721 return -ENOSYS;
722 }
723
724 return api->is_busy(dev);
725}
726
747__syscall int auxdisplay_custom_character_set(const struct device *dev,
748 struct auxdisplay_character *character);
749
750static inline int z_impl_auxdisplay_custom_character_set(const struct device *dev,
751 struct auxdisplay_character *character)
752{
753 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
754
755 if (!api->custom_character_set) {
756 return -ENOSYS;
757 }
758
759 return api->custom_character_set(dev, character);
760}
761
773__syscall int auxdisplay_write(const struct device *dev, const uint8_t *data,
774 uint16_t len);
775
776static inline int z_impl_auxdisplay_write(const struct device *dev,
777 const uint8_t *data, uint16_t len)
778{
779 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
780
781 return api->write(dev, data, len);
782}
783
795__syscall int auxdisplay_custom_command(const struct device *dev,
796 struct auxdisplay_custom_data *data);
797
798static inline int z_impl_auxdisplay_custom_command(const struct device *dev,
799 struct auxdisplay_custom_data *data)
800{
801 struct auxdisplay_driver_api *api = (struct auxdisplay_driver_api *)dev->api;
802
803 if (!api->custom_command) {
804 return -ENOSYS;
805 }
806
807 return api->custom_command(dev, data);
808}
809
810#ifdef __cplusplus
811}
812#endif
813
818#include <zephyr/syscalls/auxdisplay.h>
819
820#endif /* ZEPHYR_INCLUDE_DRIVERS_AUXDISPLAY_H_ */
int auxdisplay_display_position_set(const struct device *dev, enum auxdisplay_position type, int16_t x, int16_t y)
Set display position on an auxiliary display.
int auxdisplay_brightness_get(const struct device *dev, uint8_t *brightness)
Get the current brightness level of an auxiliary display.
int auxdisplay_display_position_get(const struct device *dev, int16_t *x, int16_t *y)
Get current display position on an auxiliary display.
int auxdisplay_write(const struct device *dev, const uint8_t *data, uint16_t len)
Write data to auxiliary display screen at current position.
int auxdisplay_backlight_set(const struct device *dev, uint8_t backlight)
Update the backlight level of an auxiliary display.
int auxdisplay_is_busy(const struct device *dev)
Check if an auxiliary display driver is busy.
int auxdisplay_brightness_set(const struct device *dev, uint8_t brightness)
Update the brightness level of an auxiliary display.
int auxdisplay_cursor_position_get(const struct device *dev, int16_t *x, int16_t *y)
Get current cursor on an auxiliary display.
int auxdisplay_capabilities_get(const struct device *dev, struct auxdisplay_capabilities *capabilities)
Fetch capabilities (and details) of auxiliary display.
auxdisplay_direction
Used for setting character append position.
Definition auxdisplay.h:58
int auxdisplay_display_off(const struct device *dev)
Turn display off.
int auxdisplay_position_blinking_set_enabled(const struct device *dev, bool enabled)
Set cursor blinking status on an auxiliary display.
int auxdisplay_cursor_set_enabled(const struct device *dev, bool enabled)
Set cursor enabled status on an auxiliary display.
uint32_t auxdisplay_mode_t
Used to describe the mode of an auxiliary (text) display.
Definition auxdisplay.h:37
int auxdisplay_custom_command(const struct device *dev, struct auxdisplay_custom_data *data)
Send a custom command to the display (if supported by driver)
auxdisplay_position
Used for moving the cursor or display position.
Definition auxdisplay.h:40
int auxdisplay_cursor_position_set(const struct device *dev, enum auxdisplay_position type, int16_t x, int16_t y)
Set cursor (and write position) on an auxiliary display.
int auxdisplay_clear(const struct device *dev)
Clear display of auxiliary display and return to home position (note that this does not reset the dis...
int auxdisplay_custom_character_set(const struct device *dev, struct auxdisplay_character *character)
Sets a custom character in the display, the custom character struct must contain the pixel data for t...
int auxdisplay_backlight_get(const struct device *dev, uint8_t *backlight)
Get the backlight level details of an auxiliary display.
int auxdisplay_cursor_shift_set(const struct device *dev, uint8_t direction, bool display_shift)
Set cursor shift after character write and display shift.
int auxdisplay_display_on(const struct device *dev)
Turn display on.
@ AUXDISPLAY_DIRECTION_LEFT
Each character will be placed to the left of existing characters.
Definition auxdisplay.h:63
@ AUXDISPLAY_DIRECTION_COUNT
Definition auxdisplay.h:65
@ AUXDISPLAY_DIRECTION_RIGHT
Each character will be placed to the right of existing characters.
Definition auxdisplay.h:60
@ AUXDISPLAY_POSITION_COUNT
Definition auxdisplay.h:54
@ AUXDISPLAY_POSITION_ABSOLUTE
Moves to specified X,Y position.
Definition auxdisplay.h:42
@ AUXDISPLAY_POSITION_RELATIVE
Shifts current position by +/- X,Y position, does not take display direction into consideration.
Definition auxdisplay.h:47
@ AUXDISPLAY_POSITION_RELATIVE_DIRECTION
Shifts current position by +/- X,Y position, takes display direction into consideration.
Definition auxdisplay.h:52
#define EINVAL
Invalid argument.
Definition errno.h:60
#define ENOSYS
Function not implemented.
Definition errno.h:82
Public kernel APIs.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT16_TYPE__ int16_t
Definition stdint.h:73
Structure holding display capabilities.
Definition auxdisplay.h:80
struct auxdisplay_light brightness
Brightness details for display (if supported)
Definition auxdisplay.h:91
uint8_t custom_characters
Number of custom characters supported by display (0 if unsupported)
Definition auxdisplay.h:97
auxdisplay_mode_t mode
Display-specific data (e.g.
Definition auxdisplay.h:88
uint16_t columns
Number of character columns.
Definition auxdisplay.h:82
struct auxdisplay_light backlight
Backlight details for display (if supported)
Definition auxdisplay.h:94
uint8_t custom_character_width
Width (in pixels) of a custom character, supplied custom characters should match.
Definition auxdisplay.h:100
uint8_t custom_character_height
Height (in pixels) of a custom character, supplied custom characters should match.
Definition auxdisplay.h:103
uint16_t rows
Number of character rows.
Definition auxdisplay.h:85
Structure for a custom character.
Definition auxdisplay.h:119
uint8_t character_code
Will be updated with custom character index to use in the display write function to disaplay this cus...
Definition auxdisplay.h:133
uint8_t * data
Custom character pixel data, a character must be valid for a display consisting of a uint8 array of s...
Definition auxdisplay.h:128
uint8_t index
Custom character index on the display.
Definition auxdisplay.h:121
Structure for a custom command.
Definition auxdisplay.h:107
uint32_t options
Display-driver specific options for command.
Definition auxdisplay.h:115
uint16_t len
Length of supplied data.
Definition auxdisplay.h:112
uint8_t * data
Raw command data to be sent.
Definition auxdisplay.h:109
Light levels for brightness and/or backlight.
Definition auxdisplay.h:71
uint8_t minimum
Minimum light level supported.
Definition auxdisplay.h:73
uint8_t maximum
Maximum light level supported.
Definition auxdisplay.h:76
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
void * data
Address of the device instance private data.
Definition device.h:413
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409