Library to use my Photo MOS Relays Circuit having 16 or less channels.
Fork of PMRC4ch by
Diff: PMRC16ch.cpp
- Revision:
- 44:20a890fe5f83
- Parent:
- 43:03e875137433
- Child:
- 47:a097e670a983
--- a/PMRC16ch.cpp Tue Nov 20 20:55:37 2018 +0000 +++ b/PMRC16ch.cpp Tue Oct 29 02:43:14 2019 +0000 @@ -80,8 +80,11 @@ // ---------------------------------------------------------------------------- void PMRC16ch::setTwin(char arg_stim_ch, char arg_ref_ch) { + uint32_t l_state = m_PMRC_state; + m_PMRC_state = m_statearray[arg_stim_ch] | (m_statearray[arg_ref_ch] >> 1); + if(l_state == m_PMRC_state) return; + m_PMRC_mode = TWIN_ELECTRODES; - m_PMRC_state = m_statearray[arg_stim_ch] + (m_statearray[arg_ref_ch] >> 1); setBits(m_PMRC_state); upload(); m_pos_stim = arg_stim_ch; @@ -91,8 +94,8 @@ { m_PMRC_mode = TWIN_ELECTRODES; m_PMRC_state = m_statearray[arg_stim_ch] - + (m_statearray[arg_ref_ch1] >> 1) - + (m_statearray[arg_ref_ch2] >> 1); + | (m_statearray[arg_ref_ch1] >> 1) + | (m_statearray[arg_ref_ch2] >> 1); setBits(m_PMRC_state); upload(); m_pos_stim = arg_stim_ch; @@ -112,7 +115,7 @@ } shiftby(num_of_shift); m_PMRC_mode = ONE_VS_THEOTHERS; - m_PMRC_state = ALLGROUND + m_statearray[arg_ch]; + m_PMRC_state = ALLGROUND | m_statearray[arg_ch]; upload(); m_pos_stim = arg_ch; @@ -167,11 +170,11 @@ update(); //enable insertion data to SR m_CLR = 1; - for(int i = 0; i < m_num_ch; i++) { + for(int i = 16 - m_num_ch; i < 16; i++) { tmp_bit[0] = 0b01 & (arg_bits >> (2 * i)); tmp_bit[1] = 0b01 & (arg_bits >> (2 * i + 1)); // if the chan. is not HiZ meaning Hi or Lw - if(tmp_bit[0] + tmp_bit[1] == 1) { + if(tmp_bit[0] | tmp_bit[1] == 0b01) { m_SER = (tmp_bit[0] ^ m_PMRC_POL); //XOR Polarity update(); m_SER = (tmp_bit[1] ^ m_PMRC_POL); //XOR Polarity