Subversion Repositories idreammicro-avr

Rev

Rev 36 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/**************************************************************************//**
 * \brief Deuligne library - Demonstration program
 * \author Copyright (C) 2011  Julien Le Sech - www.idreammicro.com
 * \version 1.0
 * \date 20121026
 *
 * This file is part of the iDreamMicro library.
 *
 * This library is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 ******************************************************************************/


/**************************************************************************//**
 * \file deuligne__demo.c
 ******************************************************************************/


/******************************************************************************
 * Header file inclusions.
 ******************************************************************************/


#include <deuligne/deuligne.h>

#include <util/delay.h>

#include <stdio.h>

/******************************************************************************
 * Public function definitions.
 ******************************************************************************/


/**************************************************************************//**
 * \fn int main(void)
 *
 * \brief Main function.
 ******************************************************************************/

int
main
(
    void
){
    // Initialize Deuligne and configure display.
    deuligne__initialize();
    deuligne__set_display(true, false, false);

    // Switch on backlight.
    deuligne__switch_on_backlight();

    // Say "Hello world!"
    deuligne__write_string("Hello world!");

    // Infinite loop.
    for(;;)
    {
        // Set cursor position.
        deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0);

        // Get key.
        deuligne__key_t key = deuligne__get_key();

        // Display key.
        switch (key)
        {
            case DEULIGNE__KEY__UP:
                deuligne__write_string("Up    ");
                break;

            case DEULIGNE__KEY__DOWN:
                deuligne__write_string("Down  ");
                break;

            case DEULIGNE__KEY__LEFT:
                deuligne__write_string("Left  ");
                break;

            case DEULIGNE__KEY__RIGHT:
                deuligne__write_string("Right ");
                break;

            case DEULIGNE__KEY__SELECT:
                deuligne__write_string("Select");
                break;

            case DEULIGNE__KEY__NONE:
                deuligne__write_string("None  ");
                break;
        }

        _delay_ms(250);
    }

    return 0;
}