James & David,
Sorry it took me a bit. I came in with a headache last night and just went to sleep. :-\
I grabbed that skeleton, which appears to be the same app I’ve been seeing on the box every night. It looks like in that one, the “main” is the only changed file, so I’ll just paste it into a block here if that’s OK. That way someone else can also point out all the crap that’s wrong with it and help us both (3 actually). ;D
Warnings-
** I don’t know what the hell I’m doing
* I’ll go through a whole night of tossing lines or functions in different places to see the result, so there’s often stuff in there that serves no practical purpose (for others)
* Some things may be pasted from TK’s apps and I’ll occasionally change them to suit my needs. I skimmed over the comments and I think they still match up. (mine often have cusswords in them)
* I DON’T know what the hell I’m doing
Two things that appear to also be in there-
* A pin status check which triggers that “lightloop” sequence which I was using as a fancy “indicator”
* Incoming MIDI events which match the pot events also appear to be saved into another array (potsin) for some reason. I’m not sure what I was doing with that group. I keep a whole folder of skeleton mods, so if I can find anything else I’ll post.
Lastly-
* The screen draw (or just the pot values part) is probably sort of redundant. It gets called on init, then gets called again on AIN changes. Ideally, it probably should be somewhere else and maybe only draw the changed area, but it didn’t matter much on this. Thorsten’s apps obviously do it correctly, for a good reference. I think he’s usually got a “display update needed” variable which gets checked at more convenient intervals.
Hope there’s at least something in this mess that could maybe point you in the right direction.
Most of the C stuff I was messing with was for a small controller I built which has some unique needs “app-wise”. I’ve been planning to get some help here on the structure of it and will ask in the C forum when the time comes, but I was trying to get some of the individual routines running first anyway. A layout drawing is toward the bottom of this thread: http://www.midibox.org/forum/index.php?topic=8294.0
BTW- In an attempt to punish myself for killing my hard drive, I’ve bounced back to some assembler I was playing with on another box <grin>. I also just got a beta build of something thrown at me unexpectedly, which I’ll need to be spending time with, but I’m hoping to get back to that C stuff next week. Maybe we can arrive at some useful functions which haven’t been done yet and could be pasted as “building blocks” into other’s skeletons.
Take Care (and sorry for the forthcoming mess),
George
This was on a box with 8 pots (mux’d), 32 LEDs, 24 buttons, and a 40x2 LCD
/*
* 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"
unsigned char pots[8];
unsigned char potsin[8];
///////////////////Lights////////////////////////////////////////////////////
void lightloop(void) __wparam
{ unsigned char count;
for (count = 0 ; count<=0x1F ; count++)
MIOS_DOUT_PinSet1(count),
MIOS_Delay(60),
MIOS_DOUT_PinSet0(count),
MIOS_Delay(20);
}
///////////////////////////////////////////////////////////////////////////////
void showem(void) __wparam
{
int i,j,t;
for(i=0,j=6,t=4 ; i<=3 ; i++,j=j+10,t++)
{
MIOS_LCD_CursorSet(j);
MIOS_LCD_PrintBCD3(pots[i]);
MIOS_LCD_CursorSet(j+64);
MIOS_LCD_PrintBCD3(pots[t]);
}
}
/////////////////////////////////////////////////////////////////////////////
void potscan(void) __wparam
{
int k;
for(k=0 ; k<=7 ; k++)
pots[k] = MIOS_AIN_Pin7bitGet(k);
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
MIOS_AIN_NumberSet(8);
MIOS_AIN_Muxed();
MIOS_AIN_DeadbandSet(7);
MIOS_SRIO_UpdateFrqSet(1); // ms
MIOS_SRIO_NumberSet(4);
MIOS_SRIO_DebounceSet(10);
lightloop();
potscan();
}
/////////////////////////////////////////////////////////////////////////////
// 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(" Val- Val- Val- Val-");
MIOS_LCD_CursorSet(0x40);
MIOS_LCD_PrintCString(" Val- Val- Val- Val-");
showem();
}
/////////////////////////////////////////////////////////////////////////////
// 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
{
if(evnt1 == 0x07 && evnt0 >= 0xB0 && evnt0 <= 0xB7) { //checks for vol message on chans 1-8
potsin[(evnt0 ^ 0xB0)]=evnt2;
}
}
/////////////////////////////////////////////////////////////////////////////
// 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
{
while(!MIOS_DIN_PinGet(4)) //looks for the snap button being down
lightloop();
}
/////////////////////////////////////////////////////////////////////////////
// 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_BeginStream();
MIOS_MIDI_TxBufferPut(0xb0+pin); // pin= channel number OxB*
MIOS_MIDI_TxBufferPut(0x07); // volume cc message
MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit pin_value, but 7bit value
MIOS_MIDI_EndStream();
potscan();
showem();
}