我在指针世界中有点迷路:-) 使用传递一个数来读取值readSystemVal的工作原理就像是一个魅力,但现在我想写给这些使用writeSystemVal的变量。丢失在pointerworld中,通过数组写入到变量
无法真正找到我应该做的事情: * systemVal将地址保存在变量中,但是如何将其值写入它?
你会好看吗?
(系统:AVR,蚀,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;
*/
}
你可能在寻找'* systemVal = ctrlValue;'? – Angew
将事物铸造成现有类型只会导致混乱和潜在的未来错误。 – molbdnilo