@@ -53,14 +53,14 @@ void loop() {
5353
5454 Serial.println ();
5555 // Write the status value to On to all the Output Pins
56- setAll (SWITCH_ON );
56+ digital_programmables. writeAll (SWITCH_ON_ALL );
5757
5858 // Reads from all Input Pins
5959 readAll ();
6060 delay (1000 );
6161
6262 // Write the status value to Off all to all the Output Pins
63- setAll (SWITCH_OFF );
63+ digital_programmables. writeAll (SWITCH_OFF_ALL );
6464
6565 // Reads from all Input Pins
6666 readAll ();
@@ -69,43 +69,30 @@ void loop() {
6969
7070}
7171
72- void setAll (PinStatus status) {
73- // Write the status value to each Pin
74- digital_programmables.set (IO_WRITE_CH_PIN_00, status);
75- digital_programmables.set (IO_WRITE_CH_PIN_01, status);
76- digital_programmables.set (IO_WRITE_CH_PIN_02, status);
77- digital_programmables.set (IO_WRITE_CH_PIN_03, status);
78- digital_programmables.set (IO_WRITE_CH_PIN_04, status);
79- digital_programmables.set (IO_WRITE_CH_PIN_05, status);
80- digital_programmables.set (IO_WRITE_CH_PIN_06, status);
81- digital_programmables.set (IO_WRITE_CH_PIN_07, status);
82- digital_programmables.set (IO_WRITE_CH_PIN_08, status);
83- digital_programmables.set (IO_WRITE_CH_PIN_09, status);
84- digital_programmables.set (IO_WRITE_CH_PIN_10, status);
85- digital_programmables.set (IO_WRITE_CH_PIN_11, status);
86- }
8772
8873void readAll () {
89- // Reads from input pins. This API returns -1 if you try to read from a write channel.
90- Serial.println (" IO Pin 00: " + String (digital_programmables.read (IO_READ_CH_PIN_00)));
91- Serial.println (" IO Pin 01: " + String (digital_programmables.read (IO_READ_CH_PIN_01)));
92- Serial.println (" IO Pin 02: " + String (digital_programmables.read (IO_READ_CH_PIN_02)));
93- Serial.println (" IO Pin 03: " + String (digital_programmables.read (IO_READ_CH_PIN_03)));
94- Serial.println (" IO Pin 04: " + String (digital_programmables.read (IO_READ_CH_PIN_04)));
95- Serial.println (" IO Pin 05: " + String (digital_programmables.read (IO_READ_CH_PIN_05)));
96- Serial.println (" IO Pin 06: " + String (digital_programmables.read (IO_READ_CH_PIN_06)));
97- Serial.println (" IO Pin 07: " + String (digital_programmables.read (IO_READ_CH_PIN_07)));
98- Serial.println (" IO Pin 08: " + String (digital_programmables.read (IO_READ_CH_PIN_08)));
99- Serial.println (" IO Pin 09: " + String (digital_programmables.read (IO_READ_CH_PIN_09)));
100- Serial.println (" IO Pin 10: " + String (digital_programmables.read (IO_READ_CH_PIN_10)));
101- Serial.println (" IO Pin 11: " + String (digital_programmables.read (IO_READ_CH_PIN_11)));
74+ uint32_t inputs = digital_programmables.readAll ();
75+ Serial.println (" CH00: " + String ((inputs & (1 << IO_READ_CH_PIN_00)) >> IO_READ_CH_PIN_00));
76+ Serial.println (" CH01: " + String ((inputs & (1 << IO_READ_CH_PIN_01)) >> IO_READ_CH_PIN_01));
77+ Serial.println (" CH02: " + String ((inputs & (1 << IO_READ_CH_PIN_02)) >> IO_READ_CH_PIN_02));
78+ Serial.println (" CH03: " + String ((inputs & (1 << IO_READ_CH_PIN_03)) >> IO_READ_CH_PIN_03));
79+ Serial.println (" CH04: " + String ((inputs & (1 << IO_READ_CH_PIN_04)) >> IO_READ_CH_PIN_04));
80+ Serial.println (" CH05: " + String ((inputs & (1 << IO_READ_CH_PIN_05)) >> IO_READ_CH_PIN_05));
81+ Serial.println (" CH06: " + String ((inputs & (1 << IO_READ_CH_PIN_06)) >> IO_READ_CH_PIN_06));
82+ Serial.println (" CH07: " + String ((inputs & (1 << IO_READ_CH_PIN_07)) >> IO_READ_CH_PIN_07));
83+ Serial.println (" CH08: " + String ((inputs & (1 << IO_READ_CH_PIN_08)) >> IO_READ_CH_PIN_08));
84+ Serial.println (" CH09: " + String ((inputs & (1 << IO_READ_CH_PIN_09)) >> IO_READ_CH_PIN_09));
85+ Serial.println (" CH10: " + String ((inputs & (1 << IO_READ_CH_PIN_10)) >> IO_READ_CH_PIN_10));
86+ Serial.println (" CH11: " + String ((inputs & (1 << IO_READ_CH_PIN_11)) >> IO_READ_CH_PIN_11));
87+ Serial.println ();
88+ inputs = digital_inputs.readAll ();
89+ Serial.println (" CH00: " + String ((inputs & (1 << DIN_READ_CH_PIN_00)) >> DIN_READ_CH_PIN_00));
90+ Serial.println (" CH01: " + String ((inputs & (1 << DIN_READ_CH_PIN_01)) >> DIN_READ_CH_PIN_01));
91+ Serial.println (" CH02: " + String ((inputs & (1 << DIN_READ_CH_PIN_02)) >> DIN_READ_CH_PIN_02));
92+ Serial.println (" CH03: " + String ((inputs & (1 << DIN_READ_CH_PIN_03)) >> DIN_READ_CH_PIN_03));
93+ Serial.println (" CH04: " + String ((inputs & (1 << DIN_READ_CH_PIN_04)) >> DIN_READ_CH_PIN_04));
94+ Serial.println (" CH05: " + String ((inputs & (1 << DIN_READ_CH_PIN_05)) >> DIN_READ_CH_PIN_05));
95+ Serial.println (" CH06: " + String ((inputs & (1 << DIN_READ_CH_PIN_06)) >> DIN_READ_CH_PIN_06));
96+ Serial.println (" CH07: " + String ((inputs & (1 << DIN_READ_CH_PIN_07)) >> DIN_READ_CH_PIN_07));
10297 Serial.println ();
103- Serial.println (" DIN Pin 00: " + String (digital_inputs.read (DIN_READ_CH_PIN_00)));
104- Serial.println (" DIN Pin 01: " + String (digital_inputs.read (DIN_READ_CH_PIN_01)));
105- Serial.println (" DIN Pin 02: " + String (digital_inputs.read (DIN_READ_CH_PIN_02)));
106- Serial.println (" DIN Pin 03: " + String (digital_inputs.read (DIN_READ_CH_PIN_03)));
107- Serial.println (" DIN Pin 04: " + String (digital_inputs.read (DIN_READ_CH_PIN_04)));
108- Serial.println (" DIN Pin 05: " + String (digital_inputs.read (DIN_READ_CH_PIN_05)));
109- Serial.println (" DIN Pin 06: " + String (digital_inputs.read (DIN_READ_CH_PIN_06)));
110- Serial.println (" DIN Pin 07: " + String (digital_inputs.read (DIN_READ_CH_PIN_07)));
11198}
0 commit comments