我在指针世界中有点迷失 :-) 通过使用将数字传递给 readSystemVal 来读取值就像一个魅力,但现在我想使用 writeSystemVal 写入这些变量。
无法真正找到我应该做的事情:*systemVal 将地址保存到变量但我如何将我的值写入它?
你会这么好心看看吗?
(系统:AVR、eclipse、atmega644)
// User Changeable variables
uint8_t MIDIchan1 = 0; // midichannel osc 1
uint8_t MIDIchan2 = 1; // midichannel osc 2
uint8_t MIDIchan3 = 2; // midichannel osc 3
uint8_t pbRange = 12; // pitchbend
uint8_t omniModus = 0x00; // 3 osc modus or 1 omni modus
uint8_t midiThru = 0x01; // midiTrhu on/off
uint8_t *systemValList[] = {&MIDIchan1, &MIDIchan2, &MIDIchan3, &pbRange, &omniModus, &midiThru};
//**************************************************
// readSystemVal
// DESCRIPTION:
// Hele simpele note off routine
//**************************************************
uint8_t readSystemVal (uint8_t systemItem)
{
uint8_t *systemVal = (uint8_t *)systemValList[(uint8_t)systemItem];
uint8_t returnVal = *systemVal;
return returnVal;
}
void writeSystemVal (uint8_t ctrlValue, uint8_t systemItem)
{
/*
uint8_t *systemVal = (uint8_t *)systemValList[(uint8_t)systemItem];
//uint8_t returnVal = *systemVal;
// systemVal = ctrlValue;
*/
}