displayInterface.h (3396B)
1 /** 2 * @file displayInterface.h 3 * @author Adrian STEINER (steia19@bfh.ch) 4 * @brief Display interface to show the menu content on it 5 * @version 0.1 6 * @date 17-02-2025 7 * 8 * @copyright (C) 2025 Adrian STEINER 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program. If not, see <https: //www.gnu.org/licenses/>. 21 * 22 */ 23 24 #ifndef DISPLAY_INTERFACE_H 25 #define DISPLAY_INTERFACE_H 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 #include "pbm_fontHandler.h" 32 #include "pbm_types.h" 33 #include <stdint.h> 34 35 /** 36 * @brief Display power callback prototype 37 * 38 */ 39 typedef void (*displayPwrCB)(void); 40 41 /** 42 * @brief Display show data callback 43 * 44 */ 45 typedef uint32_t (*displayShowCB)(void); 46 47 /** 48 * @brief Display interface handler 49 * 50 */ 51 typedef struct { 52 /* Image references */ 53 pbm_image *image; ///< Pointer to an image structure to handle the frontend 54 pbm_font *dispFontSmall; ///< Pointer to the used small font 55 pbm_font *dispFontBig; ///< Pointer to the display big font 56 /* Callback functions */ 57 displayPwrCB powerOn; ///< Power on function 58 displayPwrCB powerOff; ///< Power off function 59 displayShowCB show; ///< Display show (update screen) 60 /* Symbol font indexes */ 61 uint8_t symbolCharge; ///< Charge symbol 62 uint8_t symbolSynchronize; ///< Synchronising symbol 63 uint8_t symbolBatteryStart; ///< Symbol update battery start with expected 4 64 ///< followed smaller states 65 /* Theme */ 66 pbm_colors theme; ///< Current display themes 67 } displayInterface; 68 69 /** 70 * @brief Initialise the display interface structure 71 * 72 * @param interfaceHandler The structure as reference to initialise 73 * @param displayImage Display pbm-image 74 * @param smallFont Small font used for frontend 75 * @param bigFont Big font reference used for frontend 76 * @param powerOnCB Power on callback 77 * @param powerOffCB Power off callback 78 * @param showCB image display data to the display 79 * @param chargeSymbolIndex Charge symbol 80 * @param synchronizeSymbolIndex Sync symbol 81 * @param batteryStartIndex Battery start with expected 4 followed symbols 82 * @param theme The current display theme 83 * @return uint8_t EXIT_SUCCESS in success, EXIT_FAILURE otherwise 84 */ 85 uint8_t display_initInterface(displayInterface *interfaceHandler, 86 pbm_image *displayImage, 87 pbm_font *smallFont, 88 pbm_font *bigFont, 89 displayPwrCB powerOnCB, 90 displayPwrCB powerOffCB, 91 displayShowCB showCB, 92 uint8_t chargeSymbolIndex, 93 uint8_t synchronizeSymbolIndex, 94 uint8_t batteryStartIndex, 95 pbm_colors theme); 96 97 #ifdef __cplusplus 98 } 99 #endif 100 101 #endif /* DISPLAY_INTERFACE_H*/