#define AIR_PRE 7 // number of secs before rise cycle
#define AIR_ON 3 // number of secs for breath
#define AIR_OFF 7 // number of secs between cycle
#define AIR_NUM 600 // number of cycles between test sequence
#define TEST_REST 5 // sleep between test sequence in seconds
#define SCAN_RATE 50000 // main iteration in msecs 

#define POWER power()
#define RPOWER powerr()
#define PUMP pump()
#define RPUMP pumpr()
#define GROUPS_N (mag*50) 
// #define STATE_N (mag*150) 

#define u1 1000
#define u2 2000
#define u3 3000
#define u4 4000
#define u5 5000

// Temporary fudge

#define u6 6000+GROUPS_N
#define u7 7000+GROUPS_N
#define u8 8000+GROUPS_N
#define u9 9000+GROUPS_N

#define u10 10000

#define u100 100000
#define u300 300000
#define u700 700000
#define u900 900000

// #define u1000 1000000-STATE_N

#define P1A pwave(150, 50, 150)

#define G1A group1(u7, u2, u9)
#define G1B group1(u7, u3, u9)
#define G1C group1(u7, u4, u9)
#define G1D group1(u7, u5, u9)
#define G1E group1(u7, u3, u100)
#define G1F group1(u8, u3, u100)

#define G2A group2(u7, u2, u9)
#define G2B group2(u7, u3, u9)
#define G2D group2(u7, u5, u9)
#define G2E group2(u7, u3, u9)
#define G2F group2(u8, u3, u100)

#define G3B group3(u7, u3, u9)
#define G3D group3(u7, u5, u9)
#define G3E group3(u7, u3, u9)
#define G3F group3(u8, u3, u7)
#define G3G group3(u8, u3, u100)
#define G3H group3(u8, u4, u100)

#define G4A group4(70000, 10000, 70000)

#define q1a   set_o(1,8)                /* (1)  set hv1a  solenoid */
#define q1b   set_o(1,9)                /* (2)  set hv1b  solenoid */
#define q2a   set_o(1,10)               /* (3)  set hv2a  solenoid */
#define q2b   set_o(1,11)               /* (4)  set hv2b  solenoid */
#define q3a   set_o(1,12)               /* (5)  set hv3a  solenoid */
#define q3b   set_o(1,13)               /* (6)  set hv3b  solenoid */
#define q4a   set_o(1,14)               /* (7)  set hv4a  solenoid */
#define q4b   set_o(1,15)               /* (8)  set hv4b  solenoid */
#define q5a   set_o(2,0)                /* (9)  set hv5a  solenoid */
#define q5b   set_o(2,1)                /* (10) set hv5b  solenoid */
#define q6a   set_o(2,2)                /* (11) set hv6a  solenoid */
#define q6b   set_o(2,3)                /* (12) set hv6b  solenoid */
#define q7a   set_o(2,4)                /* (13) set hv7a  solenoid */
#define q7b   set_o(2,5)                /* (14) set hv7b  solenoid */
#define q8a   set_o(2,6)                /* (15) set hv8a  solenoid */
#define q8b   set_o(2,7)                /* (16) set hv8b  solenoid */
#define q9a   set_o(2,8)                /* (17) set hv9a  solenoid */
#define q9b   set_o(2,9)                /* (18) set hv9b  solenoid */
#define q10a  set_o(2,10)               /* (19) set hv10a solenoid */
#define q10b  set_o(2,11)               /* (20) set hv10b solenoid */
#define q11a  set_o(2,12)               /* (21) set hv11a solenoid */
#define q11b  set_o(2,13)               /* (22) set hv11b solenoid */
#define q12a  set_o(2,14)               /* (23) set hv12a solenoid */
#define q12b  set_o(2,15)               /* (24) set hv12b solenoid */
#define q13a  set_o(0,0)                /* (25) set hv13a solenoid */
#define q13b  set_o(0,1)                /* (26) set hv13b solenoid */
#define q14a  set_o(0,2)                /* (27) set hv14a solenoid */
#define q14b  set_o(0,3)                /* (28) set hv14b solenoid */
#define q15a  set_o(0,4)                /* (29) set hv15a solenoid */
#define q15b  set_o(0,5)                /* (30) set hv15b solenoid */
#define q16a  set_o(0,6)                /* (31) set hv16a solenoid */
#define q16b  set_o(0,7)                /* (32) set hv16b solenoid */
#define q17a  set_o(0,8)                /* (33) set hv17a solenoid */
#define q17b  set_o(0,9)                /* (34) set hv17b solenoid */
#define q18a  set_o(0,10)               /* (35) set hv18a solenoid */
#define q18b  set_o(0,11)               /* (36) set hv18b solenoid */
#define q19a  set_o(0,12)               /* (37) set hv19a solenoid */
#define q19b  set_o(0,13)               /* (38) set hv19b solenoid */
#define q20a  set_o(0,14)               /* (39) set hv20a solenoid */
#define q20b  set_o(0,15)               /* (40) set hv20b solenoid */
#define q21a  set_o(1,0)                /* (41) set hv21a solenoid */
#define q21b  set_o(1,1)                /* (42) set hv21b solenoid */
#define qh1a  set_o(1,2)                /* (43) set hh1a  solenoid */
#define qh1b  set_o(1,3)                /* (44) set hh1b  solenoid */
#define qaa   set_o(1,4)                /* (45) set aira  solenoid */
#define qab   set_o(1,5)                /* (46) unused */
#define qpmp  set_o(1,6)                /* (47) set hpmp  pump solenoid */
#define qpow  set_o(1,7)                /* (48) set 3phv  mains power */   

