Subversion Repositories svn.mios32

Rev

Rev 2593 | Rev 2595 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2593 Rev 2594
Line 195... Line 195...
195
u32 getClipLengthInTicks(u8 clip)
195
u32 getClipLengthInTicks(u8 clip)
196
{
196
{
197
   return stepToTick(clipSteps_[clip][activeScene_]);
197
   return stepToTick(clipSteps_[clip][activeScene_]);
198
}
198
}
199
// -------------------------------------------------------------------------------------------------
199
// -------------------------------------------------------------------------------------------------
200
-
 
201
200
202
/**
201
/**
203
 * Update a single GP Led, only change state if
202
 * Update a single LED (called from MUTEX_DIGITALOUT protected environment)
-
 
203
 *
204
 */
204
 */
205
void updateGPLed(u8 number, u8 newState)
205
void updateLED(u8 number, u8 newState)
206
{
206
{
207
   static s8 s1 = -1, s2 = -1, s3 = -1, s4 = -1, s5 = -1, s6 = -1;
207
   static u8 ledstate[13];
208
208
209
   switch (number)
209
   switch (number)
210
   {
210
   {
211
      case 1:
211
      case LED_GP1:
212
         if (s1 != newState)
212
         if (newState != ledstate[LED_GP1])
213
         {
213
         {
214
            MIOS32_DOUT_PinSet(LED_GP1, newState);
214
            MIOS32_DOUT_PinSet(HW_LED_RED_GP1, newState & LED_RED);
-
 
215
            MIOS32_DOUT_PinSet(HW_LED_GREEN_GP1, newState & LED_GREEN);
-
 
216
            MIOS32_DOUT_PinSet(HW_LED_BLUE_GP1, newState & LED_BLUE);
215
            s1 = newState;
217
            ledstate[LED_GP1] = newState;
216
         }
218
         }
217
         break;
219
         break;
218
-
 
219
      case 2:
220
      case LED_GP2:
220
         if (s2 != newState)
221
         if (newState != ledstate[LED_GP2])
221
         {
222
         {
222
            MIOS32_DOUT_PinSet(led_gp2, newState);
223
            MIOS32_DOUT_PinSet(HW_LED_RED_GP2, newState & LED_RED);
-
 
224
            MIOS32_DOUT_PinSet(HW_LED_GREEN_GP2, newState & LED_GREEN);
-
 
225
            MIOS32_DOUT_PinSet(HW_LED_BLUE_GP2, newState & LED_BLUE);
223
            s2 = newState;
226
            ledstate[LED_GP2] = newState;
224
         }
227
         }
225
         break;
228
         break;
226
-
 
227
      case 3:
229
      case LED_GP3:
228
         if (s3 != newState)
230
         if (newState != ledstate[LED_GP3])
229
         {
231
         {
230
            MIOS32_DOUT_PinSet(led_gp3, newState);
232
            MIOS32_DOUT_PinSet(HW_LED_RED_GP3, newState & LED_RED);
-
 
233
            MIOS32_DOUT_PinSet(HW_LED_GREEN_GP3, newState & LED_GREEN);
-
 
234
            MIOS32_DOUT_PinSet(HW_LED_BLUE_GP3, newState & LED_BLUE);
231
            s3 = newState;
235
            ledstate[LED_GP3] = newState;
232
         }
236
         }
233
         break;
237
         break;
234
-
 
235
      case 4:
238
      case LED_GP4:
236
         if (s4 != newState)
239
         if (newState != ledstate[LED_GP4])
237
         {
240
         {
238
            MIOS32_DOUT_PinSet(led_gp4, newState);
241
            MIOS32_DOUT_PinSet(HW_LED_RED_GP4, newState & LED_RED);
-
 
242
            MIOS32_DOUT_PinSet(HW_LED_GREEN_GP4, newState & LED_GREEN);
-
 
243
            MIOS32_DOUT_PinSet(HW_LED_BLUE_GP4, newState & LED_BLUE);
239
            s4 = newState;
244
            ledstate[LED_GP4] = newState;
240
         }
245
         }
241
         break;
246
         break;
242
-
 
243
      case 5:
247
      case LED_GP5:
244
         if (s5 != newState)
248
         if (newState != ledstate[LED_GP5])
245
         {
249
         {
246
            MIOS32_DOUT_PinSet(led_gp5, newState);
250
            MIOS32_DOUT_PinSet(HW_LED_RED_GP5, newState & LED_RED);
-
 
251
            MIOS32_DOUT_PinSet(HW_LED_GREEN_GP5, newState & LED_GREEN);
-
 
252
            MIOS32_DOUT_PinSet(HW_LED_BLUE_GP5, newState & LED_BLUE);
247
            s5 = newState;
253
            ledstate[LED_GP5] = newState;
248
         }
254
         }
249
         break;
255
         break;
250
-
 
251
      case 6:
256
      case LED_GP6:
252
         if (s6 != newState)
257
         if (newState != ledstate[LED_GP6])
253
         {
258
         {
254
            MIOS32_DOUT_PinSet(led_gp6, newState);
259
            MIOS32_DOUT_PinSet(HW_LED_RED_GP6, newState & LED_RED);
-
 
260
            MIOS32_DOUT_PinSet(HW_LED_GREEN_GP6, newState & LED_GREEN);
-
 
261
            MIOS32_DOUT_PinSet(HW_LED_BLUE_GP6, newState & LED_BLUE);
255
            s6 = newState;
262
            ledstate[LED_GP6] = newState;
-
 
263
         }
-
 
264
         break;
-
 
265
      case LED_RUNSTOP:
-
 
266
         if (newState != ledstate[LED_RUNSTOP])
-
 
267
         {
-
 
268
            MIOS32_DOUT_PinSet(HW_LED_RED_RUNSTOP, newState & LED_RED);
-
 
269
            MIOS32_DOUT_PinSet(HW_LED_GREEN_RUNSTOP, newState & LED_GREEN);
-
 
270
            MIOS32_DOUT_PinSet(HW_LED_BLUE_RUNSTOP, newState & LED_BLUE);
-
 
271
            ledstate[LED_RUNSTOP] = newState;
-
 
272
         }
-
 
273
         break;
-
 
274
      case LED_ARM:
-
 
275
         if (newState != ledstate[LED_ARM])
-
 
276
         {
-
 
277
            MIOS32_DOUT_PinSet(HW_LED_RED_ARM, newState & LED_RED);
-
 
278
            MIOS32_DOUT_PinSet(HW_LED_GREEN_ARM, newState & LED_GREEN);
-
 
279
            MIOS32_DOUT_PinSet(HW_LED_BLUE_ARM, newState & LED_BLUE);
-
 
280
            ledstate[LED_ARM] = newState;
-
 
281
         }
-
 
282
         break;
-
 
283
      case LED_SHIFT:
-
 
284
         if (newState != ledstate[LED_SHIFT])
-
 
285
         {
-
 
286
            MIOS32_DOUT_PinSet(HW_LED_RED_SHIFT, newState & LED_RED);
-
 
287
            MIOS32_DOUT_PinSet(HW_LED_GREEN_SHIFT, newState & LED_GREEN);
-
 
288
            MIOS32_DOUT_PinSet(HW_LED_BLUE_SHIFT, newState & LED_BLUE);
-
 
289
            ledstate[LED_SHIFT] = newState;
-
 
290
         }
-
 
291
         break;
-
 
292
      case LED_MENU:
-
 
293
         if (newState != ledstate[LED_MENU])
-
 
294
         {
-
 
295
            MIOS32_DOUT_PinSet(HW_LED_RED_MENU, newState & LED_RED);
-
 
296
            MIOS32_DOUT_PinSet(HW_LED_GREEN_MENU, newState & LED_GREEN);
-
 
297
            MIOS32_DOUT_PinSet(HW_LED_BLUE_MENU, newState & LED_BLUE);
-
 
298
            ledstate[LED_MENU] = newState;
-
 
299
         }
-
 
300
         break;
-
 
301
      case LED_COPY:
-
 
302
         if (newState != ledstate[LED_COPY])
-
 
303
         {
-
 
304
            MIOS32_DOUT_PinSet(HW_LED_RED_COPY, newState & LED_RED);
-
 
305
            MIOS32_DOUT_PinSet(HW_LED_GREEN_COPY, newState & LED_GREEN);
-
 
306
            MIOS32_DOUT_PinSet(HW_LED_BLUE_COPY, newState & LED_BLUE);
-
 
307
            ledstate[LED_COPY] = newState;
-
 
308
         }
-
 
309
         break;
-
 
310
      case LED_PASTE:
-
 
311
         if (newState != ledstate[LED_PASTE])
-
 
312
         {
-
 
313
            MIOS32_DOUT_PinSet(HW_LED_RED_PASTE, newState & LED_RED);
-
 
314
            MIOS32_DOUT_PinSet(HW_LED_GREEN_PASTE, newState & LED_GREEN);
-
 
315
            MIOS32_DOUT_PinSet(HW_LED_BLUE_PASTE, newState & LED_BLUE);
-
 
316
            ledstate[LED_PASTE] = newState;
-
 
317
         }
-
 
318
         break;
-
 
319
      case LED_DELETE:
-
 
320
         if (newState != ledstate[LED_DELETE])
-
 
321
         {
-
 
322
            MIOS32_DOUT_PinSet(HW_LED_RED_DELETE, newState & LED_RED);
-
 
323
            MIOS32_DOUT_PinSet(HW_LED_GREEN_DELETE, newState & LED_GREEN);
-
 
324
            MIOS32_DOUT_PinSet(HW_LED_BLUE_DELETE, newState & LED_BLUE);
-
 
325
            ledstate[LED_DELETE] = newState;
256
         }
326
         }
257
         break;
327
         break;
258
   }
328
   }
259
-
 
260
}
329
}
261
// -------------------------------------------------------------------------------------------------
330
// -------------------------------------------------------------------------------------------------
-
 
