Jump to content

How to make a cursor?


Thomas

Recommended Posts

Hallo!

I need some input for programming.

I want to write a routine for editing same valus, the midi events of a button or poti.

A button has 4 midibytes (controller command, value1, valueOn, valueOff, type)

(if you now the PC1600 from peavey you'll know what I mean)

it's looking like this on the display (T==toggle):

----------------

old: BE017F01T

new: BE017F01T

----------------

Now I want to add a cursor, like

----------------

old: BE017F01T

new: BE017F01T

        -

----------------

(indicating that you edit the lower nipple of the second midi byte)

My current solution is:

----------------

old: BE017F01T

new: BE0>1<7F01T

----------------

But this looks ugly.

Any Ideas?

Link to comment
Share on other sites

  • 4 years later...

does someone know how to make this cursor at the good position ??? it appears on the 4th line (adress 0xc0) on a 4x20 LCD

i can edit the EditBuffer but the cursor don't want to move :getlost:

#include <cmios.h>

#include "chaosmatrix.h"

#include "softpanel.h"

#include "lcd.h"

#include "din.h"

#include "midi.h"

#include "patchnames.h"

#include "memo.h"

#include "ui_patch.h"



unsigned char banksaved;

unsigned char programsaved;

unsigned char saved;


static unsigned char cursor;



/*

    EDIT PAGE 1

    []  []   [ ]  []  []

    12345678901234567890

    SELECT EDIT GROUP

    LFO VCA ENV PRTA RMP


    EDIT PAGE 3

    []  []   [ ]  []  []

    12345678901234567890

    BNK SAVE PATCH?

    0   abcdeghj:00 save


 EDIT PAGE 2

 []  []   [ ]  []  []

 0123567890123567890

	uOOO ________ 

  <   > editname save

  o   o   *    *   o

*/


////////////////////////////////////////////////////////

// Display for edit

////////////////////////////////////////////////////////

void UI_Display_Edit (void)

{

	unsigned char i;


    switch(SoftPanel.Page)

	{

		case SOFT_PAGE1:


            MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_PATCH].dout_pin);			// off

			MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_EDIT].dout_pin); 			// on

			MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_OSCILLATORS].dout_pin); 	// on

			MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_FILTER].dout_pin); 		    // on

			MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_ENVELOPES].dout_pin); 	    // on

			MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_KEYBOARD].dout_pin); 		// on

			MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_MATRIX].dout_pin); 		    // on

            MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_PAGE].dout_pin); 		    // off


            MIOS_LCD_Clear();

			MIOS_LCD_CursorSet(0 + LCD_Offset);

            MIOS_LCD_PrintCString("SELECT EDIT GROUP");

            MIOS_LCD_CursorSet(64 + LCD_Offset);

            MIOS_LCD_PrintCString("LFO VCA ENV PRTA RMP");

		break;


		case SOFT_PAGE3: // save patch to matrix1000 memory

            if(SoftPanel.IsNewPage)

			{

                MIOS_LCD_Clear();

                MIOS_LCD_PrintCString("OSC BEND MODW PORTA");


                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_PATCH].dout_pin);			// off

                MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_EDIT].dout_pin); 			// off

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_OSCILLATORS].dout_pin); 	// off

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_FILTER].dout_pin); 		    // off

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_ENVELOPES].dout_pin); 	    // off

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_KEYBOARD].dout_pin); 		// off

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_MATRIX].dout_pin); 		    // off

                MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_PAGE].dout_pin); 		    // on


                MIOS_LCD_Clear();

				MIOS_LCD_CursorSet(0 + LCD_Offset);

                MIOS_LCD_PrintCString("BNK SAVE PATCH ");

                MIOS_LCD_PrintBCD1(BankNumber);

                MIOS_LCD_PrintBCD2(ProgramNumber);

                if(ProgramNumber < 10)

                {

                    MIOS_LCD_CursorSet(16 + LCD_Offset);

                    MIOS_LCD_PrintChar('0'); // place a zero here for values below 10

                }

                saved = 0;

			}


            MIOS_LCD_CursorSet(64 + LCD_Offset);

            MIOS_LCD_PrintBCD1(banksaved);

            MIOS_LCD_CursorSet(64+4 + LCD_Offset);

            MIOS_LCD_PrintCString(PatchNames[banksaved][programsaved]);

            MIOS_LCD_PrintChar(':');

            MIOS_LCD_PrintBCD2(programsaved);

             if(programsaved < 10)

            {

                MIOS_LCD_CursorSet(64+13 + LCD_Offset);

                MIOS_LCD_PrintChar('0'); // place a zero here for values below 10

            }


            MIOS_LCD_CursorSet(64+16 + LCD_Offset);

            if(!saved)

                MIOS_LCD_PrintCString("save");

            else

            MIOS_LCD_PrintCString("    ");


		break;


		case SOFT_PAGE2: // name the patch

            //if(SoftPanel.IsNewPage)

			//{


				/*

				 EDIT PAGE 2

				 []  []   [ ]  []  []

				 12345678901234567890

				    uOOO ________ 

				 <   >  editname save

				 o   o   *    *   o

				 */

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_PATCH].dout_pin);			// off

                MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_EDIT].dout_pin); 			// on

                MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_OSCILLATORS].dout_pin); 	// on

                MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_FILTER].dout_pin); 		    // on

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_ENVELOPES].dout_pin); 	    // off

                MIOS_DOUT_PinSet0(DIN_ConfigMap[DIN_KEYBOARD].dout_pin); 		// off

                MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_MATRIX].dout_pin); 		    // on

                MIOS_DOUT_PinSet1(DIN_ConfigMap[DIN_PAGE].dout_pin); 		    // on


				//1st line

                MIOS_LCD_Clear();

				MIOS_LCD_CursorSet(1 + LCD_Offset);

                MIOS_LCD_PrintCString("u");

                MIOS_LCD_PrintBCD2(uBS_uBank);

                MIOS_LCD_PrintBCD2(uBS_uPatch);

			    // place a zero here for values below 10 (bank & patch) :

				if(uBS_uBank < 10){

					MIOS_LCD_CursorSet(2 + LCD_Offset);

					MIOS_LCD_PrintChar('0'); 

					}

                if(uBS_uPatch < 10){

                    MIOS_LCD_CursorSet(4 + LCD_Offset);

                    MIOS_LCD_PrintChar('0');

					}

				MIOS_LCD_CursorSet(7 + LCD_Offset);

                MIOS_LCD_PrintCString(":");

				// print patch name :

                MIOS_LCD_CursorSet(9 + LCD_Offset);

				for(i=0; i<8; i++){

					MIOS_LCD_PrintChar(EditBuffer[i]);

					}


			//cursor

			//MIOS_LCD_CursorSet(cursor + 9 + LCD_Offset);

			MIOS_LCD_Cmd(0x80 + cursor + 9 + LCD_Offset);

			MIOS_LCD_Cmd(0x0e);


			// 2nd line

            MIOS_LCD_CursorSet(65 + LCD_Offset);

            MIOS_LCD_PrintCString("<");

            MIOS_LCD_CursorSet(69 + LCD_Offset);

			MIOS_LCD_PrintCString(">");

			MIOS_LCD_CursorSet(71 + LCD_Offset);

			MIOS_LCD_PrintCString("EditName SAVE");

			break;

		//}	

	}


}


