Sat, 12 Dec 2015 22:17:25 +0100
Fixes for compiling on Raspberry.
brewco/Makefile | file | annotate | diff | comparison | revisions | |
brewco/devices.c | file | annotate | diff | comparison | revisions | |
brewco/prompt.c | file | annotate | diff | comparison | revisions | |
brewco/setup.c | file | annotate | diff | comparison | revisions | |
brewco/slcd.c | file | annotate | diff | comparison | revisions |
--- a/brewco/Makefile Sat Dec 12 21:47:04 2015 +0100 +++ b/brewco/Makefile Sat Dec 12 22:17:25 2015 +0100 @@ -5,7 +5,7 @@ SRCS = $(wildcard *.c) HDRS = $(wildcard *.h) OBJS = $(SRCS:.c=.o) -SLIBS = -lpthread -lz +SLIBS = -lpthread -lz -lrt TARGET = brewco OTHER = Makefile
--- a/brewco/devices.c Sat Dec 12 21:47:04 2015 +0100 +++ b/brewco/devices.c Sat Dec 12 22:17:25 2015 +0100 @@ -30,13 +30,13 @@ extern int debug; extern sys_config Config; extern int my_shutdown; +extern uint16_t leds; +extern int slcdHandle; #ifdef USE_SIMULATOR extern int SIM_hlt_value; extern int SIM_mlt_value; -extern uint16_t leds; -extern int slcdHandle; #endif
--- a/brewco/prompt.c Sat Dec 12 21:47:04 2015 +0100 +++ b/brewco/prompt.c Sat Dec 12 22:17:25 2015 +0100 @@ -32,12 +32,12 @@ -void prompt(int index, char *text) +void prompt(int idx, char *text) { char message[81]; int line; - switch (index) { + switch (idx) { case 0: #ifdef HAVE_WIRINGPI_H piLock(LOCK_LCD); @@ -174,11 +174,11 @@ default: snprintf(message, Config.lcd_cols + 1, " N/A N/A"); } - if (index < 200) + if (idx < 200) line = 0; - else if (index < 300) + else if (idx < 300) line = 1; - else if (index < 400) + else if (idx < 400) line = 2; else line = 3;
--- a/brewco/setup.c Sat Dec 12 21:47:04 2015 +0100 +++ b/brewco/setup.c Sat Dec 12 22:17:25 2015 +0100 @@ -209,7 +209,7 @@ void editPID(pid_var *pid) { - int index = 1, key, val; + int idx = 1, key, val; char pmpt[81]; double Kp, Ki, Kd; @@ -220,14 +220,14 @@ prompt(0, NULL); prompt(135, NULL); - if (index == 1) + if (idx == 1) prompt(402, NULL); - else if (index == 5) + else if (idx == 5) prompt(404, NULL); else prompt(403, NULL); - switch (index) { + switch (idx) { case 1: snprintf(pmpt, Config.lcd_cols + 1, "PID Kp: %5.2f", PID_getKp(pid)); break; case 2: snprintf(pmpt, Config.lcd_cols + 1, "PID Ki: %5.2f", PID_getKi(pid)); @@ -248,10 +248,10 @@ return; } - if ((key == KEY_UP) && (index > 1)) - index--; - if ((key == KEY_DOWN) && (index < 5)) - index++; + if ((key == KEY_UP) && (idx > 1)) + idx--; + if ((key == KEY_DOWN) && (idx < 5)) + idx++; if (key == KEY_ENTER) { @@ -259,7 +259,7 @@ Ki = PID_getKi(pid); Kd = PID_getKd(pid); - switch(index) { + switch(idx) { case 1: editDouble(&Kp, 0.5, 50, (char *)"PID Kp"); PID_setTunings(pid, Kp, Ki, Kd); break; @@ -287,7 +287,7 @@ void editSensor(char *uuid, char *text) { char pmpt[81]; - int i, old, choices, index = 1, key; + int i, old, choices, idx = 1, key; devices_list *device; if (debug) @@ -329,13 +329,13 @@ } prompt(200, pmpt); /* Display current sensor */ i = 1; - if (index == 1) { + if (idx == 1) { snprintf(pmpt, Config.lcd_cols + 1, "N/A"); } else { for (device = Config.devices; device; device = device->next) { if (device->direction == DEVDIR_IN_ANALOG) { i++; - if (i == index) { + if (i == idx) { snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description); } } @@ -346,9 +346,9 @@ if (choices == 1) prompt(405, NULL); - else if (index == 1) + else if (idx == 1) prompt(402, NULL); - else if (index == choices) + else if (idx == choices) prompt(404, NULL); else prompt(403, NULL); @@ -360,33 +360,33 @@ return; } - if ((key == KEY_UP) && (index > 1)) - index--; - if ((key == KEY_DOWN) && (index < choices)) - index++; + if ((key == KEY_UP) && (idx > 1)) + idx--; + if ((key == KEY_DOWN) && (idx < choices)) + idx++; - if ((key == KEY_ENTER) && (index != old)) { + if ((key == KEY_ENTER) && (idx != old)) { /* * Select new sensor. */ - if (index == 1) { + if (idx == 1) { /* * Disable the sensor */ strncpy(uuid, (char *)"00000000-0000-0000-0000-000000000000", 36); - old = index; + old = idx; } else { i = 1; for (device = Config.devices; device; device = device->next) { if (device->direction == DEVDIR_IN_ANALOG) { i++; - if (i == index) { + if (i == idx) { strncpy(uuid, device->uuid, 36); break; } } } - old = index; + old = idx; } } } @@ -397,7 +397,7 @@ void editRelay(char *uuid, char *text) { char pmpt[81]; - int i, old, choices, index = 1, key; + int i, old, choices, idx = 1, key; devices_list *device; if (debug) @@ -439,13 +439,13 @@ } prompt(200, pmpt); /* Display current relay */ i = 1; - if (index == 1) { + if (idx == 1) { snprintf(pmpt, Config.lcd_cols + 1, "N/A"); } else { for (device = Config.devices; device; device = device->next) { if (device->direction == DEVDIR_OUT_ANALOG) { i++; - if (i == index) { + if (i == idx) { snprintf(pmpt, Config.lcd_cols + 1, "%s", device->description); } } @@ -455,9 +455,9 @@ if (choices == 1) prompt(405, NULL); - else if (index == 1) + else if (idx == 1) prompt(402, NULL); - else if (index == choices) + else if (idx == choices) prompt(404, NULL); else prompt(403, NULL); @@ -469,33 +469,33 @@ return; } - if ((key == KEY_UP) && (index > 1)) - index--; - if ((key == KEY_DOWN) && (index < choices)) - index++; + if ((key == KEY_UP) && (idx > 1)) + idx--; + if ((key == KEY_DOWN) && (idx < choices)) + idx++; - if ((key == KEY_ENTER) && (index != old)) { + if ((key == KEY_ENTER) && (idx != old)) { /* * Select new output. */ - if (index == 1) { + if (idx == 1) { /* * Disable the output */ strncpy(uuid, (char *)"00000000-0000-0000-0000-000000000000", 36); - old = index; + old = idx; } else { i = 1; for (device = Config.devices; device; device = device->next) { if (device->direction == DEVDIR_OUT_ANALOG) { i++; - if (i == index) { + if (i == idx) { strncpy(uuid, device->uuid, 36); break; } } } - old = index; + old = idx; } } } @@ -508,7 +508,7 @@ */ void editUnit(units_list *unit) { - int index = 1, key; + int idx = 1, key; char pmpt[81], *uuid; uLong ocrc, ncrc; @@ -524,14 +524,14 @@ prompt(0, NULL); prompt(131, NULL); - if (index == 1) + if (idx == 1) prompt(402, NULL); - else if (index == 21) + else if (idx == 21) prompt(404, NULL); else prompt(403, NULL); - switch (index) { // 12345678901234567890 + switch (idx) { // 12345678901234567890 case 1: snprintf(pmpt, Config.lcd_cols + 1, "Unit name:"); prompt(200, pmpt); snprintf(pmpt, Config.lcd_cols + 1, "%s", unit->name); @@ -609,13 +609,13 @@ return; } - if ((key == KEY_UP) && (index > 1)) - index--; - if ((key == KEY_DOWN) && (index < 21)) - index++; + if ((key == KEY_UP) && (idx > 1)) + idx--; + if ((key == KEY_DOWN) && (idx < 21)) + idx++; if (key == KEY_ENTER) { - switch(index) { + switch(idx) { case 1: // name break; case 2: uuid = xstrcpy(unit->hlt_sensor.uuid);
--- a/brewco/slcd.c Sat Dec 12 21:47:04 2015 +0100 +++ b/brewco/slcd.c Sat Dec 12 22:17:25 2015 +0100 @@ -138,15 +138,15 @@ -void slcdCharDef(int fd, int index, unsigned char data[8]) +void slcdCharDef(int fd, int idx, unsigned char data[8]) { int i; uint16_t byte; if (debug) - fprintf(stdout, "CharDef(%d, %d, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x)\n", fd, index, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); + fprintf(stdout, "CharDef(%d, %d, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x)\n", fd, idx, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); - byte = SLCD_CGRAM | ((index & 7) << 3); + byte = SLCD_CGRAM | ((idx & 7) << 3); putLCDsocket(fd, byte); for (i = 0; i < 8; i++) { byte = data[i] & 0xff;