blm_example is now available at http://www.ucapps.de/mios_download.html
I used this small application during the development of the Button/Duo-LED hardware for MIDIbox SEQ V3 in order to check different wiring options. The driver (blm.asm) is mainly based on sm_simple.asm of the sm_c_example1.
Today I added a debouncing option as requested by bugfight
I would like to highlight again, that the hardware as shown in http://www.ucapps.de/mbhp/button_duoled_matrix.pdf needs to be improved for high current LEDs. I don’t see this as my task.
Newbies: there are no premade PCBs available, and manual wiring on vero boards requires advanced soldering experiences!
Pictures: http://www.midibox.org/midibox_seq_blm_ext/
From the README.txt
[tt]
Button/Duo-LED Example
===============================================================================
Copyright 2008 Thorsten Klose (tk@midibox.org)
Licensed for personal non-commercial use only.
All other rights reserved.
===============================================================================
A precompiled binary is already part of this package:
o project.hex (can be loaded into MIOS Studio)
o project.syx (can be loaded into any SysEx upload tool)
Following tools are required to recompile the code:
o SDCC v2.5.0
o gputils
o perl
The details are described under http://www.ucapps.de/mios_c.html
===============================================================================
Required hardware:
o one MBHP_CORE module
o one DINX2 module (or DINX4) and two DOUTX4 modules
or dedicated board for BLM matrix as specified under:
http://www.ucapps.de/mbhp/button_duoled_matrix.pdf
===============================================================================
This program demonstrates the so called “BLM” driver (-> blm.c)
This driver handles a 4x16 Button/Duo-LED scan matrix of up to 64 buttons and 64 Duo-LEDs
by using the circuit documented under:
http://www.ucapps.de/mbhp/button_duoled_matrix.pdf
The hardware was originally used for MIDIbox SEQ V3, but could also be useful for
other projects.
Note that the buttons/LEDs can be easily arranged to a 8x8 matrix w/o software modifications.
Please note also, that the shift register assignments in blm.c (DEFAULT_*) need to be adapted
to your hardware. The setup used in this example is prepared for connecting the
DIN/DOUT chain directly to the MBHP_CORE module (there are no additional DINX4 or DOUTX4
modules between the BLM and the core like on the MBSEQ V3 hardware).
The function “BLM_NotifyToggle()” in main.c is called when a button has been
pressed or released. LEDs are accessible from the blm_row_green[8] and
blm_row_red[8] array.
By default, this application sends Note Events from Number 0 (C -1) to 63 (E 4)
and it receives the same numbers to control the LEDs:
Velocity 0x00 (or Note off): green and red LED off
Velocity 0x01..0x3f: green LED on, red LED off
Velocity 0x40..0x5f: green LED off, red LED on
Velocity 0x60..0x7f: both LEDs on
Optionally some code can be enabled in the BLM_NotifyToggle function
(located in main.c) to cycle the LED colour with the appr. buttons.
Buttons can be debounced with a definable delay (-> blm_button_debounce_delay)
The resulting delay is calculated as <value> * 4 mS
The Init() function in main.c sets the value to 20 (-> 20*4 mS = 80 mS)
If you want to experiment with different delays, you could (temporary)
control it with a CC event from MPROC_NotifyReceivedEvnt() function in
main.c with following code:
if( evnt0 == 0xb0 && evnt1 == 16 ) { // control debounce delay with CC#16 over Channel #1
blm_button_debounce_delay = evnt2;
}
Don’t forget to remove this change, so that a common MIDI application
isn’t able to modify the value unintentionally.
===============================================================================
Description about the most important files:
- mios_wrapper\mios_wrapper.asm and mios_wrapper\mios_tables.inc:
The MIOS wrapper code and MIOS specific configuration tables
- pic18f452.c: exports PIC18F452 specific SFRs
- main.c: the main program with all MIOS hooks
- blm.asm: the assembly optimized scan matrix code
There are additional .h files for all .c files which contain
general definitions and the declaration of global functions/variables
These .h files must be included into the program parts which
get use of these globals
===============================================================================
[/tt]
Best Regards, Thorsten.