Subversion Repositories svn.mios32

Rev

Rev 1919 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
701 tk 1
// $Id: app.c 1920 2014-01-08 19:29:35Z 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
{
1920 tk 67
  // PWM modulate the status LED (this is a sign of life)
68
  u32 timestamp = MIOS32_TIMESTAMP_Get();
69
  MIOS32_BOARD_LED_Set(1, (timestamp % 20) <= ((timestamp / 100) % 10));
1919 tk 70
}
71
 
72
 
73
/////////////////////////////////////////////////////////////////////////////
74
// This hook is called each mS from the MIDI task which checks for incoming
75
// MIDI events. You could add more MIDI related jobs here, but they shouldn't
76
// consume more than 300 uS to ensure the responsiveness of incoming MIDI.
77
/////////////////////////////////////////////////////////////////////////////
78
void APP_MIDI_Tick(void)
79
{
80
}
81
 
82
 
83
/////////////////////////////////////////////////////////////////////////////
701 tk 84
// This hook is called when a MIDI package has been received
85
/////////////////////////////////////////////////////////////////////////////
86
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
87
{
88
}
89
 
90
 
91
/////////////////////////////////////////////////////////////////////////////
92
// This hook is called before the shift register chain is scanned
93
/////////////////////////////////////////////////////////////////////////////
94
void APP_SRIO_ServicePrepare(void)
95
{
96
}
97
 
98
 
99
/////////////////////////////////////////////////////////////////////////////
100
// This hook is called after the shift register chain has been scanned
101
/////////////////////////////////////////////////////////////////////////////
102
void APP_SRIO_ServiceFinish(void)
103
{
104
}
105
 
106
 
107
/////////////////////////////////////////////////////////////////////////////
108
// This hook is called when a button has been toggled
109
// pin_value is 1 when button released, and 0 when button pressed
110
/////////////////////////////////////////////////////////////////////////////
111
void APP_DIN_NotifyToggle(u32 pin, u32 pin_value)
112
{
113
}
114
 
115
 
116
/////////////////////////////////////////////////////////////////////////////
117
// This hook is called when an encoder has been moved
118
// incrementer is positive when encoder has been turned clockwise, else
119
// it is negative
120
/////////////////////////////////////////////////////////////////////////////
121
void APP_ENC_NotifyChange(u32 encoder, s32 incrementer)
122
{
123
}
124
 
125
 
126
/////////////////////////////////////////////////////////////////////////////
127
// This hook is called when a pot has been moved
128
/////////////////////////////////////////////////////////////////////////////
129
void APP_AIN_NotifyChange(u32 pin, u32 pin_value)
130
{
131
}