On 03/12/2017 11:37 AM, Gene Heskett wrote:
> On Sunday 12 March 2017 13:05:58 Sebastian Kuzminsky wrote:
>>>   1544 static int check_bit_changed(bool halpin, bool &newpin)
>>>   1545 {
>>>   1546     if (halpin != newpin) {
>>>   1547         newpin = halpin;
>>>   1548         return halpin;
>>>   1549     }
>>>   1550     return 0;
>>>   1551 }
>>>
>>> ...
>>>
>>>   1654     if (check_bit_changed(new_halui_data.program_pause,
>>> old_halui_data.program_pause) != 0)
>>>   1655         sendProgramPause();
>>>
>>> That line 1654 looks to me as if both edges would trigger the msg
>>> emc_task_plan_pause_msg to be send.
>>>
>>> Is that correct ?
>>
>> Almost.  Look at line 1548, if the pin has switched state it turns the
>> new state.  So that function returns True on a positive edge, only.
>>
> I must be getting dense Seb, but I read that snippet around 1548 as
> changing the return if they are not equal. Its not checking for a rising
> edge, its checking for in-equality. Or so it looks to me.

The check_bit_changed() function returns 0 if the old and the new bits 
are the same, but returns the *new* bit if they are different.

If the old bit is 0 and the new bit is 1 (rising edge) it returns 1.

If the old bit is 1 and the new bit is 0 (falling edge) it returns 0.


-- 
Sebastian Kuzminsky

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to