pi_clock

Crude and unpolished clock for Raspberry Pi
git clone https://git.e1e0.net/pi_clock.git
Log | Files | Refs | README | LICENSE

commit 45faa7fb448244f4a73b853cdd9267d89a6fb9d5
parent a0dc902b7ed1f0f1da7bb22b9912a514f468f845
Author: Paco Esteban <paco@e1e0.net>
Date:   Mon,  3 Feb 2020 20:23:15 +0100

use errx whenever possible

Diffstat:
Mclock.c | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/clock.c b/clock.c @@ -17,6 +17,7 @@ */ #include <stdio.h> +#include <err.h> #include <errno.h> #include <stdlib.h> #include <string.h> @@ -29,7 +30,7 @@ #define I2C_ADDRESS 0x3f #define BUTTON1 3 -const char *version = "v0.2.1"; +const char *version = "v0.2.2"; // TODO: Make those parameters const int readInterval = 120; // 30s const int sleepInterval = 250; @@ -92,7 +93,7 @@ main(int argc, char *argv[]) lcd_i2c_t lcd={0}; if( lcd_i2c_setup(&lcd, I2C_ADDRESS) == -1 ){ - fprintf(stderr, + errx(1, "Error intialising PCF8574 at address i2c 0x%02x: %s\n", I2C_ADDRESS, strerror(errno) @@ -106,9 +107,7 @@ main(int argc, char *argv[]) printf("Display initialized\n"); if (wiringPiSetup() < 0) { - fprintf(stderr, "Unable to setup wiringPi: %s\n", - strerror(errno)) ; - return 1 ; + errx(1, "Unable to setup wiringPi: %s\n", strerror(errno)); } pinMode(BUTTON1, INPUT); @@ -137,9 +136,7 @@ main(int argc, char *argv[]) // read external file only interval * sleep if (readCount == readInterval) { if (getExtTag(extTag, extFile) < 0) { - fprintf(stderr, - "Error getting external tag\n"); - return 1; + errx(1, "Error getting external tag\n"); } readCount = 0; }