qnapd/qnaplcd.c

72 lines
1.4 KiB
C
Raw Normal View History

2011-04-17 16:59:51 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "event.h"
#include "lcd.h"
#include "logging.h"
#define LCD_DEVICE "/dev/ttyS0"
#define LCD_TIMEOUT 10
#define PAGE_MAX 7
static int page;
static int button_callback(struct lcddev *dev, int button)
{
if (button == LCD_BUTTON2)
page = (page < PAGE_MAX) ? page +1 : 0;
else if (button == LCD_BUTTON1)
page = (page > 0) ? page -1 : PAGE_MAX;
switch (page) {
case 0:
lcd_setline(dev, 0, "Debian 5.0 Lenny");
lcd_setline(dev, 1, "2.6.34-kirkwood");
break;
case 1:
lcd_setline(dev, 0, "Hostname:");
lcd_setline(dev, 1, "storenix.lan");
break;
case 2:
lcd_setline(dev, 0, "Address(br0):");
lcd_setline(dev, 1, "10.10.250.135");
break;
case 3:
lcd_setline(dev, 0, "Netmask(br0):");
lcd_setline(dev, 1, "255.255.0.0");
break;
case 4:
lcd_setline(dev, 0, "Gateway(br0):");
lcd_setline(dev, 1, "10.10.250.250");
break;
case 5:
lcd_setline(dev, 0, "LoadAVG:");
lcd_setline(dev, 1, "x.xx x.xx x.xx");
break;
case 6:
lcd_setline(dev, 0, "Uptime:");
lcd_setline(dev, 1, " XXXd XX:XX:XX");
break;
case 7:
lcd_setline(dev, 0, "Time: XX:XX:XX");
lcd_setline(dev, 1, "Date: XX-XX-XXXX");
break;
}
return 0;
}
int main(int argc, const char *argv[])
{
if (lcd_init(LCD_DEVICE, LCD_TIMEOUT, &button_callback) < 0)
return -1;
event_loop(NULL, NULL);
return 0;
}