mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys: add interface for generic display device
This commit is contained in:
parent
63a5fd3eb7
commit
ac6d0b9077
1
drivers/disp_dev/Makefile
Normal file
1
drivers/disp_dev/Makefile
Normal file
@ -0,0 +1 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
61
drivers/disp_dev/disp_dev.c
Normal file
61
drivers/disp_dev/disp_dev.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Inria
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_disp_dev
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Helper functions for generic API of display device
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "disp_dev.h"
|
||||
|
||||
void disp_dev_map(disp_dev_t *dev,
|
||||
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
||||
const uint16_t *color)
|
||||
{
|
||||
assert(dev);
|
||||
|
||||
dev->driver->map(dev, x1, x2, y1, y2, color);
|
||||
}
|
||||
|
||||
uint16_t disp_dev_height(disp_dev_t *dev)
|
||||
{
|
||||
assert(dev);
|
||||
|
||||
return dev->driver->height(dev);
|
||||
}
|
||||
|
||||
uint16_t disp_dev_width(disp_dev_t *dev)
|
||||
{
|
||||
assert(dev);
|
||||
|
||||
return dev->driver->width(dev);
|
||||
}
|
||||
|
||||
uint8_t disp_dev_color_depth(disp_dev_t *dev)
|
||||
{
|
||||
assert(dev);
|
||||
|
||||
return dev->driver->color_depth(dev);
|
||||
}
|
||||
|
||||
void disp_dev_set_invert(disp_dev_t *dev, bool invert)
|
||||
{
|
||||
assert(dev);
|
||||
|
||||
dev->driver->set_invert(dev, invert);
|
||||
}
|
146
drivers/include/disp_dev.h
Normal file
146
drivers/include/disp_dev.h
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Inria
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup drivers_disp_dev Display device generic API
|
||||
* @ingroup drivers_display
|
||||
* @brief Define the generic API of a display device
|
||||
* @experimental This API is experimental and in an early state - expect
|
||||
* changes!
|
||||
* @{
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef DISP_DEV_H
|
||||
#define DISP_DEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Forward declaration for display device struct
|
||||
*/
|
||||
typedef struct disp_dev disp_dev_t;
|
||||
|
||||
/**
|
||||
* @brief Generic type for a display driver
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Map an area to display on the device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
* @param[in] x1 Left coordinate
|
||||
* @param[in] x2 Right coordinate
|
||||
* @param[in] y1 Top coordinate
|
||||
* @param[in] y2 Bottom coordinate
|
||||
* @param[in] color Array of color to map to the display
|
||||
*/
|
||||
void (*map)(disp_dev_t *dev,
|
||||
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
||||
const uint16_t *color);
|
||||
|
||||
/**
|
||||
* @brief Get the height of the display device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
*
|
||||
* @return Height in pixels
|
||||
*/
|
||||
uint16_t (*height)(disp_dev_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Get the width of the display device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
*
|
||||
* @return Width in pixels
|
||||
*/
|
||||
uint16_t (*width)(disp_dev_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Get the color depth of the display device
|
||||
*
|
||||
* @return The color depth
|
||||
*/
|
||||
uint8_t (*color_depth)(disp_dev_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Invert the display device colors
|
||||
*
|
||||
* @param[in] dev Network device descriptor
|
||||
* @param[in] invert Invert mode (true if invert, false otherwise)
|
||||
*/
|
||||
void (*set_invert)(disp_dev_t *dev, bool invert);
|
||||
} disp_dev_driver_t;
|
||||
|
||||
/**
|
||||
* @brief Generic type for a display device
|
||||
*/
|
||||
struct disp_dev {
|
||||
const disp_dev_driver_t *driver; /**< Pointer to driver of the display device */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Map an area to display on the device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
* @param[in] x1 Left coordinate
|
||||
* @param[in] x2 Right coordinate
|
||||
* @param[in] y1 Top coordinate
|
||||
* @param[in] y2 Bottom coordinate
|
||||
* @param[in] color Array of color to map to the display
|
||||
*/
|
||||
void disp_dev_map(disp_dev_t *dev,
|
||||
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
||||
const uint16_t *color);
|
||||
|
||||
/**
|
||||
* @brief Get the height of the display device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
*
|
||||
* @return Height in pixels
|
||||
*/
|
||||
uint16_t disp_dev_height(disp_dev_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Get the width of the display device
|
||||
*
|
||||
* @param[in] dev Pointer to the display device
|
||||
*
|
||||
* @return Width in pixels
|
||||
*/
|
||||
uint16_t disp_dev_width(disp_dev_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Get the color depth of the display device
|
||||
*
|
||||
* @return The color depth
|
||||
*/
|
||||
uint8_t disp_dev_color_depth(disp_dev_t *dev);
|
||||
|
||||
/**
|
||||
* @brief Invert the display device colors
|
||||
*
|
||||
* @param[in] dev Network device descriptor
|
||||
* @param[in] invert Invert mode (true if invert, false otherwise)
|
||||
*/
|
||||
void disp_dev_set_invert(disp_dev_t *dev, bool invert);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DISP_DEV_H */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user