#define cq1a  clr_o (1,8)               /* (1)  reset hv1a  solenoid */
#define cq1b  clr_o(1,9)                /* (2)  reset hv1b  solenoid */
#define cq2a  clr_o(1,10)               /* (3)  reset hv2a  solenoid */
#define cq2b  clr_o(1,11)               /* (4)  reset hv2b  solenoid */
#define cq3a  clr_o(1,12)               /* (5)  reset hv3a  solenoid */
#define cq3b  clr_o(1,13)               /* (6)  reset hv3b  solenoid */
#define cq4a  clr_o(1,14)               /* (7)  reset hv4a  solenoid */
#define cq4b  clr_o(1,15)               /* (8)  reset hv4b  solenoid */
#define cq5a  clr_o(2,0)                /* (9)  reset hv5a  solenoid */
#define cq5b  clr_o(2,1)                /* (10) reset hv5b  solenoid */
#define cq6a  clr_o(2,2)                /* (11) reset hv6a  solenoid */
#define cq6b  clr_o(2,3)                /* (12) reset hv6b  solenoid */
#define cq7a  clr_o(2,4)                /* (13) reset hv7a  solenoid */
#define cq7b  clr_o(2,5)                /* (14) reset hv7b  solenoid */
#define cq8a  clr_o(2,6)                /* (15) reset hv8a  solenoid */
#define cq8b  clr_o(2,7)                /* (16) reset hv8b  solenoid */
#define cq9a  clr_o(2,8)                /* (17) reset hv9a  solenoid */
#define cq9b  clr_o(2,9)                /* (18) reset hv9b  solenoid */
#define cq10a clr_o(2,10)               /* (19) reset hv10a solenoid */
#define cq10b clr_o(2,11)               /* (20) reset hv10b solenoid */
#define cq11a clr_o(2,12)               /* (21) reset hv11a solenoid */
#define cq11b clr_o(2,13)               /* (22) reset hv11b solenoid */
#define cq12a clr_o(2,14)               /* (23) reset hv12a solenoid */
#define cq12b clr_o(2,15)               /* (24) reset hv12b solenoid */
#define cq13a clr_o(0,0)                /* (25) reset hv13a solenoid */
#define cq13b clr_o(0,1)                /* (26) reset hv13b solenoid */
#define cq14a clr_o(0,2)                /* (27) reset hv14a solenoid */
#define cq14b clr_o(0,3)                /* (28) reset hv14b solenoid */
#define cq15a clr_o(0,4)                /* (29) reset hv15a solenoid */
#define cq15b clr_o(0,5)                /* (30) reset hv15b solenoid */
#define cq16a clr_o(0,6)                /* (31) reset hv16a solenoid */
#define cq16b clr_o(0,7)                /* (32) reset hv16b solenoid */
#define cq17a clr_o(0,8)                /* (33) reset hv17a solenoid */
#define cq17b clr_o(0,9)                /* (34) reset hv17b solenoid */
#define cq18a clr_o(0,10)               /* (35) reset hv18a solenoid */
#define cq18b clr_o(0,11)               /* (36) reset hv18b solenoid */
#define cq19a clr_o(0,12)               /* (37) reset hv19a solenoid */
#define cq19b clr_o(0,13)               /* (38) reset hv19b solenoid */
#define cq20a clr_o(0,14)               /* (39) reset hv20a solenoid */
#define cq20b clr_o(0,15)               /* (40) reset hv20b solenoid */
#define cq21a clr_o(1,0)                /* (41) reset hv21a solenoid */
#define cq21b clr_o(1,1)                /* (42) reset hv21b solenoid */
#define cqh1a clr_o(1,2)                /* (43) reset hha   solenoid */
#define cqh1b clr_o(1,3)                /* (44) reset hhb   solenoid */
#define cqaa  clr_o(1,4)                /* (45) reset aira  solenoid */
#define cqab  clr_o(1,5)                /* (46) unused */
#define cqpmp clr_o(1,6)                /* (47) reset hpmp  pump solenoid */
#define cqpow clr_o(1,7)                /* (48) reset 3phv  mains power */    
