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

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Wed Dec 25 23:59:52 2019 +0000
Revision:
71:531419862202
Parent:
68:61a4ccb0a4b6
Changed Mode2 C++ refresh code (graphical errors)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 43:6183b12dd99c 1 /**************************************************************************/
Pokitto 43:6183b12dd99c 2 /*!
Pokitto 43:6183b12dd99c 3 @file HWButtons.cpp
Pokitto 43:6183b12dd99c 4 @author Jonne Valola
Pokitto 43:6183b12dd99c 5
Pokitto 43:6183b12dd99c 6 @section LICENSE
Pokitto 43:6183b12dd99c 7
Pokitto 43:6183b12dd99c 8 Software License Agreement (BSD License)
Pokitto 43:6183b12dd99c 9
Pokitto 43:6183b12dd99c 10 Copyright (c) 2016, Jonne Valola
Pokitto 43:6183b12dd99c 11 All rights reserved.
Pokitto 43:6183b12dd99c 12
Pokitto 43:6183b12dd99c 13 Redistribution and use in source and binary forms, with or without
Pokitto 43:6183b12dd99c 14 modification, are permitted provided that the following conditions are met:
Pokitto 43:6183b12dd99c 15 1. Redistributions of source code must retain the above copyright
Pokitto 43:6183b12dd99c 16 notice, this list of conditions and the following disclaimer.
Pokitto 43:6183b12dd99c 17 2. Redistributions in binary form must reproduce the above copyright
Pokitto 43:6183b12dd99c 18 notice, this list of conditions and the following disclaimer in the
Pokitto 43:6183b12dd99c 19 documentation and/or other materials provided with the distribution.
Pokitto 43:6183b12dd99c 20 3. Neither the name of the copyright holders nor the
Pokitto 43:6183b12dd99c 21 names of its contributors may be used to endorse or promote products
Pokitto 43:6183b12dd99c 22 derived from this software without specific prior written permission.
Pokitto 43:6183b12dd99c 23
Pokitto 43:6183b12dd99c 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
Pokitto 43:6183b12dd99c 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Pokitto 43:6183b12dd99c 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Pokitto 43:6183b12dd99c 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
Pokitto 43:6183b12dd99c 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Pokitto 43:6183b12dd99c 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Pokitto 43:6183b12dd99c 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Pokitto 43:6183b12dd99c 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Pokitto 43:6183b12dd99c 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Pokitto 43:6183b12dd99c 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Pokitto 43:6183b12dd99c 34 */
Pokitto 43:6183b12dd99c 35 /**************************************************************************/
Pokitto 43:6183b12dd99c 36
Pokitto 43:6183b12dd99c 37 #include "HWButtons.h"
Pokitto 43:6183b12dd99c 38 #include "PokittoCore.h"
Pokitto 43:6183b12dd99c 39 #include "PokittoSound.h"
Pokitto 43:6183b12dd99c 40 #include "PokittoDisplay.h"
Pokitto 43:6183b12dd99c 41
Pokitto 43:6183b12dd99c 42 Pokitto::Sound _s;
Pokitto 43:6183b12dd99c 43 Pokitto::Display _bd;
Pokitto 43:6183b12dd99c 44
Pokitto 43:6183b12dd99c 45 using namespace mbed;
Pokitto 43:6183b12dd99c 46
Pokitto 68:61a4ccb0a4b6 47 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 48 InterruptIn ABtn(POK_BTN_A_PIN);
Pokitto 43:6183b12dd99c 49 InterruptIn BBtn(POK_BTN_B_PIN);
Pokitto 43:6183b12dd99c 50 InterruptIn CBtn(POK_BTN_C_PIN);
Pokitto 43:6183b12dd99c 51 InterruptIn UBtn(POK_BTN_UP_PIN);
Pokitto 43:6183b12dd99c 52 InterruptIn DBtn(POK_BTN_DOWN_PIN);
Pokitto 43:6183b12dd99c 53 InterruptIn LBtn(POK_BTN_LEFT_PIN);
Pokitto 43:6183b12dd99c 54 InterruptIn RBtn(POK_BTN_RIGHT_PIN);
Pokitto 68:61a4ccb0a4b6 55 #else
Pokitto 68:61a4ccb0a4b6 56 DigitalIn ABtn(POK_BTN_A_PIN);
Pokitto 68:61a4ccb0a4b6 57 DigitalIn BBtn(POK_BTN_B_PIN);
Pokitto 68:61a4ccb0a4b6 58 DigitalIn CBtn(POK_BTN_C_PIN);
Pokitto 68:61a4ccb0a4b6 59 DigitalIn UBtn(POK_BTN_UP_PIN);
Pokitto 68:61a4ccb0a4b6 60 DigitalIn DBtn(POK_BTN_DOWN_PIN);
Pokitto 68:61a4ccb0a4b6 61 DigitalIn LBtn(POK_BTN_LEFT_PIN);
Pokitto 68:61a4ccb0a4b6 62 DigitalIn RBtn(POK_BTN_RIGHT_PIN);
Pokitto 68:61a4ccb0a4b6 63 #endif
Pokitto 68:61a4ccb0a4b6 64
Pokitto 43:6183b12dd99c 65
Pokitto 43:6183b12dd99c 66 #define BS_IDLE 0
Pokitto 43:6183b12dd99c 67 #define BS_DOWN 1
Pokitto 43:6183b12dd99c 68 #define BS_UP 2
Pokitto 43:6183b12dd99c 69
Pokitto 43:6183b12dd99c 70 uint8_t Pokitto::heldStates[NUM_BTN];
Pokitto 43:6183b12dd99c 71 bool vol_control_clicked=false;
Pokitto 43:6183b12dd99c 72
Pokitto 43:6183b12dd99c 73 void APressed() {
Pokitto 43:6183b12dd99c 74 Pokitto::heldStates[BTN_A] = 1;
Pokitto 43:6183b12dd99c 75 }
Pokitto 43:6183b12dd99c 76 void AReleased() {
Pokitto 43:6183b12dd99c 77 Pokitto::heldStates[BTN_A] = 0;
Pokitto 43:6183b12dd99c 78 }
Pokitto 43:6183b12dd99c 79 void BPressed() { Pokitto::heldStates[BTN_B] = 1; }
Pokitto 43:6183b12dd99c 80 void BReleased() { Pokitto::heldStates[BTN_B] = 0; }
Pokitto 43:6183b12dd99c 81 void CPressed() {
Pokitto 43:6183b12dd99c 82 Pokitto::heldStates[BTN_C] = 1;
Pokitto 43:6183b12dd99c 83 }
Pokitto 43:6183b12dd99c 84 void CReleased() { Pokitto::heldStates[BTN_C] = 0; }
Pokitto 43:6183b12dd99c 85 void UPressed() { Pokitto::heldStates[BTN_UP] = 1; }
Pokitto 43:6183b12dd99c 86 void UReleased() { Pokitto::heldStates[BTN_UP] = 0; }
Pokitto 43:6183b12dd99c 87 void DPressed() { Pokitto::heldStates[BTN_DOWN] = 1; }
Pokitto 43:6183b12dd99c 88 void DReleased() { Pokitto::heldStates[BTN_DOWN] = 0; }
Pokitto 43:6183b12dd99c 89 void RPressed() {
Pokitto 43:6183b12dd99c 90 /* Hardware volume control */
Pokitto 43:6183b12dd99c 91 if (Pokitto::heldStates[BTN_C]) _s.volumeUp();
Pokitto 43:6183b12dd99c 92 else Pokitto::heldStates[BTN_RIGHT] = 1;
Pokitto 43:6183b12dd99c 93 }
Pokitto 43:6183b12dd99c 94 void RReleased() { Pokitto::heldStates[BTN_RIGHT] = 0; }
Pokitto 43:6183b12dd99c 95 void LPressed() {
Pokitto 43:6183b12dd99c 96 /* Hardware volume control */
Pokitto 43:6183b12dd99c 97 if (Pokitto::heldStates[BTN_C]) _s.volumeDown();
Pokitto 43:6183b12dd99c 98 else Pokitto::heldStates[BTN_LEFT] = 1;
Pokitto 43:6183b12dd99c 99 }
Pokitto 43:6183b12dd99c 100 void LReleased() { Pokitto::heldStates[BTN_LEFT] = 0; }
Pokitto 43:6183b12dd99c 101
Pokitto 68:61a4ccb0a4b6 102 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 103 static inline void ClearPinInt(LPC_PIN_INT_T *pPININT, uint32_t pins)
Pokitto 43:6183b12dd99c 104 {
Pokitto 43:6183b12dd99c 105 pPININT->IST = pins;
Pokitto 43:6183b12dd99c 106 }
Pokitto 43:6183b12dd99c 107
Pokitto 43:6183b12dd99c 108 void PIN_INT0_IRQHandler(void)
Pokitto 43:6183b12dd99c 109 {
Pokitto 43:6183b12dd99c 110 //Pokitto::heldStates[BTN_A] = 1 - Pokitto::heldStates[BTN_A];
Pokitto 43:6183b12dd99c 111 //uint32_t pins = ((LPC_PIN_INT_T*)LPC_PININT)->FALL;
Pokitto 43:6183b12dd99c 112 //if ((((LPC_PIN_INT_T*)LPC_PININT)->RISE)&(1<<0)) Pokitto::heldStates[BTN_A] = 1;
Pokitto 43:6183b12dd99c 113 //else if ((((LPC_PIN_INT_T*)LPC_PININT)->FALL)&(1<<0)) Pokitto::heldStates[BTN_A] = 0;
Pokitto 43:6183b12dd99c 114 Pokitto::heldStates[BTN_A]=ABtn.read();
Pokitto 43:6183b12dd99c 115 ClearPinInt((LPC_PIN_INT_T *)LPC_PININT, PININTCH(0));
Pokitto 43:6183b12dd99c 116 }
Pokitto 43:6183b12dd99c 117
Pokitto 43:6183b12dd99c 118 void PIN_INT1_IRQHandler(void)
Pokitto 43:6183b12dd99c 119 {
Pokitto 43:6183b12dd99c 120 //if ((((LPC_PIN_INT_T*)LPC_PININT)->RISE)&(1<<1)) Pokitto::heldStates[BTN_B] = 1;
Pokitto 43:6183b12dd99c 121 //else if ((((LPC_PIN_INT_T*)LPC_PININT)->FALL)&(1<<1)) Pokitto::heldStates[BTN_B] = 0;
Pokitto 43:6183b12dd99c 122 Pokitto::heldStates[BTN_B]=BBtn.read();
Pokitto 43:6183b12dd99c 123 ClearPinInt((LPC_PIN_INT_T *)LPC_PININT, PININTCH(1));
Pokitto 43:6183b12dd99c 124 }
Pokitto 43:6183b12dd99c 125
Pokitto 43:6183b12dd99c 126 void PIN_INT2_IRQHandler(void)
Pokitto 43:6183b12dd99c 127 {
Pokitto 43:6183b12dd99c 128 //if ((((LPC_PIN_INT_T*)LPC_PININT)->RISE)&(1<<2)) Pokitto::heldStates[BTN_C] = 1;
Pokitto 43:6183b12dd99c 129 //else if ((((LPC_PIN_INT_T*)LPC_PININT)->FALL)&(1<<2)) Pokitto::heldStates[BTN_C] = 0;
Pokitto 43:6183b12dd99c 130 Pokitto::heldStates[BTN_C]=CBtn.read();
Pokitto 43:6183b12dd99c 131 ClearPinInt((LPC_PIN_INT_T *)LPC_PININT, PININTCH(2));
Pokitto 43:6183b12dd99c 132 }
Pokitto 43:6183b12dd99c 133
Pokitto 43:6183b12dd99c 134 void PIN_INT3_IRQHandler(void)
Pokitto 43:6183b12dd99c 135 {
Pokitto 43:6183b12dd99c 136 //if ((((LPC_PIN_INT_T*)LPC_PININT)->RISE)&(1<<3)) Pokitto::heldStates[BTN_UP] = 1;
Pokitto 43:6183b12dd99c 137 //else if ((((LPC_PIN_INT_T*)LPC_PININT)->FALL)&(1<<3)) Pokitto::heldStates[BTN_UP] = 0;
Pokitto 43:6183b12dd99c 138 Pokitto::heldStates[BTN_UP]=UBtn.read();
Pokitto 43:6183b12dd99c 139 ClearPinInt((LPC_PIN_INT_T *)LPC_PININT, PININTCH(3));
Pokitto 43:6183b12dd99c 140 }
Pokitto 43:6183b12dd99c 141
Pokitto 43:6183b12dd99c 142 void PIN_INT4_IRQHandler(void)
Pokitto 43:6183b12dd99c 143 {
Pokitto 43:6183b12dd99c 144 //if ((((LPC_PIN_INT_T*)LPC_PININT)->RISE)&(1<<4)) Pokitto::heldStates[BTN_DOWN] = 1;
Pokitto 43:6183b12dd99c 145 //else if ((((LPC_PIN_INT_T*)LPC_PININT)->FALL)&(1<<4)) Pokitto::heldStates[BTN_DOWN] = 0;
Pokitto 43:6183b12dd99c 146 Pokitto::heldStates[BTN_DOWN]=DBtn.read();
Pokitto 43:6183b12dd99c 147 ClearPinInt((LPC_PIN_INT_T *)LPC_PININT, PININTCH(4));
Pokitto 43:6183b12dd99c 148 }
Pokitto 43:6183b12dd99c 149
Pokitto 43:6183b12dd99c 150 void PIN_INT5_IRQHandler(void)
Pokitto 43:6183b12dd99c 151 {
Pokitto 43:6183b12dd99c 152 /* Hardware volume control */
Pokitto 43:6183b12dd99c 153 //if ((((LPC_PIN_INT_T*)LPC_PININT)->RISE)&(1<<5)) Pokitto::heldStates[BTN_LEFT] = 1;
Pokitto 43:6183b12dd99c 154 //else if ((((LPC_PIN_INT_T*)LPC_PININT)->FALL)&(1<<5)) Pokitto::heldStates[BTN_LEFT] = 0;
Pokitto 43:6183b12dd99c 155 Pokitto::heldStates[BTN_C]=CBtn.read();
Pokitto 43:6183b12dd99c 156 Pokitto::heldStates[BTN_LEFT]=LBtn.read();
Pokitto 43:6183b12dd99c 157 if (Pokitto::heldStates[BTN_C] && Pokitto::heldStates[BTN_LEFT])
Pokitto 43:6183b12dd99c 158 {
Pokitto 43:6183b12dd99c 159 if (!vol_control_clicked) _s.volumeDown();
Pokitto 43:6183b12dd99c 160 Pokitto::heldStates[BTN_LEFT]=0; //do not do normal button operation
Pokitto 43:6183b12dd99c 161 vol_control_clicked=true;
Pokitto 43:6183b12dd99c 162 } else vol_control_clicked=false;
Pokitto 43:6183b12dd99c 163
Pokitto 43:6183b12dd99c 164 ClearPinInt((LPC_PIN_INT_T *)LPC_PININT, PININTCH(5));
Pokitto 43:6183b12dd99c 165 }
Pokitto 43:6183b12dd99c 166
Pokitto 43:6183b12dd99c 167 void PIN_INT6_IRQHandler(void)
Pokitto 43:6183b12dd99c 168 {
Pokitto 43:6183b12dd99c 169 /* Hardware volume control */
Pokitto 43:6183b12dd99c 170 //if ((((LPC_PIN_INT_T*)LPC_PININT)->RISE)&(1<<6)) Pokitto::heldStates[BTN_RIGHT] = 1;
Pokitto 43:6183b12dd99c 171 //else if ((((LPC_PIN_INT_T*)LPC_PININT)->FALL)&(1<<6)) Pokitto::heldStates[BTN_RIGHT] = 0;
Pokitto 43:6183b12dd99c 172 Pokitto::heldStates[BTN_C]=CBtn.read();
Pokitto 43:6183b12dd99c 173 Pokitto::heldStates[BTN_RIGHT]=RBtn.read();
Pokitto 43:6183b12dd99c 174 if (Pokitto::heldStates[BTN_C] && Pokitto::heldStates[BTN_RIGHT])
Pokitto 43:6183b12dd99c 175 {
Pokitto 43:6183b12dd99c 176 if (!vol_control_clicked) _s.volumeUp();
Pokitto 43:6183b12dd99c 177 Pokitto::heldStates[BTN_RIGHT]=0; //do not do normal button operation
Pokitto 43:6183b12dd99c 178 vol_control_clicked=true;
Pokitto 43:6183b12dd99c 179 } else vol_control_clicked=false;
Pokitto 43:6183b12dd99c 180
Pokitto 43:6183b12dd99c 181 ClearPinInt((LPC_PIN_INT_T *)LPC_PININT, PININTCH(6));
Pokitto 43:6183b12dd99c 182 }
Pokitto 68:61a4ccb0a4b6 183 #endif
Pokitto 68:61a4ccb0a4b6 184
Pokitto 43:6183b12dd99c 185
Pokitto 43:6183b12dd99c 186
Pokitto 43:6183b12dd99c 187 void Pokitto::initButtons() {
Pokitto 68:61a4ccb0a4b6 188 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 189 ABtn.fall(&AReleased);
Pokitto 43:6183b12dd99c 190 ABtn.rise(&APressed);
Pokitto 43:6183b12dd99c 191 BBtn.fall(&BReleased);
Pokitto 43:6183b12dd99c 192 BBtn.rise(&BPressed);
Pokitto 43:6183b12dd99c 193 CBtn.fall(&CReleased);
Pokitto 43:6183b12dd99c 194 CBtn.rise(&CPressed);
Pokitto 43:6183b12dd99c 195 UBtn.fall(&UReleased);
Pokitto 43:6183b12dd99c 196 UBtn.rise(&UPressed);
Pokitto 43:6183b12dd99c 197 DBtn.fall(&DReleased);
Pokitto 43:6183b12dd99c 198 DBtn.rise(&DPressed);
Pokitto 43:6183b12dd99c 199 LBtn.fall(&LReleased);
Pokitto 43:6183b12dd99c 200 LBtn.rise(&LPressed);
Pokitto 43:6183b12dd99c 201 RBtn.fall(&RReleased);
Pokitto 43:6183b12dd99c 202 RBtn.rise(&RPressed);
Pokitto 43:6183b12dd99c 203 NVIC_SetVector((IRQn_Type)(PIN_INT0_IRQn), (uint32_t)&PIN_INT0_IRQHandler);
Pokitto 43:6183b12dd99c 204 NVIC_SetVector((IRQn_Type)(PIN_INT1_IRQn), (uint32_t)&PIN_INT1_IRQHandler);
Pokitto 43:6183b12dd99c 205 NVIC_SetVector((IRQn_Type)(PIN_INT2_IRQn), (uint32_t)&PIN_INT2_IRQHandler);
Pokitto 43:6183b12dd99c 206 NVIC_SetVector((IRQn_Type)(PIN_INT3_IRQn), (uint32_t)&PIN_INT3_IRQHandler);
Pokitto 43:6183b12dd99c 207 NVIC_SetVector((IRQn_Type)(PIN_INT4_IRQn), (uint32_t)&PIN_INT4_IRQHandler);
Pokitto 43:6183b12dd99c 208 NVIC_SetVector((IRQn_Type)(PIN_INT5_IRQn), (uint32_t)&PIN_INT5_IRQHandler);
Pokitto 43:6183b12dd99c 209 NVIC_SetVector((IRQn_Type)(PIN_INT6_IRQn), (uint32_t)&PIN_INT6_IRQHandler);
Pokitto 68:61a4ccb0a4b6 210 #endif
Pokitto 43:6183b12dd99c 211 }
Pokitto 43:6183b12dd99c 212
Pokitto 43:6183b12dd99c 213 uint8_t Pokitto::Core::aBtn() {
Pokitto 68:61a4ccb0a4b6 214
Pokitto 68:61a4ccb0a4b6 215 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 216 return Pokitto::heldStates[BTN_A];
Pokitto 68:61a4ccb0a4b6 217 #else
Pokitto 68:61a4ccb0a4b6 218 Pokitto::heldStates[BTN_A]=ABtn.read();
Pokitto 68:61a4ccb0a4b6 219 return Pokitto::heldStates[BTN_A];
Pokitto 68:61a4ccb0a4b6 220 #endif
Pokitto 68:61a4ccb0a4b6 221
Pokitto 43:6183b12dd99c 222 }
Pokitto 43:6183b12dd99c 223
Pokitto 43:6183b12dd99c 224 uint8_t Pokitto::Core::bBtn() {
Pokitto 68:61a4ccb0a4b6 225
Pokitto 68:61a4ccb0a4b6 226 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 227 return Pokitto::heldStates[BTN_B];
Pokitto 68:61a4ccb0a4b6 228 #else
Pokitto 68:61a4ccb0a4b6 229 Pokitto::heldStates[BTN_B]=BBtn.read();
Pokitto 68:61a4ccb0a4b6 230 return Pokitto::heldStates[BTN_B];
Pokitto 68:61a4ccb0a4b6 231 #endif
Pokitto 43:6183b12dd99c 232 }
Pokitto 43:6183b12dd99c 233
Pokitto 43:6183b12dd99c 234 uint8_t Pokitto::Core::cBtn() {
Pokitto 68:61a4ccb0a4b6 235
Pokitto 68:61a4ccb0a4b6 236 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 237 return Pokitto::heldStates[BTN_C];
Pokitto 68:61a4ccb0a4b6 238 #else
Pokitto 68:61a4ccb0a4b6 239 Pokitto::heldStates[BTN_C]=CBtn.read();
Pokitto 68:61a4ccb0a4b6 240 return Pokitto::heldStates[BTN_C];
Pokitto 68:61a4ccb0a4b6 241 #endif
Pokitto 43:6183b12dd99c 242 }
Pokitto 43:6183b12dd99c 243
Pokitto 43:6183b12dd99c 244 uint8_t Pokitto::Core::upBtn() {
Pokitto 68:61a4ccb0a4b6 245
Pokitto 68:61a4ccb0a4b6 246 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 247 return Pokitto::heldStates[BTN_UP];
Pokitto 68:61a4ccb0a4b6 248 #else
Pokitto 68:61a4ccb0a4b6 249 Pokitto::heldStates[BTN_UP]=UBtn.read();
Pokitto 68:61a4ccb0a4b6 250 return Pokitto::heldStates[BTN_UP];
Pokitto 68:61a4ccb0a4b6 251 #endif
Pokitto 43:6183b12dd99c 252 }
Pokitto 43:6183b12dd99c 253 uint8_t Pokitto::Core::downBtn() {
Pokitto 68:61a4ccb0a4b6 254
Pokitto 68:61a4ccb0a4b6 255 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 256 return Pokitto::heldStates[BTN_DOWN];
Pokitto 68:61a4ccb0a4b6 257 #else
Pokitto 68:61a4ccb0a4b6 258 Pokitto::heldStates[BTN_DOWN]=DBtn.read();
Pokitto 68:61a4ccb0a4b6 259 return Pokitto::heldStates[BTN_DOWN];
Pokitto 68:61a4ccb0a4b6 260 #endif
Pokitto 43:6183b12dd99c 261 }
Pokitto 43:6183b12dd99c 262
Pokitto 43:6183b12dd99c 263 uint8_t Pokitto::Core::leftBtn() {
Pokitto 68:61a4ccb0a4b6 264
Pokitto 68:61a4ccb0a4b6 265 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 266 return Pokitto::heldStates[BTN_LEFT];
Pokitto 68:61a4ccb0a4b6 267 #else
Pokitto 68:61a4ccb0a4b6 268 Pokitto::heldStates[BTN_LEFT]=LBtn.read();
Pokitto 68:61a4ccb0a4b6 269 return Pokitto::heldStates[BTN_LEFT];
Pokitto 68:61a4ccb0a4b6 270 #endif
Pokitto 43:6183b12dd99c 271 }
Pokitto 43:6183b12dd99c 272 uint8_t Pokitto::Core::rightBtn() {
Pokitto 68:61a4ccb0a4b6 273
Pokitto 68:61a4ccb0a4b6 274 #ifndef PROJ_BUTTONS_POLLING_ONLY
Pokitto 43:6183b12dd99c 275 return Pokitto::heldStates[BTN_RIGHT];
Pokitto 68:61a4ccb0a4b6 276 #else
Pokitto 68:61a4ccb0a4b6 277 Pokitto::heldStates[BTN_RIGHT]=RBtn.read();
Pokitto 68:61a4ccb0a4b6 278 return Pokitto::heldStates[BTN_RIGHT];
Pokitto 68:61a4ccb0a4b6 279 #endif
Pokitto 43:6183b12dd99c 280 }
Pokitto 43:6183b12dd99c 281