fix indizes
This commit is contained in:
parent
33781be4d6
commit
fb592b6f13
|
@ -23,7 +23,7 @@ void cleanup_display() {
|
|||
uint32_t height; // normally 25, may vary
|
||||
char *image; // dimension is width x height
|
||||
*/
|
||||
void print_current_image(struct message* msg, int start, int end) {
|
||||
static void print_current_image(const struct message* msg, int start, int end) {
|
||||
end = 80; // end is ignored and 80 is used, should be handled properly later
|
||||
|
||||
//move(0,0); // start in the upper left corner
|
||||
|
@ -31,12 +31,11 @@ void print_current_image(struct message* msg, int start, int end) {
|
|||
|
||||
for (int row=0; row < 25; row++) { // iterate over rows
|
||||
char *original_line = pic + row * msg->width; // pointer to the start of the line to print
|
||||
char *line = (char*) malloc(end+1); // allocate a line because we modify it
|
||||
char *line = (char*) malloc(end-start+1); // allocate a line because we modify it
|
||||
strcpy(line, original_line + start); // get a line from the right start
|
||||
line[end] = '\0'; // terminate it
|
||||
line[end-start] = '\0'; // terminate it
|
||||
|
||||
mvprintw(row, 0, "%s", line); // print it
|
||||
|
||||
free(line); // free it
|
||||
}
|
||||
|
||||
|
@ -44,8 +43,13 @@ void print_current_image(struct message* msg, int start, int end) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
void callback(const struct message *msg) {
|
||||
printf("in callback, tst=%d\n", msg->timestamp);
|
||||
|
||||
int start;
|
||||
|
||||
|
||||
print_current_image(msg, start, start+80);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user