Version 0.2 (add clock info)
diff --git a/display.c b/display.c
index 326b223..ff2295a 100644
--- a/display.c
+++ b/display.c
@@ -14,7 +14,6 @@
* - initial API and implementation
*******************************************************************************/
-
#include "powerdebug.h"
#define print(w, x, y, fmt, args...) do { mvwprintw(w, y, x, fmt, ##args); } while (0)
@@ -22,6 +21,8 @@
static WINDOW *header_win;
static WINDOW *regulator_win;
+static WINDOW *clock_win;
+static WINDOW *sensor_win;
static WINDOW *footer_win;
int maxx, maxy;
@@ -42,6 +43,14 @@
delwin(regulator_win);
regulator_win = NULL;
}
+ if (clock_win) {
+ delwin(clock_win);
+ clock_win = NULL;
+ }
+ if (sensor_win) {
+ delwin(sensor_win);
+ sensor_win = NULL;
+ }
if (footer_win) {
delwin(footer_win);
footer_win = NULL;
@@ -60,13 +69,13 @@
use_default_colors();
init_pair(PT_COLOR_DEFAULT, COLOR_WHITE, COLOR_BLACK);
- init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE);
init_pair(PT_COLOR_ERROR, COLOR_BLACK, COLOR_RED);
- init_pair(PT_COLOR_RED, COLOR_WHITE, COLOR_RED);
+ init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE);
init_pair(PT_COLOR_YELLOW, COLOR_WHITE, COLOR_YELLOW);
init_pair(PT_COLOR_GREEN, COLOR_WHITE, COLOR_GREEN);
- init_pair(PT_COLOR_BLUE, COLOR_WHITE, COLOR_BLUE);
init_pair(PT_COLOR_BRIGHT, COLOR_WHITE, COLOR_BLACK);
+ init_pair(PT_COLOR_BLUE, COLOR_WHITE, COLOR_BLUE);
+ init_pair(PT_COLOR_RED, COLOR_WHITE, COLOR_RED);
atexit(fini_curses);
}
@@ -79,7 +88,8 @@
killall_windows();
header_win = subwin(stdscr, 1, maxx, 0, 0);
- regulator_win = subwin(stdscr, maxy-3, maxx, 1, 0);
+// regulator_win = subwin(stdscr, maxy/2 - 2, maxx, 1, 0);
+// clock_win = subwin(stdscr, maxy/2 - 2, maxx, maxy/2, 0);
footer_win = subwin(stdscr, 1, maxx, maxy-1, 0);
@@ -91,6 +101,68 @@
}
+int create_regulator_win(int row, int maxrows)
+{
+ int numrows;
+
+ if (regulator_win) {
+ delwin(regulator_win);
+ regulator_win = NULL;
+ }
+
+ getmaxyx(stdscr, maxy, maxx);
+ if (maxrows < (maxy/2 - 2))
+ numrows = maxrows;
+ else
+ numrows = maxy/2 - 2;
+ regulator_win = subwin(stdscr, numrows, maxx, row, 0);
+
+ refresh();
+
+ return numrows + row;
+}
+
+int create_clock_win(int row, int maxrows)
+{
+ int numrows;
+
+ if (clock_win) {
+ delwin(clock_win);
+ clock_win = NULL;
+ }
+
+ getmaxyx(stdscr, maxy, maxx);
+ if (maxrows < (maxy/2 - 2))
+ numrows = maxrows;
+ else
+ numrows = maxy/2 - 2;
+ clock_win = subwin(stdscr, numrows, maxx, row, 0);
+
+ refresh();
+
+ return numrows + row;
+}
+
+int create_sensor_win(int row, int maxrows)
+{
+ int numrows;
+
+ if (sensor_win) {
+ delwin(sensor_win);
+ sensor_win = NULL;
+ }
+
+ getmaxyx(stdscr, maxy, maxx);
+ if (maxrows < 4)
+ numrows = maxrows;
+ else
+ numrows = 4;
+ sensor_win = subwin(stdscr, numrows, maxx, row, 0);
+
+ refresh();
+
+ return numrows + row;
+}
void show_header(void)
{
@@ -172,3 +244,60 @@
wrefresh(regulator_win);
}
+
+void print_clock_header(int level)
+{
+ char lev[NAME_MAX];
+
+ sprintf(lev, "(Level %d)\n", level);
+ werase(clock_win);
+ wattron(clock_win, A_BOLD);
+ wattron(clock_win, A_STANDOUT);
+ print(clock_win, 0, 0, "Clock Information");
+ wattroff(clock_win, A_STANDOUT);
+ print(clock_win, 0, 1, "Name");
+ print(clock_win, 24, 1, "Flags");
+ print(clock_win, 36, 1, "Rate");
+ print(clock_win, 48, 1, "Usecount");
+ print(clock_win, 60, 1, lev);
+ wattroff(clock_win, A_BOLD);
+ wrefresh(clock_win);
+}
+
+void print_sensor_header(void)
+{
+ werase(sensor_win);
+ wattron(sensor_win, A_BOLD);
+ wattron(sensor_win, A_STANDOUT);
+ print(sensor_win, 0, 0, "Sensor Information");
+ wattroff(sensor_win, A_STANDOUT);
+ print(sensor_win, 0, 1, "Name");
+ print(sensor_win, 36, 1, "Temperature");
+ wattroff(sensor_win, A_BOLD);
+ wattron(sensor_win, A_BLINK);
+ print(sensor_win, 0, 2, "Currently Sensor information available"
+ " only in Dump mode!");
+ wattroff(sensor_win, A_BLINK);
+ wrefresh(sensor_win);
+}
+
+void print_clock_info_line(int line, char *clockname, int flags, int rate,
+ int usecount, int highlight)
+{
+ if (highlight) {
+ //wattrset(clock_win, COLOR_PAIR(PT_COLOR_RED));
+ //wbkgd(clock_win, COLOR_PAIR(PT_COLOR_RED));
+ wattron(clock_win, WA_BOLD);
+ }
+ print(clock_win, 0, line + 2, "%s", clockname);
+ print(clock_win, 24, line + 2, "%d", flags);
+ print(clock_win, 36, line + 2, "%d", rate);
+ print(clock_win, 48, line + 2, "%d", usecount);
+ if (highlight) {
+ //use_default_colors();
+ //wattrset(clock_win, COLOR_PAIR(PT_COLOR_DEFAULT));
+ //wbkgd(clock_win, COLOR_PAIR(PT_COLOR_DEFAULT));
+ wattroff(clock_win, WA_BOLD);
+ }
+ wrefresh(clock_win);
+}