pi_clock

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

commit c5520f341297059b468dc591cb50ba670c09ba75
parent 46d617a6f488ad9b2263a5636727a5d12f4e0589
Author: Paco Esteban <paco@e1e0.net>
Date:   Mon,  6 Jul 2020 13:11:09 +0200

wiringpi init and pin init go to separate function

Diffstat:
Mclock.c | 23++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/clock.c b/clock.c @@ -41,6 +41,7 @@ void setmonth(char *, int); void setwday(char *, int); void usage(); int getExtTag(char *, char *); +int init_pins(void); int main(int argc, char *argv[]) @@ -104,13 +105,8 @@ main(int argc, char *argv[]) strerror(errno) ); - if (wiringPiSetup() < 0) { + if (init_pins() == -1) errx(1, "Unable to setup wiringPi: %s\n", strerror(errno)); - } - - pinMode(BUTTON1, INPUT); - pullUpDnControl(BUTTON1, PUD_UP); - printf("Input pins initialized\n"); for (;;) { t = time(NULL); @@ -300,7 +296,7 @@ usage(void) } lcd_i2c_t * -init_lcd() +init_lcd(void) { lcd_i2c_t *lcd = malloc(sizeof(lcd_i2c_t)); if (lcd_i2c_setup(lcd, I2C_ADDRESS) == -1){ @@ -313,3 +309,16 @@ init_lcd() return lcd; } + +int +init_pins(void) +{ + if (wiringPiSetup() < 0) + return -1; + + pinMode(BUTTON1, INPUT); + pullUpDnControl(BUTTON1, PUD_UP); + printf("Input pins initialized\n"); + + return 0; +}