Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

BatteryCheckControl.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_BatteryCheckControl_h_
00002 #define INCLUDED_BatteryCheckControl_h_
00003 
00004 #include "ControlBase.h"
00005 #include "Events/EventListener.h"
00006 
00007 //! When activated, this will print a battery report to stdout and light up LEDs to specify power level
00008 /*! The LEDs use the LedEngine::displayPercent() function, with minor/major style.  This means
00009  *  the left column (viewing the dog head on) will show the overall power level, and the
00010  *  right column will show the level within the tick lit up in the left column.  The more geeky
00011  *  among you may prefer to think of this as a two digit base 5 display.
00012  *
00013  *  This gives you pretty precise visual feedback as to remaining power (perhaps more than
00014  *  you really need, but it's as much a demo as a useful tool)
00015  *
00016  *  This is implemented as a Control instead of a Behavior on the assumption you
00017  *  wouldn't want to leave this running while you were doing other things (ie not
00018  *  in e-stop). But it definitely blurs the line between the two.
00019  */
00020 class BatteryCheckControl : public ControlBase, public EventListener {
00021 public:
00022   
00023   //!Constructor
00024   BatteryCheckControl() : ControlBase("Battery Check","Reports % power remaining, and gives details on console") {}
00025   
00026   //!Destructor
00027   virtual ~BatteryCheckControl() {}
00028   
00029   //!Prints a report to stdio and lights up the face to show battery level
00030   /*! keeps running until deactivated - will listen for power events and continue to update display */
00031   virtual ControlBase * activate(MC_ID display, Socket * gui);
00032   
00033   //! stops listening for power events and sets display to invalid
00034   virtual void pause();
00035   
00036   //! calls report()
00037   virtual void refresh();
00038   
00039   //! stops listening for power events and sets display to invalid
00040   virtual void deactivate();
00041   
00042   //! calls refresh() to redisplay with new information if it's not a vibration event
00043   virtual void processEvent(const EventBase& event);
00044   
00045   virtual ControlBase * doSelect() { return this; }
00046   
00047   //! redisplay text to sout and refresh LED values
00048   void report();  
00049 };
00050 
00051 /*! @file
00052  * @brief Describes BatteryCheckControl, which will spew a power report to stdout upon activation
00053  * @author ejt (Creator)
00054  */
00055 
00056 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:36 2016 by Doxygen 1.6.3