1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/spin.c Fri Nov 22 22:13:07 2013 +0000
1.3 @@ -0,0 +1,84 @@
1.4 +/*
1.5 + * A demonstration of area filling using different orientations.
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 +
1.21 +/**
1.22 + * Handle termination of the process.
1.23 + */
1.24 +void shutdown(int signum)
1.25 +{
1.26 + printf("Closing...\n");
1.27 + ubb_close(0);
1.28 + exit(1);
1.29 +}
1.30 +
1.31 +/**
1.32 + * Show a pattern on the screen.
1.33 + */
1.34 +void pattern()
1.35 +{
1.36 + LCD_area(0, 0, 131, 131, 0x000);
1.37 + LCD_area(21, 21, 35, 65, 0xf800); LCD_area(21, 66, 35, 110, 0xfbe0);
1.38 + LCD_area(36, 21, 50, 65, 0xffe0); LCD_area(36, 66, 50, 110, 0x7fe0);
1.39 + LCD_area(51, 21, 65, 65, 0x07e0); LCD_area(51, 66, 65, 110, 0x07ef);
1.40 + LCD_area(66, 21, 80, 65, 0x07ff); LCD_area(66, 66, 80, 110, 0x0bff);
1.41 + LCD_area(81, 21, 95, 65, 0x001f); LCD_area(81, 66, 95, 110, 0x781f);
1.42 + LCD_area(96, 21, 110, 65, 0xf81f); LCD_area(96, 66, 110, 110, 0xf80f);
1.43 +}
1.44 +
1.45 +uint8_t states[] = {LCD_MADCTL_MY_MX, LCD_MADCTL_MY_V, 0, LCD_MADCTL_MX_V};
1.46 +
1.47 +int main(int argc, char *argv[])
1.48 +{
1.49 + uint8_t state = 1, times = 10;
1.50 +
1.51 + signal(SIGINT, shutdown);
1.52 +
1.53 + /* Access the 8:10 port. */
1.54 +
1.55 + if (ubb_open(0) < 0) {
1.56 + perror("ubb_open");
1.57 + return 1;
1.58 + }
1.59 +
1.60 + ubb_power(1);
1.61 + printf("Power on.\n");
1.62 +
1.63 + spi_init();
1.64 + LCD_init();
1.65 +
1.66 + printf("Updating...\n");
1.67 + pattern();
1.68 +
1.69 + while (times--)
1.70 + {
1.71 + sleep(1);
1.72 + printf("Updating...\n");
1.73 +
1.74 + LCD_send(LCD_COMMAND, LCD_MADCTL);
1.75 + LCD_send(LCD_DATA, states[state]);
1.76 + pattern();
1.77 +
1.78 + state = (state + 1) % 4;
1.79 + }
1.80 +
1.81 + printf("Closing...\n");
1.82 + ubb_close(0);
1.83 + return 0;
1.84 +}
1.85 +
1.86 +/* vim: tabstop=4 expandtab shiftwidth=4
1.87 + */