cwIo.h/cpp : Include timer index in timer callback record.

This commit is contained in:
kevin 2023-05-09 07:29:43 -04:00
parent d094a551ae
commit 136d2974a9
2 changed files with 9 additions and 2 deletions

View File

@ -55,6 +55,7 @@ namespace cw
bool startedFl;
char* label;
unsigned id;
unsigned index;
unsigned periodMicroSec;
bool asyncFl;
} timer_t;
@ -298,6 +299,7 @@ namespace cw
timer_msg_t tm;
tm.id = t->id;
tm.index = t->index;
m.tid = kTimerTId;
m.u.timer = &tm;
@ -312,12 +314,14 @@ namespace cw
{
rc_t rc = kOkRC;
timer_t* t = nullptr;
unsigned timer_idx = kInvalidIdx;
// look for a deleted timer
for(unsigned i=0; i<p->timerN; ++i)
if( p->timerA[i].deletedFl )
{
t = p->timerA + i;
timer_idx = i;
break;
}
@ -331,6 +335,7 @@ namespace cw
// keep a pointer to the empty slot
t = tA + p->timerN;
timer_idx = p->timerN;
// update the timer array
mem::release( p->timerA );
@ -343,6 +348,7 @@ namespace cw
t->io = p;
t->label = mem::duplStr(label);
t->id = id;
t->index = timer_idx;
t->asyncFl = asyncFl;
t->periodMicroSec = periodMicroSec;
@ -594,7 +600,7 @@ namespace cw
m.u.midi = &mm;
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)

3
cwIo.h
View File

@ -47,7 +47,8 @@ namespace cw
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;
typedef struct serial_msg_str