Subversion Repositories svn.mios32

Rev

Rev 701 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
701 tk 1
// $Id: app.c 1919 2014-01-08 19:13:48Z 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
    // print system time
44
    MIOS32_LCD_CursorSet(0, 0); // X, Y
45
    MIOS32_LCD_PrintFormattedString("System Time");
46
 
47
    MIOS32_LCD_CursorSet(0, 1); // X, Y
48
    mios32_sys_time_t t = MIOS32_SYS_TimeGet();
49
    int hours = t.seconds / 3600;
50
    int minutes = (t.seconds % 3600) / 60;
51
    int seconds = (t.seconds % 3600) % 60;
52
    int milliseconds = t.fraction_ms;
53
    MIOS32_LCD_PrintFormattedString("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds);
54
  }
55
}
56
 
57
 
58
/////////////////////////////////////////////////////////////////////////////
1919 tk 59
// This hook is called each mS from the main task which also handles DIN, ENC
60
// and AIN events. You could add more jobs here, but they shouldn't consume
61
// more than 300 uS to ensure the responsiveness of buttons, encoders, pots.
62
// Alternatively you could create a dedicated task for application specific
63
// jobs as explained in $MIOS32_PATH/apps/tutorials/006_rtos_tasks
64
/////////////////////////////////////////////////////////////////////////////
65
void APP_Tick(void)
66
{
67
  // toggle the state of all LEDs (this is a sign of life)
68
  MIOS32_BOARD_LED_Set(0x0001, ~MIOS32_BOARD_LED_Get());
69
}
70
 
71
 
72
/////////////////////////////////////////////////////////////////////////////
73
// This hook is called each mS from the MIDI task which checks for incoming
74
// MIDI events. You could add more MIDI related jobs here, but they shouldn't
75
// consume more than 300 uS to ensure the responsiveness of incoming MIDI.
76
/////////////////////////////////////////////////////////////////////////////
77
void APP_MIDI_Tick(void)
78
{
79
}
80
 
81
 
82
/////////////////////////////////////////////////////////////////////////////
701 tk 83
// This hook is called when a MIDI package has been received
84
/////////////////////////////////////////////////////////////////////////////
85
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
86
{
87
}
88
 
89
 
90
/////////////////////////////////////////////////////////////////////////////
91
// This hook is called before the shift register chain is scanned
92
/////////////////////////////////////////////////////////////////////////////
93
void APP_SRIO_ServicePrepare(void)
94
{
95
}
96
 
97
 
98
/////////////////////////////////////////////////////////////////////////////
99
// This hook is called after the shift register chain has been scanned
100
/////////////////////////////////////////////////////////////////////////////
101
void APP_SRIO_ServiceFinish(void)
102
{
103
}
104
 
105
 
106
/////////////////////////////////////////////////////////////////////////////
107
// This hook is called when a button has been toggled
108
// pin_value is 1 when button released, and 0 when button pressed
109
/////////////////////////////////////////////////////////////////////////////
110
void APP_DIN_NotifyToggle(u32 pin, u32 pin_value)
111
{
112
}
113
 
114
 
115
/////////////////////////////////////////////////////////////////////////////
116
// This hook is called when an encoder has been moved
117
// incrementer is positive when encoder has been turned clockwise, else
118
// it is negative
119
/////////////////////////////////////////////////////////////////////////////
120
void APP_ENC_NotifyChange(u32 encoder, s32 incrementer)
121
{
122
}
123
 
124
 
125
/////////////////////////////////////////////////////////////////////////////
126
// This hook is called when a pot has been moved
127
/////////////////////////////////////////////////////////////////////////////
128
void APP_AIN_NotifyChange(u32 pin, u32 pin_value)
129
{
130
}