Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

kernel/battery.c

Go to the documentation of this file.
00001 
00006 /*
00007  *  The contents of this file are subject to the Mozilla Public License
00008  *  Version 1.0 (the "License"); you may not use this file except in
00009  *  compliance with the License. You may obtain a copy of the License
00010  *  at http://www.mozilla.org/MPL/
00011  *
00012  *  Software distributed under the License is distributed on an "AS IS"
00013  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00014  *  the License for the specific language governing rights and
00015  *  limitations under the License.
00016  *
00017  *  The Original Code is legOS code, released October 17, 1999.
00018  *
00019  *  The Initial Developer of the Original Code is Markus L. Noga.
00020  *  Portions created by Markus L. Noga are Copyright (C) 1999
00021  *  Markus L. Noga. All Rights Reserved.
00022  *
00023  *  Contributor(s): Markus L. Noga <markus@noga.de>
00024  *        Paolo Masetti  <paolo.masetti@itlug.org>
00025  */
00026 
00027 #include <sys/irq.h>
00028 #include <dsensor.h>
00029 #include <dlcd.h>
00030 
00031 #include <sys/battery.h>
00032 
00034 //
00035 // Global Variables
00036 //
00038 #ifdef CONF_BATTERY_INDICATOR
00039 unsigned int battery_refresh_counter = 0; 
00040 unsigned int battery_refresh_period  = 2000;  
00041 #endif
00042 
00044 //
00045 // Functions
00046 //
00048 
00050 #if defined(CONF_DSENSOR)
00051 int get_battery_mv()
00052 {
00053     long b = ds_scale(BATTERY) * 0xABD4L;
00054     return (int)(b / 0x618L);
00055 }
00056 #endif // CONF_DSENSOR
00057 
00058 #ifdef CONF_BATTERY_INDICATOR
00059 // battery indicator handed by kernel task when CONF_TM
00060 #ifndef CONF_TM
00061 
00062 #ifdef CONF_RCX_COMPILER
00063 void battery_refresh(void) {
00064 #else // CONF_RCX_COMPILER
00065 HANDLER_WRAPPER("battery_refresh","battery_refresh_core");
00066 void battery_refresh_core(void) {
00067 #endif // CONF_RCX_COMPILER
00068     int bmv = get_battery_mv();
00069 
00070     if (bmv > BATTERY_NORMAL_THRESHOLD_MV)
00071   dlcd_hide(LCD_BATTERY_X);
00072     else if (bmv > BATTERY_LOW_THRESHOLD_MV)
00073   dlcd_show(LCD_BATTERY_X);
00074 }
00075 #endif // CONF_TM
00076 #endif // CONF_BATTERY_INDICATOR

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2002 by the authors.

Generated on Mon Feb 16 21:02:10 2004 for brickOS Kernel Developer by doxygen 1.3.5