Assignment 3: comment rework
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* console.c
|
||||
/*!
|
||||
* \file console.c
|
||||
* \brief
|
||||
* A simple serial console implementation for out thermostat
|
||||
*
|
||||
* Created on: Jun 28, 2020
|
||||
* Author: hoo2
|
||||
* Author: Christos Choutouridis AEM: 8997
|
||||
* email : <cchoutou@ece.auth.gr>
|
||||
*/
|
||||
|
||||
#include "console.h"
|
||||
|
||||
static char _buffer[COM_BUFFER_SIZE];
|
||||
@@ -12,6 +13,10 @@ static int _cursor;
|
||||
|
||||
static char _ans[512];
|
||||
|
||||
/*!
|
||||
* Parse and respond funcionality for serial console
|
||||
* \param buffer Pointer to buffer
|
||||
*/
|
||||
void parse (char* buffer) {
|
||||
int i;
|
||||
float_t s;
|
||||
@@ -102,6 +107,9 @@ void parse (char* buffer) {
|
||||
COM_Transmit((uint8_t*)_ans, i);
|
||||
}
|
||||
|
||||
/*!
|
||||
* A simple terminal with echo
|
||||
*/
|
||||
void console (void) {
|
||||
int ch;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* console.h
|
||||
/*!
|
||||
* \file console.h
|
||||
* \brief
|
||||
* A simple serial console implementation for out thermostat
|
||||
*
|
||||
* Created on: Jun 28, 2020
|
||||
* Author: hoo2
|
||||
* Author: Christos Choutouridis AEM: 8997
|
||||
* email : <cchoutou@ece.auth.gr>
|
||||
*/
|
||||
|
||||
#ifndef CONSOLE_H_
|
||||
#define CONSOLE_H_
|
||||
|
||||
|
||||
+20
-1
@@ -27,6 +27,14 @@ float_t temp_get_current (void) {
|
||||
return (app_data.cur) ? app_data.T[app_data.cur-1] : app_data.T[MEASUREMENTS-1];
|
||||
}
|
||||
|
||||
/*!
|
||||
* Control functionality
|
||||
* Handles:
|
||||
* * Sensor reading
|
||||
* * Temp averaging
|
||||
* * Output calculation
|
||||
* \note Non-blocking
|
||||
*/
|
||||
void control (void) {
|
||||
static time_t sample =0;
|
||||
time_t now = time(0); // get time
|
||||
@@ -81,6 +89,11 @@ void control (void) {
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Display functionality
|
||||
* Implement a state machine for lcd display
|
||||
* \note Non-blocking
|
||||
*/
|
||||
void display (void) {
|
||||
static time_t mark =0;
|
||||
|
||||
@@ -151,6 +164,10 @@ void display (void) {
|
||||
lcd_puts(line2);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Set outputs
|
||||
* \note Non-blocking
|
||||
*/
|
||||
void outputs (void) {
|
||||
static uint8_t pr_output =0;
|
||||
|
||||
@@ -166,7 +183,9 @@ void outputs (void) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main loop
|
||||
*/
|
||||
int main(void) {
|
||||
|
||||
hal_hw_init ();
|
||||
|
||||
@@ -1,51 +1,67 @@
|
||||
/*
|
||||
* thermostat.h
|
||||
/*!
|
||||
* \file thermostat.h
|
||||
* \brief
|
||||
* Application wide data type declarations
|
||||
*
|
||||
* Created on: Jun 27, 2020
|
||||
* Author: hoo2
|
||||
* Author: Christos Choutouridis AEM: 8997
|
||||
* email : <cchoutou@ece.auth.gr>
|
||||
*/
|
||||
|
||||
#ifndef THERMOSTAT_H_
|
||||
#define THERMOSTAT_H_
|
||||
|
||||
/*
|
||||
* Hard coded user settings
|
||||
*/
|
||||
#define MEAS_WINDOW (120) // [sec]
|
||||
#define MEAS_INTERVAL (5) // [sec]
|
||||
#define MEASUREMENTS (MEAS_WINDOW / MEAS_INTERVAL) // keep this integer
|
||||
#define UI_AVERAGE_TIME (10) // [sec]
|
||||
//#define UI_USER_TIME (10)
|
||||
|
||||
typedef float float_t;
|
||||
typedef int int_t;
|
||||
|
||||
typedef float float_t; //!< Select the floating point type for application
|
||||
typedef int int_t; //!< Select the integer type for application
|
||||
|
||||
/*!
|
||||
* Thermostat mode enumerator
|
||||
*/
|
||||
typedef enum {
|
||||
HEATING =0,
|
||||
COOLING
|
||||
HEATING =0, //!< HEATING
|
||||
COOLING //!< COOLING
|
||||
} mode_en;
|
||||
|
||||
/*!
|
||||
* Application common data type
|
||||
*/
|
||||
typedef struct {
|
||||
float_t T[MEASUREMENTS];
|
||||
float_t Tav;
|
||||
uint32_t cur;
|
||||
uint8_t flag_output;
|
||||
uint8_t flag_init;
|
||||
uint8_t flag_proximity;
|
||||
uint8_t signal_cycle;
|
||||
float_t T[MEASUREMENTS]; //!< Temperature samples
|
||||
float_t Tav; //!< Average temperature
|
||||
uint32_t cur; //!< Cursor on sample array
|
||||
uint8_t flag_output; //!< Momentary flag to indicate the relay state
|
||||
uint8_t flag_init; //!< Momentary flag to indicate the end of initialization state
|
||||
uint8_t flag_proximity; //!< Momentary flag to indicate that the user is near
|
||||
uint8_t signal_cycle; //!< Acknolegable flag to indicate the end of measurement cycle
|
||||
} app_data_t;
|
||||
|
||||
|
||||
/*!
|
||||
* Settings struct
|
||||
*/
|
||||
typedef struct {
|
||||
mode_en mode;
|
||||
float_t Tset;
|
||||
float_t Thyst;
|
||||
float_t Pset;
|
||||
float_t Physt;
|
||||
mode_en mode; //!< Operational mode
|
||||
float_t Tset; //!< Target temperature
|
||||
float_t Thyst; //!< Target temperature hysteresis
|
||||
float_t Pset; //!< Proximity distance
|
||||
float_t Physt; //!< Proximity distance hysteresis
|
||||
} settings_t;
|
||||
|
||||
/*!
|
||||
* User interface states
|
||||
*/
|
||||
typedef enum {
|
||||
ST_INIT =0,
|
||||
ST_COUNT,
|
||||
ST_AVERAGE,
|
||||
ST_USER
|
||||
ST_INIT =0, //!< ST_INIT: Still initializing
|
||||
ST_COUNT, //!< ST_COUNT: Measurement cycle
|
||||
ST_AVERAGE, //!< ST_AVERAGE: Display average
|
||||
ST_USER //!< ST_USER: Display when a user is near
|
||||
} state_en;
|
||||
|
||||
/*
|
||||
@@ -55,6 +71,9 @@ extern app_data_t app_data;
|
||||
extern state_en state;
|
||||
extern settings_t settings;
|
||||
|
||||
/*!
|
||||
* Factory defaults
|
||||
*/
|
||||
#define _Init_settings(s) s = { \
|
||||
.mode = HEATING, \
|
||||
.Tset = 21.0, \
|
||||
|
||||
Reference in New Issue
Block a user