# HG changeset patch # User Paul Boddie # Date 1369694008 0 # Node ID 0ee6f445296c070551b7c4bed7dc3189a691fc26 # Parent eebb87468f35c95a87562800f2eae64c62a599ea Renamed the main program. diff -r eebb87468f35 -r 0ee6f445296c Makefile --- a/Makefile Mon May 27 22:10:53 2013 +0000 +++ b/Makefile Mon May 27 22:33:28 2013 +0000 @@ -25,8 +25,8 @@ CFLAGS = -g -Wall -fPIC -march=mips32 -I$(LIBUBB)/include -DNANONOTE # -DDISPLAY_IN_USE=EPD_TYPE_270 # -DDEBUG=1 LDFLAGS = -lubb -L$(LIBUBB) #-static #-L$(SYSLIBS) -TARGET = test -SRC = test.c bsp.c Display_COG_Process.c Display_Controller.c Display_Hardware_Driver.c images.c +TARGET = epaper +SRC = epaper.c bsp.c Display_COG_Process.c Display_Controller.c Display_Hardware_Driver.c images.c OBJ = $(SRC:.c=.o) .PHONY: all clean distclean diff -r eebb87468f35 -r 0ee6f445296c epaper.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/epaper.c Mon May 27 22:33:28 2013 +0000 @@ -0,0 +1,177 @@ +/* + * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication. + * + * Copyright (C) 2013 Paul Boddie + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include "images.h" +#include "Display_Controller.h" +#include "bsp.h" + +typedef enum { + FALSE=0, + TRUE=1 +} bool; + +/** + * Handle termination of the process. + */ +void shutdown(int signum) +{ + printf("Closing...\n"); + ubb_close(0); + exit(1); +} + +/* Main program and basic initialisation. */ + +int main(int argc, char *argv[]) +{ + uint8_t *current_image, *next_image, blank_image[176][33], image_number, arg; + bool blank_screen, have_image; + int delay; + + signal(SIGINT, &shutdown); + + if (ubb_open(0) < 0) { + perror("ubb_open"); + return 1; + } + + ubb_power(1); + printf("Power on.\n"); + + /* Need to initialise the board. */ + + bsp_init(); + printf("Initialised.\n"); + + /* Initialise an array containing the blank image. */ + + memset((uint8_t*) &blank_image[0][0], 0xff, 176*33); + + /* Determine whether to blank the screen or leave an image on it. */ + + if (argc < 2) + { + printf("Usage: %s ( --have | --blank | | --wait )...\n", argv[0]); + ubb_close(0); + return 1; + } + + /* Assume a blank screen by default. */ + + current_image = (uint8_t*) &blank_image[0][0]; + + for (arg = 1; arg < argc; arg ++) + { + /* Wait for a specified delay. */ + + if (strcmp(argv[arg], "--wait") == 0) + { + arg++; + + if (!isdigit(argv[arg][0])) + { + printf("Expected an delay in seconds instead of %s.\n", argv[arg]); + ubb_close(0); + return 1; + } + + delay = atoi(argv[arg]); + printf("Waiting for %d seconds...\n", delay); + sleep(delay); + continue; + } + + /* Indicate an image presumably on screen already. */ + + have_image = strcmp(argv[arg], "--have") == 0; + blank_screen = strcmp(argv[arg], "--blank") == 0; + + if (have_image) + arg++; + + /* If a blank screen operation is not requested, find the image + specified. */ + + if (!blank_screen) + { + if (!isdigit(argv[arg][0])) + { + printf("Expected an image number instead of %s.\n", argv[arg]); + ubb_close(0); + return 1; + } + + image_number = atoi(argv[arg]); + + if (image_number > MAX_IMAGE) + { + printf("Image number cannot be greater than %d.\n", MAX_IMAGE); + ubb_close(0); + return 1; + } + + /* If just specifying the current image, start the next iteration + expecting an image to replace the current image. */ + + if (have_image) + { + current_image = (uint8_t *) &image_data[image_number][0][0]; + printf("Set current image as %d.\n", image_number); + continue; + } + + /* Otherwise, choose the replacement image. */ + + else + { + next_image = (uint8_t *) &image_data[image_number][0][0]; + printf("Set next image as %d.\n", image_number); + } + } + + /* To blank the screen choose the blank image as the next image. */ + + else + { + next_image = (uint8_t*) &blank_image[0][0]; + printf("Set blank image.\n"); + } + + /* Call epd_DisplayImg with the new image and current image. */ + + epd_DisplayImg(DISPLAY_IN_USE, next_image, current_image); + printf("Updated image.\n"); + + current_image = next_image; + } + + /* Detach from the board. */ + + printf("Closing...\n"); + ubb_close(0); + + return 0; +} diff -r eebb87468f35 -r 0ee6f445296c test.c --- a/test.c Mon May 27 22:10:53 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,177 +0,0 @@ -/* - * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication. - * - * Copyright (C) 2013 Paul Boddie - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 3 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include -#include "images.h" -#include "Display_Controller.h" -#include "bsp.h" - -typedef enum { - FALSE=0, - TRUE=1 -} bool; - -/** - * Handle termination of the process. - */ -void shutdown(int signum) -{ - printf("Closing...\n"); - ubb_close(0); - exit(1); -} - -/* Main program and basic initialisation. */ - -int main(int argc, char *argv[]) -{ - uint8_t *current_image, *next_image, blank_image[176][33], image_number, arg; - bool blank_screen, have_image; - int delay; - - signal(SIGINT, &shutdown); - - if (ubb_open(0) < 0) { - perror("ubb_open"); - return 1; - } - - ubb_power(1); - printf("Power on.\n"); - - /* Need to initialise the board. */ - - bsp_init(); - printf("Initialised.\n"); - - /* Initialise an array containing the blank image. */ - - memset((uint8_t*) &blank_image[0][0], 0xff, 176*33); - - /* Determine whether to blank the screen or leave an image on it. */ - - if (argc < 2) - { - printf("Usage: %s ( --have | --blank | | --wait )...\n", argv[0]); - ubb_close(0); - return 1; - } - - /* Assume a blank screen by default. */ - - current_image = (uint8_t*) &blank_image[0][0]; - - for (arg = 1; arg < argc; arg ++) - { - /* Wait for a specified delay. */ - - if (strcmp(argv[arg], "--wait") == 0) - { - arg++; - - if (!isdigit(argv[arg][0])) - { - printf("Expected an delay in seconds instead of %s.\n", argv[arg]); - ubb_close(0); - return 1; - } - - delay = atoi(argv[arg]); - printf("Waiting for %d seconds...\n", delay); - sleep(delay); - continue; - } - - /* Indicate an image presumably on screen already. */ - - have_image = strcmp(argv[arg], "--have") == 0; - blank_screen = strcmp(argv[arg], "--blank") == 0; - - if (have_image) - arg++; - - /* If a blank screen operation is not requested, find the image - specified. */ - - if (!blank_screen) - { - if (!isdigit(argv[arg][0])) - { - printf("Expected an image number instead of %s.\n", argv[arg]); - ubb_close(0); - return 1; - } - - image_number = atoi(argv[arg]); - - if (image_number > MAX_IMAGE) - { - printf("Image number cannot be greater than %d.\n", MAX_IMAGE); - ubb_close(0); - return 1; - } - - /* If just specifying the current image, start the next iteration - expecting an image to replace the current image. */ - - if (have_image) - { - current_image = (uint8_t *) &image_data[image_number][0][0]; - printf("Set current image as %d.\n", image_number); - continue; - } - - /* Otherwise, choose the replacement image. */ - - else - { - next_image = (uint8_t *) &image_data[image_number][0][0]; - printf("Set next image as %d.\n", image_number); - } - } - - /* To blank the screen choose the blank image as the next image. */ - - else - { - next_image = (uint8_t*) &blank_image[0][0]; - printf("Set blank image.\n"); - } - - /* Call epd_DisplayImg with the new image and current image. */ - - epd_DisplayImg(DISPLAY_IN_USE, next_image, current_image); - printf("Updated image.\n"); - - current_image = next_image; - } - - /* Detach from the board. */ - - printf("Closing...\n"); - ubb_close(0); - - return 0; -}