Skip to content

Commit

Permalink
split into multiple source files
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrovski committed Jun 19, 2012
1 parent 29aa604 commit 9508a78
Show file tree
Hide file tree
Showing 10 changed files with 1,818 additions and 1,781 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TAGS
*~
*.o
wattsup
Expand Down
100 changes: 100 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include "wattsup_common.h"

const char * wu_version = "0.03";

const char * prog_name = "wattsup";

const char * sysfs_path_start = "/sys/class/tty";

struct wu_field wu_fields[wu_num_fields] = {
[wu_field_watts] = {
.name = "watts",
.descr = "Watt Consumption",
},

[wu_field_min_watts] = {
.name = "min-watts",
.descr = "Minimum Watts Consumed",
},

[wu_field_max_watts] = {
.name = "max-watts",
.descr = "Maxium Watts Consumed",
},

[wu_field_volts] = {
.name = "volts",
.descr = "Volts Consumption",
},

[wu_field_min_volts] = {
.name = "max-volts",
.descr = "Minimum Volts Consumed",
},

[wu_field_max_volts] = {
.name = "min-volts",
.descr = "Maximum Volts Consumed",
},

[wu_field_amps] = {
.name = "amps",
.descr = "Amp Consumption",
},

[wu_field_min_amps] = {
.name = "min-amps",
.descr = "Minimum Amps Consumed",
},

[wu_field_max_amps] = {
.name = "max-amps",
.descr = "Maximum Amps Consumed",
},

[wu_field_watt_hours] = {
.name = "kwh",
.descr = "Average KWH",
},

[wu_field_mo_kwh] = {
.name = "mo-kwh",
.descr = "Average monthly KWH",
},

[wu_field_cost] = {
.name = "cost",
.descr = "Cost per watt",
},

[wu_field_mo_cost] = {
.name = "mo-cost",
.descr = "Monthly Cost",
},

[wu_field_power_factor] = {
.name = "power-factor",
.descr = "Ratio of Watts vs. Volt Amps",
},

[wu_field_duty_cycle] = {
.name = "duty-cycle",
.descr = "Percent of the Time On vs. Time Off",
},

[wu_field_power_cycle] = {
.name = "power-cycle",
.descr = "Indication of power cycle",
},

[wu_field_frequency] = {
.name = "frequency",
.descr = "AC frequency (HZ)",
},

[wu_field_va] = {
.name = "VA",
.descr = "VA",
},
};

15 changes: 15 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef CONFIG_H
#define CONFIG_H

#include "wattsup_common.h"
#include "config.h"

extern const char * wu_version,
*prog_name,
*sysfs_path_start;

#define wu_num_options ARRAY_SIZE(wu_options)

extern struct wu_field wu_fields[];

#endif
5 changes: 5 additions & 0 deletions globals.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
char * wu_device = "ttyUSB0";
int wu_fd = 0;
int wu_info_all = 0;
int wu_no_data = 0;
int wu_set_only = 0;
10 changes: 10 additions & 0 deletions globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef GLOBALS_H
#define GLOBALS_H
extern char *wu_device;
extern int wu_fd;
extern int wu_info_all;
extern int wu_no_data;
extern int wu_set_only;


#endif
5 changes: 5 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
all: wattsup

wattsup: wattsup.c util.c config.c globals.c

install: all
install -m 0555 wattsup /usr/local/bin

clean:
rm -f *~ wattsup
Loading

0 comments on commit 9508a78

Please sign in to comment.