@@ -17,7 +17,7 @@ const char STRING_SERIAL[] PROGMEM = "UPS10";
17
17
const byte bDeviceChemistry = IDEVICECHEMISTRY;
18
18
const byte bOEMVendor = IOEMVENDOR;
19
19
20
- uint16_t iPresentStatus = 0 , iPreviousStatus = 0 ;
20
+ PresentStatus iPresentStatus = {} , iPreviousStatus = {} ;
21
21
22
22
byte bRechargable = 1 ;
23
23
byte bCapacityMode = 2 ; // units are in %%
@@ -108,54 +108,54 @@ void loop() {
108
108
109
109
// Charging
110
110
if (bCharging)
111
- bitSet ( iPresentStatus,PRESENTSTATUS_CHARGING) ;
111
+ iPresentStatus. CHARGING = 1 ;
112
112
else
113
- bitClear ( iPresentStatus,PRESENTSTATUS_CHARGING) ;
113
+ iPresentStatus. CHARGING = 0 ;
114
114
if (bACPresent)
115
- bitSet ( iPresentStatus,PRESENTSTATUS_ACPRESENT) ;
115
+ iPresentStatus. ACPRESENT = 1 ;
116
116
else
117
- bitClear ( iPresentStatus,PRESENTSTATUS_ACPRESENT) ;
117
+ iPresentStatus. ACPRESENT = 0 ;
118
118
if (iRemaining == iFullChargeCapacity)
119
- bitSet ( iPresentStatus,PRESENTSTATUS_FULLCHARGE) ;
119
+ iPresentStatus. FULLCHARGE = 1 ;
120
120
else
121
- bitClear ( iPresentStatus,PRESENTSTATUS_FULLCHARGE) ;
121
+ iPresentStatus. FULLCHARGE = 0 ;
122
122
123
123
// Discharging
124
124
if (bDischarging) {
125
- bitSet ( iPresentStatus,PRESENTSTATUS_DISCHARGING) ;
126
- // if(iRemaining < iRemnCapacityLimit) bitSet( iPresentStatus,PRESENTSTATUS_BELOWRCL) ;
125
+ iPresentStatus. DISCHARGING = 1 ;
126
+ // if(iRemaining < iRemnCapacityLimit) iPresentStatus.BELOWRCL = 1 ;
127
127
128
128
if (iRunTimeToEmpty < iRemainTimeLimit)
129
- bitSet ( iPresentStatus, PRESENTSTATUS_RTLEXPIRED) ;
129
+ iPresentStatus. RTLEXPIRED = 1 ;
130
130
else
131
- bitClear ( iPresentStatus, PRESENTSTATUS_RTLEXPIRED) ;
131
+ iPresentStatus. RTLEXPIRED = 0 ;
132
132
133
133
}
134
134
else {
135
- bitClear ( iPresentStatus,PRESENTSTATUS_DISCHARGING) ;
136
- bitClear ( iPresentStatus, PRESENTSTATUS_RTLEXPIRED) ;
135
+ iPresentStatus. DISCHARGING = 0 ;
136
+ iPresentStatus. RTLEXPIRED = 0 ;
137
137
}
138
138
139
139
// Shutdown requested
140
140
if (iDelayBe4ShutDown > 0 ) {
141
- bitSet ( iPresentStatus, PRESENTSTATUS_SHUTDOWNREQ) ;
141
+ iPresentStatus. SHUTDOWNREQ = 1 ;
142
142
Serial.println (" shutdown requested" );
143
143
}
144
144
else
145
- bitClear ( iPresentStatus, PRESENTSTATUS_SHUTDOWNREQ) ;
145
+ iPresentStatus. SHUTDOWNREQ = 0 ;
146
146
147
147
// Shutdown imminent
148
- if ((iPresentStatus & ( 1 << PRESENTSTATUS_SHUTDOWNREQ) ) ||
149
- (iPresentStatus & ( 1 << PRESENTSTATUS_RTLEXPIRED) )) {
150
- bitSet ( iPresentStatus, PRESENTSTATUS_SHUTDOWNIMNT) ;
148
+ if ((iPresentStatus. SHUTDOWNREQ ) ||
149
+ (iPresentStatus. RTLEXPIRED )) {
150
+ iPresentStatus. SHUTDOWNIMNT = 1 ;
151
151
Serial.println (" shutdown imminent" );
152
152
}
153
153
else
154
- bitClear ( iPresentStatus, PRESENTSTATUS_SHUTDOWNIMNT) ;
154
+ iPresentStatus. SHUTDOWNIMNT = 0 ;
155
155
156
156
157
157
158
- bitSet ( iPresentStatus ,PRESENTSTATUS_BATTPRESENT) ;
158
+ iPresentStatus. BATTPRESENT = 1 ;
159
159
160
160
161
161
0 commit comments