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
- Import this library to online compiler (see button "import" on the right hand side
- DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
- Change My_settings.h according to your project
- Start coding!
POKITTO_CORE/PokittoConsole.cpp@0:e8b8f36b4505, 2017-09-18 (annotated)
- Committer:
- Pokitto
- Date:
- Mon Sep 18 11:47:51 2017 +0000
- Revision:
- 0:e8b8f36b4505
- Child:
- 2:968589ca3484
Initial;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pokitto | 0:e8b8f36b4505 | 1 | /**************************************************************************/ |
Pokitto | 0:e8b8f36b4505 | 2 | /*! |
Pokitto | 0:e8b8f36b4505 | 3 | @file PokittoConsole.cpp |
Pokitto | 0:e8b8f36b4505 | 4 | @author Jonne Valola |
Pokitto | 0:e8b8f36b4505 | 5 | |
Pokitto | 0:e8b8f36b4505 | 6 | @section LICENSE |
Pokitto | 0:e8b8f36b4505 | 7 | |
Pokitto | 0:e8b8f36b4505 | 8 | Software License Agreement (BSD License) |
Pokitto | 0:e8b8f36b4505 | 9 | |
Pokitto | 0:e8b8f36b4505 | 10 | Copyright (c) 2016, Jonne Valola |
Pokitto | 0:e8b8f36b4505 | 11 | All rights reserved. |
Pokitto | 0:e8b8f36b4505 | 12 | |
Pokitto | 0:e8b8f36b4505 | 13 | Redistribution and use in source and binary forms, with or without |
Pokitto | 0:e8b8f36b4505 | 14 | modification, are permitted provided that the following conditions are met: |
Pokitto | 0:e8b8f36b4505 | 15 | 1. Redistributions of source code must retain the above copyright |
Pokitto | 0:e8b8f36b4505 | 16 | notice, this list of conditions and the following disclaimer. |
Pokitto | 0:e8b8f36b4505 | 17 | 2. Redistributions in binary form must reproduce the above copyright |
Pokitto | 0:e8b8f36b4505 | 18 | notice, this list of conditions and the following disclaimer in the |
Pokitto | 0:e8b8f36b4505 | 19 | documentation and/or other materials provided with the distribution. |
Pokitto | 0:e8b8f36b4505 | 20 | 3. Neither the name of the copyright holders nor the |
Pokitto | 0:e8b8f36b4505 | 21 | names of its contributors may be used to endorse or promote products |
Pokitto | 0:e8b8f36b4505 | 22 | derived from this software without specific prior written permission. |
Pokitto | 0:e8b8f36b4505 | 23 | |
Pokitto | 0:e8b8f36b4505 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
Pokitto | 0:e8b8f36b4505 | 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Pokitto | 0:e8b8f36b4505 | 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Pokitto | 0:e8b8f36b4505 | 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY |
Pokitto | 0:e8b8f36b4505 | 28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Pokitto | 0:e8b8f36b4505 | 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Pokitto | 0:e8b8f36b4505 | 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
Pokitto | 0:e8b8f36b4505 | 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Pokitto | 0:e8b8f36b4505 | 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Pokitto | 0:e8b8f36b4505 | 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Pokitto | 0:e8b8f36b4505 | 34 | */ |
Pokitto | 0:e8b8f36b4505 | 35 | /**************************************************************************/ |
Pokitto | 0:e8b8f36b4505 | 36 | |
Pokitto | 0:e8b8f36b4505 | 37 | #include "PokittoGlobs.h" |
Pokitto | 0:e8b8f36b4505 | 38 | #include "PokittoConsole.h" |
Pokitto | 0:e8b8f36b4505 | 39 | #include "PokittoFonts.h" |
Pokitto | 0:e8b8f36b4505 | 40 | #include "PokittoDisplay.h" |
Pokitto | 0:e8b8f36b4505 | 41 | |
Pokitto | 0:e8b8f36b4505 | 42 | Pokitto::Console pConsole; |
Pokitto | 0:e8b8f36b4505 | 43 | |
Pokitto | 0:e8b8f36b4505 | 44 | using namespace Pokitto; |
Pokitto | 0:e8b8f36b4505 | 45 | |
Pokitto | 0:e8b8f36b4505 | 46 | consmsg Console::msgbuf[CONSOLEBUFSIZE]; |
Pokitto | 0:e8b8f36b4505 | 47 | uint8_t Console::conslast; |
Pokitto | 0:e8b8f36b4505 | 48 | uint8_t Console::consfirst; |
Pokitto | 0:e8b8f36b4505 | 49 | uint8_t Console::conspointer; |
Pokitto | 0:e8b8f36b4505 | 50 | uint16_t Console::conscounter; |
Pokitto | 0:e8b8f36b4505 | 51 | uint16_t Console::color; |
Pokitto | 0:e8b8f36b4505 | 52 | Display* Console::_display; |
Pokitto | 0:e8b8f36b4505 | 53 | uint8_t Console::mode; |
Pokitto | 0:e8b8f36b4505 | 54 | uint8_t Console::visible; |
Pokitto | 0:e8b8f36b4505 | 55 | unsigned char* Console::font; |
Pokitto | 0:e8b8f36b4505 | 56 | |
Pokitto | 0:e8b8f36b4505 | 57 | Console::Console() { |
Pokitto | 0:e8b8f36b4505 | 58 | conslast=consfirst=conspointer=conscounter=0; |
Pokitto | 0:e8b8f36b4505 | 59 | color=0xFFFF; |
Pokitto | 0:e8b8f36b4505 | 60 | font=(unsigned char*)fontMini; |
Pokitto | 0:e8b8f36b4505 | 61 | #if POK_CONSOLE_VISIBLE_AT_STARTUP > 0 |
Pokitto | 0:e8b8f36b4505 | 62 | mode=CONS_OVERLAY|CONS_VISIBLE; |
Pokitto | 0:e8b8f36b4505 | 63 | #else |
Pokitto | 0:e8b8f36b4505 | 64 | mode=CONS_OVERLAY;//|CONS_VISIBLE; |
Pokitto | 0:e8b8f36b4505 | 65 | #endif |
Pokitto | 0:e8b8f36b4505 | 66 | } |
Pokitto | 0:e8b8f36b4505 | 67 | |
Pokitto | 0:e8b8f36b4505 | 68 | void Console::Toggle() { |
Pokitto | 0:e8b8f36b4505 | 69 | if (!conscounter) // conscounter is a debounce feature for console toggle |
Pokitto | 0:e8b8f36b4505 | 70 | { |
Pokitto | 0:e8b8f36b4505 | 71 | mode ^= CONS_VISIBLE; |
Pokitto | 0:e8b8f36b4505 | 72 | conscounter = CONS_TIMEOUT; |
Pokitto | 0:e8b8f36b4505 | 73 | } |
Pokitto | 0:e8b8f36b4505 | 74 | } |
Pokitto | 0:e8b8f36b4505 | 75 | |
Pokitto | 0:e8b8f36b4505 | 76 | |
Pokitto | 0:e8b8f36b4505 | 77 | void Console::AddMessage(uint8_t source, uint8_t msgtype) { |
Pokitto | 0:e8b8f36b4505 | 78 | AddMessage(source,msgtype, V_NONE,0); |
Pokitto | 0:e8b8f36b4505 | 79 | } |
Pokitto | 0:e8b8f36b4505 | 80 | |
Pokitto | 0:e8b8f36b4505 | 81 | |
Pokitto | 0:e8b8f36b4505 | 82 | void Console::AddMessage(uint8_t type, char* stringptr) { |
Pokitto | 0:e8b8f36b4505 | 83 | AddMessage(MSOURCE_USER,type,V_STRING, (uint32_t) stringptr); |
Pokitto | 0:e8b8f36b4505 | 84 | } |
Pokitto | 0:e8b8f36b4505 | 85 | |
Pokitto | 0:e8b8f36b4505 | 86 | |
Pokitto | 0:e8b8f36b4505 | 87 | void Console::AddMessage(uint8_t msgtype, uint8_t valtype, uint32_t val) { |
Pokitto | 0:e8b8f36b4505 | 88 | AddMessage(MSOURCE_USER,msgtype,valtype,val); |
Pokitto | 0:e8b8f36b4505 | 89 | } |
Pokitto | 0:e8b8f36b4505 | 90 | |
Pokitto | 0:e8b8f36b4505 | 91 | void Console::AddMessage(uint8_t source, uint8_t msgtype, uint8_t valtype, uint32_t val) { |
Pokitto | 0:e8b8f36b4505 | 92 | consmsg c; |
Pokitto | 0:e8b8f36b4505 | 93 | c.msgsource = source; |
Pokitto | 0:e8b8f36b4505 | 94 | c.msgtype = msgtype; |
Pokitto | 0:e8b8f36b4505 | 95 | c.valtype = valtype; |
Pokitto | 0:e8b8f36b4505 | 96 | c.val = val; |
Pokitto | 0:e8b8f36b4505 | 97 | msgbuf[conslast] = c; |
Pokitto | 0:e8b8f36b4505 | 98 | conslast++; |
Pokitto | 0:e8b8f36b4505 | 99 | if (conslast==CONSOLEBUFSIZE) conslast = 0; // wrap around the buffer |
Pokitto | 0:e8b8f36b4505 | 100 | consfirst = conslast + 1; |
Pokitto | 0:e8b8f36b4505 | 101 | if (consfirst == CONSOLEBUFSIZE) consfirst = 0; |
Pokitto | 0:e8b8f36b4505 | 102 | } |
Pokitto | 0:e8b8f36b4505 | 103 | |
Pokitto | 0:e8b8f36b4505 | 104 | void Console::Last() { |
Pokitto | 0:e8b8f36b4505 | 105 | conspointer = conslast; |
Pokitto | 0:e8b8f36b4505 | 106 | } |
Pokitto | 0:e8b8f36b4505 | 107 | |
Pokitto | 0:e8b8f36b4505 | 108 | void Console::RemoveLast() { |
Pokitto | 0:e8b8f36b4505 | 109 | Last(); |
Pokitto | 0:e8b8f36b4505 | 110 | Previous(); |
Pokitto | 0:e8b8f36b4505 | 111 | msgbuf[conspointer].msgsource = MSOURCE_USER; |
Pokitto | 0:e8b8f36b4505 | 112 | msgbuf[conspointer].msgtype = MSG_OK; |
Pokitto | 0:e8b8f36b4505 | 113 | msgbuf[conspointer].val = 0; |
Pokitto | 0:e8b8f36b4505 | 114 | msgbuf[conspointer].valtype = 0; |
Pokitto | 0:e8b8f36b4505 | 115 | conslast = conspointer; |
Pokitto | 0:e8b8f36b4505 | 116 | } |
Pokitto | 0:e8b8f36b4505 | 117 | |
Pokitto | 0:e8b8f36b4505 | 118 | void Console::First() { |
Pokitto | 0:e8b8f36b4505 | 119 | consmsg c; |
Pokitto | 0:e8b8f36b4505 | 120 | uint16_t outofbounds=0; |
Pokitto | 0:e8b8f36b4505 | 121 | conspointer = consfirst; |
Pokitto | 0:e8b8f36b4505 | 122 | c=GetMessage(); |
Pokitto | 0:e8b8f36b4505 | 123 | while (!c.msgsource) { |
Pokitto | 0:e8b8f36b4505 | 124 | Next(); |
Pokitto | 0:e8b8f36b4505 | 125 | c=GetMessage(); |
Pokitto | 0:e8b8f36b4505 | 126 | outofbounds++; |
Pokitto | 0:e8b8f36b4505 | 127 | if (outofbounds==CONSOLEBUFSIZE) { |
Pokitto | 0:e8b8f36b4505 | 128 | conspointer = consfirst; |
Pokitto | 0:e8b8f36b4505 | 129 | break; |
Pokitto | 0:e8b8f36b4505 | 130 | } |
Pokitto | 0:e8b8f36b4505 | 131 | } |
Pokitto | 0:e8b8f36b4505 | 132 | } |
Pokitto | 0:e8b8f36b4505 | 133 | |
Pokitto | 0:e8b8f36b4505 | 134 | void Console::Previous() { |
Pokitto | 0:e8b8f36b4505 | 135 | if (conspointer==0) conspointer = CONSOLEBUFSIZE-1; |
Pokitto | 0:e8b8f36b4505 | 136 | else conspointer--; |
Pokitto | 0:e8b8f36b4505 | 137 | } |
Pokitto | 0:e8b8f36b4505 | 138 | |
Pokitto | 0:e8b8f36b4505 | 139 | void Console::Next() { |
Pokitto | 0:e8b8f36b4505 | 140 | if (conspointer==CONSOLEBUFSIZE-1) conspointer = 0; |
Pokitto | 0:e8b8f36b4505 | 141 | else conspointer++; |
Pokitto | 0:e8b8f36b4505 | 142 | } |
Pokitto | 0:e8b8f36b4505 | 143 | |
Pokitto | 0:e8b8f36b4505 | 144 | consmsg Console::GetMessage() { |
Pokitto | 0:e8b8f36b4505 | 145 | return msgbuf[conspointer]; |
Pokitto | 0:e8b8f36b4505 | 146 | } |
Pokitto | 0:e8b8f36b4505 | 147 | |
Pokitto | 0:e8b8f36b4505 | 148 | void Console::PrintMessage() { |
Pokitto | 0:e8b8f36b4505 | 149 | consmsg c = msgbuf[conspointer]; |
Pokitto | 0:e8b8f36b4505 | 150 | switch (c.msgsource) { |
Pokitto | 0:e8b8f36b4505 | 151 | case MSOURCE_APP: |
Pokitto | 0:e8b8f36b4505 | 152 | _display->print("App:");break; |
Pokitto | 0:e8b8f36b4505 | 153 | case MSOURCE_BATT: |
Pokitto | 0:e8b8f36b4505 | 154 | _display->print("Batt:");break; |
Pokitto | 0:e8b8f36b4505 | 155 | case MSOURCE_BTNA: |
Pokitto | 0:e8b8f36b4505 | 156 | _display->print("A:");break; |
Pokitto | 0:e8b8f36b4505 | 157 | case MSOURCE_BTNB: |
Pokitto | 0:e8b8f36b4505 | 158 | _display->print("B:");break; |
Pokitto | 0:e8b8f36b4505 | 159 | case MSOURCE_BTNC: |
Pokitto | 0:e8b8f36b4505 | 160 | _display->print("C:");break; |
Pokitto | 0:e8b8f36b4505 | 161 | case MSOURCE_BTNU: |
Pokitto | 0:e8b8f36b4505 | 162 | _display->print("Up:");break; |
Pokitto | 0:e8b8f36b4505 | 163 | case MSOURCE_BTND: |
Pokitto | 0:e8b8f36b4505 | 164 | _display->print("Down:");break; |
Pokitto | 0:e8b8f36b4505 | 165 | case MSOURCE_BTNL: |
Pokitto | 0:e8b8f36b4505 | 166 | _display->print("Left:");break; |
Pokitto | 0:e8b8f36b4505 | 167 | case MSOURCE_BTNR: |
Pokitto | 0:e8b8f36b4505 | 168 | _display->print("Right:");break; |
Pokitto | 0:e8b8f36b4505 | 169 | case MSOURCE_LCD: |
Pokitto | 0:e8b8f36b4505 | 170 | _display->print("LCD:");break; |
Pokitto | 0:e8b8f36b4505 | 171 | case MSOURCE_SD: |
Pokitto | 0:e8b8f36b4505 | 172 | _display->print("SD:");break; |
Pokitto | 0:e8b8f36b4505 | 173 | case MSOURCE_SOUND: |
Pokitto | 0:e8b8f36b4505 | 174 | _display->print("Sound:");break; |
Pokitto | 0:e8b8f36b4505 | 175 | case MSOURCE_TIMER: |
Pokitto | 0:e8b8f36b4505 | 176 | _display->print("Timer:");break; |
Pokitto | 0:e8b8f36b4505 | 177 | case MSOURCE_USER: |
Pokitto | 0:e8b8f36b4505 | 178 | _display->print("User:");break; |
Pokitto | 0:e8b8f36b4505 | 179 | case MSOURCE_COLLISION: |
Pokitto | 0:e8b8f36b4505 | 180 | _display->print("Hit:");break; |
Pokitto | 0:e8b8f36b4505 | 181 | default: |
Pokitto | 0:e8b8f36b4505 | 182 | return; |
Pokitto | 0:e8b8f36b4505 | 183 | break; |
Pokitto | 0:e8b8f36b4505 | 184 | } |
Pokitto | 0:e8b8f36b4505 | 185 | |
Pokitto | 0:e8b8f36b4505 | 186 | switch (c.msgtype) { |
Pokitto | 0:e8b8f36b4505 | 187 | case MSG_OK: |
Pokitto | 0:e8b8f36b4505 | 188 | _display->print("OK ");break; |
Pokitto | 0:e8b8f36b4505 | 189 | case MSG_INIT_OK: |
Pokitto | 0:e8b8f36b4505 | 190 | _display->print("INIT OK ");break; |
Pokitto | 0:e8b8f36b4505 | 191 | case MSG_INIT_FAIL: |
Pokitto | 0:e8b8f36b4505 | 192 | _display->print("INIT FAIL ");break; |
Pokitto | 0:e8b8f36b4505 | 193 | case MSG_WARNING: |
Pokitto | 0:e8b8f36b4505 | 194 | _display->print("WARNING ");break; |
Pokitto | 0:e8b8f36b4505 | 195 | case MSG_FATAL: |
Pokitto | 0:e8b8f36b4505 | 196 | _display->print("FATAL ");break; |
Pokitto | 0:e8b8f36b4505 | 197 | case MSG_GFX_MODE_CHANGE: |
Pokitto | 0:e8b8f36b4505 | 198 | _display->print("MODE ");break; |
Pokitto | 0:e8b8f36b4505 | 199 | case MSG_GFX_MODE_INVALID: |
Pokitto | 0:e8b8f36b4505 | 200 | _display->print("INVALID!");break; |
Pokitto | 0:e8b8f36b4505 | 201 | case MSG_NOT_ENOUGH_MEM: |
Pokitto | 0:e8b8f36b4505 | 202 | _display->print("NOT ENOUGH MEM ");break; |
Pokitto | 0:e8b8f36b4505 | 203 | case MSG_UP: |
Pokitto | 0:e8b8f36b4505 | 204 | _display->print("KEYUP");break; |
Pokitto | 0:e8b8f36b4505 | 205 | case MSG_DOWN: |
Pokitto | 0:e8b8f36b4505 | 206 | _display->print("KEYDOWN");break; |
Pokitto | 0:e8b8f36b4505 | 207 | case MSG_BREAK: |
Pokitto | 0:e8b8f36b4505 | 208 | _display->print("BREAK ");break; |
Pokitto | 0:e8b8f36b4505 | 209 | case MSG_YESNO: |
Pokitto | 0:e8b8f36b4505 | 210 | _display->print("YES(A)/NO(B)");break; |
Pokitto | 0:e8b8f36b4505 | 211 | case MSG_YES: |
Pokitto | 0:e8b8f36b4505 | 212 | _display->print("YES");break; |
Pokitto | 0:e8b8f36b4505 | 213 | case MSG_NO: |
Pokitto | 0:e8b8f36b4505 | 214 | _display->print("NO");break; |
Pokitto | 0:e8b8f36b4505 | 215 | case MSG_OBJECT: |
Pokitto | 0:e8b8f36b4505 | 216 | _display->print("OBJ1: ");break; |
Pokitto | 0:e8b8f36b4505 | 217 | case MSG_OBJECT2: |
Pokitto | 0:e8b8f36b4505 | 218 | _display->print("OBJ2: ");break; |
Pokitto | 0:e8b8f36b4505 | 219 | default: |
Pokitto | 0:e8b8f36b4505 | 220 | _display->print(" "); |
Pokitto | 0:e8b8f36b4505 | 221 | } |
Pokitto | 0:e8b8f36b4505 | 222 | |
Pokitto | 0:e8b8f36b4505 | 223 | switch (c.valtype) { |
Pokitto | 0:e8b8f36b4505 | 224 | case V_NONE: |
Pokitto | 0:e8b8f36b4505 | 225 | _display->println();break; |
Pokitto | 0:e8b8f36b4505 | 226 | case V_UINT8: |
Pokitto | 0:e8b8f36b4505 | 227 | _display->println((uint16_t)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 228 | case V_INT8: |
Pokitto | 0:e8b8f36b4505 | 229 | _display->println((int16_t)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 230 | case V_UINT16: |
Pokitto | 0:e8b8f36b4505 | 231 | _display->println((uint16_t)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 232 | case V_INT16: |
Pokitto | 0:e8b8f36b4505 | 233 | _display->println((int16_t)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 234 | case V_UINT32: |
Pokitto | 0:e8b8f36b4505 | 235 | _display->println((uint32_t)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 236 | case V_INT32: |
Pokitto | 0:e8b8f36b4505 | 237 | _display->println((int32_t)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 238 | case V_FLOAT: |
Pokitto | 0:e8b8f36b4505 | 239 | _display->println((float)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 240 | case V_STRING: |
Pokitto | 0:e8b8f36b4505 | 241 | _display->println((char*)c.val);break; |
Pokitto | 0:e8b8f36b4505 | 242 | default: |
Pokitto | 0:e8b8f36b4505 | 243 | _display->println(); |
Pokitto | 0:e8b8f36b4505 | 244 | } |
Pokitto | 0:e8b8f36b4505 | 245 | |
Pokitto | 0:e8b8f36b4505 | 246 | if (c.msgtype == MSG_BREAK || c.msgtype == MSG_YESNO) { |
Pokitto | 0:e8b8f36b4505 | 247 | #ifndef POK_SIM |
Pokitto | 0:e8b8f36b4505 | 248 | __disable_irq(); // Disable Interrupts |
Pokitto | 0:e8b8f36b4505 | 249 | #else |
Pokitto | 0:e8b8f36b4505 | 250 | pauseAudio(1); |
Pokitto | 0:e8b8f36b4505 | 251 | visible = false; // avoid loop in loop inside refreshDisplay |
Pokitto | 0:e8b8f36b4505 | 252 | simulator.wait_ms(300); |
Pokitto | 0:e8b8f36b4505 | 253 | #endif |
Pokitto | 0:e8b8f36b4505 | 254 | int rval=0; |
Pokitto | 0:e8b8f36b4505 | 255 | while(!rval) { |
Pokitto | 0:e8b8f36b4505 | 256 | _buttons->pollButtons(); |
Pokitto | 0:e8b8f36b4505 | 257 | #ifdef POK_SIM |
Pokitto | 0:e8b8f36b4505 | 258 | simulator.refreshDisplay(); |
Pokitto | 0:e8b8f36b4505 | 259 | #endif // POK_SIM |
Pokitto | 0:e8b8f36b4505 | 260 | if (_buttons->aBtn()) rval = 1; |
Pokitto | 0:e8b8f36b4505 | 261 | if (_buttons->bBtn()) rval = -1; |
Pokitto | 0:e8b8f36b4505 | 262 | } |
Pokitto | 0:e8b8f36b4505 | 263 | /* now remove this message to prevent it from rerunning */ |
Pokitto | 0:e8b8f36b4505 | 264 | if (c.msgtype == MSG_YESNO) { |
Pokitto | 0:e8b8f36b4505 | 265 | int8_t* v; |
Pokitto | 0:e8b8f36b4505 | 266 | v = (int8_t*) c.val; //c.val is a pointer to the memory location that receives answer |
Pokitto | 0:e8b8f36b4505 | 267 | *v = rval; // return value through pointer |
Pokitto | 0:e8b8f36b4505 | 268 | msgbuf[conspointer].msgsource = MSOURCE_USER; |
Pokitto | 0:e8b8f36b4505 | 269 | if (rval==1) msgbuf[conspointer].msgtype = MSG_YES; |
Pokitto | 0:e8b8f36b4505 | 270 | else msgbuf[conspointer].msgtype = MSG_NO; |
Pokitto | 0:e8b8f36b4505 | 271 | } else msgbuf[conspointer].msgsource = MSOURCE_NULL; |
Pokitto | 0:e8b8f36b4505 | 272 | |
Pokitto | 0:e8b8f36b4505 | 273 | #ifndef POK_SIM |
Pokitto | 0:e8b8f36b4505 | 274 | __enable_irq(); // Enable Interrupts |
Pokitto | 0:e8b8f36b4505 | 275 | #else |
Pokitto | 0:e8b8f36b4505 | 276 | pauseAudio(0); |
Pokitto | 0:e8b8f36b4505 | 277 | visible = true; |
Pokitto | 0:e8b8f36b4505 | 278 | #endif |
Pokitto | 0:e8b8f36b4505 | 279 | } |
Pokitto | 0:e8b8f36b4505 | 280 | } |
Pokitto | 0:e8b8f36b4505 | 281 | |
Pokitto | 0:e8b8f36b4505 | 282 | void Console::Draw() { |
Pokitto | 0:e8b8f36b4505 | 283 | unsigned char* oldfont; |
Pokitto | 0:e8b8f36b4505 | 284 | int16_t oldx,oldy; |
Pokitto | 0:e8b8f36b4505 | 285 | uint16_t oldcolor; |
Pokitto | 0:e8b8f36b4505 | 286 | uint8_t oldsize; |
Pokitto | 0:e8b8f36b4505 | 287 | bool oldenable; |
Pokitto | 0:e8b8f36b4505 | 288 | oldfont = (unsigned char*) _display->font; |
Pokitto | 0:e8b8f36b4505 | 289 | oldx = _display->cursorX; |
Pokitto | 0:e8b8f36b4505 | 290 | oldy = _display->cursorY; |
Pokitto | 0:e8b8f36b4505 | 291 | oldcolor = _display->directcolor; |
Pokitto | 0:e8b8f36b4505 | 292 | oldsize = _display->fontSize; |
Pokitto | 0:e8b8f36b4505 | 293 | if (!(mode & CONS_OVERLAY)) _display->clearLCD(); |
Pokitto | 0:e8b8f36b4505 | 294 | _display->setFont(font5x7); |
Pokitto | 0:e8b8f36b4505 | 295 | _display->fontSize=1; |
Pokitto | 0:e8b8f36b4505 | 296 | _display->setCursor(0,0); |
Pokitto | 0:e8b8f36b4505 | 297 | _display->directcolor=color; |
Pokitto | 0:e8b8f36b4505 | 298 | First(); |
Pokitto | 0:e8b8f36b4505 | 299 | while(conspointer!=conslast) { |
Pokitto | 0:e8b8f36b4505 | 300 | PrintMessage(); |
Pokitto | 0:e8b8f36b4505 | 301 | Next(); |
Pokitto | 0:e8b8f36b4505 | 302 | if (GetMessage().msgsource==MSOURCE_NULL) break; |
Pokitto | 0:e8b8f36b4505 | 303 | } |
Pokitto | 0:e8b8f36b4505 | 304 | _display->font = oldfont; |
Pokitto | 0:e8b8f36b4505 | 305 | _display->fontSize = oldsize; |
Pokitto | 0:e8b8f36b4505 | 306 | _display->cursorX = oldx; |
Pokitto | 0:e8b8f36b4505 | 307 | _display->cursorY = oldy; |
Pokitto | 0:e8b8f36b4505 | 308 | _display->directcolor = oldcolor; |
Pokitto | 0:e8b8f36b4505 | 309 | } |
Pokitto | 0:e8b8f36b4505 | 310 | |
Pokitto | 0:e8b8f36b4505 | 311 | |
Pokitto | 0:e8b8f36b4505 | 312 | |
Pokitto | 0:e8b8f36b4505 | 313 | |
Pokitto | 0:e8b8f36b4505 | 314 | |
Pokitto | 0:e8b8f36b4505 | 315 |