a suggestion about inputs coded to be used with buttons

Post your requests and ideas on the future development of mikroC PRO for PIC.
Post Reply
Author
Message
tol87
Posts: 16
Joined: 08 Jul 2011 17:36

a suggestion about inputs coded to be used with buttons

#1 Post by tol87 » 09 Jul 2011 06:59

I find it very comfortable that I can assign states to individual pins in the port by assigning a value to the whole port:
PORTA = 0b00010000

Why wouldn't MikroC utilize the same principle for the digital input pins?
Instead of (PORTA.F0 == 0) {code...} a compiler could understand an instruction such as:
if (PORTA == 0b00000011) {code...}

That would be really handy for keypads and irregular communication sequences and no special libraries describing the keypad would be necessery.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: a suggestion about inputs coded to be used with buttons

#2 Post by zristic » 11 Jul 2011 08:47

Logically, it would be incorrect.
You should write it like this:

if ((PORTA & 0b00000011) == 0b00000011)

tol87
Posts: 16
Joined: 08 Jul 2011 17:36

Re: a suggestion about inputs coded to be used with buttons

#3 Post by tol87 » 11 Jul 2011 22:55

So that option already exists?

Post Reply

Return to “mikroC PRO for PIC Wish List”