Skip to content

Commit

Permalink
fixes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
amagura committed Mar 1, 2015
1 parent 105cdda commit 48a9001
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
13 changes: 10 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ all-local:
test-clean:
mkdir -p test/{ACAD,BAT0,BAT1}
echo 1 > 'test/ACAD/online'
echo 100 > 'test/'{BAT0,BAT1}'/capacity'
echo 'Battery' > 'test/'{BAT0,BAT1}'/type'
echo 100 > 'test/BAT0/capacity'
echo 100 > 'test/BAT1/capactiy'
echo 'Battery' > 'test/BAT0/type'
echo 'Battery' > 'test/BAT1/type'
echo 'Mains' > 'test/ACAD/type'

test-onac:
Expand All @@ -19,6 +21,11 @@ test-noac:
echo 0 > 'test/ACAD/online'

test-lowbat:
echo 1 > 'test/'{BAT0,BAT1}'/capacity'
echo 1 > 'test/BAT0/capacity'
echo 1 > 'test/BAT1/capacity'

test-empty:
echo 0 > 'test/BAT0/capacity'
echo 0 > 'test/BAT0/capacity'

SUBDIRS = src img
15 changes: 15 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,18 @@ drone:

akpi:
$(CC) $(AM_CFLAGS) $(AM_CPPFLAGS) $(AM_LDFLAGS) -o acpi acpi.c main.c

test-clean:
cd "$(top_srcdir)"; make $@

test-onac:
cd "$(top_srcdir)"; make $@

test-noac:
cd "$(top_srcdir)"; make $@

test-lowbat:
cd "$(top_srcdir)"; make $@

test-empty:
cd "$(top_srcdir)"; make $@
7 changes: 6 additions & 1 deletion src/main-color.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ struct pp_disp_opts {
void disp(struct pp_disp_opts pp, struct power pwr)
{
printf("\033[%sm", pp.norm.ccode);
ZB_DBG("pwr.charge.raw: %d\n", pwr.charge.raw);
if (!pp.blnk.ctl.mc || (pwr.charge.raw) > pp.blnk.ctl.thold)
return;
if (pwr.acline && !pp.blnk.ctl.ac)
if (pwr.acline && !pp.blnk.ctl.ac) {
ZB_DBG("%s\n", "On A/C power: no need to blink");
return;
}
// When all the planets are in proper alignment...
ZB_DBG("pwr.charge.tr: %d\n", pwr.charge.tr);
printf("\033[%sm", pp.blnk.ccode);
}

Expand All @@ -64,6 +68,7 @@ int main(int argc, char **argv)
pp.blnk.ctl.mc = true;
pp.blnk.ctl.thold = 3; // 30%
pp.norm.ccode = "31";
pp.blnk.ccode = "5";

char *sopts = \
"hv" \
Expand Down
2 changes: 1 addition & 1 deletion test/ACAD/online
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0
1
2 changes: 1 addition & 1 deletion test/BAT0/capacity
Original file line number Diff line number Diff line change
@@ -1 +1 @@
100
0

0 comments on commit 48a9001

Please sign in to comment.