axiomriddler Posted October 9, 2009 Report Posted October 9, 2009 hi all..i need a clue about this modificationhere is my attempt:i use ain64_din128_dout128_v2c..i did manage to:1. use 2 encoders at SR1 pin 0-32. use 48 toggles at SR 3-SR 83. keep 78 buttons in on/off mode at SR 9-SR 16, SR 2, SR 1 pin 4-7i did modify:main.c///////////////////////////////////////////////////////////////////////////// // Application specific encoder table // the default (dummy) table has been disabled via -DDONT_INCLUDE_MIOS_ENC_TABLE ///////////////////////////////////////////////////////////////////////////// MIOS_ENC_TABLE { // sr pin mode MIOS_ENC_ENTRY(1, 0, MIOS_ENC_MODE_DETENTED2), MIOS_ENC_ENTRY(1, 2, MIOS_ENC_MODE_DETENTED2), MIOS_ENC_EOT }; ///////////////////////////////////////////////////////////////////////////// // This function is called by MIOS when an encoder has been moved // incrementer is positive when encoder has been turned clockwise, else // it is negative ///////////////////////////////////////////////////////////////////////////// void ENC_NotifyChange(unsigned char encoder, char incrementer) __wparam { MIOS_MIDI_TxBufferPut(0xb0); // CC at MIDI Channel #1 MIOS_MIDI_TxBufferPut(0x10 + encoder); // CC# is 0x10 (16) for first encoder MIOS_MIDI_TxBufferPut((0x40 + incrementer) & 0x7f); // this "40 +/- speed" format is used by NI software and some others } ///////////////////////////////////////////////////////////////////////////// // This function is called by MIOS when an button has been toggled // pin_value is 1 when button released, and 0 when button pressed ///////////////////////////////////////////////////////////////////////////// void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam { unsigned char array_index; unsigned char bit_index; // DIN 16..63 should toggle if( pin >= 16 && pin <= 63 ) { if( pin_value == 0 ) { // only react when button is pressed // determine the index of the array element (starts from 0) array_index = (pin - 16) >> 3; // fastest way to divide value / 8; // determine bit position bit_index = (pin - 16) & 0x07; // remainder of x/8 // toggle the flag which saves the current button state toggle_state[array_index] ^= (1 << bit_index); // '^' is a XOR operation // send MIDI Note event depending on toggle state MIOS_MIDI_TxBufferPut(0x90); MIOS_MIDI_TxBufferPut(0x30 + pin - 16); MIOS_MIDI_TxBufferPut((toggle_state[array_index] & (1 << bit_index)) ? 0x7f : 0x00); // set LED (same pin number like button) MIOS_DOUT_PinSet(pin, (toggle_state[array_index] & (1 << bit_index)) ? 0x7f : 0x00); } } else { // this branch handles DIN 0..15 and DIN 64..127 } } makefile.orig # $Id: Makefile 311 2008-05-01 17:56:23Z tk $ # define the processor, linker file and project name PROCESSOR = 18f452 LKR_FILE = $(MIOS_PATH)/etc/lkr/p$(PROCESSOR).lkr PROJECT = project # list of objects that should be created and linked OBJS = mios_wrapper.o app_lcd.o main.o # include pathes (more will be added by .mk files) GPASM_INCLUDE = SDCC_INCLUDE = # optional defines that should be passed to GPASM/SDCC GPASM_DEFINES = -DDEBUG_MODE=0 SDCC_DEFINES = -DDEBUG_MODE=0 # pass parameters to MIOS wrapper MIOS_WRAPPER_DEFINES = -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f -DDONT_INCLUDE_MIOS_ENC_TABLE # directories and files that should be part of the distribution (release) package # more will be added by *.mk files DIST = ./ # include the common.mk file include $(MIOS_PATH)/include/makefile/common.mk # include application specific driver (select app_lcd/dummy if MIOS internal driver used) include $(MIOS_PATH)/modules/app_lcd/dummy/app_lcd.mk mios_enc_table.inc ; $Id: mios_enc_table.inc 69 2008-02-01 00:20:18Z tk $ ; ; "Dummy" Configuration Table for Rotary Encoders ; ; Should be included by the application, if no rotary encoders are connected ; in order to pre-initialize the table area with EOT's ; ; ========================================================================== org 0x3280 ; never change the origin! ;; -------------------------------------------------------------------------- ;; In this table DIN pins have to be assigned to rotary encoders for the ;; MIOS_ENC driver ;; ;; up to 64 entries are provided ;; ;; The table must be terminated with an ENC_EOT entry. Unused entries should ;; be filled with ENC_EOT ;; ;; ENC_ENTRY provides following parameters ;; o first parameter: number of shift register - 1, 2, 3, ... 16 ;; o second parameter: number of pin; since two pins are necessary ;; for each encoder, an even number is expected: 0, 2, 4 or 6 ;; o the third parameter contains the encoder mode: ;; either MIOS_ENC_MODE_NON_DETENTED ;; or MIOS_ENC_MODE_DETENTED ;; or MIOS_ENC_MODE_DETENTED2 ;; or MIOS_ENC_MODE_DETENTED3 ;; ;; Configuration Examples: ;; ENC_ENTRY 1, 0, MIOS_ENC_MODE_NON_DETENTED ; non-detented encoder at pin 0 and 1 of SR 1 ;; ENC_ENTRY 1, 2, MIOS_ENC_MODE_DETENTED ; detented encoder at pin 2 and 3 of SR 1 ;; ENC_ENTRY 9, 6, MIOS_ENC_MODE_NON_DETENTED ; non-detented encoder at pin 6 and 7 of SR 9 ;; -------------------------------------------------------------------------- ;; encoder entry structure ENC_ENTRY MACRO sr, din_0, mode dw (mode << 8) | (din_0 + 8*(sr-1)) ENDM ENC_EOT MACRO dw 0xffff ENDM _MIOS_ENC_PIN_TABLE MIOS_ENC_PIN_TABLE ;; encoders 1-16 ;; SR Pin Mode ENC_ENTRY 1, 0, MIOS_ENC_MODE_DETENTED2 ; detented encoder at pin 0 and 1 of SR 1 ENC_ENTRY 1, 2, MIOS_ENC_MODE_DETENTED2 ; detented encoder at pin 2 and 3 of SR 1 ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ;; encoders 17-32 ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ;; encoders 33-48 ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ;; encoders 49-64 ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT ENC_EOT and here is the error message: rm -rf _output/* rm -rf _output rm -rf *.cod *.map *.lst rm -rf *.hex mkdir -p _output sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./include/share -I ./modules/app_lcd/dummy -DDEBUG_MODE=0 -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x3 3f -DDONT_INCLUDE_MIOS_ENC_TABLE -I ./modules/mios_wrapper modules/mios_wrapper/ mios_wrapper.asm -o _output/mios_wrapper.o sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./include/share -I ./modules/app_lcd/dummy -DDEBUG_MODE=0 modules/app_lcd/dummy/app_lcd.asm -o _ output/app_lcd.o sh ./bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto -- optimize-cmp --disable-warning 85 --obanksel=2 -I./src -I ./include/c -I ./incl ude/share -DDEBUG_MODE=0 main.c -o _output/main.o at 1: warning 117: unknown compiler option '--optimize-goto' ignored main.c:215: error 20: Undefined identifier 'toggle_state' main.c:215: error 22: Array or pointer required for '[]' operation main.c:215: error 20: Undefined identifier 'toggle_state' main.c:215: error 22: Array or pointer required for '[]' operation main.c:220: error 20: Undefined identifier 'toggle_state' main.c:220: error 22: Array or pointer required for '[]' operation main.c:223: error 20: Undefined identifier 'toggle_state' main.c:223: error 22: Array or pointer required for '[]' operation make: *** [_output/main.o] Error 1 they are: line 215 toggle_state[array_index] ^= (1 << bit_index); // '^' is a XOR operation line 220 MIOS_MIDI_TxBufferPut((toggle_state[array_index] & (1 << bit_index)) ? 0x7f : 0x00); line 223 MIOS_DOUT_PinSet(pin, (toggle_state[array_index] & (1 << bit_index)) ? 0x7f : 0x00);what did i do wrong? what about the warning 117 message? what should i do?any helps will be very appeciated...regards,anto Quote
nILS Posted October 10, 2009 Report Posted October 10, 2009 Where (and how) is toggle_state defined? Quote
axiomriddler Posted October 11, 2009 Author Report Posted October 11, 2009 Where (and how) is toggle_state defined?what do you mean?..(if i didn't misunderstand), i put it in the main.c as follows:void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam { unsigned char array_index; unsigned char bit_index; // DIN 16..63 should toggle if( pin >= 16 && pin <= 63 ) { if( pin_value == 0 ) { // only react when button is pressed // determine the index of the array element (starts from 0) array_index = (pin - 16) >> 3; // fastest way to divide value / 8; // determine bit position bit_index = (pin - 16) & 0x07; // remainder of x/8 // toggle the flag which saves the current button state toggle_state[array_index] ^= (1 << bit_index); // '^' is a XOR operation // send MIDI Note event depending on toggle state MIOS_MIDI_TxBufferPut(0x90); MIOS_MIDI_TxBufferPut(0x30 + pin - 16); MIOS_MIDI_TxBufferPut((toggle_state[array_index] & (1 << bit_index)) ? 0x7f : 0x00); // set LED (same pin number like button) MIOS_DOUT_PinSet(pin, (toggle_state[array_index] & (1 << bit_index)) ? 0x7f : 0x00); } } else { // this branch handles DIN 0..15 and DIN 64..127 } }is that what you mean?thanks heaps for your response :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.