| 37,19 → 37,6 |
| #include <stdio.h> |
| |
| /****************************************************************************** |
| * Private constant definitions. |
| ******************************************************************************/ |
| |
| static const char* strings[] = |
| { |
| [DEULIGNE__KEY__RIGHT] = "Right Key OK ", |
| [DEULIGNE__KEY__UP] = "Up Key OK ", |
| [DEULIGNE__KEY__DOWN] = "Down Key OK ", |
| [DEULIGNE__KEY__LEFT] = "Left Key OK ", |
| [DEULIGNE__KEY__SELECT] = "Select Key OK" |
| }; |
| |
| /****************************************************************************** |
| * Public function definitions. |
| ******************************************************************************/ |
| |
| 73,27 → 60,44 |
| // Switch on backlight. |
| deuligne__switch_on_backlight(); |
| |
| deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_1, 5); |
| deuligne__write_string("Setup"); |
| deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 7); |
| deuligne__write_string("ok"); |
| _delay_ms(2000); |
| // Say "Hello world!" |
| deuligne__write_string("Hello world!"); |
| |
| deuligne__clear_display(); |
| deuligne__write_string("Move Joystick"); |
| |
| // Infinite loop. |
| for(;;) |
| { |
| // Set cursor position. |
| deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0); |
| |
| // Get key. |
| deuligne__key_t key = deuligne__get_key(); |
| if (key != DEULIGNE__KEY__NONE) |
| |
| // Display key. |
| switch (key) |
| { |
| // Set cursor position. |
| deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0); |
| case DEULIGNE__KEY__UP: |
| deuligne__write_string("Up "); |
| break; |
| |
| // Write string. |
| deuligne__write_string(strings[key]); |
| 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); |