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/PokittoGlobs.h@28:958b71c4b92a, 2018-01-05 (annotated)
- Committer:
- Pokitto
- Date:
- Fri Jan 05 02:19:51 2018 +0000
- Revision:
- 28:958b71c4b92a
- Parent:
- 0:e8b8f36b4505
Sound level stored in EEPROM, sound output improved
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 PokittoGlobs.h |
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 | #ifndef POKITTO_GLOBS_H |
Pokitto | 0:e8b8f36b4505 | 38 | #define POKITTO_GLOBS_H |
Pokitto | 0:e8b8f36b4505 | 39 | |
Pokitto | 0:e8b8f36b4505 | 40 | #include <stdint.h> |
Pokitto | 0:e8b8f36b4505 | 41 | |
Pokitto | 0:e8b8f36b4505 | 42 | #ifdef POK_SIM |
Pokitto | 0:e8b8f36b4505 | 43 | #include "SimLCD.h" |
Pokitto | 0:e8b8f36b4505 | 44 | #include "SimSound.h" |
Pokitto | 0:e8b8f36b4505 | 45 | #include "PokittoSimulator.h" |
Pokitto | 0:e8b8f36b4505 | 46 | #else |
Pokitto | 0:e8b8f36b4505 | 47 | #include "mbed.h" |
Pokitto | 0:e8b8f36b4505 | 48 | #include "HWLCD.h" |
Pokitto | 0:e8b8f36b4505 | 49 | #include "HWSound.h" |
Pokitto | 0:e8b8f36b4505 | 50 | #endif // POK_SIM |
Pokitto | 0:e8b8f36b4505 | 51 | |
Pokitto | 0:e8b8f36b4505 | 52 | extern int random(int); |
Pokitto | 0:e8b8f36b4505 | 53 | extern int random(int,int); |
Pokitto | 0:e8b8f36b4505 | 54 | |
Pokitto | 0:e8b8f36b4505 | 55 | #define HIGH 1 |
Pokitto | 0:e8b8f36b4505 | 56 | #define LOW 0 |
Pokitto | 0:e8b8f36b4505 | 57 | |
Pokitto | 0:e8b8f36b4505 | 58 | #define swapWT(type, a, b) \ |
Pokitto | 0:e8b8f36b4505 | 59 | { \ |
Pokitto | 0:e8b8f36b4505 | 60 | type _t_; \ |
Pokitto | 0:e8b8f36b4505 | 61 | _t_ = a; \ |
Pokitto | 0:e8b8f36b4505 | 62 | a = b; \ |
Pokitto | 0:e8b8f36b4505 | 63 | b = _t_; \ |
Pokitto | 0:e8b8f36b4505 | 64 | } |
Pokitto | 0:e8b8f36b4505 | 65 | |
Pokitto | 0:e8b8f36b4505 | 66 | #define SAMPLE_RATE POK_AUD_FREQ //was 16000, was 57000 |
Pokitto | 0:e8b8f36b4505 | 67 | #define NUMFRAMES 570 //1 ms before refresh was 357 |
Pokitto | 0:e8b8f36b4505 | 68 | |
Pokitto | 0:e8b8f36b4505 | 69 | |
Pokitto | 0:e8b8f36b4505 | 70 | // TODO: move these into some suitable place |
Pokitto | 0:e8b8f36b4505 | 71 | extern void fakeISR(); |
Pokitto | 0:e8b8f36b4505 | 72 | extern void audio_IRQ(); |
Pokitto | 0:e8b8f36b4505 | 73 | extern void update_SDAudioStream(); |
Pokitto | 0:e8b8f36b4505 | 74 | extern uint16_t soundbyte; |
Pokitto | 0:e8b8f36b4505 | 75 | |
Pokitto | 0:e8b8f36b4505 | 76 | #if POK_STREAMING_MUSIC |
Pokitto | 0:e8b8f36b4505 | 77 | #define SPEAKER 3 |
Pokitto | 0:e8b8f36b4505 | 78 | // #define BUFFER_SIZE 512 //5120 // was 256 |
Pokitto | 0:e8b8f36b4505 | 79 | extern unsigned char buffers[][BUFFER_SIZE]; |
Pokitto | 0:e8b8f36b4505 | 80 | extern volatile int currentBuffer, oldBuffer; |
Pokitto | 0:e8b8f36b4505 | 81 | extern volatile int bufindex, vol; |
Pokitto | 0:e8b8f36b4505 | 82 | extern volatile unsigned char * currentPtr; |
Pokitto | 0:e8b8f36b4505 | 83 | extern volatile unsigned char * endPtr; |
Pokitto | 0:e8b8f36b4505 | 84 | extern int8_t streamvol; |
Pokitto | 0:e8b8f36b4505 | 85 | extern uint32_t streamcounter; |
Pokitto | 0:e8b8f36b4505 | 86 | extern uint8_t streamstep; |
Pokitto | 0:e8b8f36b4505 | 87 | #endif |
Pokitto | 0:e8b8f36b4505 | 88 | |
Pokitto | 0:e8b8f36b4505 | 89 | #endif // POKITTO_GLOBS_H |
Pokitto | 0:e8b8f36b4505 | 90 |