cwIo.h/cpp : Include timer index in timer callback record.
This commit is contained in:
parent
d094a551ae
commit
136d2974a9
8
cwIo.cpp
8
cwIo.cpp
@ -55,6 +55,7 @@ namespace cw
|
|||||||
bool startedFl;
|
bool startedFl;
|
||||||
char* label;
|
char* label;
|
||||||
unsigned id;
|
unsigned id;
|
||||||
|
unsigned index;
|
||||||
unsigned periodMicroSec;
|
unsigned periodMicroSec;
|
||||||
bool asyncFl;
|
bool asyncFl;
|
||||||
} timer_t;
|
} timer_t;
|
||||||
@ -298,6 +299,7 @@ namespace cw
|
|||||||
timer_msg_t tm;
|
timer_msg_t tm;
|
||||||
|
|
||||||
tm.id = t->id;
|
tm.id = t->id;
|
||||||
|
tm.index = t->index;
|
||||||
m.tid = kTimerTId;
|
m.tid = kTimerTId;
|
||||||
m.u.timer = &tm;
|
m.u.timer = &tm;
|
||||||
|
|
||||||
@ -312,12 +314,14 @@ namespace cw
|
|||||||
{
|
{
|
||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
timer_t* t = nullptr;
|
timer_t* t = nullptr;
|
||||||
|
unsigned timer_idx = kInvalidIdx;
|
||||||
|
|
||||||
// look for a deleted timer
|
// look for a deleted timer
|
||||||
for(unsigned i=0; i<p->timerN; ++i)
|
for(unsigned i=0; i<p->timerN; ++i)
|
||||||
if( p->timerA[i].deletedFl )
|
if( p->timerA[i].deletedFl )
|
||||||
{
|
{
|
||||||
t = p->timerA + i;
|
t = p->timerA + i;
|
||||||
|
timer_idx = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +335,7 @@ namespace cw
|
|||||||
|
|
||||||
// keep a pointer to the empty slot
|
// keep a pointer to the empty slot
|
||||||
t = tA + p->timerN;
|
t = tA + p->timerN;
|
||||||
|
timer_idx = p->timerN;
|
||||||
|
|
||||||
// update the timer array
|
// update the timer array
|
||||||
mem::release( p->timerA );
|
mem::release( p->timerA );
|
||||||
@ -343,6 +348,7 @@ namespace cw
|
|||||||
t->io = p;
|
t->io = p;
|
||||||
t->label = mem::duplStr(label);
|
t->label = mem::duplStr(label);
|
||||||
t->id = id;
|
t->id = id;
|
||||||
|
t->index = timer_idx;
|
||||||
t->asyncFl = asyncFl;
|
t->asyncFl = asyncFl;
|
||||||
t->periodMicroSec = periodMicroSec;
|
t->periodMicroSec = periodMicroSec;
|
||||||
|
|
||||||
@ -594,7 +600,7 @@ namespace cw
|
|||||||
m.u.midi = &mm;
|
m.u.midi = &mm;
|
||||||
|
|
||||||
if((rc = _ioCallback( p, p->midiAsyncFl, &m )) !=kOkRC )
|
if((rc = _ioCallback( p, p->midiAsyncFl, &m )) !=kOkRC )
|
||||||
cwLogError(rc,"MIDI app callback failed.");
|
cwLogError(rc,"MIDI app callback failed: async fl:%i",p->midiAsyncFl);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for(unsigned j=0; j<pkt->msgCnt; ++j)
|
for(unsigned j=0; j<pkt->msgCnt; ++j)
|
||||||
|
3
cwIo.h
3
cwIo.h
@ -47,7 +47,8 @@ namespace cw
|
|||||||
|
|
||||||
typedef struct timer_msg_str
|
typedef struct timer_msg_str
|
||||||
{
|
{
|
||||||
unsigned id;
|
unsigned id; // timer id (as set in create)
|
||||||
|
unsigned index; // timer index as used by timer accessor functions
|
||||||
} timer_msg_t;
|
} timer_msg_t;
|
||||||
|
|
||||||
typedef struct serial_msg_str
|
typedef struct serial_msg_str
|
||||||
|
Loading…
Reference in New Issue
Block a user