Exemple #1
0
/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
  const char root_name[12*2] = "C C#D D#E F F#G G#A A#B ";

  // init LCD
  MIOS32_LCD_Clear();

  // endless loop
  while( 1 ) {
    // toggle the state of all LEDs (allows to measure the execution speed with a scope)
    MIOS32_BOARD_LED_Set(0xffffffff, ~MIOS32_BOARD_LED_Get());

    if( display_update ) {
      display_update = 0;

      MIOS32_LCD_CursorSet(0, 0);
      MIOS32_LCD_PrintString("Root: ");
      char *selected_root_name = (char *)&root_name[2*selected_root];
      MIOS32_LCD_PrintChar(*selected_root_name++);
      MIOS32_LCD_PrintChar(*selected_root_name);

      MIOS32_LCD_CursorSet(0, 1);
      if( selected_scale == 0 ) {
	MIOS32_LCD_PrintString("No Scale            ");
      } else {
	MIOS32_LCD_PrintString(SCALE_NameGet(selected_scale-1));
      }
    }
  }
}
Exemple #2
0
/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
  // print static screen
  MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL);

  // clear LCD
  MIOS32_LCD_Clear();

  u8 last_touchpanel_x = 0;
  u8 last_touchpanel_y = 0;

  // endless loop - LED will flicker on each iteration
  while( 1 ) {
    // toggle the state of all LEDs (allows to measure the execution speed with a scope)
    MIOS32_BOARD_LED_Set(0xffffffff, ~MIOS32_BOARD_LED_Get());

    // check for X/Y coordinate changes
    if( touchpanel_x != last_touchpanel_x || touchpanel_y != last_touchpanel_y ) {
      // clear marker at last position
      MIOS32_LCD_GCursorSet(last_touchpanel_x, last_touchpanel_y / 2);
      MIOS32_LCD_PrintChar(' ');

      // clear coordinate at the left/right side if required
      if( (last_touchpanel_x < 64 && touchpanel_x >= 64) || (last_touchpanel_x >= 64 && touchpanel_x < 64) ) {
	MIOS32_LCD_GCursorSet((last_touchpanel_x < 64) ? 128-5*6 : 0, 0*8);
	MIOS32_LCD_PrintString("     ");
	MIOS32_LCD_GCursorSet((last_touchpanel_x < 64) ? 128-5*6 : 0, 1*8);
	MIOS32_LCD_PrintString("     ");
      }

      // set marker at new position
      MIOS32_LCD_GCursorSet(touchpanel_x, touchpanel_y / 2);
      MIOS32_LCD_PrintChar('x');

      // print new coordinates
      MIOS32_LCD_GCursorSet((touchpanel_x < 64) ? 128-5*6 : 0, 0*8);
      MIOS32_LCD_PrintFormattedString("X:%3d", touchpanel_x);
      MIOS32_LCD_GCursorSet((touchpanel_x < 64) ? 128-5*6 : 0, 1*8);
      MIOS32_LCD_PrintFormattedString("Y:%3d", touchpanel_y);

      // store new position
      last_touchpanel_x = touchpanel_x;
      last_touchpanel_y = touchpanel_y;
    }
  }
}
/////////////////////////////////////////////////////////////////////////////
//! Prints a \\0 (zero) terminated string
//! \param[in] str pointer to string
//! \return < 0 on errors
/////////////////////////////////////////////////////////////////////////////
s32 MIOS32_LCD_PrintString(const char *str)
{
  s32 status = 0;

  while( *str != '\0' )
    status |= MIOS32_LCD_PrintChar(*str++);

  return status;
}
/////////////////////////////////////////////////////////////////////////////
//! transfers the buffer to LCDs
//! \param[in] force if != 0, it is ensured that the whole screen will be refreshed, regardless
//! if characters have changed or not
/////////////////////////////////////////////////////////////////////////////
s32 BUFLCD_Update(u8 force)
{
  int next_x = -1;
  int next_y = -1;
  int x, y;

  u32 bufpos_len = BUFLCD_MaxBufferGet();
  int phys_y = buflcd_offset_y;
  for(y=0; y<buflcd_device_num_y*buflcd_device_height; ++y, ++phys_y) {
    u32 bufpos = y * buflcd_device_num_x * buflcd_device_width;
    if( bufpos >= bufpos_len )
      break;

    u8 *ptr = (u8 *)&lcd_buffer[bufpos];
#if BUFLCD_SUPPORT_GLCD_FONTS
    u8 *font_ptr = (u8 *)&lcd_buffer[bufpos + (BUFLCD_BUFFER_SIZE/2)];
#endif
    int phys_x = buflcd_offset_x;
    int device = (buflcd_device_num_x * (phys_y / buflcd_device_height)) - 1;
    for(x=0; x<(buflcd_device_num_x * buflcd_device_width) && bufpos < bufpos_len; ++x, ++phys_x, ++bufpos) {
      if( (phys_x % buflcd_device_width) == 0 )
	++device;

      if( force || !(*ptr & 0x80)
#if BUFLCD_SUPPORT_GLCD_FONTS
	  || (glcd_font_handling && !(*font_ptr & 0x80))
#endif
	  ) {
#if BUFLCD_SUPPORT_GLCD_FONTS
	u8 *glcd_font = NULL;
	if( glcd_font_handling ) {
	  switch( *font_ptr & 0x7f ) {
	  case 'n': glcd_font = (u8 *)GLCD_FONT_NORMAL; break;
	  case 'i': glcd_font = (u8 *)GLCD_FONT_NORMAL_INV; break;
	  case 'b': glcd_font = (u8 *)GLCD_FONT_BIG; break;
	  case 's': glcd_font = (u8 *)GLCD_FONT_SMALL; break;
	  case 't': glcd_font = (u8 *)GLCD_FONT_TINY; break;
	  case 'k': glcd_font = (u8 *)GLCD_FONT_KNOB_ICONS; break;
	  case 'h': glcd_font = (u8 *)GLCD_FONT_METER_ICONS_H; break;
	  case 'v': glcd_font = (u8 *)GLCD_FONT_METER_ICONS_V; break;
	  default:
	    glcd_font = NULL; // no character will be print
	  }

	  MIOS32_LCD_FontInit(glcd_font);
	}
#endif

	if( x != next_x || y != next_y ) {
#if BUFLCD_SUPPORT_GLCD_FONTS
	  if( glcd_font_handling && glcd_font ) {
	    // temporary use pseudo-font to ensure that Y is handled equaly for all fonts
	    u8 pseudo_font[4];
	    // just to ensure...
#if MIOS32_LCD_FONT_WIDTH_IX != 0 || MIOS32_LCD_FONT_HEIGHT_IX != 1 || MIOS32_LCD_FONT_X0_IX != 2 || MIOS32_LCD_FONT_OFFSET_IX != 3
# error "Please adapt this part for new LCD Font parameter positions!"
#endif
	    pseudo_font[MIOS32_LCD_FONT_WIDTH_IX] = glcd_font[MIOS32_LCD_FONT_WIDTH_IX];
	    pseudo_font[MIOS32_LCD_FONT_HEIGHT_IX] = 1*8; // forced!
	    pseudo_font[MIOS32_LCD_FONT_X0_IX] = glcd_font[MIOS32_LCD_FONT_X0_IX];
	    pseudo_font[MIOS32_LCD_FONT_OFFSET_IX] = glcd_font[MIOS32_LCD_FONT_OFFSET_IX];
	    MIOS32_LCD_FontInit((u8 *)&pseudo_font);
	  }
#endif
	  MIOS32_LCD_DeviceSet(device);
	  MIOS32_LCD_CursorSet(phys_x % buflcd_device_width, phys_y % buflcd_device_height);
#if BUFLCD_SUPPORT_GLCD_FONTS
	  if( glcd_font_handling ) {
	    // switch back to original font
	    MIOS32_LCD_FontInit(glcd_font);
	  }
#endif
	}

#if BUFLCD_SUPPORT_GLCD_FONTS
	if( !glcd_font_handling || glcd_font )
#endif
	  MIOS32_LCD_PrintChar(*ptr & 0x7f);

	MIOS32_IRQ_Disable(); // must be atomic
	*ptr |= 0x80;
#if BUFLCD_SUPPORT_GLCD_FONTS
	*font_ptr |= 0x80;
#endif
	MIOS32_IRQ_Enable();

	next_y = y;
	next_x = x+1;

	// for multiple LCDs: ensure that cursor is set when we reach the next partition
	if( (next_x % buflcd_device_width) == 0 )
	  next_x = -1;
      }
      ++ptr;
#if BUFLCD_SUPPORT_GLCD_FONTS
      ++font_ptr;
#endif
    }
  }

  return 0; // no error
}
Exemple #5
0
/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
  int num_lcds = mios32_lcd_parameters.num_x * mios32_lcd_parameters.num_y;

  // print configured LCD parameters
  MIOS32_MIDI_SendDebugMessage("\n");
  MIOS32_MIDI_SendDebugMessage("\n");
  MIOS32_MIDI_SendDebugMessage("Multi-CLCD Demo started.");
  MIOS32_MIDI_SendDebugMessage("Configured LCD Parameters in MIOS32 Bootloader Info Range:\n");
  MIOS32_MIDI_SendDebugMessage("lcd_type: 0x%02x (%s)\n", mios32_lcd_parameters.lcd_type, MIOS32_LCD_LcdTypeName(mios32_lcd_parameters.lcd_type));
  MIOS32_MIDI_SendDebugMessage("num_x:    %4d\n", mios32_lcd_parameters.num_x);
  MIOS32_MIDI_SendDebugMessage("num_y:    %4d\n", mios32_lcd_parameters.num_y);
  MIOS32_MIDI_SendDebugMessage("width:    %4d\n", mios32_lcd_parameters.width);
  MIOS32_MIDI_SendDebugMessage("height:   %4d\n", mios32_lcd_parameters.height);

  if( mios32_lcd_parameters.lcd_type != MIOS32_LCD_TYPE_CLCD &&
      mios32_lcd_parameters.lcd_type != MIOS32_LCD_TYPE_CLCD_DOG ) {
    // print warning if correct LCD hasn't been selected
    MIOS32_MIDI_SendDebugMessage("WARNING: your core module hasn't been configured for CLCD or CLCD_DOG!\n");
    MIOS32_MIDI_SendDebugMessage("Please do this with the bootloader update application!\n");
  }

  // initialize all LCDs (although programming_models/traditional/main.c will only initialize the first two)
  int lcd;
  for(lcd=0; lcd<num_lcds; ++lcd) {
    MIOS32_MIDI_SendDebugMessage("Initialize LCD #%d\n", lcd+1);
    MIOS32_LCD_DeviceSet(lcd);
    if( MIOS32_LCD_Init(0) < 0 ) {
      MIOS32_MIDI_SendDebugMessage("Failed - no response from LCD #%d.%d\n",
				   (lcd % mios32_lcd_parameters.num_x) + 1,
				   (lcd / mios32_lcd_parameters.num_x) + 1);
    }
  }

  // init special characters for all LCDs
  for(lcd=0; lcd<num_lcds; ++lcd) {
    MIOS32_LCD_DeviceSet(lcd);
    MIOS32_LCD_SpecialCharsInit((u8 *)charset_vert_bars);
    MIOS32_LCD_Clear();
  }

  // print text on all LCDs
  for(lcd=0; lcd<num_lcds; ++lcd) {
    MIOS32_LCD_DeviceSet(lcd);
    MIOS32_LCD_CursorSet(0, 0);
    MIOS32_LCD_PrintFormattedString("LCD #%d.%d",
				    (lcd % mios32_lcd_parameters.num_x) + 1,
				    (lcd / mios32_lcd_parameters.num_x) + 1);
    MIOS32_LCD_CursorSet(0, 1);
    MIOS32_LCD_PrintFormattedString("READY.");
  }


  // print animated vertical bar
  while( 1 ) {
    int i, j;
    for(i=0; i<8; ++i) {
      // print vertical bars depending on i
      for(lcd=0; lcd<num_lcds; ++lcd) {
	MIOS32_LCD_DeviceSet(lcd);
	MIOS32_LCD_CursorSet(12, 0);

	for(j=0; j<8; ++j) {
	  u8 c = (i + j) % 8;
	  MIOS32_LCD_PrintChar(c);
	}
      }

      // wait for 100 mS
      for(j=0; j<100; ++j)
	MIOS32_DELAY_Wait_uS(1000);
    }
  }
}
/////////////////////////////////////////////////////////////////////////////
// Local Display Handler function
// IN: <high_prio>: if set, a high-priority LCD update is requested
/////////////////////////////////////////////////////////////////////////////
static s32 LCD_Handler(u8 high_prio)
{
  // layout:
  // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
  // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
  // <--------------------------------------> <-------------------------------------->
  //     No Patterns available as long as the Session hasn't been created!
  //                   Please press EXIT and  create a new Session!
	
  // Main Page
  // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
  // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
  // <--------------------------------------> <-------------------------------------->
  // A1: Breakbeats 2                   16.16 A4: Breakbeat full              10:10:10
  // ____ ____ ____ ____ T01: Track Name      x__x __x_ ____ ____              126 BPM
	
  // Remix Page
  // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
  // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
  // <--------------------------------------> <-------------------------------------->
  //  1    2    3    4    5    6    7    8     9    10   11   12   13   14   15   16
  // MIX  .... UMIX .... UMIX .... .... MIX   .... .... .... .... .... .... .... ....
	
  // In preview_mode we can state tracks to Mix state only(on/off), on normal mode
  // we can state track do DMix state only(on/off)
	
  // Options Page
  // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
  // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
  // <--------------------------------------> <-------------------------------------->
  // A1: Breakbeats 2                         Auto save Auto rset Abtn. Api
  // Save Name Copy Paste          Trk Delay     Off       On        On
	
  // Edit Name Page
  // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
  // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
  // <--------------------------------------> <-------------------------------------->
  // A1: <xxxxxxxxxxxxxxxxxxxx>
  // .,!1 ABC2 DEF3 GHI4 JKL5 MNO6 PQRS7 TUV8 WXYZ9 -_ 0  Char <>  Del Ins        OK  
	
  // Track Delay Page
  // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
  // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
  // <--------------------------------------> <-------------------------------------->
  //   1    2    3    4    5    6    7    8     9    10   11   12   13   14   15   16
  //  -10 +230  -45  -22  +23  -43 +221  -32  -210 +230  -45 -322 +323  -43 +221  -32
  // for this we could use t->bpm_tick_delay, but we need a way to saving
  // this values inside the track pattern

  if( SEQ_FILE_FormattingRequired() ) {
    if( high_prio )
      return 0;

    MIOS32_LCD_CursorSet(0, 0);
    MIOS32_LCD_PrintString(" No Patterns available "); 
	MIOS32_LCD_CursorSet(0, 1);
    MIOS32_LCD_PrintString("as long as theSession ");
	MIOS32_LCD_CursorSet(0, 2);
    MIOS32_LCD_PrintString("hasn't been created!");
    MIOS32_LCD_CursorSet(0, 3);
    MIOS32_LCD_PrintString("Please press EXIT and");
	MIOS32_LCD_CursorSet(0, 4);
    MIOS32_LCD_PrintString("create a new Session! ");
	MIOS32_LCD_CursorSet(0, 5);
	SEQ_LCD_PrintSpaces(21);
	MIOS32_LCD_CursorSet(0, 6);
	SEQ_LCD_PrintSpaces(21);
	MIOS32_LCD_CursorSet(0, 7);
	SEQ_LCD_PrintSpaces(21);
    return 0;
  }
	
  switch( selected_page ) {

    ///////////////////////////////////////////////////////////////////////////
    // REMIX PAGE
    case PAGE_REMIX: {

      // Remix Page
      // 00000000001111111111222222222233333333330000000000111111111122222222223333333333
      // 01234567890123456789012345678901234567890123456789012345678901234567890123456789
      // <--------------------------------------><-------------------------------------->
      //  1M   2    3M   4    5    6    7    8    9    10   11   12   13   14   15   16
      // ...  .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....

      // <--------------------------------------><-------------------------------------->
      //  1D    2   3D    4   5    6    7    8    9    10   11   12   13   14   15   16
      //  .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....

      if( high_prio ) {

        ///////////////////////////////////////////////////////////////////////////
        // frequently update VU meters and step position counter
        u8 track;
        //u8 spacer = 0;

        MIOS32_LCD_CursorSet(0, 1);

        seq_core_trk_t *t = &seq_core_trk[0];
        for(track=0; track<16; ++t, ++track) {

          //if( !(track % 4) && (track!=0) )
          //  spacer++;

          //MIOS32_LCD_CursorSet(track+spacer, 1);
			switch( track ) {
				case 0:
					MIOS32_LCD_CursorSet(0, 1);
					break;
				case 4:
					MIOS32_LCD_CursorSet(0, 3);
					break;
				case 8:
					MIOS32_LCD_CursorSet(0, 5);
					break;
				case 12:
					MIOS32_LCD_CursorSet(0, 7);
					break;
			}

					//SEQ_LCD_PrintVBar(t->vu_meter >> 4);
					SEQ_LCD_PrintHBar(t->vu_meter >> 3);

        }

      } else { // not high_prio

        u8 track;

        MIOS32_LCD_CursorSet(0, 0);
				SEQ_LCD_PrintSpaces(1);
				
        for(track=0; track<16; ++track) {
			switch( track ) {
				case 0:
					MIOS32_LCD_CursorSet(1, 0);
					break;
				case 4:
					MIOS32_LCD_CursorSet(0, 2);
					break;
				case 8:
					MIOS32_LCD_CursorSet(0, 4);
					break;
				case 12:
					MIOS32_LCD_CursorSet(0, 6);
					break;
			}
					// print the mixed state info
					if( seq_pattern_remix_map & (1 << track) ) {
						
						MIOS32_LCD_PrintFormattedString("%dM", track+1);
            if (track < 9) {
              SEQ_LCD_PrintSpaces(3);
            } else {
              SEQ_LCD_PrintSpaces(2);
            }
						
					// print the demixed state info	
					} else if ( ( seq_pattern_remix_map ^ seq_pattern_demix_map ) & (1 << track) ) { 
					
						MIOS32_LCD_PrintFormattedString("%dD", track+1);
            if (track < 9) {
              SEQ_LCD_PrintSpaces(3);
            } else {
              SEQ_LCD_PrintSpaces(2);
            }
						
				  }else {
						
            MIOS32_LCD_PrintFormattedString("%d", track+1);
            if (track < 9) {
              SEQ_LCD_PrintSpaces(4);
            } else {
              SEQ_LCD_PrintSpaces(3);
            }
						
					}
					
        }
				
				SEQ_LCD_PrintSpaces(1);

      }

    } break;

    ///////////////////////////////////////////////////////////////////////////
    // OPTION PAGE
    case PAGE_OPTION: {

      // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
      // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
      // <--------------------------------------> <-------------------------------------->
      // A1: Breakbeats 2                                              Auto save Abtn. Api
      // Save Name Copy Paste                                             Off        On

      ///////////////////////////////////////////////////////////////////////////
      // Current Pattern Name
			SEQ_LCD_Clear();
      MIOS32_LCD_CursorSet(0, 0);
      SEQ_LCD_PrintPattern(seq_pattern[0]);
      MIOS32_LCD_PrintFormattedString(": %s", seq_pattern_name[0]);

      ///////////////////////////////////////////////////////////////////////////
      // Options Labels Left Side
      MIOS32_LCD_CursorSet(0, 1);
      MIOS32_LCD_PrintString("Save ");
      MIOS32_LCD_PrintString("Name ");
      MIOS32_LCD_PrintString("Copy ");
      MIOS32_LCD_PrintString("Paste");

      //MIOS32_LCD_CursorSet(30, 1);
      //MIOS32_LCD_PrintString("Trk Delay ");

      ///////////////////////////////////////////////////////////////////////////
      // Options Labels Right Side
      MIOS32_LCD_CursorSet(0, 2);
      MIOS32_LCD_PrintString("Auto save ");
      //MIOS32_LCD_PrintString("Auto rset ");
      MIOS32_LCD_PrintString("Abtn. Api ");

      MIOS32_LCD_CursorSet(0, 3);
      if (auto_save) {
        MIOS32_LCD_PrintString("   On     ");
      } else {
        MIOS32_LCD_PrintString("   Off    ");
      }

      //if (auto_reset) {
      //  MIOS32_LCD_PrintString("   On     ");
      //} else {
      //  MIOS32_LCD_PrintString("   Off    ");
      //}

      if (ableton_api) {
        MIOS32_LCD_PrintString("   On     ");
      } else {
        MIOS32_LCD_PrintString("   Off    ");
      }

    } break;

    ///////////////////////////////////////////////////////////////////////////
    // PATTERN NAME EDIT PAGE
    case PAGE_NAME_EDIT: {

      u8 i;

			SEQ_LCD_Clear();
			

      MIOS32_LCD_CursorSet(0, 0);

      SEQ_LCD_PrintPattern(seq_pattern[0]);
      MIOS32_LCD_PrintString(": ");

      for(i=0; i<20; ++i)
        MIOS32_LCD_PrintChar(seq_pattern_name[ui_selected_group][i]);

      // insert flashing cursor
      if( ui_cursor_flash ) {
        MIOS32_LCD_CursorSet(3 + ((ui_edit_name_cursor < 5) ? 1 : 2) + ui_edit_name_cursor, 0);
        MIOS32_LCD_PrintChar('*');
      }


      SEQ_UI_KeyPad_LCD_Msg();
      MIOS32_LCD_CursorSet(10, 7);
      MIOS32_LCD_PrintString("Back");

      //return 0;

    } break;

    ///////////////////////////////////////////////////////////////////////////
    // TRACK DELAY PAGE
    case PAGE_TRK_DELAY: {

      // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
      // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
      // <--------------------------------------> <-------------------------------------->
      //   1    2    3    4    5    6    7    8     9    10   11   12   13   14   15   16
      //  -10 +230  -45  -22  +23  -43 +221  -32  -210 +230  -45 -322 +323  -43 +221  -32

      u8 track;

      MIOS32_LCD_CursorSet(0, 2);
      for(track=0; track<16; ++track) {

          MIOS32_LCD_PrintFormattedString("%d", track);
          if (track < 11) {
            SEQ_LCD_PrintSpaces(4);
          } else {
            SEQ_LCD_PrintSpaces(3);
          }

      }

      MIOS32_LCD_CursorSet(1, 2);
      for(track=0; track<16; ++track) {

          MIOS32_LCD_PrintFormattedString("%d", track);
          //MIOS32_LCD_PrintFormattedString("%d", 0);
          if (track < 11) {
            SEQ_LCD_PrintSpaces(4);
          } else {
            SEQ_LCD_PrintSpaces(3);
          }

      }

    } break;

    ///////////////////////////////////////////////////////////////////////////
    // MAIN PAGE
    case PAGE_MAIN: {

      // 0000000000111111111122222222223333333333 0000000000111111111122222222223333333333
      // 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
      // <--------------------------------------> <-------------------------------------->
      // A1: Breakbeats 2                   16.16 A4: Breakbeat full              10:10:10
      // ____ ____ ____ ____ T01: Track Name      x__x __x_ ____ ____              126 BPM

			//MIOS32_LCD_CursorSet(0, 0);
			//SEQ_LCD_PrintSpaces();
			
      if( high_prio ) {

        ///////////////////////////////////////////////////////////////////////////
        // Frequently update VU meters
        u8 track;
        u8 spacer = 0;
        seq_core_trk_t *t = &seq_core_trk[0];
        for(track=0; track<16; ++t, ++track) {

          if( !(track % 4) && (track!=0) )
            spacer++;

          MIOS32_LCD_CursorSet(track+spacer, 2);

          //if( seq_core_trk_muted & (1 << track) )
          //  SEQ_LCD_PrintVBar('M');
          //else
            SEQ_LCD_PrintVBar(t->vu_meter >> 4);

				}
				
				if ( remix_mode && preview_mode ) {
					
					spacer = 0;
					seq_core_trk_t *t = &seq_core_trk[0];
          for(track=0; track<16; ++t, ++track) {
						
            if( !(track % 4) && (track!=0) )
              spacer++;
						
            MIOS32_LCD_CursorSet((track+spacer), 6);
						
						if( !( seq_pattern_remix_map & (1 << track) ) )
							SEQ_LCD_PrintVBar(t->vu_meter >> 4);
						
          }
					
				}
				
				///////////////////////////////////////////////////////////////////////////
				// Print Pattern Relative Sequencer Position
				// MIOS32_LCD_CursorSet(28, 0);
				// u32 tick = SEQ_BPM_TickGet();
				// tick = tick - seq_pattern_start_tick;
				// u32 ticks_per_step = SEQ_BPM_PPQN_Get() / 4;
				// u32 ticks_per_measure = ticks_per_step * (seq_core_steps_per_measure+1);
				// u32 measure = (tick / ticks_per_measure) + 1;
				// u32 step = ((tick % ticks_per_measure) / ticks_per_step) + 1;
				//u32 microstep = tick % ticks_per_step;
				//MIOS32_LCD_PrintFormattedString("%8u.%3d.%3d", measure, step, microstep);
				// MIOS32_LCD_PrintFormattedString("%8u.%3d", measure, step);

      } else { // not high_prio
Exemple #7
0
/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
  // print static screen
  MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL);
  MIOS32_LCD_BColourSet(0x000000);
  MIOS32_LCD_FColourSet(0xffffff);

  // clear LCD
  MIOS32_LCD_Clear();

  // print text
  MIOS32_LCD_CursorSet(3, 3);
  MIOS32_LCD_PrintString("ST7637 LCD");

  MIOS32_LCD_CursorSet(7, 5);
  MIOS32_LCD_PrintString("powered by");

  // endless loop: print animations
  u8 mios_r = 0;
  u8 mios_g = 0;
  u8 mios_b = 0;
  u8 dir = 1;
  u8 knob_icon_ctr[4] = {0, 3, 6, 9}; // memo: 12 icons
  u8 knob_icon_delay_ctr[4] = {0, 2, 4, 6};
  const u8 knob_icon_x[4] = {0, 100, 0, 100}; // memo: icon width 28
  const u8 knob_icon_y[4] = {0, 0, 104, 104}; // memo: icon height 24

  u8 vmeter_icon_ctr[2] = {0, 5}; // memo: 28 icons (14 used)
  u8 vmeter_icon_dir[2] = {1, 1};
  u8 vmeter_icon_delay_ctr[2] = {1, 4};
  const u8 vmeter_icon_x[2] = {0, 120}; // memo: icon width 8
  const u8 vmeter_icon_y[2] = {48, 48}; // memo: icon height 32

  u8 hmeter_icon_ctr[2] = {6, 11}; // memo: 28 icons (14 used)
  u8 hmeter_icon_dir[2] = {1, 0};
  u8 hmeter_icon_delay_ctr[2] = {4, 2};
  const u8 hmeter_icon_x[2] = {50, 50}; // memo: icon width 28
  const u8 hmeter_icon_y[2] = {0, 120}; // memo: icon height 8

  while( 1 ) {
    s32 i;

    // toggle the state of all LEDs (allows to measure the execution speed with a scope)
    MIOS32_BOARD_LED_Set(0xffffffff, ~MIOS32_BOARD_LED_Get());

    // colour-cycle "MIOS32" up and down :-)
    // ST7637 supports 5bit r, 6bit g and 5bit b
    if( dir ) {
      if( mios_r < 0x1f )
	++mios_r;
      else if( mios_g < 0x3f )
	++mios_g;
      else if( mios_b < 0x1f )
	++mios_b;
      else
	dir = 0;
    } else {
      if( mios_r > 0x00 )
	--mios_r;
      else if( mios_g > 0x00 )
	--mios_g;
      else if( mios_b > 0x00 )
	--mios_b;
      else
	dir = 1;
    }

    // set new colour
    MIOS32_LCD_FColourSet((mios_r << 16) | (mios_g << 8) | mios_b);

    // print "MIOS32"
    MIOS32_LCD_FontInit((u8 *)GLCD_FONT_BIG);
    MIOS32_LCD_GCursorSet(16, 52);
    MIOS32_LCD_PrintString("MIOS32");

    // icons with different colour
    MIOS32_LCD_FColourSet(((dir?mios_r:~mios_r) << 16) | 
			  (~mios_g << 8) | 
			  (dir?mios_b:~mios_b));

    // print turning Knob icons at all edges
    MIOS32_LCD_FontInit((u8 *)GLCD_FONT_KNOB_ICONS); // memo: 12 icons, icon size: 28x24
    for(i=0; i<4; ++i) {
      if( ++knob_icon_delay_ctr[i] > 10 ) {
	knob_icon_delay_ctr[i] = 0;
	if( ++knob_icon_ctr[i] >= 12 )
	  knob_icon_ctr[i] = 0;
      }
      MIOS32_LCD_GCursorSet(knob_icon_x[i], knob_icon_y[i]);
      MIOS32_LCD_PrintChar(knob_icon_ctr[i]);
    }

    // print vmeter icons
    MIOS32_LCD_FontInit((u8 *)GLCD_FONT_METER_ICONS_V); // memo: 28 icons, 14 used, icon size: 8x32
    for(i=0; i<2; ++i) {
      if( ++vmeter_icon_delay_ctr[i] > 5 ) {
	vmeter_icon_delay_ctr[i] = 0;
	if( vmeter_icon_dir[i] ) {
	  if( ++vmeter_icon_ctr[i] >= 13 )
	    vmeter_icon_dir[i] = 0;
	} else {
	  if( --vmeter_icon_ctr[i] < 1 )
	    vmeter_icon_dir[i] = 1;
	}
      }
      MIOS32_LCD_GCursorSet(vmeter_icon_x[i], vmeter_icon_y[i]);
      MIOS32_LCD_PrintChar(vmeter_icon_ctr[i]);
    }

    // print hmeter icons
    MIOS32_LCD_FontInit((u8 *)GLCD_FONT_METER_ICONS_H); // memo: 28 icons, 14 used, icon size: 28x8
    for(i=0; i<2; ++i) {
      if( ++hmeter_icon_delay_ctr[i] > 7 ) {
	hmeter_icon_delay_ctr[i] = 0;
	if( hmeter_icon_dir[i] ) {
	  if( ++hmeter_icon_ctr[i] >= 13 )
	    hmeter_icon_dir[i] = 0;
	} else {
	  if( --hmeter_icon_ctr[i] < 1 )
	    hmeter_icon_dir[i] = 1;
	}
      }
      MIOS32_LCD_GCursorSet(hmeter_icon_x[i], hmeter_icon_y[i]);
      MIOS32_LCD_PrintChar(hmeter_icon_ctr[i]);
    }
  }
}
Exemple #8
0
/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
#define MAX_LCDS 16
  int num_lcds = mios32_lcd_parameters.num_x * mios32_lcd_parameters.num_y;
  if( num_lcds > MAX_LCDS ) {
    MIOS32_MIDI_SendDebugMessage("WARNING: this application only supports up to 16 displays!\n");
    num_lcds = MAX_LCDS;
  }

  // clear LCDs
  {
    u8 n;
    for(n=0; n<num_lcds; ++n) {
      MIOS32_LCD_DeviceSet(n);
      MIOS32_LCD_Clear();
    }
  }

  u8 vmeter_icon_ctr[MAX_LCDS][2] = {{0,5},{3,14},{7,1},{3,9},{13,6},{10,2},{1,4},{6,2},{13,6},{10,2},{1,4},{6,2},{1,2},{13,14},{5,5},{6,1}}; // memo: 28 icons (14 used)
  u8 vmeter_icon_dir[MAX_LCDS][2] = {{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,1}};
  u8 vmeter_icon_delay_ctr[MAX_LCDS][2] = {{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4},{1,4}};
  const u8 vmeter_icon_x[2] = {0, 120}; // memo: icon width 8
  const u8 vmeter_icon_y[2] = {12, 12}; // memo: icon height 32

  u8 hmeter_icon_ctr[MAX_LCDS][2] = {{6,11},{2,27},{23,1},{15,6},{18,9},{10,12},{3,25},{26,7},{18,9},{10,12},{3,25},{26,7},{6,9},{18,18},{20,10},{3,10}}; // memo: 28 icons (14 used)
  u8 hmeter_icon_dir[MAX_LCDS][2] = {{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0},{1,0}};
  u8 hmeter_icon_delay_ctr[MAX_LCDS][2] = {{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2},{4,2}};
  const u8 hmeter_icon_x[2] = {20, 80}; // memo: icon width 28
  const u8 hmeter_icon_y[2] = {60, 60}; // memo: icon height 8

  // print configured LCD parameters
  MIOS32_MIDI_SendDebugMessage("\n");
  MIOS32_MIDI_SendDebugMessage("\n");
  MIOS32_MIDI_SendDebugMessage("SSD1306 Demo started.");
  MIOS32_MIDI_SendDebugMessage("Configured LCD Parameters in MIOS32 Bootloader Info Range:\n");
  MIOS32_MIDI_SendDebugMessage("lcd_type: 0x%02x (%s)\n", mios32_lcd_parameters.lcd_type, MIOS32_LCD_LcdTypeName(mios32_lcd_parameters.lcd_type));
  MIOS32_MIDI_SendDebugMessage("num_x:    %4d\n", mios32_lcd_parameters.num_x);
  MIOS32_MIDI_SendDebugMessage("num_y:    %4d\n", mios32_lcd_parameters.num_y);
  MIOS32_MIDI_SendDebugMessage("width:    %4d\n", mios32_lcd_parameters.width);
  MIOS32_MIDI_SendDebugMessage("height:   %4d\n", mios32_lcd_parameters.height);
  MIOS32_MIDI_SendDebugMessage("Testing %d LCDs\n", num_lcds);

  if( mios32_lcd_parameters.lcd_type != MIOS32_LCD_TYPE_GLCD_SSD1306 && mios32_lcd_parameters.lcd_type != MIOS32_LCD_TYPE_GLCD_SSD1306_ROTATED ) {
    // print warning if correct LCD hasn't been selected
    MIOS32_MIDI_SendDebugMessage("WARNING: your core module hasn't been configured for the SSD1306 GLCD!\n");
    MIOS32_MIDI_SendDebugMessage("Please do this with the bootloader update application!\n");
  }



  // print static screen
  MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL);

  // endless loop - LED will flicker on each iteration
  while( 1 ) {
    // wait some mS
    MIOS32_DELAY_Wait_uS(10000);

    // toggle the state of all LEDs (allows to measure the execution speed with a scope)
    MIOS32_BOARD_LED_Set(0xffffffff, ~MIOS32_BOARD_LED_Get());

    u8 n;
    for(n=0; n<num_lcds; ++n) {
      int i;
#if 0
      // X/Y "position" of displays
      const u8 lcd_x[MAX_LCDS] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; // CS#0..7
      const u8 lcd_y[MAX_LCDS] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7};

      // X/Y "position" of displays
      u8 x_offset = 128*lcd_x[n];
      u8 y_offset = 64*lcd_y[n];
#else
      // TK: expired! LCDs now addressed via MIOS32_LCD_DeviceSet()
      u8 x_offset = 0;
      u8 y_offset = 0;
      MIOS32_LCD_DeviceSet(n);
#endif

      // print text
      MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL);
      MIOS32_LCD_GCursorSet(x_offset + 6*6, y_offset + 1*8);
      MIOS32_LCD_PrintFormattedString("SSD1306 #%d", n+1);

      MIOS32_LCD_GCursorSet(x_offset + 6*6, y_offset + 2*8);
      MIOS32_LCD_PrintString("powered by    ");

      MIOS32_LCD_FontInit((u8 *)GLCD_FONT_BIG);
      MIOS32_LCD_GCursorSet(x_offset + 3*6, y_offset + 3*8);
      MIOS32_LCD_PrintString("MIOS32");

      // print vmeter icons
      MIOS32_LCD_FontInit((u8 *)GLCD_FONT_METER_ICONS_V); // memo: 28 icons, 14 used, icon size: 8x32
      for(i=0; i<2; ++i) {
	if( ++vmeter_icon_delay_ctr[n][i] ) {
	  vmeter_icon_delay_ctr[n][i] = 0;
	  if( vmeter_icon_dir[n][i] ) {
	    if( ++vmeter_icon_ctr[n][i] >= 13 )
	      vmeter_icon_dir[n][i] = 0;
	  } else {
	    if( --vmeter_icon_ctr[n][i] < 1 )
	      vmeter_icon_dir[n][i] = 1;
	  }
	}
	MIOS32_LCD_GCursorSet(vmeter_icon_x[i]+x_offset, vmeter_icon_y[i]+y_offset);
	MIOS32_LCD_PrintChar(vmeter_icon_ctr[n][i]);
      }

      // print hmeter icons
      for(i=0; i<2; ++i) {
	MIOS32_LCD_FontInit((u8 *)GLCD_FONT_METER_ICONS_H); // memo: 28 icons, 14 used, icon size: 28x8
	if( ++hmeter_icon_delay_ctr[n][i] > 7 ) {
	  hmeter_icon_delay_ctr[n][i] = 0;
	  if( hmeter_icon_dir[n][i] ) {
	    if( ++hmeter_icon_ctr[n][i] >= 13 )
	      hmeter_icon_dir[n][i] = 0;
	  } else {
	    if( --hmeter_icon_ctr[n][i] < 1 )
	      hmeter_icon_dir[n][i] = 1;
	  }
	}
	MIOS32_LCD_GCursorSet(hmeter_icon_x[i]+x_offset, hmeter_icon_y[i]+y_offset);
	MIOS32_LCD_PrintChar(hmeter_icon_ctr[n][i]);

	MIOS32_LCD_FontInit((u8 *)GLCD_FONT_NORMAL);
	if( i == 0 ) {
	  MIOS32_LCD_GCursorSet(0+x_offset, hmeter_icon_y[i]+y_offset);
	  MIOS32_LCD_PrintFormattedString("%d", hmeter_icon_ctr[n][i]*4);
	} else {
	  MIOS32_LCD_GCursorSet(128-3*6+x_offset, hmeter_icon_y[i]+y_offset);
	  MIOS32_LCD_PrintFormattedString("%3d", hmeter_icon_ctr[n][i]*4);
	}
      }
    }
  }
}