331
262
332
263
333
264
/**
334
/**
265
 *  Update the six general purpose LED states (called periodically from app.c)
335
 * Update the LED states of the Matias switches (called every 20ms from app.c timer)
266
 *
336
 *
267
 */
337
 */
268
void updateGPLeds()
338
void updateLEDs()
269
{
339
{
-
 
340
   u8 led_gp1 = LED_OFF, led_gp2 = LED_OFF, led_gp3 = LED_OFF, led_gp4 = LED_OFF, led_gp5 = LED_OFF, led_gp6 = LED_OFF;
-
 
341
   u8 led_runstop = LED_OFF, led_arm = LED_OFF, led_shift = LED_OFF, led_menu = LED_OFF;
270
   MUTEX_DIGITALOUT_TAKE;
342
   u8 led_copy = LED_OFF, led_paste = LED_OFF, led_delete = LED_OFF;
271
343
272
   if (screenIsInMenu())
344
   if (screenIsInMenu())
273
   {
345
   {
-
 
346
      led_menu = LED_RED;
274
347
-
 
348
      switch (page_)
-
 
349
      {
-
 
350
         case PAGE_MIDIMONITOR:
-
 
351
            led_gp2 = LED_RED;
-
 
352
            break;
-
 
353
         case PAGE_TEMPO:
-
 
354
            led_gp3 = LED_RED;
-
 
355
            break;
-
 
356
         case PAGE_MUTE:
-
 
357
            led_gp4 = LED_RED;
-
 
358
            break;
-
 
359
         case PAGE_NOTES:
-
 
360
            led_gp5 = LED_RED;
-
 
361
            break;
-
 
362
         case PAGE_ROUTER:
-
 
363
            led_arm = LED_RED;
-
 
364
            break;
-
 
365
         case PAGE_DISK:
-
 
366
            led_shift = LED_RED;
-
 
367
            break;
-
 
368
         case PAGE_CLIP:
-
 
369
            led_copy = LED_RED;
-
 
370
            break;
-
 
371
         case PAGE_FX:
-
 
372
            led_paste = LED_RED;
-
 
373
            break;
-
 
374
         case PAGE_TRACK:
-
 
375
            led_delete = LED_RED;
-
 
376
            break;
-
 
377
      }
275
   }
378
   }
276
-
 
277
   else
379
   else
278
   {
380
   {
-
 
381
      // Normal pages, outside menu/shift
-
 
382
-
 
383
      // Always indicate active track with a blue upper LED
-
 
384
      led_gp1 = activeTrack_ == 0 ? LED_BLUE : LED_OFF;
-
 
385
      led_gp2 = activeTrack_ == 1 ? LED_BLUE : LED_OFF;
-
 
386
      led_gp3 = activeTrack_ == 2 ? LED_BLUE : LED_OFF;
-
 
387
      led_gp4 = activeTrack_ == 3 ? LED_BLUE : LED_OFF;
-
 
388
      led_gp5 = activeTrack_ == 4 ? LED_BLUE : LED_OFF;
-
 
389
      led_gp6 = activeTrack_ == 5 ? LED_BLUE : LED_OFF;
-
 
390
-
 
391
      // Page-specific additonal lighting
279
      switch (page_) {
392
      switch (page_)
-
 
393
      {
280
         case PAGE_MUTE:
394
         case PAGE_MUTE:
281
            updateGPLed(1, !trackMute_[0]);
395
            led_gp1 |= trackMute_[0] ? LED_OFF : LED_GREEN;
282
            updateGPLed(2, !trackMute_[1]);
396
            led_gp2 |= trackMute_[1] ? LED_OFF : LED_GREEN;
283
            updateGPLed(3, !trackMute_[2]);
397
            led_gp3 |= trackMute_[2] ? LED_OFF : LED_GREEN;
284
            updateGPLed(4, !trackMute_[3]);
398
            led_gp4 |= trackMute_[3] ? LED_OFF : LED_GREEN;
285
            updateGPLed(5, !trackMute_[4]);
399
            led_gp5 |= trackMute_[4] ? LED_OFF : LED_GREEN;
286
            updateGPLed(6, !trackMute_[5]);
400
            led_gp6 |= trackMute_[5] ? LED_OFF : LED_GREEN;
287
            break;
401
            break;
288
402
289
         case PAGE_CLIP:
403
         case PAGE_CLIP:
290
            updateGPLed(1, command_ == COMMAND_CLIPLEN);
404
            led_gp1 |= command_ == COMMAND_CLIPLEN ? LED_RED : LED_OFF;
291
            updateGPLed(2, command_ == COMMAND_QUANTIZE);
405
            led_gp2 |= command_ == COMMAND_QUANTIZE ? LED_RED : LED_OFF;
292
            updateGPLed(3, command_ == COMMAND_TRANSPOSE);
406
            led_gp3 |= command_ == COMMAND_TRANSPOSE ? LED_RED : LED_OFF;
293
            updateGPLed(4, command_ == COMMAND_SCROLL);
407
            led_gp4 |= command_ == COMMAND_SCROLL ? LED_RED : LED_OFF;
294
            updateGPLed(5, command_ == COMMAND_STRETCH);
408
            led_gp5 |= command_ == COMMAND_STRETCH ? LED_RED : LED_OFF;
295
            updateGPLed(6, command_ == COMMAND_CLEAR);
409
            led_gp6 |= command_ == COMMAND_FREEZE ? LED_RED : LED_OFF;
-
 
410
            break;
-
 
411
-
 
412
         case PAGE_FX:
296
            break;
413
            break;
297
414
298
         case PAGE_NOTES:
415
         case PAGE_NOTES:
299
            updateGPLed(1, command_ == COMMAND_POSITION);
416
            led_gp1 |= command_ == COMMAND_POSITION ? LED_RED : LED_OFF;
300
            updateGPLed(2, command_ == COMMAND_NOTE);
417
            led_gp2 |= command_ == COMMAND_NOTE ? LED_RED : LED_OFF;
301
            updateGPLed(3, command_ == COMMAND_VELOCITY);
418
            led_gp3 |= command_ == COMMAND_VELOCITY ? LED_RED : LED_OFF;
302
            updateGPLed(4, command_ == COMMAND_LENGTH);
419
            led_gp4 |= command_ == COMMAND_LENGTH ? LED_RED : LED_OFF;
303
            updateGPLed(5, 0);
-
 
304
            updateGPLed(6, command_ == COMMAND_DELETENOTE);
420
            led_gp6 |= command_ == COMMAND_DELETENOTE ? LED_RED : LED_OFF;
305
            break;
421
            break;
306
422
307
         case PAGE_TRACK:
423
         case PAGE_TRACK:
308
            updateGPLed(1, command_ == COMMAND_PORT);
424
            led_gp1 |= command_ == COMMAND_PORT ? LED_RED : LED_OFF;
309
            updateGPLed(2, command_ == COMMAND_CHANNEL);
425
            led_gp2 |= command_ == COMMAND_CHANNEL ? LED_RED : LED_OFF;
310
            updateGPLed(3, 0);
-
 
311
            updateGPLed(4, 0);
-
 
312
            updateGPLed(5, 0);
-
 
313
            updateGPLed(6, 0);
-
 
314
            break;
426
            break;
315
427
316
         case PAGE_DISK:
428
         case PAGE_DISK:
317
            updateGPLed(1, command_ == COMMAND_SAVE);
429
            led_gp1 |= command_ == COMMAND_SAVE ? LED_RED : LED_OFF;
318
            updateGPLed(2, command_ == COMMAND_LOAD);
430
            led_gp2 |= command_ == COMMAND_LOAD ? LED_RED : LED_OFF;
319
            updateGPLed(3, command_ == COMMAND_NEW);
431
            led_gp3 |= command_ == COMMAND_NEW ? LED_RED : LED_OFF;
320
            updateGPLed(4, 0);
-
 
321
            updateGPLed(5, 0);
-
 
322
            updateGPLed(6, 0);
-
 
323
            break;
432
            break;
324
433
325
         case PAGE_TEMPO:
434
         case PAGE_TEMPO:
326
            updateGPLed(1, command_ == COMMAND_BPM);
435
            led_gp1 |= command_ == COMMAND_BPM ? LED_RED : LED_OFF;
327
            updateGPLed(2, command_ == COMMAND_BPMFLASH);
436
            led_gp2 |= command_ == COMMAND_BPMFLASH ? LED_RED : LED_OFF;
328
            updateGPLed(3, 0);
-
 
329
            updateGPLed(4, 0);
-
 
330
            updateGPLed(5, 0);
-
 
331
            updateGPLed(6, 0);
-
 
332
            break;
437
            break;
333
      }
438
      }
334
   }
439
   }
-
 
440
-
 
441
   MUTEX_DIGITALOUT_TAKE;
-
 
442
-
 
443
   updateLED(LED_GP1, led_gp1);
-
 
444
   updateLED(LED_GP2, led_gp2);
-
 
445
   updateLED(LED_GP3, led_gp3);
-
 
446
   updateLED(LED_GP4, led_gp4);
-
 
447
   updateLED(LED_GP5, led_gp5);
-
 
448
   updateLED(LED_GP6, led_gp6);
-
 
449
   updateLED(LED_RUNSTOP, led_runstop);
-
 
450
   updateLED(LED_ARM, led_arm);
-
 
451
   updateLED(LED_SHIFT, led_shift);
-
 
452
   updateLED(LED_MENU, led_menu);
-
 
453
   updateLED(LED_COPY, led_copy);
-
 
454
   updateLED(LED_PASTE, led_paste);
-
 
455
   updateLED(LED_DELETE, led_delete);
335
456
336
   MUTEX_DIGITALOUT_GIVE;
457
   MUTEX_DIGITALOUT_GIVE;
337
}
458
}
338
// -------------------------------------------------------------------------------------------------
459
// -------------------------------------------------------------------------------------------------
339
460
Line 344... Line 465...
344
void setActiveTrack(u8 trackNumber)
465
void setActiveTrack(u8 trackNumber)
345
{
466
{
346
   activeTrack_ = trackNumber;
467
   activeTrack_ = trackNumber;
347
   screenSetClipSelected(activeTrack_);
468
   screenSetClipSelected(activeTrack_);
348
469
349
   MUTEX_DIGITALOUT_TAKE;
470
   /* MUTEX_DIGITALOUT_TAKE;
350
   MIOS32_DOUT_PinSet(led_active1, activeTrack_ == 0);
471
   MIOS32_DOUT_PinSet(HW_LED_BLUE_GP1, activeTrack_ == 0);
351
   MIOS32_DOUT_PinSet(led_active2, activeTrack_ == 1);
472
   MIOS32_DOUT_PinSet(HW_LED_BLUE_GP2, activeTrack_ == 1);
352
   MIOS32_DOUT_PinSet(led_active3, activeTrack_ == 2);
473
   MIOS32_DOUT_PinSet(HW_LED_BLUE_GP3, activeTrack_ == 2);
353
   MIOS32_DOUT_PinSet(led_active4, activeTrack_ == 3);
474
   MIOS32_DOUT_PinSet(HW_LED_BLUE_GP4, activeTrack_ == 3);
354
   MIOS32_DOUT_PinSet(led_active5, activeTrack_ == 4);
475
   MIOS32_DOUT_PinSet(HW_LED_BLUE_GP5, activeTrack_ == 4);
355
   MIOS32_DOUT_PinSet(led_active6, activeTrack_ == 5);
476
   MIOS32_DOUT_PinSet(HW_LED_BLUE_GP6, activeTrack_ == 5);
356
   MUTEX_DIGITALOUT_GIVE;
477
   MUTEX_DIGITALOUT_GIVE;
-
 
478
    */
357
}
479
}
358
// -------------------------------------------------------------------------------------------------
480
// -------------------------------------------------------------------------------------------------
359
481
360
/**
482
/**
361
 * Set a new active scene number
483
 * Set a new active scene number
Line 834... Line 956...
834
static void seqUpdateBeatLEDs(u32 bpm_tick)
956
static void seqUpdateBeatLEDs(u32 bpm_tick)
835
{
957
{
836
   static u8 lastLEDstate = 255;
958
   static u8 lastLEDstate = 255;
837
959
838
   u16 ticksPerStep = SEQ_BPM_PPQN_Get() / 4;
960
   u16 ticksPerStep = SEQ_BPM_PPQN_Get() / 4;
839
-
 
840
   u8 beatled = (bpm_tick / ticksPerStep) % 4;
961
   u8 beatled = (bpm_tick / ticksPerStep) % 4;
841
962
842
   if (beatled != lastLEDstate)
963
   if (beatled != lastLEDstate)
843
   {
964
   {
844
      lastLEDstate = beatled;
965
      lastLEDstate = beatled;
845
966
846
      MUTEX_DIGITALOUT_TAKE;
967
      if (!screenIsInMenu() && !screenIsInShift())
847
      switch (beatled)
-
 
848
      {
968
      {
-
 
969
         MUTEX_DIGITALOUT_TAKE;
-
 
970
         switch (beatled) {
849
      case 0:
971
            case 0:
850
         oledBeatFlashState_ = (bpm_tick / (ticksPerStep * 4) % 4 == 0) ? 2 : 1; // flash background (strong/normal)
972
               oledBeatFlashState_ = (bpm_tick / (ticksPerStep * 4) % 4 == 0) ? 2
-
 
973
                                                                              : 1; // flash background (strong/normal)
851
         MIOS32_DOUT_PinSet(led_beat0, 1);
974
               MIOS32_DOUT_PinSet(led_beat0, 1);
852
         MIOS32_DOUT_PinSet(led_beat1, 0);
975
               MIOS32_DOUT_PinSet(led_beat1, 0);
853
         MIOS32_DOUT_PinSet(led_beat2, 0);
976
               MIOS32_DOUT_PinSet(led_beat2, 0);
854
         MIOS32_DOUT_PinSet(led_beat3, 0);
977
               MIOS32_DOUT_PinSet(led_beat3, 0);
855
         break;
978
               break;
Line 871... Line 994...
871
         MIOS32_DOUT_PinSet(led_beat2, 0);
994
               MIOS32_DOUT_PinSet(led_beat2, 0);
872
         MIOS32_DOUT_PinSet(led_beat3, 1);
995
               MIOS32_DOUT_PinSet(led_beat3, 1);
873
         break;
996
               break;
874
      }
997
         }
875
      MUTEX_DIGITALOUT_GIVE;
998
         MUTEX_DIGITALOUT_GIVE;
-
 
999
      }
876
1000
877
      // New step, Update clip positions
1001
      // New step, Update clip positions
878
      u8 i;
1002
      u8 i;
879
      for (i = 0; i < TRACKS; i++)
1003
      for (i = 0; i < TRACKS; i++)
880
      {
1004
      {
Line 1037... Line 1161...
1037
void handleStop()
1161
void handleStop()
1038
{
1162
{
1039
   screenFormattedFlashMessage("Stopped");
1163
   screenFormattedFlashMessage("Stopped");
1040
1164
1041
   MUTEX_DIGITALOUT_TAKE;
1165
   MUTEX_DIGITALOUT_TAKE;
1042
   MIOS32_DOUT_PinSet(led_startstop, 0);
1166
   MIOS32_DOUT_PinSet(HW_LED_GREEN_RUNSTOP, 0);
1043
   MIOS32_DOUT_PinSet(led_armrecord, 0);
1167
   MIOS32_DOUT_PinSet(HW_LED_RED_ARM, 0);
1044
   MUTEX_DIGITALOUT_GIVE;
1168
   MUTEX_DIGITALOUT_GIVE;
1045
1169
1046
   SEQ_BPM_Stop(); // stop sequencer
1170
   SEQ_BPM_Stop(); // stop sequencer
1047
1171
1048
   // Clear "stuck" notes, that may still be depressed while stop has been hit
1172
   // Clear "stuck" notes, that may still be depressed while stop has been hit
Line 1074... Line 1198...
1074
1198
1075
     // start sequencer
1199
     // start sequencer
1076
     SEQ_BPM_Start();
1200
     SEQ_BPM_Start();
1077
1201
1078
     MUTEX_DIGITALOUT_TAKE;
1202
     MUTEX_DIGITALOUT_TAKE;
1079
     MIOS32_DOUT_PinSet(led_startstop, 1);
1203
     MIOS32_DOUT_PinSet(HW_LED_GREEN_RUNSTOP, 1);
1080
     MUTEX_DIGITALOUT_GIVE;
1204
     MUTEX_DIGITALOUT_GIVE;
1081
1205
1082
     screenFormattedFlashMessage("Play");
1206
     screenFormattedFlashMessage("Play");
1083
  }
1207
  }
1084
1208
Line 1097... Line 1221...
1097
  {
1221
  {
1098
     screenFormattedFlashMessage("Armed");
1222
     screenFormattedFlashMessage("Armed");
1099
     isRecording_ = 1;
1223
     isRecording_ = 1;
1100
1224
1101
     MUTEX_DIGITALOUT_TAKE;
1225
     MUTEX_DIGITALOUT_TAKE;
1102
     MIOS32_DOUT_PinSet(led_armrecord, 1);
1226
     MIOS32_DOUT_PinSet(HW_LED_RED_ARM, 1);
1103
     MUTEX_DIGITALOUT_GIVE;
1227
     MUTEX_DIGITALOUT_GIVE;
1104
  }
1228
  }
1105
  else
1229
  else
1106
  {
1230
  {
1107
     screenFormattedFlashMessage("Disarmed");
1231
     screenFormattedFlashMessage("Disarmed");
1108
     isRecording_ = 0;
1232
     isRecording_ = 0;
1109
1233
1110
     MUTEX_DIGITALOUT_TAKE;
1234
     MUTEX_DIGITALOUT_TAKE;
1111
     MIOS32_DOUT_PinSet(led_armrecord, 0);
1235
     MIOS32_DOUT_PinSet(HW_LED_RED_ARM, 0);
1112
     MUTEX_DIGITALOUT_GIVE;
1236
     MUTEX_DIGITALOUT_GIVE;
1113
  }
1237
  }
1114
1238
1115
  return 0; // no error
1239
  return 0; // no error
1116
}
1240
}
Line 1298... Line 1422...
1298
 * Edit Clip Page: Clear clip
1422
 * Edit Clip Page: Clear clip
1299
 *
1423
 *
1300
 */
