Fraise  2.1
FRAmework for Interfacing Software and Electronics
switch.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Switch library for Fraise pic18f device
4  *
5  *
6  *********************************************************************
7  * Author Date Comment
8  *********************************************************************
9  * Antoine Rousseau march 2013 Original.
10  ********************************************************************/
11 /*
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 # MA 02110-1301, USA.
26 */
27 #ifndef _SWITCH__H_
28 #define _SWITCH__H_
29 
31 #include <fruit.h>
41 void switchSelectHW(unsigned char channel, unsigned char *port, unsigned char bit); // assign a port/bit to a channel ; bit is decimal (0-7)
42 #define SWITCH_SELECT_(num,connport,connbit) \
43  do { switchSelectHW(num,&PORT##connport,connbit); } while(0)
44 
47 
48 void switchInit();
49 // use next macro like this : SERVO_SET_PORT(0,K2); to assign switch_0 to K2 connector.
55 #define switchSelect(num,conn) do { \
56  pinModeDigitalIn(conn); \
57  CALL_FUN3(SWITCH_SELECT_,num,KPORT(conn),KBIT(conn)); } while(0)
58 
60 
63 
64 void switchService(void);
67 char switchSend(void);
69 
72 
73 void switchDeselect(unsigned char channel);
77 char switchGet(unsigned char chan);
79 
80 
82 #endif //
switchGet
char switchGet(unsigned char chan)
Get the state of a channel.
switchInit
void switchInit()
Call it once in setup()
switchDeselect
void switchDeselect(unsigned char channel)
Deselect a channel.
switchSend
char switchSend(void)
Call at the maximum rate you want to report switches.
fruit.h
switchService
void switchService(void)
Call in loop().