PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Committer:
Pokitto
Date:
Sun Apr 22 23:55:36 2018 +0000
Revision:
39:e8bb18900c34
Button handling and initRandom fixed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 39:e8bb18900c34 1 /**************************************************************************/
Pokitto 39:e8bb18900c34 2 /*!
Pokitto 39:e8bb18900c34 3 @file PokittoBattery.cpp
Pokitto 39:e8bb18900c34 4 @author Jonne Valola
Pokitto 39:e8bb18900c34 5
Pokitto 39:e8bb18900c34 6 @section LICENSE
Pokitto 39:e8bb18900c34 7
Pokitto 39:e8bb18900c34 8 Software License Agreement (BSD License)
Pokitto 39:e8bb18900c34 9
Pokitto 39:e8bb18900c34 10 Copyright (c) 2016, Jonne Valola
Pokitto 39:e8bb18900c34 11 All rights reserved.
Pokitto 39:e8bb18900c34 12
Pokitto 39:e8bb18900c34 13 Redistribution and use in source and binary forms, with or without
Pokitto 39:e8bb18900c34 14 modification, are permitted provided that the following conditions are met:
Pokitto 39:e8bb18900c34 15 1. Redistributions of source code must retain the above copyright
Pokitto 39:e8bb18900c34 16 notice, this list of conditions and the following disclaimer.
Pokitto 39:e8bb18900c34 17 2. Redistributions in binary form must reproduce the above copyright
Pokitto 39:e8bb18900c34 18 notice, this list of conditions and the following disclaimer in the
Pokitto 39:e8bb18900c34 19 documentation and/or other materials provided with the distribution.
Pokitto 39:e8bb18900c34 20 3. Neither the name of the copyright holders nor the
Pokitto 39:e8bb18900c34 21 names of its contributors may be used to endorse or promote products
Pokitto 39:e8bb18900c34 22 derived from this software without specific prior written permission.
Pokitto 39:e8bb18900c34 23
Pokitto 39:e8bb18900c34 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
Pokitto 39:e8bb18900c34 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Pokitto 39:e8bb18900c34 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Pokitto 39:e8bb18900c34 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
Pokitto 39:e8bb18900c34 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Pokitto 39:e8bb18900c34 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Pokitto 39:e8bb18900c34 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Pokitto 39:e8bb18900c34 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Pokitto 39:e8bb18900c34 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Pokitto 39:e8bb18900c34 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Pokitto 39:e8bb18900c34 34 */
Pokitto 39:e8bb18900c34 35 /**************************************************************************/
Pokitto 39:e8bb18900c34 36
Pokitto 39:e8bb18900c34 37 #include "PokittoBattery.h"
Pokitto 39:e8bb18900c34 38
Pokitto 39:e8bb18900c34 39 using namespace Pokitto;
Pokitto 39:e8bb18900c34 40
Pokitto 39:e8bb18900c34 41 bool Battery::show;
Pokitto 39:e8bb18900c34 42 uint8_t Battery::level;
Pokitto 39:e8bb18900c34 43 uint16_t Battery::voltage;
Pokitto 39:e8bb18900c34 44 uint16_t Battery::thresholds[NUM_LVL];
Pokitto 39:e8bb18900c34 45 uint8_t Battery::nextUpdate;
Pokitto 39:e8bb18900c34 46
Pokitto 39:e8bb18900c34 47 AnalogIn BatLevelPin(P0_23);
Pokitto 39:e8bb18900c34 48
Pokitto 39:e8bb18900c34 49 void Battery::begin() {
Pokitto 39:e8bb18900c34 50 level = BatLevelPin*0xFF;
Pokitto 39:e8bb18900c34 51 }
Pokitto 39:e8bb18900c34 52
Pokitto 39:e8bb18900c34 53 void Battery::update() {
Pokitto 39:e8bb18900c34 54 //ToDo - make a real function
Pokitto 39:e8bb18900c34 55 level = BatLevelPin*0xFF;
Pokitto 39:e8bb18900c34 56 }
Pokitto 39:e8bb18900c34 57
Pokitto 39:e8bb18900c34 58