1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/bitmap.c Sun Nov 24 19:01:08 2013 +0000
1.3 @@ -0,0 +1,77 @@
1.4 +/*
1.5 + * A demonstration of bitmap plotting.
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 "pcf8833.h"
1.16 +#include <stdio.h>
1.17 +#include <unistd.h>
1.18 +#include <signal.h>
1.19 +#include <stdlib.h>
1.20 +#include "bitmaps.h"
1.21 +
1.22 +/**
1.23 + * Handle termination of the process.
1.24 + */
1.25 +void shutdown(int signum)
1.26 +{
1.27 + printf("Closing...\n");
1.28 + ubb_close(0);
1.29 + exit(1);
1.30 +}
1.31 +
1.32 +void bitmap(uint8_t image)
1.33 +{
1.34 + LCD_image(0, 0, image_data[image], IMAGE_WIDTH, IMAGE_HEIGHT);
1.35 +}
1.36 +
1.37 +uint8_t states[] = {LCD_MADCTL_MY_MX, LCD_MADCTL_MY_V, 0, LCD_MADCTL_MX_V};
1.38 +
1.39 +int main(int argc, char *argv[])
1.40 +{
1.41 + uint8_t state = 1;
1.42 + uint8_t times;
1.43 + uint8_t current_image = 0;
1.44 +
1.45 + signal(SIGINT, shutdown);
1.46 +
1.47 + /* Access the 8:10 port. */
1.48 +
1.49 + if (ubb_open(0) < 0) {
1.50 + perror("ubb_open");
1.51 + return 1;
1.52 + }
1.53 +
1.54 + ubb_power(1);
1.55 + printf("Power on.\n");
1.56 +
1.57 + spi_init();
1.58 + LCD_init();
1.59 + bitmap(current_image);
1.60 +
1.61 + while (times--)
1.62 + {
1.63 + sleep(1);
1.64 + printf("Updating...\n");
1.65 +
1.66 + LCD_send(LCD_COMMAND, LCD_MADCTL);
1.67 + LCD_send(LCD_DATA, states[state]);
1.68 + bitmap(current_image);
1.69 +
1.70 + state = (state + 1) % 4;
1.71 + current_image = (current_image + 1) % NUMBER_OF_IMAGES;
1.72 + }
1.73 +
1.74 + printf("Closing...\n");
1.75 + ubb_close(0);
1.76 + return 0;
1.77 +}
1.78 +
1.79 +/* vim: tabstop=4 expandtab shiftwidth=4
1.80 + */