diff -r 000000000000 -r b74b0e4902c3 main/buttons.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/buttons.h Sat Oct 20 13:23:15 2018 +0200 @@ -0,0 +1,230 @@ +/** + * @file buttons.h + * @brief The touch buttons. + */ + +#ifndef _BUTTONS_H +#define _BUTTONS_H + +#define MAXBUTTONS 40 + + +/** + * @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 text The text to display on the button. + * If the text 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 Scan keyboard, all characters, 4 screens. + * @return The ASCII code of the key, or -1 if no key is pressed. + */ +int KeyBoardAll(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 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); + +/** + * @bried Edit SSR2 value. + * @param val The SSR2 value. + */ +void EditSSR2(int *val); + +/** + * @brief Confirm or not choice. Uses the whole screen. + * @param top The top screen message. + * #param yes The text for the ack button. + * @param no The text for the nack button. + * @return true when ack, or false. + */ +int Confirm(char *top, char *ack, char *nak); + +#endif