////////////////////////////////////////////////////////

// Handle for Edit

////////////////////////////////////////////////////////

void UI_Handle_Edit(void)

{	

    if(SoftPanel.Page == SOFT_PAGE1){

        switch (SoftPanel.Button)

        {

            case DIN_PAGE:

                SoftPanel.Page = SOFT_PAGE2;

            break;

        }


	}

	else if(SoftPanel.Page == SOFT_PAGE2){


		switch (SoftPanel.Button){

            case DIN_PAGE:

				SoftPanel.Page = SOFT_PAGE3;

				break;


            case SOFT_EDIT_1: // "<"

				cursor--;

				MIOS_LCD_Cmd(0x10);

				break;


            case SOFT_EDIT_2: // ">"

				cursor++;

				MIOS_LCD_Cmd(0x14);

				break;


				case SOFT_EDIT_5:

				Write_Patch_To_BS(uBS_uBank,uBS_uPatch);

				break;


            case DIN_EDIT:

					SoftPanel.Page = SOFT_PAGE1;

				break;

			}


		//if(SoftPanel.EncoderValue != 0){

            // encoder

            EditBuffer[cursor] += SoftPanel.EncoderValue;

			if (cursor > 7)

				cursor = 0;

		  //}	



	}

	else{ // page 3


        switch (SoftPanel.Button){


            case DIN_PAGE:

				if(!RefreshSoftPanel)

                SoftPanel.Page = SOFT_PAGE1;

				break;


            case SOFT_EDIT_1:

                if(!RefreshSoftPanel){

                    banksaved = banksaved == 0 ? 1 : 0;

                    saved = 0;

                 }

				break;


            case SOFT_EDIT_5:

                if(!RefreshSoftPanel){

                    MIDI_SavePatch(banksaved, programsaved);

                    saved = 1;

				}

				break;


            case DIN_EDIT:

				if(!RefreshSoftPanel)

                SoftPanel.Page = SOFT_PAGE1;

				break;

        }


        if(SoftPanel.EncoderValue != 0){

            // encoder

            programsaved += SoftPanel.EncoderValue;

            if(programsaved > 99)

                programsaved = 0;


            if(programsaved > 99)

                programsaved = 99;


            saved = 0;


        } // end if encoder

	} // end else page 2

}


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...