using scan matrix together with led matrix?

Hi

Is it possible to integrate the led matrix driver (from sidmatrix test)

with the C scanmatrix example?

I want to drive 64 leds and 32 buttons using a DINX1 and a DOUTX2

Michaël

You might find some helpful clues linked from the DrumStuff wiki page.

I allready looked at that page but none of the links provide the combination of buttons and leds

(correct me if I’m wrong  ???)

in the meantime I’ve build the button/led matrix with two DOUT registers for the leds

and seperate DIN/DOUT registers for the button matrix (driven by sm_example code)

so I just have to modify the SID ledmatrix example and

add a C style header for the asm functions…

I’ve managed to get this to work  :slight_smile:

I’m using one dout to drive both matrices

and a din/dout for buttons/leds

modifications to scan matrix example:

in main.c:

...
//second shiftregister drives the leds
#define LEDOUT 1
...
void LM_SetRow(){
	MIOS_DOUT_SRSet(LEDOUT,ledtest[sm_col]);
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS before the shift register are loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Prepare(void) __wparam
{
  // call the Scan Matrix Driver
  SM_PrepareCol();
  // call the Led Matrix Driver
  LM_SetRow();
}
...

in sm_simple.asm:

...
	global	_sm_button_column
	global	_sm_button_row
	global	_sm_button_value
	global  _sm_col

	;; import lables
	extern	_SM_NotifyToggle

; ==========================================================================

accessram udata ; (no access ram required, these variables can be located anywhere)

_sm_button_column	res	1	; exported to C, therefore an "_" has been added
_sm_button_row res	1
_sm_button_value	res	1
_sm_col res 1

...

SM_PrepareCol
	;; select next DOUT register

	;; (current column + 1) & 0x07
	SET_BSR	sm_selected_column
	incf	sm_selected_column, W, BANKED	; (* see note below)
	andlw	0x07
	;_sm_col is used by LM_SetRow()
	movwf	_sm_col
	call	MIOS_HLP_GetBitANDMask	; (inverted 1 of 8 code)
...

and finally in sm_simple.h:

...
extern unsigned char sm_button_value;
extern unsigned char sm_col;
...

I don’t think this is the most efficient way to do this

but it works for me  :slight_smile:

Michaël

Well done mess :D  I’m adding a link to here from the Drumstuff page.

What project are you building this into?

ever since I saw the clockbox example I wanted to build a drum seq

so it’s gonna be a drumseq  :smiley:

you can read some information on my first attempt here:

http://www.midibox.org/forum/index.php?topic=6980.msg45082#msg45082

the new design is based on some of the suggestions

in the “when will come the trseq” thread

feature list:

32 step 8 track drum seq, each step has trig/acc/roll

16 patterns, will be expanded when seq is up and running

patterns are saved on a bankstick

simple UI:

lcd: displaying [bpm pat trknr (edited par)]

32 step buttons + stepleds, leds are dual color to display trig/acc

all functions are accessed with a stepkey + shift combination

pattern selection: stepkey + pattern button

track select/mute: stepkey + track button

rotary encoder for modifying parameters

some pics of the seq:

picture to show the size (it’s reeaally compact ;D)

matrix wiring mess:

looks good.. very nice!

Nice work!

I’ve started a wiki page about the seq:

http://www.midibox.org/dokuwiki/doku.php?id=dseq32

page is still under construction  :slight_smile:

Michaël