1424
 */
1301
void editClear()
1425
void editClear()
1302
{
1426
{
1303
   command_ = command_ == COMMAND_CLEAR ? COMMAND_NONE : COMMAND_CLEAR;
1427
   command_ = command_ == COMMAND_FREEZE ? COMMAND_NONE : COMMAND_FREEZE;
1304
1428
1305
   clipNotesSize_[activeTrack_][activeScene_] = 0;
1429
   clipNotesSize_[activeTrack_][activeScene_] = 0;
1306
1430
1307
   u8 i;
1431
   u8 i;
1308
   for (i=0; i<128; i++)
1432
   for (i=0; i<128; i++)
Line 1494... Line 1618...
1494
 */
1618
 */
1495
void loopaButtonPressed(s32 pin)
1619
void loopaButtonPressed(s32 pin)
1496
{
1620
{
1497
   DEBUG_MSG("Button: %d pressed\n", pin);
1621
   DEBUG_MSG("Button: %d pressed\n", pin);
1498
1622
1499
   if (pin == sw_startstop)
1623
   if (pin == sw_runstop)
-
 
1624
   {
-
 
1625
      if (screenIsInMenu())
-
 
1626
      {
-
 
1627
         page_ = PAGE_SETUP;
-
 
1628
      }
-
 
1629
      else
1500
   {
1630
      {
1501
      seqPlayStopButton();
1631
         seqPlayStopButton();
-
 
1632
      }
1502
   }
1633
   }
1503
   else if (pin == sw_armrecord)
1634
   else if (pin == sw_armrecord)
-
 
1635
   {
-
 
1636
      if (screenIsInMenu())
-
 
1637
      {
-
 
1638
         page_ = PAGE_ROUTER;
-
 
1639
      }
-
 
1640
      else
1504
   {
1641
      {
1505
      seqArmButton();
1642
         seqArmButton();
-
 
1643
      }
1506
   }
1644
   }
1507
   else if (pin == sw_shift)
1645
   else if (pin == sw_shift)
1508
   {
1646
   {
1509
      if (screenIsInMenu())
1647
      if (screenIsInMenu())
1510
      {
1648
      {
1511
         page_ = PAGE_MUTE;
1649
         page_ = PAGE_DISK;
1512
      }
1650
      }
1513
      else
1651
      else
1514
      {
1652
      {
1515
         // normal mode "shift"
1653
         // normal mode "shift"
1516
         screenShowShift(1);
1654
         screenShowShift(1);
Line 1532... Line 1670...
1532
   }
1670
   }
1533
   else if (pin == sw_copy)
1671
   else if (pin == sw_copy)
1534
   {
1672
   {
1535
      if (screenIsInMenu())
1673
      if (screenIsInMenu())
1536
      {
1674
      {
1537
         page_ = PAGE_TRACK;
1675
         page_ = PAGE_CLIP;
1538
      }
1676
      }
1539
      else
1677
      else
1540
      {
1678
      {
1541
         // normal mode "copy"
1679
         // normal mode "copy"
1542
         copiedClipSteps_ = clipSteps_[activeTrack_][activeScene_];
1680
         copiedClipSteps_ = clipSteps_[activeTrack_][activeScene_];
Line 1549... Line 1687...
1549
         screenFormattedFlashMessage("copied clip to buffer");
1687
         screenFormattedFlashMessage("copied clip to buffer");
1550
      }
1688
      }
1551
   }
1689
   }
1552
   else if (pin == sw_paste)
1690
   else if (pin == sw_paste)
1553
   {
1691
   {
-
 
1692
      if (screenIsInMenu())
-
 
1693
      {
-
 
1694
         page_ = PAGE_FX;
-
 
1695
      }
1554
      voxelFrame();
1696
      else
-
 
1697
      {
1555
      // paste only, if we have a clip in memory
1698
         // paste only, if we have a clip in memory
1556
      if (copiedClipSteps_ > 0)
1699
         if (copiedClipSteps_ > 0)
1557
      {
1700
         {
1558
         clipSteps_[activeTrack_][activeScene_] = copiedClipSteps_;
1701
            clipSteps_[activeTrack_][activeScene_] = copiedClipSteps_;
1559
         clipQuantize_[activeTrack_][activeScene_] = copiedClipQuantize_;
1702
            clipQuantize_[activeTrack_][activeScene_] = copiedClipQuantize_;
Line 1564... Line 1707...
1564
         clipNotesSize_[activeTrack_][activeScene_] = copiedClipNotesSize_;
1707
            clipNotesSize_[activeTrack_][activeScene_] = copiedClipNotesSize_;
1565
         screenFormattedFlashMessage("pasted clip from buffer");
1708
            screenFormattedFlashMessage("pasted clip from buffer");
1566
      }
1709
         }
1567
      else
1710
         else
1568
         screenFormattedFlashMessage("no clip in buffer");
1711
            screenFormattedFlashMessage("no clip in buffer");
1569
1712
      }
1570
   }
1713
   }
1571
   else if (pin == sw_delete)
1714
   else if (pin == sw_delete)
-
 
1715
   {
-
 
1716
      if (screenIsInMenu())
-
 
1717
      {
-
 
1718
         page_ = PAGE_TRACK;
-
 
1719
      }
-
 
1720
      else
1572
   {
1721
      {
1573
       editClear(); // shortcut: clear track
1722
         editClear(); // shortcut: clear track
1574
       command_ = COMMAND_NONE;
1723
         command_ = COMMAND_NONE;
-
 
1724
      }
1575
   }
1725
   }
1576
   else if (pin == sw_gp1)
1726
   else if (pin == sw_gp1)
-
 
1727
   {
-
 
1728
      if (screenIsInMenu())
-
 
1729
      {
-
 
1730
         // page_ = PAGE_SYSEX; TODO
-
 
1731
      }
-
 
1732
      else
1577
   {
1733
      {
1578
      switch (page_)
1734
         switch (page_)
1579
      {
1735
         {
1580
         case PAGE_MUTE:
1736
            case PAGE_MUTE:
1581
            toggleMute(0);
1737
               toggleMute(0);
Line 1593... Line 1749...
1593
            diskSave();
1749
               diskSave();
1594
            break;
1750
               break;
1595
         case PAGE_TEMPO:
1751
            case PAGE_TEMPO:
1596
            bpmBpm();
1752
               bpmBpm();
1597
            break;
1753
               break;
-
 
1754
         }
1598
      }
1755
      }
1599
   }
1756
   }
1600
   else if (pin == sw_gp2)
1757
   else if (pin == sw_gp2)
-
 
1758
   {
-
 
1759
      if (screenIsInMenu())
-
 
1760
      {
-
 
1761
         page_ = PAGE_MIDIMONITOR;
-
 
1762
      }
-
 
1763
      else
1601
   {
1764
      {
1602
      switch (page_)
1765
         switch (page_)
1603
      {
1766
         {
1604
         case PAGE_MUTE:
1767
            case PAGE_MUTE:
1605
            toggleMute(1);
1768
               toggleMute(1);
Line 1617... Line 1780...
1617
            diskLoad();
1780
               diskLoad();
1618
            break;
1781
               break;
1619
         case PAGE_TEMPO:
1782
            case PAGE_TEMPO:
1620
            bpmBpmflash();
1783
               bpmBpmflash();
1621
            break;
1784
               break;
-
 
1785
         }
1622
      }
1786
      }
1623
   }
1787
   }
1624
   else if (pin == sw_gp3)
1788
   else if (pin == sw_gp3)
1625
   {
1789
   {
1626
      if (screenIsInMenu())
1790
      if (screenIsInMenu())
1627
      {
1791
      {
1628
         page_ = PAGE_CLIP;
1792
         page_ = PAGE_TEMPO;
1629
      }
1793
      }
1630
      else
1794
      else
1631
      {
1795
      {
1632
         // Normal GP3 page handling
1796
         // Normal GP3 page handling
1633
1797
Line 1647... Line 1811...
1647
               break;
1811
               break;
1648
         }
1812
         }
1649
      }
1813
      }
1650
   }
1814
   }
1651
   else if (pin == sw_gp4)
1815
   else if (pin == sw_gp4)
-
 
1816
   {
-
 
1817
      if (screenIsInMenu())
-
 
1818
      {
-
 
1819
         page_ = PAGE_MUTE;
-
 
1820
      }
-
 
1821
      else
1652
   {
1822
      {
1653
      switch (page_)
1823
         switch (page_)
1654
      {
1824
         {
1655
         case PAGE_MUTE:
1825
            case PAGE_MUTE:
1656
            toggleMute(3);
1826
               toggleMute(3);
Line 1659... Line 1829...
1659
            editScroll();
1829
               editScroll();
1660
            break;
1830
               break;
1661
         case PAGE_NOTES:
1831
            case PAGE_NOTES:
1662
            notesLength();
1832
               notesLength();
1663
            break;
1833
               break;
-
 
1834
         }
1664
      }
1835
      }
1665
   }
1836
   }
1666
   else if (pin == sw_gp5)
1837
   else if (pin == sw_gp5)
-
 
1838
   {
-
 
1839
      if (screenIsInMenu())
-
 
1840
      {
-
 
1841
         page_ = PAGE_NOTES;
-
 
1842
      }
-
 
1843
      else
1667
   {
1844
      {
1668
      switch (page_)
1845
         switch (page_)
1669
      {
1846
         {
1670
         case PAGE_MUTE:
1847
            case PAGE_MUTE:
1671
            toggleMute(4);
1848
               toggleMute(4);
1672
            break;
1849
               break;
1673
         case PAGE_CLIP:
1850
            case PAGE_CLIP:
1674
            editStretch();
1851
               editStretch();
1675
            break;
1852
               break;
-
 
1853
         }
1676
      }
1854
      }
1677
   }
1855
   }
1678
   else if (pin == sw_gp6)
1856
   else if (pin == sw_gp6)
-
 
1857
   {
-
 
1858
      if (screenIsInMenu())
-
 
1859
      {
-
 
1860
         // page_ = PAGE_SONG; TODO
-
 
1861
      }
-
 
1862
      else
1679
   {
1863
      {
1680
      switch (page_)
1864
         switch (page_)
1681
      {
1865
         {
1682
         case PAGE_MUTE:
1866
            case PAGE_MUTE:
1683
            toggleMute(5);
1867
               toggleMute(5);
Line 1686... Line 1870...
1686
            editClear();
1870
               editClear();
1687
            break;
1871
               break;
1688
         case PAGE_NOTES:
1872
            case PAGE_NOTES:
1689
            notesDeleteNote();
1873
               notesDeleteNote();
1690
            break;
1874
               break;
-
 
1875
         }
1691
      }
1876
      }
1692
   }
1877
   }
1693
   else if (pin == sw_encoder2)
1878
   else if (pin == sw_encoder2)
1694
   {
1879
   {
1695
      page_ = PAGE_MUTE; // shortcut back to track display
1880
      page_ = PAGE_MUTE; // shortcut back to track display