Main Page
Related Pages
Modules
Classes
Files
File List
File Members
battery.c
Go to the documentation of this file.
1
6
/*
7
* The contents of this file are subject to the Mozilla Public License
8
* Version 1.0 (the "License"); you may not use this file except in
9
* compliance with the License. You may obtain a copy of the License
10
* at http://www.mozilla.org/MPL/
11
*
12
* Software distributed under the License is distributed on an "AS IS"
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
* the License for the specific language governing rights and
15
* limitations under the License.
16
*
17
* The Original Code is legOS code, released October 17, 1999.
18
*
19
* The Initial Developer of the Original Code is Markus L. Noga.
20
* Portions created by Markus L. Noga are Copyright (C) 1999
21
* Markus L. Noga. All Rights Reserved.
22
*
23
* Contributor(s): Markus L. Noga <markus@noga.de>
24
* Paolo Masetti <paolo.masetti@itlug.org>
25
*/
26
27
#include <
sys/irq.h
>
28
#include <dsensor.h>
29
#include <
dlcd.h
>
30
31
#include <
sys/battery.h
>
32
34
//
35
// Global Variables
36
//
38
#ifdef CONF_BATTERY_INDICATOR
39
unsigned
int
battery_refresh_counter = 0;
40
unsigned
int
battery_refresh_period = 2000;
41
#endif
42
44
//
45
// Functions
46
//
48
50
#if defined(CONF_DSENSOR)
51
int
get_battery_mv
()
52
{
53
long
b =
ds_scale
(
BATTERY
) * 0xABD4L;
54
return
(
int
)(b / 0x618L);
55
}
56
#endif // CONF_DSENSOR
57
58
#ifdef CONF_BATTERY_INDICATOR
59
// battery indicator handed by kernel task when CONF_TM
60
#ifndef CONF_TM
61
62
#ifdef CONF_RCX_COMPILER
63
void
battery_refresh
(
void
) {
64
#else // CONF_RCX_COMPILER
65
HANDLER_WRAPPER
(
"battery_refresh"
,
"battery_refresh_core"
);
66
void
battery_refresh_core(
void
) {
67
#endif // CONF_RCX_COMPILER
68
int
bmv =
get_battery_mv
();
69
70
if
(bmv >
BATTERY_NORMAL_THRESHOLD_MV
)
71
dlcd_hide
(
LCD_BATTERY_X
);
72
else
if
(bmv >
BATTERY_LOW_THRESHOLD_MV
)
73
dlcd_show
(
LCD_BATTERY_X
);
74
}
75
#endif // CONF_TM
76
#endif // CONF_BATTERY_INDICATOR
brickOS
is released under the
Mozilla Public License
.
Original code copyright 1998-2005 by the authors.
Generated on Sat Mar 15 2014 11:28:21 for brickOS Kernel Developer by
1.8.1.2