|
Here's a short program to display the battery voltage. The get_battery_mv()
interface might be useful in the kernel itself. Would it be appropriate for
the kernel to turn on the low battery indicator as well? The A/D converter
that the RCX uses to measure this is pretty accurate. I compared the output
against a Fluke multimeter and the RCX was consistently within 0.05v.
While writing this it occured to me that cls() would be more useful if it also
cleared the dots in the number output area. Does that sound like a good idea?
I can submit the trivial diff if so...
#include <dsensor.h>
#include <dlcd.h>
#include <conio.h>
int
get_battery_mv()
{
long b;
int mv;
b = BATTERY;
b = ds_scale(b) * 0xABD4L;
mv = b / 0x618L;
return mv;
}
int
main(int ac, char **av)
{
int b;
b = get_battery_mv() / 100;
cls();
cputc_hex_3(b / 10);
cputc_hex_2(b % 10);
dlcd_show(LCD_3_DOT);
cputc_1('v');
sleep(5);
dlcd_hide(LCD_3_DOT);
cls();
}
|
|
Message has 1 Reply: | | Re: useful battery program
|
| Ben Jackson schrieb: (...) Yes, this is a good idea. The system timer handler will probably become a C routine, anyway, as it does so many things now. It might as well check for low battery power and display it. I was thinking about a configuration (...) (25 years ago, 12-Jan-00, to lugnet.robotics.rcx.legos)
|
4 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|