|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2025 HAW Hamburg |
| 3 | + * SPDX-License-Identifier: LGPL-2.1-only |
| 4 | + */ |
| 5 | + |
| 6 | +#pragma once |
| 7 | + |
| 8 | +/** |
| 9 | + * @defgroup u8g2_disp_dev_params Default configuration for U8G2 displays |
| 10 | + * @ingroup u8g2_disp_dev |
| 11 | + * |
| 12 | + * These configuration parameters are used by @ref auto_init when the the integration of |
| 13 | + * @ref pkg_u8g2 to @ref drivers_disp_dev is enabled. |
| 14 | + * |
| 15 | + * @{ |
| 16 | + * @file |
| 17 | + * @brief Default configuration |
| 18 | + * |
| 19 | + * @author Leandro Lanzieri <[email protected]> |
| 20 | + */ |
| 21 | + |
| 22 | +#include "board.h" |
| 23 | +#include "u8g2_display.h" |
| 24 | + |
| 25 | +#include "periph/i2c.h" |
| 26 | +#include "periph/spi.h" |
| 27 | +#include "periph/gpio.h" |
| 28 | + |
| 29 | +#ifdef __cplusplus |
| 30 | +extern "C" { |
| 31 | +#endif |
| 32 | + |
| 33 | +/** |
| 34 | + * @name Default configuration parameters for u8g2 displays |
| 35 | + * @{ |
| 36 | + */ |
| 37 | +/** |
| 38 | + * @brief Default I2C or SPI device. |
| 39 | + * |
| 40 | + * For I2C displays, set to the desired I2C bus using @ref I2C_DEV (e.g. `I2C_DEV(0)`). |
| 41 | + * For SPI displays, set to the desired SPI bus using @ref SPI_DEV (e.g. `SPI_DEV(0)`). |
| 42 | + */ |
| 43 | +#ifndef U8G2_DISPLAY_PARAM_DEV |
| 44 | +# define U8G2_DISPLAY_PARAM_DEV I2C_DEV(0) |
| 45 | +#endif |
| 46 | + |
| 47 | +/** |
| 48 | + * @brief Default I2C address |
| 49 | + * @note Set to `0` when using SPI |
| 50 | + */ |
| 51 | +#ifndef U8G2_DISPLAY_PARAM_I2C_ADDR |
| 52 | +# define U8G2_DISPLAY_PARAM_I2C_ADDR (0x3c) |
| 53 | +#endif |
| 54 | + |
| 55 | +/** |
| 56 | + * @brief Default SPI CS pin |
| 57 | + * @note Set to @ref GPIO_UNDEF when using I2C |
| 58 | + */ |
| 59 | +#ifndef U8G2_DISPLAY_PARAM_PIN_CS |
| 60 | +# define U8G2_DISPLAY_PARAM_PIN_CS GPIO_UNDEF |
| 61 | +#endif |
| 62 | + |
| 63 | +/** |
| 64 | + * @brief Default SPI D/C pin |
| 65 | + * @note Set to @ref GPIO_UNDEF when using I2C |
| 66 | + */ |
| 67 | +#ifndef U8G2_DISPLAY_PARAM_PIN_DC |
| 68 | +# define U8G2_DISPLAY_PARAM_PIN_DC GPIO_UNDEF |
| 69 | +#endif |
| 70 | + |
| 71 | +/** |
| 72 | + * @brief Default SPI Reset pin |
| 73 | + * @note Set to @ref GPIO_UNDEF when using I2C |
| 74 | + */ |
| 75 | +#ifndef U8G2_DISPLAY_PARAM_PIN_RESET |
| 76 | +# define U8G2_DISPLAY_PARAM_PIN_RESET GPIO_UNDEF |
| 77 | +#endif |
| 78 | + |
| 79 | +/** |
| 80 | + * @brief Default U8G2 initialization function |
| 81 | + * @see Check the u8g2 reference for possible setup functions: |
| 82 | + * https://github.com/olikraus/u8g2/wiki/u8g2setupc#setup-function-reference |
| 83 | + */ |
| 84 | +#ifndef U8G2_DISPLAY_PARAM_INIT_FUNCTION |
| 85 | +# define U8G2_DISPLAY_PARAM_INIT_FUNCTION u8g2_Setup_ssd1306_i2c_128x64_noname_f |
| 86 | +#endif |
| 87 | + |
| 88 | +/** |
| 89 | + * @brief Default configuration struct |
| 90 | + */ |
| 91 | +#ifndef U8G2_DISPLAY_PARAMS |
| 92 | +# define U8G2_DISPLAY_PARAMS \ |
| 93 | + { \ |
| 94 | + .init_function = U8G2_DISPLAY_PARAM_INIT_FUNCTION, \ |
| 95 | + .peripheral_configuration = { \ |
| 96 | + .device_index = U8G2_DISPLAY_PARAM_DEV, \ |
| 97 | + .pin_cs = U8G2_DISPLAY_PARAM_PIN_CS, \ |
| 98 | + .pin_dc = U8G2_DISPLAY_PARAM_PIN_DC, \ |
| 99 | + .pin_reset = U8G2_DISPLAY_PARAM_PIN_RESET, \ |
| 100 | + }, \ |
| 101 | + .i2c_address = U8G2_DISPLAY_PARAM_I2C_ADDR, \ |
| 102 | + } |
| 103 | +#endif |
| 104 | +/**@}*/ |
| 105 | + |
| 106 | +/** |
| 107 | + * @brief Configuration struct |
| 108 | + */ |
| 109 | +static const u8g2_display_params_t u8g2_display_params[] = |
| 110 | +{ |
| 111 | + U8G2_DISPLAY_PARAMS |
| 112 | +}; |
| 113 | + |
| 114 | +/** |
| 115 | + * @brief Default screen identifiers |
| 116 | + */ |
| 117 | +#ifndef U8G2_DISPLAY_PARAM_SCREEN_IDS |
| 118 | +# define U8G2_DISPLAY_PARAM_SCREEN_IDS 0 |
| 119 | +#endif |
| 120 | + |
| 121 | +/** |
| 122 | + * @brief Configure screen identifiers |
| 123 | + */ |
| 124 | +static const uint8_t u8g2_display_screen_ids[] = |
| 125 | +{ |
| 126 | + U8G2_DISPLAY_PARAM_SCREEN_IDS, |
| 127 | +}; |
| 128 | + |
| 129 | +#ifdef __cplusplus |
| 130 | +} |
| 131 | +#endif |
| 132 | + |
| 133 | +/** @} */ |
0 commit comments