main/buttons.h

Wed, 10 Jun 2020 09:43:51 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 10 Jun 2020 09:43:51 +0200
changeset 87
47253f294a9f
parent 41
7639cfa6aec0
child 101
1bc6e9263ada
permissions
-rw-r--r--

SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.

/**
 * @file buttons.h
 * @brief The touch buttons.
 */

#ifndef _BUTTONS_H
#define _BUTTONS_H

#define MAXBUTTONS              40	///< Maximum buttons on a screen


/**
 * @brief Definition of the touch screen buttons.
 */
typedef struct {
    int         x;              ///< Starting X position, -1 is terminator.
    int         y;              ///< Starting Y position
    int         w;              ///< Width
    int         h;              ///< Height
    char        text[11];       ///< Button text
    bool	dark;		///< Alternate dark color.
    bool	small;		///< Use small font.
    bool	lock;		///< Indicate locked color.
} sButton;


/**
 * @brief Wait for the touch screen is released.
 */
void WaitTouchReleased(void);

/**
 * @brief Clear the configured buttons list
 */
void Buttons_Clear(void);

/**
 * @brief Add a button to the buttons list.
 * @param x The X start position
 * @param y The Y start position
 * @param w The width of the button in pixels
 * @param h The height of the button in pixels.
 * @param txt The text to display on the button.
 *            If the txt is empty, no key will be shown.
 *            Use this for other areas that must act as a key.
 * @param order The order number in the list.
 */
void Buttons_Add(int x, int y, int w, int h, char *txt, int order);

/**
 * @brief Draw all defined buttons in the list on the screen.
 */
void Buttons_Show(void);

/**
 * @brief Search if the x and y coordinates belong to a button.
 * @param x The touched X position.
 * @param y The touched Y position.
 * @return The order number if a valid button, -1 is not valid.
 */
int Buttons_Search(int x, int y);

/**
 * @brief Scan for the touch of a button. A touch is only valid after the
 *        screen is left untouched. So a short or long press makes no difference.
 * @return The order number for a valid button, -1 if not valid.
 */
int Buttons_Scan(void);

/**
 * @brief Insert button coordinates received from a websocket.
 * @param x The touched X position.
 * @param y The touched Y position.
 */
void WS_touched(int x, int y);

/**
 * @brief Scan keyboard, all characters, 4 screens.
 * @return The ASCII code of the key, or -1 if no key is pressed.
 */
int KeyBoardAll(void);

/**
 * @brief Scan keyboard, just digits.
 * @return The ASCII code of the key, or -1 if no key is pressed.
 */
int KeyBoardDigits(void);

/**
 * @brief Show data text field.
 * @param x The X position on the screen
 * @param y The Y position on the screen
 * @param label The field name text
 * @param txt The field text data
 */
void ShowText(uint16_t x, uint16_t y, char *label, char *txt);

/**
 * @brief Show integer data field.
 * @param x The X position on the screen
 * @param y The Y position on the screen
 * @param label The field name text
 * @param suffix Some text after the data value or NULL
 * @param val The integer data value to show.
 */
void ShowInteger(uint16_t x, uint16_t y, char *label, char *suffix, int val);

/**
 * @brief Show boolean data field.
 * @param x The X position on the screen
 * @param y The Y position on the screen
 * @param label The field name text
 * @param val The bolean value, displays 'J' or 'N'
 */
void ShowBool(uint16_t x, uint16_t y, char *label, bool val);

/**
 * @brief Show SSR2 value.
 * @param x The X position on the screen
 * @param y The Y position on the screen
 * @param val The SSR2 value.
 */
void ShowSSR2(uint16_t x, uint16_t y, int val);

/**
 * @brief Show float data field.
 * @param x The X position on the screen
 * @param y The Y position on the screen
 * @param label The field name text
 * @param suffix Some text after the data value or NULL
 * @param val The float data value to show.
 * @param decimals The number of decimals to show.
 */
void ShowFloat(uint16_t x, uint16_t y, char *label, char *suffix, float val, int decimals);

/**
 @brief Show double data field.
 * @param x The X position on the screen
 * @param y The Y position on the screen
 * @param label The field name text
 * @param suffix Some text after the data value or NULL
 * @param val The float data value to show.
 * @param decimals The number of decimals to show.
 */
void ShowDouble(uint16_t x, uint16_t y, char *label, char *suffix, double val, int decimals);

/**
 * @brief A complete new screen is used to show only the top message.
 * @param label The top field name text.
 */
void EditerTop(char *label);

/**
 * @brief Edit data field. A complete new screen is used.
 * @param label The field name text
 * @param txt The field text data
 * @param errmsg The error message to show after an input error.
 * @param len The total length of the data field.
 * @param type The keyboard type to use.
 */
void Editer(char *label, char *txt, char *errmsg, int len, int type);

/**
 * @brief Edit data field. A complete new screen is used.
 * @param label The field name text
 * @param txt The field text data
 * @param len The total length of the data field.
 */
void EditText(char *label, char *txt, int len);

/**
 * @brief Edit data field. A complete new screen is used.
 * @param label The field name text
 * @param txt The field text data
 * @param len The total length of the data field.
 * @param min The minimum field length.
 */
 void EditTextMin(char *label, char *txt, int len, int min);

/**
 * @brief Edit integer field. A complete new screen is used.
 * @param label The field name text
 * @param val The field integer data
 * @param min The minimum value of the data.
 * @param max The maximum value of the data.
 */
void EditInt(char *label, int *val, int min, int max);

/**
 * @brief Edit uint8_t field. A complete new screen is used.
 * @param label The field name text
 * @param val The field uint8_t data
 * @param min The minimum value of the data.
 * @param max The maximum value of the data.
 */
void EditUint8(char *label, uint8_t *val, uint8_t min, uint8_t max);

/**
 * @brief Edit uint16_t field. A complete new screen is used.
 * @param label The field name text
 * @param val The field uint16_t data
 * @param min The minimum value of the data.
 * @param max The maximum value of the data.
 */
void EditUint16(char *label, uint16_t *val, uint16_t min, uint16_t max);

/**
 * @brief Edit float field. A complete new screen is used.
 * @param label The field name text
 * @param val The field float data
 * @param min The minimum value of the data.
 * @param max The maximum value of the data.
 * @param decimals The number of decimals to show.
 */
void EditFloat(char *label, float *val, float min, float max, int decimals);

/**
 * @brief Edit double field. A complete new screen is used.
 * @param label The field name text
 * @param val The field float data
 * @param min The minimum value of the data.
 * @param max The maximum value of the data.
 * @param decimals The number of decimals to show.
 */
void EditDouble(char *label, double *val, double min, double max, int decimals);

/**
 * @brief Edit a boolean value
 * @param label The field name text
 * @param val The field integer data
 */
void EditBool(char *label, bool *val);

/**
 * @brief Edit SSR2 value.
 * @param val The SSR2 value.
 */
void EditSSR2(int *val);

/**
 * @brief Edit Mashtype value
 * @param val The mash type
 */
void EditMashType(uint8_t *val);

/**
 * @brief Confirm or not choice. Uses the whole screen.
 * @param top The top screen message.
 * @param ack The text for the ack button.
 * @param nak The text for the nack button.
 * @return true when ack, or false.
 */
int Confirm(char *top, char *ack, char *nak);

#endif

mercurial