model for printing

This commit is contained in:
Lennart Buhl 2013-11-02 19:47:37 +01:00
parent 38f2f8d15f
commit ea62134420
2 changed files with 46 additions and 2 deletions

View File

@ -1,6 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ncurses.h>
#include "display.h"
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) {
move(0,0);
char *pic = msg->img;
for (int row=0; row < 25; row++) {
char *line = (char*) malloc(81);
strcpy(line, strtok(pic, '\n'));
line[81] = '\0';
printw("%s", line);
}
refresh(); // refresh the screen
}
void callback(long tst) {
printf("in callback, tst=%ld\n", tst);
}

View File

@ -1,8 +1,11 @@
#ifndef __DISPLAY
#define __DISPLAY
#include <stdio.h>
void setup_display();
void cleanup_display();
void callback(long tst);
void
#endif