So, mein Controller ist jetzt fertig! Er besteht aus 32 Potis und 64 Tastern mit zugehörigen LEDs. Ich habe nun das MIOS und mein Programm erfolgreich installiert. Die Potis funktionieren einwandfrei, allerdings habe ich ein Problem mit den Tastern und den LEDs: Bei Druck auf die Taster passiert erst einmal gar nichts... Ich empfange weder ein Midi-Signal, noch wird irgendeine LED aktiviert. Wenn ich viele Taster hintereinander betätige, werden plötzlich alle Aktivierungen per Midi auf einmal übertragen (Aufstauung der Befehle??). Die LEDs werden immer noch nicht gesetzt. Was mir leider erst im Nachhinein aufgefallen ist: Ich habe Taster in Schalterform verbaut (Aktivierung -> Wechsel der Spannung, beim Loslassen allerdings nicht zurück). Das sollte technisch gesehen allerdings kein Problem sein, oder? Die Funktion "DIN_NotifyToggle" sollte ja trotzdem aufgerufen werden. Ich habe nochmal alles mit einem Multimeter ausgemessen. Die Buttons reagieren einwandfrei... mittlerweile komme ich nicht mehr weiter mit diesem Problem:( Über Hilfe würde ich mich sehr freuen!! Ich sende nochmal meinen gesamten C-Quellcode mit, vielleicht steckt da ja der Wurm drin /*
* MIOS SDCC Wrapper
*
* ==========================================================================
*
* Copyright (C) <year> <name> (<email>)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
#include "cmios.h"
#include "pic18f452.h"
// Belegung der Potis (127 Werte, Course)
const unsigned char pot_event_map[32][2] = {
// Pot 1..16 send CC#0x11 (General Purpose Slider1) over MIDI Channel #1..16 {0xb0, 0x5b}, {0xb1, 0x5b}, {0xb2, 0x5b}, {0xb3, 0x5b},
{0xb0, 0x11}, {0xb1, 0x11}, {0xb2, 0x11}, {0xb3, 0x11},
{0xb4, 0x11}, {0xb5, 0x11}, {0xb6, 0x11}, {0xb7, 0x11},
{0xb8, 0x11}, {0xb9, 0x11}, {0xba, 0x11}, {0xbb, 0x11},
{0xbc, 0x11}, {0xbd, 0x11}, {0xbe, 0x11}, {0xbf, 0x11},
// Pot 17..32 send CC#0x12 (General Purpose Slider2) over MIDI Channel #1..16
{0xb0, 0x12}, {0xb1, 0x12}, {0xb2, 0x12}, {0xb3, 0x12},
{0xb4, 0x12}, {0xb5, 0x12}, {0xb6, 0x12}, {0xb7, 0x12},
{0xb8, 0x12}, {0xb9, 0x12}, {0xba, 0x12}, {0xbb, 0x12},
{0xbc, 0x12}, {0xbd, 0x12}, {0xbe, 0x12}, {0xbf, 0x12},
};
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
MIOS_SRIO_UpdateFrqSet(1); // set shift register update frequency (ms)
MIOS_AIN_NumberSet(32); // 32 pots are connected
MIOS_AIN_Muxed(); // the AINX4 modules are used
MIOS_AIN_DeadbandSet(7); // should be 7 when 7bit resolution is used
MIOS_SRIO_NumberSet(8); // set IO shift registers for 64 pins
MIOS_SRIO_DebounceSet(10); // debouncing value for DINs
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS in the mainloop when nothing else is to do
/////////////////////////////////////////////////////////////////////////////
void Tick(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is periodically called by MIOS. The frequency has to be
// initialized with MIOS_Timer_Set
/////////////////////////////////////////////////////////////////////////////
void Timer(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when the display content should be
// initialized. Thats the case during startup and after a temporary message
// has been printed on the screen
/////////////////////////////////////////////////////////////////////////////
void DISPLAY_Init(void) __wparam
{
MIOS_LCD_Clear();
MIOS_LCD_CursorSet(0x00);
MIOS_LCD_PrintCString("Hello World!");
}
/////////////////////////////////////////////////////////////////////////////
// This function is called in the mainloop when no temporary message is shown
// on screen. Print the realtime messages here
/////////////////////////////////////////////////////////////////////////////
void DISPLAY_Tick(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI event has been received
// which has been specified in the MIOS_MPROC_EVENT_TABLE
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyFoundEvent(unsigned entry, unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI event has not been completly
// received within 2 seconds
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyTimeout(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI byte has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedByte(unsigned char byte) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS before the shift register are loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Prepare(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after the shift register have been loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Finish(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// 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
{
// Midi Events senden
MIOS_MIDI_TxBufferPut(0x90); // Note Event at channel #1
MIOS_MIDI_TxBufferPut(pin); // just forward the pin number (0..127)
MIOS_MIDI_TxBufferPut(0x7f); // Velocity = 0x7f when button pressed
// verknüpfte Buttons 1-32 (von 0 ab gezählt)
if(pin < 32)
{
MIOS_DOUT_SRSet(0, 0x00); //löschen der ersten 32 LEDs (von 0 ab gezählt)
MIOS_DOUT_SRSet(1, 0x00);
MIOS_DOUT_SRSet(2, 0x00);
MIOS_DOUT_SRSet(3, 0x00);
MIOS_DOUT_PinSet1(pin); //Setzen der zugehörigen LED
}
// die übrigen Buttons toggeln die LEDs
else
{
if(MIOS_DOUT_PinGet(pin)==0) // LED aus -> LED an
MIOS_DOUT_PinSet1(pin);
else // LED an -> LED aus
MIOS_DOUT_PinSet0(pin);
}
}
/////////////////////////////////////////////////////////////////////////////
// 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
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{
MIOS_MIDI_TxBufferPut(pot_event_map[pin][0]); // first value from table
MIOS_MIDI_TxBufferPut(pot_event_map[pin][1]); // second value from table
MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // 7bit pot value
}
Grüße Joscha