Subversion Repositories svn.mios32

Rev

Rev 1919 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
701 tk 1
// $Id: app.c 701 2009-08-10 22:33:13Z tk $
2
/*
3
 * MIOS32 Tutorial #020: LCD Output
4
 * see README.txt for details
5
 *
6
 * ==========================================================================
7
 *
8
 *  Copyright (C) 2009 Thorsten Klose (tk@midibox.org)
9
 *  Licensed for personal non-commercial use only.
10
 *  All other rights reserved.
11
 *
12
 * ==========================================================================
13
 */
14
 
15
/////////////////////////////////////////////////////////////////////////////
16
// Include files
17
/////////////////////////////////////////////////////////////////////////////
18
 
19
#include <mios32.h>
20
#include "app.h"
21
 
22
 
23
/////////////////////////////////////////////////////////////////////////////
24
// This hook is called after startup to initialize the application
25
/////////////////////////////////////////////////////////////////////////////
26
void APP_Init(void)
27
{
28
  // initialize all LEDs
29
  MIOS32_BOARD_LED_Init(0xffffffff);
30
}
31
 
32
 
33
/////////////////////////////////////////////////////////////////////////////
34
// This task is running endless in background
35
/////////////////////////////////////////////////////////////////////////////
36
void APP_Background(void)
37
{
38
  // clear LCD
39
  MIOS32_LCD_Clear();
40
 
41
  // endless loop
42
  while( 1 ) {
43
    // toggle Status LED on each call of this function
44
    MIOS32_BOARD_LED_Set(1, ~MIOS32_BOARD_LED_Get());
45
 
46
    // print system time
47
    MIOS32_LCD_CursorSet(0, 0); // X, Y
48
    MIOS32_LCD_PrintFormattedString("System Time");
49
 
50
    MIOS32_LCD_CursorSet(0, 1); // X, Y
51
    mios32_sys_time_t t = MIOS32_SYS_TimeGet();
52
    int hours = t.seconds / 3600;
53
    int minutes = (t.seconds % 3600) / 60;
54
    int seconds = (t.seconds % 3600) % 60;
55
    int milliseconds = t.fraction_ms;
56
    MIOS32_LCD_PrintFormattedString("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds);
57
  }
58
}
59
 
60
 
61
/////////////////////////////////////////////////////////////////////////////
62
// This hook is called when a MIDI package has been received
63
/////////////////////////////////////////////////////////////////////////////
64
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
65
{
66
}
67
 
68
 
69
/////////////////////////////////////////////////////////////////////////////
70
// This hook is called before the shift register chain is scanned
71
/////////////////////////////////////////////////////////////////////////////
72
void APP_SRIO_ServicePrepare(void)
73
{
74
}
75
 
76
 
77
/////////////////////////////////////////////////////////////////////////////
78
// This hook is called after the shift register chain has been scanned
79
/////////////////////////////////////////////////////////////////////////////
80
void APP_SRIO_ServiceFinish(void)
81
{
82
}
83
 
84
 
85
/////////////////////////////////////////////////////////////////////////////
86
// This hook is called when a button has been toggled
87
// pin_value is 1 when button released, and 0 when button pressed
88
/////////////////////////////////////////////////////////////////////////////
89
void APP_DIN_NotifyToggle(u32 pin, u32 pin_value)
90
{
91
}
92
 
93
 
94
/////////////////////////////////////////////////////////////////////////////
95
// This hook is called when an encoder has been moved
96
// incrementer is positive when encoder has been turned clockwise, else
97
// it is negative
98
/////////////////////////////////////////////////////////////////////////////
99
void APP_ENC_NotifyChange(u32 encoder, s32 incrementer)
100
{
101
}
102
 
103
 
104
/////////////////////////////////////////////////////////////////////////////
105
// This hook is called when a pot has been moved
106
/////////////////////////////////////////////////////////////////////////////
107
void APP_AIN_NotifyChange(u32 pin, u32 pin_value)
108
{
109
}