# HG changeset patch # User Michiel Broek # Date 1540048188 -7200 # Node ID ad2c8b13eb88a91bde056dc58ca04881af920511 # Parent b74b0e4902c395c5a68f3bf95a10fae4f389b1fc Updated lots of doxygen comments diff -r b74b0e4902c3 -r ad2c8b13eb88 components/PID/PID_v1.c --- a/components/PID/PID_v1.c Sat Oct 20 13:23:15 2018 +0200 +++ b/components/PID/PID_v1.c Sat Oct 20 17:09:48 2018 +0200 @@ -29,7 +29,7 @@ double *mySetpoint; // PID, freeing the user from having to constantly tell us // what these values are. with pointers we'll just know. -unsigned long lastTime; +unsigned long lastTime; ///< Last time of the time window. double outputSum, lastInput; unsigned long SampleTime; diff -r b74b0e4902c3 -r ad2c8b13eb88 components/esp32-ds18b20/ds18b20.c --- a/components/esp32-ds18b20/ds18b20.c Sat Oct 20 13:23:15 2018 +0200 +++ b/components/esp32-ds18b20/ds18b20.c Sat Oct 20 17:09:48 2018 +0200 @@ -51,12 +51,12 @@ static const int T_CONV = 750; // maximum conversion time at 12-bit resolution in milliseconds // Function commands -#define DS18B20_FUNCTION_TEMP_CONVERT 0x44 -#define DS18B20_FUNCTION_SCRATCHPAD_WRITE 0x4E -#define DS18B20_FUNCTION_SCRATCHPAD_READ 0xBE -#define DS18B20_FUNCTION_SCRATCHPAD_COPY 0x48 -#define DS18B20_FUNCTION_EEPROM_RECALL 0xB8 -#define DS18B20_FUNCTION_POWER_SUPPLY_READ 0xB4 +#define DS18B20_FUNCTION_TEMP_CONVERT 0x44 ///< Start temperature conversion +#define DS18B20_FUNCTION_SCRATCHPAD_WRITE 0x4E ///< Write scratchpad +#define DS18B20_FUNCTION_SCRATCHPAD_READ 0xBE ///< Read scratchpad +#define DS18B20_FUNCTION_SCRATCHPAD_COPY 0x48 ///< Copy scratchpad +#define DS18B20_FUNCTION_EEPROM_RECALL 0xB8 ///< EEPROM recall +#define DS18B20_FUNCTION_POWER_SUPPLY_READ 0xB4 ///< Read powersupply mode /// @cond ignore typedef struct diff -r b74b0e4902c3 -r ad2c8b13eb88 components/esp32-ds18b20/include/ds18b20.h --- a/components/esp32-ds18b20/include/ds18b20.h Sat Oct 20 13:23:15 2018 +0200 +++ b/components/esp32-ds18b20/include/ds18b20.h Sat Oct 20 17:09:48 2018 +0200 @@ -111,7 +111,6 @@ * * @param[in] ds18b20_info Pointer to device info instance. * @param[in] bus Pointer to initialised 1-Wire bus instance. - * @param[in] rom_code Device-specific ROM code to identify a device on the bus. */ void ds18b20_init_solo(DS18B20_Info * ds18b20_info, const OneWireBus * bus); @@ -151,6 +150,7 @@ /** * @brief Start a temperature measurement conversion on a single device. * @param[in] ds18b20_info Pointer to device info instance. + * @return True if successfull. */ bool ds18b20_convert(const DS18B20_Info * ds18b20_info); @@ -165,7 +165,7 @@ /** * @brief Wait for the maximum conversion time according to the current resolution of the device. - * @param[in] bus Pointer to initialised bus instance. + * @param[in] ds18b20_info Pointer to device info instance. Must be initialised first. * @return An estimate of the time elapsed, in milliseconds. Actual elapsed time may be greater. */ float ds18b20_wait_for_conversion(const DS18B20_Info * ds18b20_info); diff -r b74b0e4902c3 -r ad2c8b13eb88 components/spidriver/spi_master_lobo.c --- a/components/spidriver/spi_master_lobo.c Sat Oct 20 13:23:15 2018 +0200 +++ b/components/spidriver/spi_master_lobo.c Sat Oct 20 17:09:48 2018 +0200 @@ -95,9 +95,9 @@ return (ret_val); \ } -/* - Stores a bunch of per-spi-peripheral data. -*/ +/** + * @brief Stores a bunch of per-spi-peripheral data. + */ typedef struct { const uint8_t spiclk_out; //GPIO mux output signals const uint8_t spid_out; diff -r b74b0e4902c3 -r ad2c8b13eb88 components/vnc_server/vnc-server.c --- a/components/vnc_server/vnc-server.c Sat Oct 20 13:23:15 2018 +0200 +++ b/components/vnc_server/vnc-server.c Sat Oct 20 17:09:48 2018 +0200 @@ -85,6 +85,9 @@ static QueueHandle_t message_queue; ///< Websockets message queue const static int message_queue_size = 5; ///< Message queue size +/** + * @brief VNC messages. + */ struct strMessage { int length; ///< Length of the message uint8_t message[MESSAGE_BUFFER_SIZE]; ///< The message diff -r b74b0e4902c3 -r ad2c8b13eb88 main/automation.c --- a/main/automation.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/automation.c Sat Oct 20 17:09:48 2018 +0200 @@ -5,48 +5,48 @@ #include "config.h" -int BoilPower = 100; -int LastMashStep = 0; -char temp_buf[64]; -char logline[128]; -char strftime_buf[64]; -bool loop; -bool CoolBeep = false; -bool Resume = false; -bool pumpRest = false; -bool updateRuntime = false; -bool NewMinute = false; -bool TempReached = false; -uint8_t MashState = MASH_NONE; -float temp_MLT; -float MinMash = 38.0; -float MaxMash = 80.0; -uint32_t power_MLT = 0; -uint32_t power_HLT = 0; -uint32_t counts = 0; -float stageTemp = 0.0; -uint16_t stageTime = 0; -uint16_t TimeWhirlPool = 0; -uint32_t TimeLeft = 0; -uint32_t TimeSpent = 0; -uint32_t SecsCount = 0; -uint32_t pumpTime = 0; -uint32_t TimeBrewing = 0; -uint16_t Steady = 0; -bool _NewMinute = false; -bool _UseHLT = false; -bool _Prompt = false; +int BoilPower = 100; ///< Boil power 0..100% +int LastMashStep = 0; ///< Last valid mash step +char temp_buf[64]; ///< Temporary buffer +char logline[128]; ///< Log line buffer +char strftime_buf[64]; ///< Time buffer +bool loop; ///< Loop flag +bool CoolBeep = false; ///< Did beep during cooling +bool Resume = false; ///< Resume brew flag +bool pumpRest = false; ///< Pump is resting +bool updateRuntime = false; ///< Update runtime record +bool NewMinute = false; ///< We have a new minute +bool TempReached = false; ///< Temperature is reached +uint8_t MashState = MASH_NONE; ///< Mash states +float temp_MLT; ///< MLT temperature +float MinMash = 38.0; ///< Minimum edit value +float MaxMash = 80.0; ///< Maximum edit value +uint32_t power_MLT = 0; ///< MLT power +uint32_t power_HLT = 0; ///< HLT power +uint32_t counts = 0; ///< Counter for power average +float stageTemp = 0.0; ///< Current stage temperature +uint16_t stageTime = 0; ///< Current stage timer +uint16_t TimeWhirlPool = 0; ///< Whirlpool timer +uint32_t TimeLeft = 0; ///< Tie left in this stage +uint32_t TimeSpent = 0; ///< Tota time spent +uint32_t SecsCount = 0; ///< Seconds counter +uint32_t pumpTime = 0; ///< Pump running time +uint32_t TimeBrewing = 0; ///< Brewing time elapsed +uint16_t Steady = 0; ///< Temperature is steady +bool _NewMinute = false; ///< New minute slave flag +bool _UseHLT = false; ///< Use HLT slave flag +bool _Prompt = false; ///< Prompt display flag -extern bool System_TimeOk; -extern sButton Buttons[MAXBUTTONS]; -extern int Main_Screen; -extern DS18B20_State *ds18b20_state; -extern DRIVER_State *driver_state; -extern SemaphoreHandle_t xSemaphoreDS18B20; -extern SemaphoreHandle_t xSemaphoreDriver; -extern double Output; -extern time_t now; -extern struct tm timeinfo; +extern bool System_TimeOk; ///< System time is valid +extern sButton Buttons[MAXBUTTONS]; ///< Buttons definitions +extern int Main_Screen; ///< Current screen +extern DS18B20_State *ds18b20_state; ///< DS18B20 state +extern DRIVER_State *driver_state; ///< Relays driver state +extern SemaphoreHandle_t xSemaphoreDS18B20; ///< DS18B20 lock semaphore +extern SemaphoreHandle_t xSemaphoreDriver; ///< Relays driver lock semaphore +extern double Output; ///< Cakculated outpout power +extern time_t now; ///< Current time +extern struct tm timeinfo; ///< Current time structure #ifdef CONFIG_TEMP_SENSORS_SIMULATOR extern float Fake_MLT; diff -r b74b0e4902c3 -r ad2c8b13eb88 main/automation.h --- a/main/automation.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/automation.h Sat Oct 20 17:09:48 2018 +0200 @@ -14,7 +14,7 @@ /** * @brief Automation loop screens. Non-blocking (mostly). - * #return true if should jump to startover. + * @return true if should jump to startover. */ bool Automation_Loop(void); diff -r b74b0e4902c3 -r ad2c8b13eb88 main/brewboard.c --- a/main/brewboard.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/brewboard.c Sat Oct 20 17:09:48 2018 +0200 @@ -20,9 +20,9 @@ extern WIFI_State *wifi_state; -int Main_Screen = MAIN_MODE_UNKNOWN; -int Old_Screen = MAIN_MODE_UNKNOWN; -bool System_TimeOk = false; +int Main_Screen = MAIN_MODE_UNKNOWN; ///< Screen number +int Old_Screen = MAIN_MODE_UNKNOWN; ///< Previous screen number +bool System_TimeOk = false; ///< System time status diff -r b74b0e4902c3 -r ad2c8b13eb88 main/buttons.c --- a/main/buttons.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/buttons.c Sat Oct 20 17:09:48 2018 +0200 @@ -6,18 +6,17 @@ #include "config.h" -sButton Buttons[MAXBUTTONS]; // 40 buttons on a screen. -int level = 1; // Keyboard level. +sButton Buttons[MAXBUTTONS]; ///< 40 buttons on a screen. +int level = 1; ///< Keyboard level. -extern uint8_t VNC_pointer_button; -extern uint16_t VNC_pointer_x; -extern uint16_t VNC_pointer_y; +extern uint8_t VNC_pointer_button; ///< Mouse buttons mask +extern uint16_t VNC_pointer_x; ///< Mouse coordinate X +extern uint16_t VNC_pointer_y; ///< Mouse coordinate Y -//static const char *TAG = "buttons"; -#define EDIT_TYPE_TEXT 0 -#define EDIT_TYPE_INT 1 -#define EDIT_TYPE_FLOAT 2 +#define EDIT_TYPE_TEXT 0 ///< Editor type is text +#define EDIT_TYPE_INT 1 ///< Editor type is integer +#define EDIT_TYPE_FLOAT 2 ///< Editor type is float /***************************************************************************/ @@ -157,7 +156,9 @@ 'a','s','d','f','g','h','j','k','l', 'z','x','c','v','b','n','m' }; -/* Level 1 keys */ +/** + * @brief Level 1 keys, lowercase alpha. + */ void B_AlphaLow(void) { Buttons_Clear(); @@ -216,7 +217,9 @@ 'A','S','D','F','G','H','J','K','L', 'Z','X','C','V','B','N','M' }; -/* Level 2 and 3 keys */ +/** + * @brief Level 2 and 3 keys, uppercase alpha. + */ void B_AlphaCaps(int level) { Buttons_Clear(); @@ -278,7 +281,9 @@ '!','@','#','$','/','^','&','*','(',')', '-','\'','\"',':',';',',','?' }; -/* Level 4 keys */ +/** + * @brief Level 4, numeric keys and symbol + */ void B_Nums1(void) { Buttons_Clear(); @@ -335,7 +340,9 @@ ' ',' ',' ',' ','%','~','`',' ',' ',' ', '_','\\','|',' ',' ',' ',' ' }; -/* Level 5 */ +/** + * @brief Level 5, symbol keys + */ void B_Nums2(void) { Buttons_Clear(); @@ -390,6 +397,9 @@ static const uint8_t digits_tab[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '+', '-', '.' }; +/** + * @brief A small nummeric keyboard + */ void B_Digits(void) { Buttons_Clear(); diff -r b74b0e4902c3 -r ad2c8b13eb88 main/buttons.h --- a/main/buttons.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/buttons.h Sat Oct 20 17:09:48 2018 +0200 @@ -6,7 +6,7 @@ #ifndef _BUTTONS_H #define _BUTTONS_H -#define MAXBUTTONS 40 +#define MAXBUTTONS 40 ///< Maximum buttons on a screen /** @@ -40,9 +40,9 @@ * @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 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); @@ -74,6 +74,12 @@ 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 @@ -213,7 +219,7 @@ void EditBool(char *label, bool *val); /** - * @bried Edit SSR2 value. + * @brief Edit SSR2 value. * @param val The SSR2 value. */ void EditSSR2(int *val); @@ -221,8 +227,8 @@ /** * @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. + * @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); diff -r b74b0e4902c3 -r ad2c8b13eb88 main/calibration.c --- a/main/calibration.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/calibration.c Sat Oct 20 17:09:48 2018 +0200 @@ -9,14 +9,14 @@ static const char *TAG = "calibration"; -extern uint16_t tp_xleft; -extern uint16_t tp_xright; -extern uint16_t tp_ytop; -extern uint16_t tp_ybottom; +extern uint16_t tp_xleft; ///< Testpoint X left +extern uint16_t tp_xright; ///< Testpoint X right +extern uint16_t tp_ytop; ///< Testpoint Y top +extern uint16_t tp_ybottom; ///< Testpoint Y bottom // Distance of the testpoints from the corders. -#define CAL_DISTANCE 15 +#define CAL_DISTANCE 15 ///< Testpoint size int TS_set_calibration(int xleft, int xright, int ytop, int ybottom) diff -r b74b0e4902c3 -r ad2c8b13eb88 main/calibration.h --- a/main/calibration.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/calibration.h Sat Oct 20 17:09:48 2018 +0200 @@ -14,6 +14,7 @@ * @param xright X right side (landscape top) * @param ytop Y top (landscape left) * @param ybottom Y botto (landscape right) + * @return 1 if error, 0 if success. */ int TS_set_calibration(int xleft, int xright, int ytop, int ybottom); diff -r b74b0e4902c3 -r ad2c8b13eb88 main/config.h --- a/main/config.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/config.h Sat Oct 20 17:09:48 2018 +0200 @@ -80,7 +80,7 @@ #include "task_http.h" -#define VERSION "0.2.2" +#define VERSION "0.2.3" ///< Application version /** @@ -133,6 +133,9 @@ MAIN_MANUAL_MAIN, ///< Manual control main menu } MAIN_MODE; +/** + * @brief The differents stages in the mash steps. + */ typedef enum { MASH_NONE = 0, ///< Initial Mash state MASH_WAITTEMP, ///< Wait to reach temperature. @@ -142,6 +145,9 @@ MASH_REMOVE, ///< Wait mash remove } MASH_TYPE; +/** + * @brief The working mode of the second heater SSR. + */ typedef enum { SSR2_OFF = 0, ///< SSR2 not used. SSR2_HLT_SHARE, ///< SSR2 for HLT shared with MLT @@ -177,7 +183,7 @@ int RecipeRec; ///< Current recipe record. char uuid[37]; ///< Sort of uuid code. char lastSSID[32]; ///< Last connected station. -} config; +} config; ///< Config record. /** * @brief Write configuration to disk. @@ -215,7 +221,7 @@ double PID_kD; ///< PID D setting. bool PID_POn; ///< PID compute on Measurement or Errors. int SampleTime; ///< PID sample time in seconds. -} equipment; +} equipment; ///< Equipment record. /** * @brief Append equipments record to disk. @@ -251,7 +257,7 @@ char SSID[32]; ///< Station SSID char Password[64]; ///< Station password bool hide; ///< Hide from AP scan. -} wifiStation; +} wifiStation; ///< Station record. /** * @brief Add a new station record. @@ -274,6 +280,11 @@ */ void remove_station(uint8_t *SSID); +/** + * @brief Blacklist station SSID + * @param SSID The SSID to blacklist. + * @return -1 if error, else the record number. + */ int blacklist_station(uint8_t *SSID); @@ -294,7 +305,7 @@ bool UseHLT; ///< Use HLT during brew. bool PumpCooling; ///< Pump during cooling. uint32_t TimeBrewing; ///< Time we are brewing. -} runtime; +} runtime; ///< Runtime record. /** @@ -309,6 +320,10 @@ void read_runtime(void); + +/** + * @brief Addition types + */ typedef enum { ADDITION_HOP = 0, ADDITION_FERMENTABLE = 1, @@ -344,7 +359,7 @@ */ struct strRecipe { uint8_t Version; ///< Record version number. - int Record; + int Record; ///< Record number char Name[128]; ///< Recipe name. char Code[32]; ///< Recipe code. mashstep_t MashStep[8]; ///< Mash steps. @@ -357,7 +372,7 @@ uint16_t Whirlpool6; ///< Zero or the "Tepid" Whirlpool time 60..66 ° uint16_t Whirlpool2; ///< Zero or the Cold Whirlpool time < 30 ° float SpargeTemp; ///< Sparge water temperature. -} recipe; +} recipe; ///< Recipe record. /** * @brief Append a recipe record. Create file if it doesn't exist. diff -r b74b0e4902c3 -r ad2c8b13eb88 main/files.c --- a/main/files.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/files.c Sat Oct 20 17:09:48 2018 +0200 @@ -9,10 +9,12 @@ extern sButton Buttons[MAXBUTTONS]; extern int Main_Screen; -bool Refresh = false; - +/** + * @brief Show files directory + * @param path The path from which to list + */ void Files_Dir(char *path) { char filename[256], tmp[42]; diff -r b74b0e4902c3 -r ad2c8b13eb88 main/recipes.c --- a/main/recipes.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/recipes.c Sat Oct 20 17:09:48 2018 +0200 @@ -6,32 +6,38 @@ #include "config.h" -extern sButton Buttons[MAXBUTTONS]; -extern int Main_Screen; +extern sButton Buttons[MAXBUTTONS]; ///< Buttons definitions +extern int Main_Screen; ///< Current screen -bool r_UpdateRec = false; -int r_CurrentRec = 1; -int r_Records = 1; -int r_Imported = 0; -char _xml_element[10][32]; -int _xml_depth; -int _xml_mashsteps; -char _xml_add_name[64]; -int _xml_add_type; -int _xml_add_time; -int _xml_add_ramp; -float _xml_add_temp; -float _xml_tun_temp; -bool _xml_add_valid; +bool r_UpdateRec = false; ///< Update record flag +int r_CurrentRec = 1; ///< Current record +int r_Records = 1; ///< Total records +int r_Imported = 0; ///< Total imported +char _xml_element[10][32]; ///< XML element array +int _xml_depth; ///< Current depths +int _xml_mashsteps; ///< Mash steps +char _xml_add_name[64]; ///< Mash name +int _xml_add_type; ///< Mash type +int _xml_add_time; ///< Mash rest time +int _xml_add_ramp; ///< Mash ramp time +float _xml_add_temp; ///< Mash temperature +float _xml_tun_temp; ///< TUN temperature +bool _xml_add_valid; ///< Add is valid static const char *TAG = "recipes"; -char char_data_buffer[1024]; -size_t offs; -bool overflow; +char char_data_buffer[1024]; ///< Data buffer +size_t offs; ///< Offset in buffer +bool overflow; ///< Overflow in buffer +/** + * @brief Add addition to the recipe. + * @param Name The addition name. + * @param Type The addition type. + * @param Time The addition time to add. + */ void Addition_Add(char *Name, uint8_t Type, uint16_t Time) { printf("Addition_Add(%s, %d, %d)\n", Name, Type, Time); @@ -80,6 +86,9 @@ +/** + * @brief Reset the parser buffer. + */ void reset_char_data_buffer (void) { offs = 0; @@ -88,7 +97,10 @@ -void char_data (void *userData, const XML_Char *s, int len) +/** + * @brief Datahandler get bytes into the data buffer. + */ +void char_data(void *userData, const XML_Char *s, int len) { if (!overflow) { if (len + offs >= sizeof(char_data_buffer) ) { @@ -101,7 +113,9 @@ } - +/** + * @brief Process the XML parser data buffer. + */ void process_char_data_buffer (void) { bool allspace = true; @@ -215,6 +229,12 @@ +/** + * @brief Start new XML element. + * @param userData + * @param name XML element name + * @param attr XML element attribute + */ void startElement(void *userData, const char *name, const char **attr) { sprintf(_xml_element[_xml_depth], "%s", name); @@ -225,6 +245,11 @@ +/** + * @brief End XML element + * @param userData + * @param name XML element name + */ void endElement(void *userData, const char *name) { process_char_data_buffer(); @@ -325,6 +350,7 @@ } } +#if 0 printf("Recipe: %s\n", recipe.Name); printf("Code : %s\n", recipe.Code); printf("Boil time %d minutes\n", recipe.BoilTime); @@ -352,6 +378,7 @@ if (recipe.Whirlpool2) printf("Whirlpool2 %d\n", recipe.Whirlpool2); printf("SpargeTemp %5.2f\n", recipe.SpargeTemp); +#endif return 0; } diff -r b74b0e4902c3 -r ad2c8b13eb88 main/recipes.h --- a/main/recipes.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/recipes.h Sat Oct 20 17:09:48 2018 +0200 @@ -9,6 +9,8 @@ /** * @brief Parse a Beerxml file and add the recipe. + * @param fn The recipe filename. + * @param code The recipe code serial. * @return Zero if no errors were found. */ int ParseRecipe(char *fn, char *code); diff -r b74b0e4902c3 -r ad2c8b13eb88 main/setup.c --- a/main/setup.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/setup.c Sat Oct 20 17:09:48 2018 +0200 @@ -6,12 +6,12 @@ #include "config.h" -extern sButton Buttons[MAXBUTTONS]; -extern int Main_Screen; +extern sButton Buttons[MAXBUTTONS]; +extern int Main_Screen; -bool UpdateRec = false; -int CurrentRec = 1; -int Records = 1; +bool UpdateRec = false; ///< Update record flag +int CurrentRec = 1; ///< Current record +int Records = 1; ///< Total records. static const char *TAG = "setup"; diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_driver.c --- a/main/task_driver.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_driver.c Sat Oct 20 17:09:48 2018 +0200 @@ -15,22 +15,25 @@ #include "config.h" -#define SSR_MLT CONFIG_SSR_MLT_GPIO -#define SSR_HLT CONFIG_SSR_HLT_GPIO -#define SSR_PUMP CONFIG_SSR_PUMP_GPIO +#define SSR_MLT CONFIG_SSR_MLT_GPIO ///< GPIO SSR MLT pin +#define SSR_HLT CONFIG_SSR_HLT_GPIO ///< GPIO SSR HLT pin +#define SSR_PUMP CONFIG_SSR_PUMP_GPIO ///< GPIO Pump relay pin -bool outEnable = false; -DRIVER_State * driver_state; -SemaphoreHandle_t xSemaphoreDriver = NULL; -int MLT_pin = 0; -int HLT_pin = 0; -int Pump_pin = 0; -double Input = 0, Output = 0, Setpoint = 0; -int MLT_Mode = MLT_MODE_NONE; -double HLT_Input = 0, HLT_Setpoint = 0; -int HLT_Output = 0; -int HLT_Mode = HLT_MODE_NONE; +bool outEnable = false; ///< Enable outputs flag +DRIVER_State * driver_state; ///< Driver state +SemaphoreHandle_t xSemaphoreDriver = NULL; ///< Driver state lock +int MLT_pin = 0; ///< MLT state +int HLT_pin = 0; ///< HLT state +int Pump_pin = 0; ///< Pump state +double Input = 0; ///< PID input value +double Output = 0; ///< PID output value +double Setpoint = 0; ///< PID setpoint value +int MLT_Mode = MLT_MODE_NONE; ///< MLT mode flag +double HLT_Input = 0; ///< HLT input value +double HLT_Setpoint = 0; ///< HLT setpoint values +int HLT_Output = 0; ///< HLT output value +int HLT_Mode = HLT_MODE_NONE; ///< HLT mode flag static const char *TAG = "task_driver"; @@ -95,6 +98,9 @@ +/** + * @brief Load PID settings from equipment record. + */ void LoadPIDsettings() { PID_SetTunings(equipment.PID_kP, equipment.PID_kI, equipment.PID_kD, equipment.PID_POn); PID_SetSampleTime(equipment.SampleTime); diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_driver.h --- a/main/task_driver.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_driver.h Sat Oct 20 17:09:48 2018 +0200 @@ -11,6 +11,9 @@ */ +/** + * @brief MLT working mode. + */ typedef enum { MLT_MODE_NONE = 0, ///< Not active MLT_MODE_BANG = 1, ///< Bang on/off mode @@ -19,6 +22,9 @@ MLT_MODE_EXT = 4, ///< External regulation } MLT_MODE_TYPE; +/** + * @brief HLT working mode. + */ typedef enum { HLT_MODE_NONE = 0, ///< Not active HLT_MODE_BANG = 1, ///< Bang on/off mode diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_ds18b20.h --- a/main/task_ds18b20.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_ds18b20.h Sat Oct 20 17:09:48 2018 +0200 @@ -18,11 +18,11 @@ /* * Error codes in this task */ -#define DS18B20_ERR_NONE 0 -#define DS18B20_ERR_NOSENSOR 1 -#define DS18B20_ERR_TOOMANY 2 -#define DS18B20_ERR_CRC 3 -#define DS18B20_ERR_READ 4 +#define DS18B20_ERR_NONE 0 ///< No errors +#define DS18B20_ERR_NOSENSOR 1 ///< No sensor detected +#define DS18B20_ERR_TOOMANY 2 ///< Too many sensors +#define DS18B20_ERR_CRC 3 ///< CRC read error +#define DS18B20_ERR_READ 4 ///< Generic read error /** diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_http.c --- a/main/task_http.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_http.c Sat Oct 20 17:09:48 2018 +0200 @@ -8,7 +8,7 @@ #include "mbedtls/sha1.h" -const char *TAG = "task_http"; +static const char *TAG = "task_http"; static QueueHandle_t client_queue; const static int client_queue_size = 10; static TaskHandle_t xTaskHTTP = NULL; @@ -16,9 +16,15 @@ +/** + * @brief Debug dump buffer + * @param buf The buffer + * @param buflen Length of the buffer + */ void dump_buf(char *buf, uint16_t buflen); + /** * @brief Send HTTP error and message * @param conn The socket to send to. diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_sdcard.c --- a/main/task_sdcard.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_sdcard.c Sat Oct 20 17:09:48 2018 +0200 @@ -20,8 +20,8 @@ -SDCARD_State * sdcard_state; -JSON_log * json_log; +SDCARD_State *sdcard_state; ///< SD card status +JSON_log *json_log; ///< JSON log array EventGroupHandle_t xEventGroupSDcard; ///< SD card events. static const char *TAG = "task_sdcard"; @@ -33,10 +33,10 @@ #define SDCARD_HOST_SLOT VSPI_HOST ///< HSPI_HOST is used by the TFT -#define SDCARD_PIN_NUM_MISO 2 -#define SDCARD_PIN_NUM_MOSI 15 -#define SDCARD_PIN_NUM_CLK 14 -#define SDCARD_PIN_NUM_CS 13 +#define SDCARD_PIN_NUM_MISO 2 ///< MISO pin +#define SDCARD_PIN_NUM_MOSI 15 ///< MOSI pin +#define SDCARD_PIN_NUM_CLK 14 ///< CLOCK +#define SDCARD_PIN_NUM_CS 13 ///< Chip select pin #define SDCARD_DMA_CHANNEL 2 ///< Channel 1 is used by the TFT @@ -191,10 +191,14 @@ -/* - * This is a local modified version of the esp_vfs_fat_sdmmc_mount() function in - * the FreeRTOS components library. It is here so we can better handle errors - * for our application. +/** + * @brief This is a local modified version of the esp_vfs_fat_sdmmc_mount() function in + * the FreeRTOS components library. It is here so we can better handle errors + * for our application. + * @param base_path The mount path + * @param host_config SPI host configuration + * @param slot_config Slot configuration + * @return Error condition. */ esp_err_t my_vfs_fat_sdmmc_init(const char* base_path, const sdmmc_host_t* host_config, const void* slot_config) { @@ -248,6 +252,15 @@ +/** + * @brief Mount SD card. + * @param base_path The mountpoint + * @param host_config SPI host configuration + * @param slot_config Slot configuration + * @param mount_config Mount configuration + * @param[out] out_card Card information + * @return Error condition + */ esp_err_t my_esp_vfs_fat_sdmmc_mount(const char* base_path, const sdmmc_host_t* host_config, const void* slot_config, @@ -307,7 +320,11 @@ -esp_err_t my_esp_vfs_fat_sdmmc_unmount() +/** + * @brief Unmount a mounted SD card, + * @return Error condition + */ +esp_err_t my_esp_vfs_fat_sdmmc_unmount(void) { if (s_card == NULL) { return ESP_ERR_INVALID_STATE; @@ -351,6 +368,11 @@ +/** + * @brief Sync directories. + * @param fromdir Source directory + * @param todir Destination directory + */ void SyncDirs(char *fromdir, char *todir) { char ff[64], tf[64]; diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_sdcard.h --- a/main/task_sdcard.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_sdcard.h Sat Oct 20 17:09:48 2018 +0200 @@ -7,6 +7,9 @@ */ +/** + * @brief Annotation types for the log graph. + */ typedef enum { ANNOTATION_STAGE = 0, ///< Annotate stage event @@ -73,6 +76,14 @@ void log_annotation(int annotation_type, char *label); /** + * @brief Copy one file. + * @param ff The from filename + * @param tf The to filename + * @return 0 if success. + */ +int FileCopy(char *ff, char *tf); + +/** * @brief FreeRTOS sd card task. */ void task_sdcard(void *); diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_sound.c --- a/main/task_sound.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_sound.c Sat Oct 20 17:09:48 2018 +0200 @@ -7,9 +7,9 @@ #include "config.h" -#define PIEZO_BUZZER CONFIG_BUZZER_GPIO +#define PIEZO_BUZZER CONFIG_BUZZER_GPIO ///< GPIO pin with the piezo buzzer. -EventGroupHandle_t xEventGroupSound; +EventGroupHandle_t xEventGroupSound; ///< Event handle. static const char *TAG = "task_sound"; @@ -23,20 +23,25 @@ const int SOUND_WARN = BIT6; ///< When set, play warning sound. -const uint16_t _sound_Startup[] = { 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 200, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; -const uint16_t _sound_Prompt[] = { 2, 50, 125 }; -const uint16_t _sound_TempReached[] = { 6, 250, 75, 250, 75, 250, 75}; -const uint16_t _sound_TimeOut[] = {10, 25, 975, 25, 975, 25, 975, 25, 975, 500, 500 }; // 5 seconds -const uint16_t _sound_AddHop[] = {18, 50, 50, 50, 50, 50, 225, 150, 50, 150, 50, 150, 225, 50, 50, 50 , 50 , 50, 50 }; -const uint16_t _sound_End[] = { 2, 1000, 75 }; -const uint16_t _sound_Warn[] = { 6, 100, 75, 100, 75, 100, 50 }; +/* Sound arrays. The first value is the length, followed by the on and off times. */ +static const uint16_t _sound_Startup[] = { 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 200, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; +static const uint16_t _sound_Prompt[] = { 2, 50, 125 }; +static const uint16_t _sound_TempReached[] = { 6, 250, 75, 250, 75, 250, 75}; +static const uint16_t _sound_TimeOut[] = { 10, 25, 975, 25, 975, 25, 975, 25, 975, 500, 500 }; // 5 seconds +static const uint16_t _sound_AddHop[] = { 18, 50, 50, 50, 50, 50, 225, 150, 50, 150, 50, 150, 225, 50, 50, 50 , 50 , 50, 50 }; +static const uint16_t _sound_End[] = { 2, 1000, 75 }; +static const uint16_t _sound_Warn[] = { 6, 100, 75, 100, 75, 100, 50 }; +/** + * @brief Play sounds on the piezo buzzer. + * @param sound The sound array. + */ void BuzzerPlay(const uint16_t *sound) { for (int i = 1; i <= sound[0]; i += 2) { diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_sound.h --- a/main/task_sound.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_sound.h Sat Oct 20 17:09:48 2018 +0200 @@ -6,6 +6,9 @@ * @brief Sound player using the ESP32 internal DAC port. */ +/** + * @brief Sound prompt types + */ typedef enum { SOUND_StartUp = 0, ///< Startup sound. SOUND_Prompt, ///< Prompt sound diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_tft.c --- a/main/task_tft.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_tft.c Sat Oct 20 17:09:48 2018 +0200 @@ -10,13 +10,13 @@ #include "config.h" -spi_lobo_device_handle_t spi; -spi_lobo_device_handle_t tsspi = NULL; -extern sButton Buttons[MAXBUTTONS]; // 40 buttons on a screen. -time_t now; -struct tm timeinfo; -char s_timer[10]; -char s_top_msg[64]; +spi_lobo_device_handle_t spi; ///< TFT screen SPI handler +spi_lobo_device_handle_t tsspi = NULL; ///< Touchscreen SPI handler +extern sButton Buttons[MAXBUTTONS]; ///< 40 buttons on a screen. +time_t now; ///< Current time +struct tm timeinfo; ///< Current time structure +char s_timer[10]; ///< Timer sctring buffer +char s_top_msg[64]; ///< Top message string buffer extern float stageTemp; extern uint16_t stageTime; @@ -27,15 +27,14 @@ extern uint32_t pumpTime; extern uint32_t TimeBrewing; extern uint16_t Steady; -esp_timer_handle_t timerHandle; +esp_timer_handle_t timerHandle; ///< Timer handler extern bool _NewMinute; extern bool _UseHLT; extern bool System_TimeOk; static const char *TAG = "task_tft"; -// Define which spi bus to use TFT_VSPI_HOST or TFT_HSPI_HOST -#define SPI_BUS TFT_HSPI_HOST +#define SPI_BUS TFT_HSPI_HOST ///< SPI bus for the TFT, TFT_VSPI_HOST or TFT_HSPI_HOST extern int Main_Screen; extern int Old_Screen; diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_wifi.c --- a/main/task_wifi.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_wifi.c Sat Oct 20 17:09:48 2018 +0200 @@ -19,10 +19,10 @@ WIFI_State *wifi_state = NULL; ///< Public state for other tasks. -uint8_t _wifi_ssid[33]; -bool _wifi_ScanAPs = false; -bool _wifi_ScanDone = false; -uint16_t _wifi_Scanned = 0; +uint8_t _wifi_ssid[33]; ///< Current SSID +bool _wifi_ScanAPs = false; ///< Scanning +bool _wifi_ScanDone = false; ///< Scan ready +uint16_t _wifi_Scanned = 0; ///< Total scanned APs. extern int Main_Screen; ///< Current Screen number. extern sButton Buttons[MAXBUTTONS]; ///< Buttons definitions. @@ -35,7 +35,7 @@ const int TASK_WIFI_HAS_IP = BIT3; ///< Indicate that we have an IP address const int TASK_WIFI_AP_STARTED = BIT4; ///< Indicate that the SoftAP is started const int TASK_WIFI_STA_FAILED = BIT5; ///< Indicate that we could not get a connection to AP as station. -const int TASK_WIFI_STA_DISCONNECTED = BIT6; ///* Indicate that we are disconnected from an ap station. +const int TASK_WIFI_STA_DISCONNECTED = BIT6; ///< Indicate that we are disconnected from an ap station. const int TASK_WIFI_STA_CONNECTED = BIT7; ///< Indicate that we are connected to AP as station, flip of BIT6. @@ -53,6 +53,8 @@ /** * @brief Local function, WiFi event handler. + * @param ctx Context + * @param event The event * @return Esp error code. */ esp_err_t task_wifi_EventHandler(void *ctx, system_event_t *event); @@ -263,9 +265,6 @@ -/** - * @brief WiFi manager task - */ void task_wifi( void * pvParameters ) { esp_err_t ret; @@ -473,6 +472,9 @@ } +/** + * @brief Array with AP security names + */ const char *apsec[] = { "Open", "WEP", "WPA", "WPA2", "WPA WPA2", "Enterprise" }; @@ -480,7 +482,7 @@ * @brief Show an AP station as a button. The buttons are already defined. * @param idx The index position on the display, 1 to 7. * @param ap The AP information from the WiFi scan. - * @param show, How to display. 0 is blank, 1 is unknown, 2 is known, 3 is a connected AP. + * @param show How to display. 0 is blank, 1 is unknown, 2 is known, 3 is a connected AP. */ void Show_AP(uint8_t idx, wifi_ap_record_t ap, int show) { diff -r b74b0e4902c3 -r ad2c8b13eb88 main/task_wifi.h --- a/main/task_wifi.h Sat Oct 20 13:23:15 2018 +0200 +++ b/main/task_wifi.h Sat Oct 20 17:09:48 2018 +0200 @@ -37,8 +37,9 @@ char STA_gw[16]; ///< IP gateway. } WIFI_State; - - +/** + * @brief Update reason codes. + */ typedef enum update_reason_code_t { UPDATE_CONNECTION_OK = 0, UPDATE_FAILED_ATTEMPT = 1, @@ -49,15 +50,9 @@ /** - * @brief Get WiFi STA config. - * #return wifi_config_t structure. - */ -//wifi_config_t* task_wifi_GetWifiStaConfig(void); - -/** * @brief Main task for the wifi_manager */ -void task_wifi( void * pvParameters ); +void task_wifi(void *); /** * @brief WiFi setup, init screens. diff -r b74b0e4902c3 -r ad2c8b13eb88 main/updates.c --- a/main/updates.c Sat Oct 20 13:23:15 2018 +0200 +++ b/main/updates.c Sat Oct 20 17:09:48 2018 +0200 @@ -6,9 +6,8 @@ #include "config.h" -#define BUFFSIZE 1024 +#define BUFFSIZE 1024 ///< Download buffer size static char ota_write_data[BUFFSIZE + 1] = { 0 }; - static const char *TAG = "update"; extern sButton Buttons[MAXBUTTONS]; @@ -23,6 +22,9 @@ +/** + * @brief Run update procedure + */ void run_update(void) { char temp[64];