summaryrefslogtreecommitdiff
path: root/library
authorkergoth <kergoth>2003-01-26 03:42:35 (UTC)
committer kergoth <kergoth>2003-01-26 03:42:35 (UTC)
commit5ebc867249ffa7cdfb23d912426cbd8d75e7177b (patch) (unidiff)
treec97ca26ed9f757d35c32eacea241848f0f57520d /library
parente5e79961e2997848e7b6eb9515e1616effb6edab (diff)
downloadopie-5ebc867249ffa7cdfb23d912426cbd8d75e7177b.zip
opie-5ebc867249ffa7cdfb23d912426cbd8d75e7177b.tar.gz
opie-5ebc867249ffa7cdfb23d912426cbd8d75e7177b.tar.bz2
Remove the Sharp battery % read hack, not necessary in recent OZ, and supporting the stock Sharp ROM in our libqpe isnt important.
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/power.cpp61
1 files changed, 2 insertions, 59 deletions
diff --git a/library/power.cpp b/library/power.cpp
index ec5b309..21c8960 100644
--- a/library/power.cpp
+++ b/library/power.cpp
@@ -117,78 +117,24 @@ bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, i
117 break; 117 break;
118 case 0x02: 118 case 0x02:
119 ps->ac = PowerStatus::Backup; 119 ps->ac = PowerStatus::Backup;
120 break; 120 break;
121 } 121 }
122 122
123 if ( pc > 100 ) 123 if ( pc > 100 ) pc = 100;
124 pc = -1; 124 if ( pc < 0 ) pc = 0;
125 125
126 ps->percentRemain = pc; 126 ps->percentRemain = pc;
127 ps->secsRemain = sec; 127 ps->secsRemain = sec;
128 128
129 ok = true; 129 ok = true;
130 } 130 }
131 131
132 return ok; 132 return ok;
133} 133}
134 134
135#ifdef QT_QWS_SHARP
136
137void PowerStatusManager::getStatus()
138{
139 int ac, bs, bf, pc, sec;
140 ps->percentAccurate = TRUE; // not for long...
141
142 if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) {
143 // special case
144 if ( bs == 0x7f )
145 ps->bs = PowerStatus::VeryLow;
146 pc = -1; // fake percentage
147 if ( pc < 0 ) {
148 switch ( bs ) {
149 case 0x00: ps->percentRemain = 100; break; // High
150 case 0x01: ps->percentRemain = 30; break; // Low
151 case 0x7f: ps->percentRemain = 10; break; // Very Low
152 case 0x02: ps->percentRemain = 5; break; // Critical
153 case 0x03: ps->percentRemain = -1; break; // Charging
154 }
155 ps->percentAccurate = FALSE;
156 }
157 }
158
159 char *device = "/dev/apm_bios";
160 int fd = ::open (device, O_WRONLY);
161 if ( fd >= 0 ) {
162 int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 );
163 switch ( bbat_status ) {
164 case 0x00:
165 ps->bbs = PowerStatus::High;
166 break;
167 case 0x01:
168 ps->bbs = PowerStatus::Low;
169 break;
170 case 0x7f:
171 ps->bbs = PowerStatus::VeryLow;
172 break;
173 case 0x02:
174 ps->bbs = PowerStatus::Critical;
175 break;
176 case 0x03:
177 ps->bbs = PowerStatus::Charging;
178 break;
179 case 0x04:
180 ps->bbs = PowerStatus::NotPresent;
181 break;
182 }
183 ::close(fd);
184 }
185}
186
187#else
188
189void PowerStatusManager::getStatus() 135void PowerStatusManager::getStatus()
190{ 136{
191 bool usedApm = FALSE; 137 bool usedApm = FALSE;
192 138
193 ps->percentAccurate = TRUE; 139 ps->percentAccurate = TRUE;
194 140
@@ -220,9 +166,6 @@ void PowerStatusManager::getStatus()
220 ps->percentRemain = 100; 166 ps->percentRemain = 100;
221 ps->secsRemain = -1; 167 ps->secsRemain = -1;
222 ps->percentAccurate = FALSE; 168 ps->percentAccurate = FALSE;
223#endif 169#endif
224 } 170 }
225} 171}
226
227#endif
228