1.1 --- a/Makefile Mon May 27 22:10:53 2013 +0000
1.2 +++ b/Makefile Mon May 27 22:33:28 2013 +0000
1.3 @@ -25,8 +25,8 @@
1.4 CFLAGS = -g -Wall -fPIC -march=mips32 -I$(LIBUBB)/include -DNANONOTE # -DDISPLAY_IN_USE=EPD_TYPE_270 # -DDEBUG=1
1.5 LDFLAGS = -lubb -L$(LIBUBB) #-static #-L$(SYSLIBS)
1.6
1.7 -TARGET = test
1.8 -SRC = test.c bsp.c Display_COG_Process.c Display_Controller.c Display_Hardware_Driver.c images.c
1.9 +TARGET = epaper
1.10 +SRC = epaper.c bsp.c Display_COG_Process.c Display_Controller.c Display_Hardware_Driver.c images.c
1.11 OBJ = $(SRC:.c=.o)
1.12
1.13 .PHONY: all clean distclean
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/epaper.c Mon May 27 22:33:28 2013 +0000
2.3 @@ -0,0 +1,177 @@
2.4 +/*
2.5 + * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication.
2.6 + *
2.7 + * Copyright (C) 2013 Paul Boddie
2.8 + *
2.9 + * This program is free software; you can redistribute it and/or modify it under
2.10 + * the terms of the GNU General Public License as published by the Free Software
2.11 + * Foundation; either version 3 of the License, or (at your option) any later
2.12 + * version.
2.13 + *
2.14 + * This program is distributed in the hope that it will be useful, but WITHOUT
2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2.16 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2.17 + * details.
2.18 + *
2.19 + * You should have received a copy of the GNU General Public License along with
2.20 + * this program. If not, see <http://www.gnu.org/licenses/>.
2.21 + */
2.22 +
2.23 +#include <ubb/ubb.h>
2.24 +#include <stdio.h>
2.25 +#include <stdlib.h>
2.26 +#include <string.h>
2.27 +#include <ctype.h>
2.28 +#include <signal.h>
2.29 +#include <unistd.h>
2.30 +#include "images.h"
2.31 +#include "Display_Controller.h"
2.32 +#include "bsp.h"
2.33 +
2.34 +typedef enum {
2.35 + FALSE=0,
2.36 + TRUE=1
2.37 +} bool;
2.38 +
2.39 +/**
2.40 + * Handle termination of the process.
2.41 + */
2.42 +void shutdown(int signum)
2.43 +{
2.44 + printf("Closing...\n");
2.45 + ubb_close(0);
2.46 + exit(1);
2.47 +}
2.48 +
2.49 +/* Main program and basic initialisation. */
2.50 +
2.51 +int main(int argc, char *argv[])
2.52 +{
2.53 + uint8_t *current_image, *next_image, blank_image[176][33], image_number, arg;
2.54 + bool blank_screen, have_image;
2.55 + int delay;
2.56 +
2.57 + signal(SIGINT, &shutdown);
2.58 +
2.59 + if (ubb_open(0) < 0) {
2.60 + perror("ubb_open");
2.61 + return 1;
2.62 + }
2.63 +
2.64 + ubb_power(1);
2.65 + printf("Power on.\n");
2.66 +
2.67 + /* Need to initialise the board. */
2.68 +
2.69 + bsp_init();
2.70 + printf("Initialised.\n");
2.71 +
2.72 + /* Initialise an array containing the blank image. */
2.73 +
2.74 + memset((uint8_t*) &blank_image[0][0], 0xff, 176*33);
2.75 +
2.76 + /* Determine whether to blank the screen or leave an image on it. */
2.77 +
2.78 + if (argc < 2)
2.79 + {
2.80 + printf("Usage: %s ( --have <image number> | --blank | <image number> | --wait <delay in seconds>)...\n", argv[0]);
2.81 + ubb_close(0);
2.82 + return 1;
2.83 + }
2.84 +
2.85 + /* Assume a blank screen by default. */
2.86 +
2.87 + current_image = (uint8_t*) &blank_image[0][0];
2.88 +
2.89 + for (arg = 1; arg < argc; arg ++)
2.90 + {
2.91 + /* Wait for a specified delay. */
2.92 +
2.93 + if (strcmp(argv[arg], "--wait") == 0)
2.94 + {
2.95 + arg++;
2.96 +
2.97 + if (!isdigit(argv[arg][0]))
2.98 + {
2.99 + printf("Expected an delay in seconds instead of %s.\n", argv[arg]);
2.100 + ubb_close(0);
2.101 + return 1;
2.102 + }
2.103 +
2.104 + delay = atoi(argv[arg]);
2.105 + printf("Waiting for %d seconds...\n", delay);
2.106 + sleep(delay);
2.107 + continue;
2.108 + }
2.109 +
2.110 + /* Indicate an image presumably on screen already. */
2.111 +
2.112 + have_image = strcmp(argv[arg], "--have") == 0;
2.113 + blank_screen = strcmp(argv[arg], "--blank") == 0;
2.114 +
2.115 + if (have_image)
2.116 + arg++;
2.117 +
2.118 + /* If a blank screen operation is not requested, find the image
2.119 + specified. */
2.120 +
2.121 + if (!blank_screen)
2.122 + {
2.123 + if (!isdigit(argv[arg][0]))
2.124 + {
2.125 + printf("Expected an image number instead of %s.\n", argv[arg]);
2.126 + ubb_close(0);
2.127 + return 1;
2.128 + }
2.129 +
2.130 + image_number = atoi(argv[arg]);
2.131 +
2.132 + if (image_number > MAX_IMAGE)
2.133 + {
2.134 + printf("Image number cannot be greater than %d.\n", MAX_IMAGE);
2.135 + ubb_close(0);
2.136 + return 1;
2.137 + }
2.138 +
2.139 + /* If just specifying the current image, start the next iteration
2.140 + expecting an image to replace the current image. */
2.141 +
2.142 + if (have_image)
2.143 + {
2.144 + current_image = (uint8_t *) &image_data[image_number][0][0];
2.145 + printf("Set current image as %d.\n", image_number);
2.146 + continue;
2.147 + }
2.148 +
2.149 + /* Otherwise, choose the replacement image. */
2.150 +
2.151 + else
2.152 + {
2.153 + next_image = (uint8_t *) &image_data[image_number][0][0];
2.154 + printf("Set next image as %d.\n", image_number);
2.155 + }
2.156 + }
2.157 +
2.158 + /* To blank the screen choose the blank image as the next image. */
2.159 +
2.160 + else
2.161 + {
2.162 + next_image = (uint8_t*) &blank_image[0][0];
2.163 + printf("Set blank image.\n");
2.164 + }
2.165 +
2.166 + /* Call epd_DisplayImg with the new image and current image. */
2.167 +
2.168 + epd_DisplayImg(DISPLAY_IN_USE, next_image, current_image);
2.169 + printf("Updated image.\n");
2.170 +
2.171 + current_image = next_image;
2.172 + }
2.173 +
2.174 + /* Detach from the board. */
2.175 +
2.176 + printf("Closing...\n");
2.177 + ubb_close(0);
2.178 +
2.179 + return 0;
2.180 +}
3.1 --- a/test.c Mon May 27 22:10:53 2013 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,177 +0,0 @@
3.4 -/*
3.5 - * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication.
3.6 - *
3.7 - * Copyright (C) 2013 Paul Boddie
3.8 - *
3.9 - * This program is free software; you can redistribute it and/or modify it under
3.10 - * the terms of the GNU General Public License as published by the Free Software
3.11 - * Foundation; either version 3 of the License, or (at your option) any later
3.12 - * version.
3.13 - *
3.14 - * This program is distributed in the hope that it will be useful, but WITHOUT
3.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3.16 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3.17 - * details.
3.18 - *
3.19 - * You should have received a copy of the GNU General Public License along with
3.20 - * this program. If not, see <http://www.gnu.org/licenses/>.
3.21 - */
3.22 -
3.23 -#include <ubb/ubb.h>
3.24 -#include <stdio.h>
3.25 -#include <stdlib.h>
3.26 -#include <string.h>
3.27 -#include <ctype.h>
3.28 -#include <signal.h>
3.29 -#include <unistd.h>
3.30 -#include "images.h"
3.31 -#include "Display_Controller.h"
3.32 -#include "bsp.h"
3.33 -
3.34 -typedef enum {
3.35 - FALSE=0,
3.36 - TRUE=1
3.37 -} bool;
3.38 -
3.39 -/**
3.40 - * Handle termination of the process.
3.41 - */
3.42 -void shutdown(int signum)
3.43 -{
3.44 - printf("Closing...\n");
3.45 - ubb_close(0);
3.46 - exit(1);
3.47 -}
3.48 -
3.49 -/* Main program and basic initialisation. */
3.50 -
3.51 -int main(int argc, char *argv[])
3.52 -{
3.53 - uint8_t *current_image, *next_image, blank_image[176][33], image_number, arg;
3.54 - bool blank_screen, have_image;
3.55 - int delay;
3.56 -
3.57 - signal(SIGINT, &shutdown);
3.58 -
3.59 - if (ubb_open(0) < 0) {
3.60 - perror("ubb_open");
3.61 - return 1;
3.62 - }
3.63 -
3.64 - ubb_power(1);
3.65 - printf("Power on.\n");
3.66 -
3.67 - /* Need to initialise the board. */
3.68 -
3.69 - bsp_init();
3.70 - printf("Initialised.\n");
3.71 -
3.72 - /* Initialise an array containing the blank image. */
3.73 -
3.74 - memset((uint8_t*) &blank_image[0][0], 0xff, 176*33);
3.75 -
3.76 - /* Determine whether to blank the screen or leave an image on it. */
3.77 -
3.78 - if (argc < 2)
3.79 - {
3.80 - printf("Usage: %s ( --have <image number> | --blank | <image number> | --wait <delay in seconds>)...\n", argv[0]);
3.81 - ubb_close(0);
3.82 - return 1;
3.83 - }
3.84 -
3.85 - /* Assume a blank screen by default. */
3.86 -
3.87 - current_image = (uint8_t*) &blank_image[0][0];
3.88 -
3.89 - for (arg = 1; arg < argc; arg ++)
3.90 - {
3.91 - /* Wait for a specified delay. */
3.92 -
3.93 - if (strcmp(argv[arg], "--wait") == 0)
3.94 - {
3.95 - arg++;
3.96 -
3.97 - if (!isdigit(argv[arg][0]))
3.98 - {
3.99 - printf("Expected an delay in seconds instead of %s.\n", argv[arg]);
3.100 - ubb_close(0);
3.101 - return 1;
3.102 - }
3.103 -
3.104 - delay = atoi(argv[arg]);
3.105 - printf("Waiting for %d seconds...\n", delay);
3.106 - sleep(delay);
3.107 - continue;
3.108 - }
3.109 -
3.110 - /* Indicate an image presumably on screen already. */
3.111 -
3.112 - have_image = strcmp(argv[arg], "--have") == 0;
3.113 - blank_screen = strcmp(argv[arg], "--blank") == 0;
3.114 -
3.115 - if (have_image)
3.116 - arg++;
3.117 -
3.118 - /* If a blank screen operation is not requested, find the image
3.119 - specified. */
3.120 -
3.121 - if (!blank_screen)
3.122 - {
3.123 - if (!isdigit(argv[arg][0]))
3.124 - {
3.125 - printf("Expected an image number instead of %s.\n", argv[arg]);
3.126 - ubb_close(0);
3.127 - return 1;
3.128 - }
3.129 -
3.130 - image_number = atoi(argv[arg]);
3.131 -
3.132 - if (image_number > MAX_IMAGE)
3.133 - {
3.134 - printf("Image number cannot be greater than %d.\n", MAX_IMAGE);
3.135 - ubb_close(0);
3.136 - return 1;
3.137 - }
3.138 -
3.139 - /* If just specifying the current image, start the next iteration
3.140 - expecting an image to replace the current image. */
3.141 -
3.142 - if (have_image)
3.143 - {
3.144 - current_image = (uint8_t *) &image_data[image_number][0][0];
3.145 - printf("Set current image as %d.\n", image_number);
3.146 - continue;
3.147 - }
3.148 -
3.149 - /* Otherwise, choose the replacement image. */
3.150 -
3.151 - else
3.152 - {
3.153 - next_image = (uint8_t *) &image_data[image_number][0][0];
3.154 - printf("Set next image as %d.\n", image_number);
3.155 - }
3.156 - }
3.157 -
3.158 - /* To blank the screen choose the blank image as the next image. */
3.159 -
3.160 - else
3.161 - {
3.162 - next_image = (uint8_t*) &blank_image[0][0];
3.163 - printf("Set blank image.\n");
3.164 - }
3.165 -
3.166 - /* Call epd_DisplayImg with the new image and current image. */
3.167 -
3.168 - epd_DisplayImg(DISPLAY_IN_USE, next_image, current_image);
3.169 - printf("Updated image.\n");
3.170 -
3.171 - current_image = next_image;
3.172 - }
3.173 -
3.174 - /* Detach from the board. */
3.175 -
3.176 - printf("Closing...\n");
3.177 - ubb_close(0);
3.178 -
3.179 - return 0;
3.180 -}