Rev 36 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
35 | jlesech | 1 | /**************************************************************************//** |
2 | * \brief Deuligne library - Demonstration program |
||
3 | * \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com |
||
4 | * \version 1.0 |
||
5 | * \date 20121026 |
||
6 | * |
||
7 | * This file is part of the iDreamMicro library. |
||
8 | * |
||
9 | * This library is free software: you can redistribute it and/or modify it under |
||
10 | * the terms of the GNU Lesser General Public License as published by the Free |
||
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
||
12 | * later version. |
||
13 | * |
||
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
||
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
16 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
||
17 | * details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU Lesser General Public License |
||
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
||
21 | ******************************************************************************/ |
||
22 | |||
23 | /**************************************************************************//** |
||
24 | * \file deuligne__demo.c |
||
25 | ******************************************************************************/ |
||
26 | |||
27 | /****************************************************************************** |
||
28 | * Header file inclusions. |
||
29 | ******************************************************************************/ |
||
30 | |||
31 | #include <deuligne/deuligne.h> |
||
36 | jlesech | 32 | #include <mcp23008/mcp23008.h> |
33 | #include <twi/twi.h> |
||
35 | jlesech | 34 | |
35 | #include <util/delay.h> |
||
36 | |||
37 | #include <stdio.h> |
||
38 | |||
39 | /****************************************************************************** |
||
57 | jlesech | 40 | * Private constant definitions. |
41 | ******************************************************************************/ |
||
42 | |||
43 | static const char* strings[] = |
||
44 | { |
||
45 | [DEULIGNE__KEY__RIGHT] = "Right Key OK ", |
||
46 | [DEULIGNE__KEY__UP] = "Up Key OK ", |
||
47 | [DEULIGNE__KEY__DOWN] = "Down Key OK ", |
||
48 | [DEULIGNE__KEY__LEFT] = "Left Key OK ", |
||
49 | [DEULIGNE__KEY__SELECT] = "Select Key OK" |
||
50 | }; |
||
51 | |||
52 | /****************************************************************************** |
||
35 | jlesech | 53 | * Public function definitions. |
54 | ******************************************************************************/ |
||
55 | |||
56 | /**************************************************************************//** |
||
57 | * \fn int main(void) |
||
58 | * |
||
59 | * \brief Main function. |
||
60 | ******************************************************************************/ |
||
61 | int |
||
62 | main |
||
63 | ( |
||
64 | void |
||
65 | ){ |
||
36 | jlesech | 66 | // Initialize TWI. |
67 | twi__initialize(MCP23008__CLOCK_RATE); |
||
68 | |||
35 | jlesech | 69 | // Initialize Deuligne and configure display. |
70 | deuligne__initialize(); |
||
71 | deuligne__set_display(true, false, false); |
||
72 | |||
73 | // Switch on backlight. |
||
74 | deuligne__switch_on_backlight(); |
||
75 | |||
57 | jlesech | 76 | deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_1, 5); |
77 | deuligne__write_string("Setup"); |
||
78 | deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 7); |
||
79 | deuligne__write_string("ok"); |
||
80 | _delay_ms(2000); |
||
35 | jlesech | 81 | |
57 | jlesech | 82 | deuligne__clear_display(); |
83 | deuligne__write_string("Move Joystick"); |
||
84 | |||
35 | jlesech | 85 | // Infinite loop. |
86 | for(;;) |
||
87 | { |
||
88 | // Get key. |
||
89 | deuligne__key_t key = deuligne__get_key(); |
||
57 | jlesech | 90 | if (key != DEULIGNE__KEY__NONE) |
35 | jlesech | 91 | { |
57 | jlesech | 92 | // Set cursor position. |
93 | deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0); |
||
35 | jlesech | 94 | |
57 | jlesech | 95 | // Write string. |
96 | deuligne__write_string(strings[key]); |
||
35 | jlesech | 97 | } |
98 | |||
99 | _delay_ms(250); |
||
100 | } |
||
101 | |||
102 | return 0; |
||
103 | } |