taler-xotp_fw

xOTP generator firmware
Log | Files | Refs | Submodules | README

frontend.h (3643B)


      1 /**
      2  * @file frontend.h
      3  * @author Adrian STEINER (steia19@bfh.ch)
      4  * @brief Frontend designs for the corresponding state
      5  * @version 0.1
      6  * @date 27-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 #ifndef FRONTEND_H
     24 #define FRONTEND_H
     25 
     26 #ifdef __cplusplus
     27 extern "C" {
     28 #endif
     29 
     30 #include "xtotp.h"
     31 
     32 /**
     33  * @brief Add data to the desired line position.
     34  * The centered line use the big font, the other use the small font
     35  *
     36  */
     37 typedef enum {
     38   FRONTEND_DATAFIELD_CENTRED = 0,
     39   FRONTEND_DATAFIELD_LINE1,
     40   FRONTEND_DATAFIELD_LINE2,
     41   FRONTEND_MAX_DATAFIELD
     42 } frontend_DataFieldPos;
     43 
     44 /**
     45  * @brief Clears the full frontend image
     46  *
     47  * @param appData The application data handler
     48  */
     49 void frontend_clear(xtotp_Data *appData);
     50 
     51 /**
     52  * @brief Write the status icons and data on the top left corner
     53  *
     54  * @param appData The application data handler
     55 
     56  */
     57 void frontend_writeStatusIcons(const xtotp_Data *appData);
     58 
     59 /**
     60  * @brief Clears the screen, add the status bar and write the menu title.
     61  * In case of data is given, it is added in the centered big font to the display
     62  *
     63  * @param appData The application data handler
     64  * @param menuTitle The title of the window
     65  * @param data Possible data in the centered big font format
     66  */
     67 void frontend_createBaseWindow(xtotp_Data *appData,
     68                                const char *menuTitle,
     69                                const char *data);
     70 
     71 /**
     72  * @brief Updates the menu title on the top right side
     73  *
     74  * @param appData The application data handler
     75  * @param menuTitle The title of the window
     76  */
     77 void frontend_updateMenuTitle(xtotp_Data *appData, const char *menuTitle);
     78 
     79 /**
     80  * @brief Add in the data field the given format data at the desired position
     81  *
     82  * @param appData The application data handler
     83  * @param position The desired position
     84  *  - FRONTEND_DATAFIELD_CENTRED (big font)
     85  *  - FRONTEND_DATAFIELD_LINE1 (small font)
     86  *  - FRONTEND_DATAFIELD_LINE2 (small font)
     87  * @param formats The data format and corresponding data
     88  * @param ... data of format string
     89  * @return uint32_t the starting y Position for the possibility to update only
     90  * the window after this line
     91  */
     92 uint32_t frontend_updateDatafield(xtotp_Data *appData,
     93                                   frontend_DataFieldPos position,
     94                                   const char *format,
     95                                   ...);
     96 
     97 /**
     98  * @brief Show the current secret states of the input number at the desired
     99  * position
    100  *
    101  * @param appData The application data handler
    102  */
    103 void frontend_showSecretState(xtotp_Data *appData);
    104 
    105 /**
    106  * @brief Clears the datafield for the desired line
    107  *
    108  * @param appData The application data handler
    109  * @param position The desired position
    110  *  - FRONTEND_DATAFIELD_CENTRED (big font)
    111  *  - FRONTEND_DATAFIELD_LINE1 (small font)
    112  *  - FRONTEND_DATAFIELD_LINE2 (small font)
    113  */
    114 void frontend_clearDatafield(xtotp_Data *appData,
    115                              frontend_DataFieldPos position);
    116 
    117 #ifdef __cplusplus
    118 }
    119 #endif
    120 
    121 #endif /* FRONTEND_H*/