1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test.c Sun May 19 21:18:16 2013 +0000
1.3 @@ -0,0 +1,71 @@
1.4 +/*
1.5 + * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication.
1.6 + *
1.7 + * Copyright (C) 2013 Paul Boddie
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or modify
1.10 + * it under the terms of the GNU General Public License as published by
1.11 + * the Free Software Foundation; either version 2 of the License, or
1.12 + * (at your option) any later version.
1.13 + */
1.14 +
1.15 +#include <ubb/ubb.h>
1.16 +#include <stdio.h>
1.17 +#include <stdlib.h>
1.18 +#include <string.h>
1.19 +#include <signal.h>
1.20 +#include "logo.h"
1.21 +#include "Display_Controller.h"
1.22 +#include "bsp.h"
1.23 +
1.24 +/**
1.25 + * Handle termination of the process.
1.26 + */
1.27 +void shutdown(int signum)
1.28 +{
1.29 + printf("Closing...\n");
1.30 + ubb_close(0);
1.31 + exit(1);
1.32 +}
1.33 +
1.34 +/* Main program and basic initialisation. */
1.35 +
1.36 +int main(int argc, char *argv[])
1.37 +{
1.38 + uint8_t *current_image, blank_image[176][33];
1.39 +
1.40 + signal(SIGINT, &shutdown);
1.41 +
1.42 + if (ubb_open(0) < 0) {
1.43 + perror("ubb_open");
1.44 + return 1;
1.45 + }
1.46 +
1.47 + ubb_power(1);
1.48 + printf("Power on.\n");
1.49 +
1.50 + /* Need to initialise the board. */
1.51 +
1.52 + bsp_init();
1.53 + printf("Initialised.\n");
1.54 +
1.55 + /* Initialise an array containing the current image. */
1.56 +
1.57 + memset((uint8_t*) &blank_image[0][0], 0xff, 176*33);
1.58 + current_image = (uint8_t*) &blank_image[0][0];
1.59 + printf("Set blank image.\n");
1.60 +
1.61 + /* Call epd_DisplayImg with the new image and current image. */
1.62 +
1.63 + epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[0][0][0], current_image);
1.64 + printf("Updated image.\n");
1.65 +
1.66 + /* Set the current image to the new image. */
1.67 +
1.68 + current_image = &image_data[0][0][0];
1.69 +
1.70 + printf("Closing...\n");
1.71 + ubb_close(0);
1.72 +
1.73 + return 0;
1.74 +}