Subversion Repositories idreammicro-avr

Rev

Rev 35 | Go to most recent revision | 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
/******************************************************************************
40
 * Public function definitions.
41
 ******************************************************************************/
42
 
43
/**************************************************************************//**
44
 * \fn int main(void)
45
 *
46
 * \brief Main function.
47
 ******************************************************************************/
48
int
49
main
50
(
51
    void
52
){
36 jlesech 53
    // Initialize TWI.
54
    twi__initialize(MCP23008__CLOCK_RATE);
55
 
35 jlesech 56
    // Initialize Deuligne and configure display.
57
    deuligne__initialize();
58
    deuligne__set_display(true, false, false);
59
 
60
    // Switch on backlight.
61
    deuligne__switch_on_backlight();
62
 
63
    // Say "Hello world!"
64
    deuligne__write_string("Hello world!");
65
 
66
    // Infinite loop.
67
    for(;;)
68
    {
69
        // Set cursor position.
70
        deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0);
71
 
72
        // Get key.
73
        deuligne__key_t key = deuligne__get_key();
74
 
75
        // Display key.
76
        switch (key)
77
        {
78
            case DEULIGNE__KEY__UP:
79
                deuligne__write_string("Up    ");
80
                break;
81
 
82
            case DEULIGNE__KEY__DOWN:
83
                deuligne__write_string("Down  ");
84
                break;
85
 
86
            case DEULIGNE__KEY__LEFT:
87
                deuligne__write_string("Left  ");
88
                break;
89
 
90
            case DEULIGNE__KEY__RIGHT:
91
                deuligne__write_string("Right ");
92
                break;
93
 
94
            case DEULIGNE__KEY__SELECT:
95
                deuligne__write_string("Select");
96
                break;
97
 
98
            case DEULIGNE__KEY__NONE:
99
                deuligne__write_string("None  ");
100
                break;
101
        }
102
 
103
        _delay_ms(250);
104
    }
105
 
106
    return 0;
107
}