mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/ili9341: provide adaption to disp_dev interface
This commit is contained in:
parent
ac6d0b9077
commit
acfac5d32d
81
drivers/ili9341/ili9341_disp_dev.c
Normal file
81
drivers/ili9341/ili9341_disp_dev.c
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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_ili9341
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Driver adaption to disp_dev generic interface
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ili9341.h"
|
||||
#include "ili9341_disp_dev.h"
|
||||
|
||||
#ifndef ILI9341_DISP_DEV_HEIGHT
|
||||
#define ILI9341_DISP_DEV_HEIGHT (240U)
|
||||
#endif
|
||||
|
||||
#ifndef ILI9341_DISP_COLOR_DEPTH
|
||||
#define ILI9341_DISP_COLOR_DEPTH (16U)
|
||||
#endif
|
||||
|
||||
static void _ili9341_map(disp_dev_t *dev, uint16_t x1, uint16_t x2,
|
||||
uint16_t y1, uint16_t y2, const uint16_t *color)
|
||||
{
|
||||
ili9341_t *ili9341 = (ili9341_t *)dev;
|
||||
ili9341_pixmap(ili9341, x1, x2, y1, y2, color);
|
||||
}
|
||||
|
||||
static uint16_t _ili9341_height(disp_dev_t *disp_dev)
|
||||
{
|
||||
(void)disp_dev;
|
||||
return ILI9341_DISP_DEV_HEIGHT;
|
||||
}
|
||||
|
||||
static uint16_t _ili9341_width(disp_dev_t *disp_dev)
|
||||
{
|
||||
const ili9341_t *dev = (ili9341_t *)disp_dev;
|
||||
assert(dev);
|
||||
|
||||
return dev->params->lines;
|
||||
}
|
||||
|
||||
static uint8_t _ili9341_color_depth(disp_dev_t *disp_dev)
|
||||
{
|
||||
(void)disp_dev;
|
||||
return ILI9341_DISP_COLOR_DEPTH;
|
||||
}
|
||||
|
||||
static void _ili9341_set_invert(disp_dev_t *disp_dev, bool invert)
|
||||
{
|
||||
const ili9341_t *dev = (ili9341_t *)disp_dev;
|
||||
|
||||
assert(dev);
|
||||
|
||||
if (invert) {
|
||||
ili9341_invert_on(dev);
|
||||
}
|
||||
else {
|
||||
ili9341_invert_off(dev);
|
||||
}
|
||||
}
|
||||
|
||||
const disp_dev_driver_t ili9341_disp_dev_driver = {
|
||||
.map = _ili9341_map,
|
||||
.height = _ili9341_height,
|
||||
.width = _ili9341_width,
|
||||
.color_depth = _ili9341_color_depth,
|
||||
.set_invert = _ili9341_set_invert,
|
||||
};
|
37
drivers/ili9341/include/ili9341_disp_dev.h
Normal file
37
drivers/ili9341/include/ili9341_disp_dev.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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_ili9341
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Definition of the driver for the disp_dev generic interface
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef ILI9341_DISP_DEV_H
|
||||
#define ILI9341_DISP_DEV_H
|
||||
|
||||
#include "disp_dev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Reference to the display device driver struct
|
||||
*/
|
||||
extern const disp_dev_driver_t ili9341_disp_dev_driver;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ILI9341_DISP_DEV_H */
|
@ -36,6 +36,10 @@
|
||||
#include "periph/spi.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#ifdef MODULE_DISP_DEV
|
||||
#include "disp_dev.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -98,6 +102,9 @@ typedef struct {
|
||||
* @brief Device descriptor for a ili9341
|
||||
*/
|
||||
typedef struct {
|
||||
#ifdef MODULE_DISP_DEV
|
||||
disp_dev_t *dev; /**< Pointer to the generic display device */
|
||||
#endif
|
||||
const ili9341_params_t *params; /**< Device initialization parameters */
|
||||
} ili9341_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user