diff --git a/Makefile b/Makefile index 183c8c9..a60e1f5 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,23 @@ CFLAGS=-g -Wall -Wextra -std=gnu99 -BIN_DIR=bin -SRC_DIR=src -TARGET=$(BIN_DIR)/netsl -OBJECTS=$(BIN_DIR)/main.o $(BIN_DIR)/msg.o $(BIN_DIR)/net.o $(BIN_DIR)/display.o +BIN=bin +SRC=src +TARGET=$(BIN)/netsl +OBJECTS=$(BIN)/main.o $(BIN)/msg.o $(BIN)/net.o $(BIN)/display.o -all: $(BIN_DIR) $(TARGET) +all: $(BIN) $(TARGET) -$(BIN_DIR): - mkdir -pv $(BIN_DIR) +$(BIN): + mkdir -pv $(BIN) $(TARGET): $(OBJECTS) gcc $^ -o $(TARGET) -# mkdir -pv $(BIN_DIR) +# mkdir -pv $(BIN) -$(BIN_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/%.h +$(BIN)/%.o: $(SRC)/%.c $(SRC)/%.h $(CC) $(CFLAGS) -o $@ -c $< - clean: - rm -rf $(BIN_DIR) - + rm -rf $(BIN) diff --git a/src/display.c b/src/display.c index 62e1530..b2430b9 100644 --- a/src/display.c +++ b/src/display.c @@ -1,6 +1,47 @@ +#include +#include +#include +#include #include "display.h" +<<<<<<< HEAD + +void setup_display() { + initscr(); // ncurses initialization + curs_set(0); // invisible cursor +} + +void cleanup_display() { + endwin(); // clean ncurses shutdown +} + +/* + image[row][col] >>> image[row*width+col]; + + uint32_t width; // normally 80 + uint32_t height; // normally 25, may vary + char *image; // dimension is width x height +*/ +void print_current_image(message* msg, int start, int end) { + // end is ignored and 80 is used, should be considered later + + move(0,0); // start in the upper left corner + char *pic = msg->img; // get a ptr to the actual image + + for (int row=0; row < 25; row++) { // iterate rows + char *line = (char*) malloc(81); + strcpy(line, strtok(pic, '\n')); // get a line + line[80] = '\0'; // terminate + printw("%s", line+start); + } + + refresh(); // refresh the screen + +} + + void callback(const struct message *msg) { printf("in callback, tst=%d\n", msg->timestamp); } + diff --git a/src/display.h b/src/display.h index caf103b..96907d2 100644 --- a/src/display.h +++ b/src/display.h @@ -4,6 +4,10 @@ #include #include "msg.h" +void setup_display(); +void cleanup_display(); + void callback(const struct message *msg); #endif + diff --git a/src/main.h b/src/main.h index 462af4a..c169102 100644 --- a/src/main.h +++ b/src/main.h @@ -8,7 +8,7 @@ // _,-' \%/|% // / / ) __,-- /%\ // \__/_,-'%(% ; %)% -// %\%, %\ -// '--%' -// +// / %\%, %\ +// / '--%' +// / // diff --git a/src/msg.h b/src/msg.h index 4525cc6..cf3f3fc 100644 --- a/src/msg.h +++ b/src/msg.h @@ -10,8 +10,8 @@ struct message { uint32_t timestamp; - uint32_t width; // varies - uint32_t height; // normally 80 + uint32_t width; // normally 80 + uint32_t height; // normally 25, may vary //char **image; // dimension is width x height char *image; // dimension is width x height