Browse Source

api add data type AVG float 3 decimal

nfactor-troky
Kano 11 years ago committed by Noel Maersk
parent
commit
b6c6ec5c83
  1. 7
      api.c
  2. 4
      miner.h

7
api.c

@ -760,6 +760,7 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu @@ -760,6 +760,7 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
break;
case API_VOLTS:
case API_TEMP:
case API_AVG:
api_data->data = (void *)malloc(sizeof(float));
*((float *)(api_data->data)) = *((float *)data);
break;
@ -894,6 +895,11 @@ struct api_data *api_add_percent(struct api_data *root, char *name, double *data @@ -894,6 +895,11 @@ struct api_data *api_add_percent(struct api_data *root, char *name, double *data
return api_add_data_full(root, name, API_PERCENT, (void *)data, copy_data);
}
struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data)
{
return api_add_data_full(root, name, API_AVG, (void *)data, copy_data);
}
static struct api_data *print_data(struct api_data *root, char *buf, bool isjson, bool precom)
{
struct api_data *tmp;
@ -973,6 +979,7 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson @@ -973,6 +979,7 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson
sprintf(buf, "%.0f", *((double *)(root->data)));
break;
case API_VOLTS:
case API_AVG:
sprintf(buf, "%.3f", *((float *)(root->data)));
break;
case API_MHTOTAL:

4
miner.h

@ -1446,7 +1446,8 @@ enum api_data_type { @@ -1446,7 +1446,8 @@ enum api_data_type {
API_VOLTS,
API_HS,
API_DIFF,
API_PERCENT
API_PERCENT,
API_AVG
};
struct api_data {
@ -1482,5 +1483,6 @@ extern struct api_data *api_add_volts(struct api_data *root, char *name, float * @@ -1482,5 +1483,6 @@ extern struct api_data *api_add_volts(struct api_data *root, char *name, float *
extern struct api_data *api_add_hs(struct api_data *root, char *name, double *data, bool copy_data);
extern struct api_data *api_add_diff(struct api_data *root, char *name, double *data, bool copy_data);
extern struct api_data *api_add_percent(struct api_data *root, char *name, double *data, bool copy_data);
extern struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data);
#endif /* __MINER_H__ */

Loading…
Cancel
Save