Subversion Repositories svn.mios32

Rev

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

Rev Author Line No. Line
704 tk 1
// $Id: app.c 1920 2014-01-08 19:29:35Z tk $
2
/*
3
 * MIOS32 Tutorial #021: Graphical 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
#include <glcd_font.h>
23
 
24
 
25
/////////////////////////////////////////////////////////////////////////////
26
// Local variables
27
/////////////////////////////////////////////////////////////////////////////
28
static u8 modwheel_values[16];
29
 
30
/////////////////////////////////////////////////////////////////////////////
31
// This hook is called after startup to initialize the application
32
/////////////////////////////////////////////////////////////////////////////
33
void APP_Init(void)
34
{
35
  int i;
36
 
37
  // initialize all LEDs
38
  MIOS32_BOARD_LED_Init(0xffffffff);
39
 
40
  // initialize modwheel values for all 16 channels
41
  for(i=0; i<16; ++i)
42
    modwheel_values[i] = 0;
43
}
44
 
45
 
46
/////////////////////////////////////////////////////////////////////////////
47
// This task is running endless in background
48
/////////////////////////////////////////////////////////////////////////////
49
void APP_Background(void)
50
{
51
  // clear LCD
52
  MIOS32_LCD_Clear();
53
 
54
  // endless loop
55
  while( 1 ) {
56
    int i;
57
 
58
    for(i=0; i<16; ++i) {
59
      MIOS32_LCD_GCursorSet(0, i*8);
60
      MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL); // 6x8 font
61
      MIOS32_LCD_PrintFormattedString("%03d ", modwheel_values[i]);
62
 
63
      MIOS32_LCD_FontInit((u8 *)GLCD_FONT_METER_ICONS_H); // memo: 28 icons, 14 used, icon size: 28x8
64
      MIOS32_LCD_PrintChar((14 * modwheel_values[i]) / 128);
65
    }
66
  }
67
}
68
 
69
 
70
/////////////////////////////////////////////////////////////////////////////
1919 tk 71
// This hook is called each mS from the main task which also handles DIN, ENC
72
// and AIN events. You could add more jobs here, but they shouldn't consume
73
// more than 300 uS to ensure the responsiveness of buttons, encoders, pots.
74
// Alternatively you could create a dedicated task for application specific
75
// jobs as explained in $MIOS32_PATH/apps/tutorials/006_rtos_tasks
76
/////////////////////////////////////////////////////////////////////////////
77
void APP_Tick(void)
78
{
1920 tk 79
  // PWM modulate the status LED (this is a sign of life)
80
  u32 timestamp = MIOS32_TIMESTAMP_Get();
81
  MIOS32_BOARD_LED_Set(1, (timestamp % 20) <= ((timestamp / 100) % 10));
1919 tk 82
}
83
 
84
 
85
/////////////////////////////////////////////////////////////////////////////
86
// This hook is called each mS from the MIDI task which checks for incoming
87
// MIDI events. You could add more MIDI related jobs here, but they shouldn't
88
// consume more than 300 uS to ensure the responsiveness of incoming MIDI.
89
/////////////////////////////////////////////////////////////////////////////
90
void APP_MIDI_Tick(void)
91
{
92
}
93
 
94
 
95
/////////////////////////////////////////////////////////////////////////////
704 tk 96
// This hook is called when a MIDI package has been received
97
/////////////////////////////////////////////////////////////////////////////
98
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
99
{
100
  // store incoming ModWheel values
101
  if( midi_package.type == CC && midi_package.cc_number == 1 )
102
    modwheel_values[midi_package.chn] = midi_package.value;
103
}
104
 
105
 
106
/////////////////////////////////////////////////////////////////////////////
107
// This hook is called before the shift register chain is scanned
108
/////////////////////////////////////////////////////////////////////////////
109
void APP_SRIO_ServicePrepare(void)
110
{
111
}
112
 
113
 
114
/////////////////////////////////////////////////////////////////////////////
115
// This hook is called after the shift register chain has been scanned
116
/////////////////////////////////////////////////////////////////////////////
117
void APP_SRIO_ServiceFinish(void)
118
{
119
}
120
 
121
 
122
/////////////////////////////////////////////////////////////////////////////
123
// This hook is called when a button has been toggled
124
// pin_value is 1 when button released, and 0 when button pressed
125
/////////////////////////////////////////////////////////////////////////////
126
void APP_DIN_NotifyToggle(u32 pin, u32 pin_value)
127
{
128
}
129
 
130
 
131
/////////////////////////////////////////////////////////////////////////////
132
// This hook is called when an encoder has been moved
133
// incrementer is positive when encoder has been turned clockwise, else
134
// it is negative
135
/////////////////////////////////////////////////////////////////////////////
136
void APP_ENC_NotifyChange(u32 encoder, s32 incrementer)
137
{
138
}
139
 
140
 
141
/////////////////////////////////////////////////////////////////////////////
142
// This hook is called when a pot has been moved
143
/////////////////////////////////////////////////////////////////////////////
144
void APP_AIN_NotifyChange(u32 pin, u32 pin_value)
145
{
146
}