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/GBcompatibility.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 | #ifndef GBCOMPATIBILITY_H |
Pokitto | 0:e8b8f36b4505 | 2 | #define GBCOMPATIBILITY_H |
Pokitto | 0:e8b8f36b4505 | 3 | |
Pokitto | 0:e8b8f36b4505 | 4 | /* |
Pokitto | 0:e8b8f36b4505 | 5 | * (C) Copyright 2014 Aurélien Rodot. All rights reserved. |
Pokitto | 0:e8b8f36b4505 | 6 | * |
Pokitto | 0:e8b8f36b4505 | 7 | * This file is part of the Gamebuino Library (http://gamebuino.com) |
Pokitto | 0:e8b8f36b4505 | 8 | * |
Pokitto | 0:e8b8f36b4505 | 9 | * The Gamebuino Library is free software: you can redistribute it and/or modify |
Pokitto | 0:e8b8f36b4505 | 10 | * it under the terms of the GNU Lesser General Public License as published by |
Pokitto | 0:e8b8f36b4505 | 11 | * the Free Software Foundation, either version 3 of the License, or |
Pokitto | 0:e8b8f36b4505 | 12 | * (at your option) any later version. |
Pokitto | 0:e8b8f36b4505 | 13 | * |
Pokitto | 0:e8b8f36b4505 | 14 | * This program is distributed in the hope that it will be useful, |
Pokitto | 0:e8b8f36b4505 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Pokitto | 0:e8b8f36b4505 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Pokitto | 0:e8b8f36b4505 | 17 | * GNU Lesser General Public License for more details. |
Pokitto | 0:e8b8f36b4505 | 18 | * |
Pokitto | 0:e8b8f36b4505 | 19 | * You should have received a copy of the GNU Lesser General Public License |
Pokitto | 0:e8b8f36b4505 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
Pokitto | 0:e8b8f36b4505 | 21 | */ |
Pokitto | 0:e8b8f36b4505 | 22 | |
Pokitto | 0:e8b8f36b4505 | 23 | |
Pokitto | 0:e8b8f36b4505 | 24 | |
Pokitto | 0:e8b8f36b4505 | 25 | #ifndef SETTINGS_C |
Pokitto | 0:e8b8f36b4505 | 26 | #define SETTINGS_C |
Pokitto | 0:e8b8f36b4505 | 27 | |
Pokitto | 0:e8b8f36b4505 | 28 | #include "binary.h" |
Pokitto | 0:e8b8f36b4505 | 29 | |
Pokitto | 0:e8b8f36b4505 | 30 | #define _BV(bit) (1 << (bit)) //jonne |
Pokitto | 0:e8b8f36b4505 | 31 | |
Pokitto | 0:e8b8f36b4505 | 32 | #define NOROT 0 |
Pokitto | 0:e8b8f36b4505 | 33 | #define ROTCCW 1 |
Pokitto | 0:e8b8f36b4505 | 34 | #define ROT180 2 |
Pokitto | 0:e8b8f36b4505 | 35 | #define ROTCW 3 |
Pokitto | 0:e8b8f36b4505 | 36 | |
Pokitto | 0:e8b8f36b4505 | 37 | //colors |
Pokitto | 0:e8b8f36b4505 | 38 | #define WHITE 0 |
Pokitto | 0:e8b8f36b4505 | 39 | #define BLACK 1 |
Pokitto | 0:e8b8f36b4505 | 40 | #define GRAY 2 |
Pokitto | 0:e8b8f36b4505 | 41 | #define INVERT 255 |
Pokitto | 0:e8b8f36b4505 | 42 | |
Pokitto | 0:e8b8f36b4505 | 43 | //for extended bitmap function : |
Pokitto | 0:e8b8f36b4505 | 44 | #define NOROT 0 |
Pokitto | 0:e8b8f36b4505 | 45 | #define ROTCCW 1 |
Pokitto | 0:e8b8f36b4505 | 46 | #define ROT180 2 |
Pokitto | 0:e8b8f36b4505 | 47 | #define ROTCW 3 |
Pokitto | 0:e8b8f36b4505 | 48 | #define NOFLIP 0 |
Pokitto | 0:e8b8f36b4505 | 49 | #define FLIPH 1 |
Pokitto | 0:e8b8f36b4505 | 50 | #define FLIPV 2 |
Pokitto | 0:e8b8f36b4505 | 51 | #define FLIPVH 3 |
Pokitto | 0:e8b8f36b4505 | 52 | |
Pokitto | 0:e8b8f36b4505 | 53 | |
Pokitto | 0:e8b8f36b4505 | 54 | |
Pokitto | 0:e8b8f36b4505 | 55 | |
Pokitto | 0:e8b8f36b4505 | 56 | //SETTINGS YOU CAN EDIT |
Pokitto | 0:e8b8f36b4505 | 57 | |
Pokitto | 0:e8b8f36b4505 | 58 | #define NUM_CHANNELS 1 //number of sound channels, between 0 and 4 |
Pokitto | 0:e8b8f36b4505 | 59 | #define DISPLAY_ROT NOROT //set to NOROT, ROTCCW, ROT180 or ROTCW. Can be used to play in portrait mode. |
Pokitto | 0:e8b8f36b4505 | 60 | #define ENABLE_GUI 1 //enable menu, keyboard, pop-up, volume adjust functions |
Pokitto | 0:e8b8f36b4505 | 61 | #define ENABLE_BITMAPS 1 //will replace bitmaps with rectangles if disabled |
Pokitto | 0:e8b8f36b4505 | 62 | #define ENABLE_GRAYSCALE 1 //allows the use of the GRAY color |
Pokitto | 0:e8b8f36b4505 | 63 | #define EXTENDED_NOTE_RANGE 0 //allows the use of notes above A 5... please avoid that they sound really bad |
Pokitto | 0:e8b8f36b4505 | 64 | |
Pokitto | 0:e8b8f36b4505 | 65 | //not really useful |
Pokitto | 0:e8b8f36b4505 | 66 | #define ENABLE_BATTERY 1 //disable battery monitoring |
Pokitto | 0:e8b8f36b4505 | 67 | #define ENABLE_BACKLIGHT 1 //disable automatic back-light |
Pokitto | 0:e8b8f36b4505 | 68 | |
Pokitto | 0:e8b8f36b4505 | 69 | //IT'S STRONGLY ADVISED TO LEAVE THE FOLLOWING SETTINGS ALONE |
Pokitto | 0:e8b8f36b4505 | 70 | |
Pokitto | 0:e8b8f36b4505 | 71 | //defaults values of settings which can be adjusted on each Gamebuino using settings.hex |
Pokitto | 0:e8b8f36b4505 | 72 | #define SCR_CONTRAST 60 |
Pokitto | 0:e8b8f36b4505 | 73 | #define START_MENU_TIMER 255 //40 = 40 frames (2sec) before start menu is skipped, 0 = no start menu, 255 = start menu until you press A |
Pokitto | 0:e8b8f36b4505 | 74 | |
Pokitto | 0:e8b8f36b4505 | 75 | //addresses of settings stored in the program memory |
Pokitto | 0:e8b8f36b4505 | 76 | #define SETTINGS_PAGE ((const char *)(0x7800-128)) |
Pokitto | 0:e8b8f36b4505 | 77 | #define SETTINGS_TOKEN 0xC001 |
Pokitto | 0:e8b8f36b4505 | 78 | #define OFFSET_CURRENTGAME 2 |
Pokitto | 0:e8b8f36b4505 | 79 | #define OFFSET_USERNAME 11 |
Pokitto | 0:e8b8f36b4505 | 80 | #define USERNAME_LENGTH 10 |
Pokitto | 0:e8b8f36b4505 | 81 | #define OFFSET_CONTRAST 22 |
Pokitto | 0:e8b8f36b4505 | 82 | #define OFFSET_BACKLIGHT_MIN 23 |
Pokitto | 0:e8b8f36b4505 | 83 | #define OFFSET_BACKLIGHT_MAX 24 |
Pokitto | 0:e8b8f36b4505 | 84 | #define OFFSET_LIGHT_MIN 25 |
Pokitto | 0:e8b8f36b4505 | 85 | #define OFFSET_LIGHT_MAX 27 |
Pokitto | 0:e8b8f36b4505 | 86 | #define OFFSET_VOLUME_MAX 29 |
Pokitto | 0:e8b8f36b4505 | 87 | #define OFFSET_VOLUME_DEFAULT 30 |
Pokitto | 0:e8b8f36b4505 | 88 | #define OFFSET_START_MENU_TIMER 31 |
Pokitto | 0:e8b8f36b4505 | 89 | #define OFFSET_BATTERY_CRITIC 32 |
Pokitto | 0:e8b8f36b4505 | 90 | #define OFFSET_BATTERY_LOW 34 |
Pokitto | 0:e8b8f36b4505 | 91 | #define OFFSET_BATTERY_MED 36 |
Pokitto | 0:e8b8f36b4505 | 92 | #define OFFSET_BATTERY_FULL 38 |
Pokitto | 0:e8b8f36b4505 | 93 | |
Pokitto | 0:e8b8f36b4505 | 94 | //GUI |
Pokitto | 0:e8b8f36b4505 | 95 | #define KEYBOARD_W 16 |
Pokitto | 0:e8b8f36b4505 | 96 | #define KEYBOARD_H 8 |
Pokitto | 0:e8b8f36b4505 | 97 | |
Pokitto | 0:e8b8f36b4505 | 98 | //sound |
Pokitto | 0:e8b8f36b4505 | 99 | #define VOLUME_CHANNEL_MAX 255/NUM_CHANNELS/7/9 //7=instrument volume 9=note volume |
Pokitto | 0:e8b8f36b4505 | 100 | |
Pokitto | 0:e8b8f36b4505 | 101 | //battery voltage monitor |
Pokitto | 0:e8b8f36b4505 | 102 | #define BAT_PIN 6 //was A6 |
Pokitto | 0:e8b8f36b4505 | 103 | #define NUM_LVL 4 |
Pokitto | 0:e8b8f36b4505 | 104 | #define BAT_LVL_CRITIC 3500 |
Pokitto | 0:e8b8f36b4505 | 105 | #define BAT_LVL_LOW 3550 |
Pokitto | 0:e8b8f36b4505 | 106 | #define BAT_LVL_MED 3700 |
Pokitto | 0:e8b8f36b4505 | 107 | #define BAT_LVL_FULL 3900 |
Pokitto | 0:e8b8f36b4505 | 108 | |
Pokitto | 0:e8b8f36b4505 | 109 | //SD card |
Pokitto | 0:e8b8f36b4505 | 110 | #define SD_CS 10 |
Pokitto | 0:e8b8f36b4505 | 111 | |
Pokitto | 0:e8b8f36b4505 | 112 | //screens back light |
Pokitto | 0:e8b8f36b4505 | 113 | #define BACKLIGHT_PIN 5 |
Pokitto | 0:e8b8f36b4505 | 114 | //auto back-light levels |
Pokitto | 0:e8b8f36b4505 | 115 | #define BACKLIGHT_MIN 0 |
Pokitto | 0:e8b8f36b4505 | 116 | #define BACKLIGHT_MAX 255 |
Pokitto | 0:e8b8f36b4505 | 117 | |
Pokitto | 0:e8b8f36b4505 | 118 | //ambient light sensor |
Pokitto | 0:e8b8f36b4505 | 119 | #define AMBIENTLIGHT_PIN A7 |
Pokitto | 0:e8b8f36b4505 | 120 | //auto back-light levels |
Pokitto | 0:e8b8f36b4505 | 121 | #define AMBIENTLIGHT_MIN 800 //800 |
Pokitto | 0:e8b8f36b4505 | 122 | #define AMBIENTLIGHT_MAX 980 //1000 |
Pokitto | 0:e8b8f36b4505 | 123 | #define AMBIENTLIGHT_SMOOTHING 16 |
Pokitto | 0:e8b8f36b4505 | 124 | |
Pokitto | 0:e8b8f36b4505 | 125 | //number of buttons |
Pokitto | 0:e8b8f36b4505 | 126 | #define NUM_BTN 7 |
Pokitto | 0:e8b8f36b4505 | 127 | //buttons ID |
Pokitto | 0:e8b8f36b4505 | 128 | #if DISPLAY_ROT == 0 |
Pokitto | 0:e8b8f36b4505 | 129 | #define BTN_UP 1 |
Pokitto | 0:e8b8f36b4505 | 130 | #define BTN_RIGHT 2 |
Pokitto | 0:e8b8f36b4505 | 131 | #define BTN_DOWN 3 |
Pokitto | 0:e8b8f36b4505 | 132 | #define BTN_LEFT 0 |
Pokitto | 0:e8b8f36b4505 | 133 | #elif DISPLAY_ROT == ROTCCW |
Pokitto | 0:e8b8f36b4505 | 134 | #define BTN_UP 2 |
Pokitto | 0:e8b8f36b4505 | 135 | #define BTN_RIGHT 3 |
Pokitto | 0:e8b8f36b4505 | 136 | #define BTN_DOWN 0 |
Pokitto | 0:e8b8f36b4505 | 137 | #define BTN_LEFT 1 |
Pokitto | 0:e8b8f36b4505 | 138 | #elif DISPLAY_ROT == ROT180 |
Pokitto | 0:e8b8f36b4505 | 139 | #define BTN_UP 3 |
Pokitto | 0:e8b8f36b4505 | 140 | #define BTN_RIGHT 0 |
Pokitto | 0:e8b8f36b4505 | 141 | #define BTN_DOWN 1 |
Pokitto | 0:e8b8f36b4505 | 142 | #define BTN_LEFT 2 |
Pokitto | 0:e8b8f36b4505 | 143 | #elif DISPLAY_ROT == ROTCW |
Pokitto | 0:e8b8f36b4505 | 144 | #define BTN_UP 0 |
Pokitto | 0:e8b8f36b4505 | 145 | #define BTN_RIGHT 1 |
Pokitto | 0:e8b8f36b4505 | 146 | #define BTN_DOWN 2 |
Pokitto | 0:e8b8f36b4505 | 147 | #define BTN_LEFT 3 |
Pokitto | 0:e8b8f36b4505 | 148 | #endif |
Pokitto | 0:e8b8f36b4505 | 149 | #define BTN_A 4 |
Pokitto | 0:e8b8f36b4505 | 150 | #define BTN_B 5 |
Pokitto | 0:e8b8f36b4505 | 151 | #define BTN_C 6 |
Pokitto | 0:e8b8f36b4505 | 152 | |
Pokitto | 0:e8b8f36b4505 | 153 | #define BTN_LEFT_PIN 0 |
Pokitto | 0:e8b8f36b4505 | 154 | #define BTN_UP_PIN 1 |
Pokitto | 0:e8b8f36b4505 | 155 | #define BTN_RIGHT_PIN 2 |
Pokitto | 0:e8b8f36b4505 | 156 | #define BTN_DOWN_PIN 3 |
Pokitto | 0:e8b8f36b4505 | 157 | #define BTN_A_PIN 4 |
Pokitto | 0:e8b8f36b4505 | 158 | #define BTN_B_PIN 5 |
Pokitto | 0:e8b8f36b4505 | 159 | #define BTN_C_PIN 6 |
Pokitto | 0:e8b8f36b4505 | 160 | |
Pokitto | 0:e8b8f36b4505 | 161 | |
Pokitto | 0:e8b8f36b4505 | 162 | |
Pokitto | 0:e8b8f36b4505 | 163 | #endif /* */ |
Pokitto | 0:e8b8f36b4505 | 164 | |
Pokitto | 0:e8b8f36b4505 | 165 | const uint16_t startupSound[] = {0x0005,0x3089,0x208,0x238,0x7849,0x1468,0x0000}; |
Pokitto | 0:e8b8f36b4505 | 166 | |
Pokitto | 0:e8b8f36b4505 | 167 | const uint8_t gamebuinoLogo[] = |
Pokitto | 0:e8b8f36b4505 | 168 | { |
Pokitto | 0:e8b8f36b4505 | 169 | 84,10, //width and height |
Pokitto | 0:e8b8f36b4505 | 170 | B00000011, B11100001, B10000001, B10000110, B01111111, B00111110, B00011000, B01101101, B10000011, B00001111, B00001111, |
Pokitto | 0:e8b8f36b4505 | 171 | B00001110, B00000001, B10000011, B10000110, B01100000, B00110011, B00011000, B01101101, B11000011, B00011001, B10001111, |
Pokitto | 0:e8b8f36b4505 | 172 | B00011000, B00000011, B11000011, B10001110, B01100000, B00110011, B00011000, B01101101, B11100011, B00110000, B11001111, |
Pokitto | 0:e8b8f36b4505 | 173 | B00011000, B00000011, B11000011, B10011110, B01100000, B00110110, B00110000, B11001101, B11100011, B01100000, B11001111, |
Pokitto | 0:e8b8f36b4505 | 174 | B00110000, B00000110, B11000111, B10011110, B01111110, B00111110, B00110000, B11001101, B10110011, B01100000, B11001111, |
Pokitto | 0:e8b8f36b4505 | 175 | B00110000, B00001100, B11000110, B11110110, B01100000, B00110011, B00110000, B11011001, B10110110, B01100000, B11001111, |
Pokitto | 0:e8b8f36b4505 | 176 | B00110011, B11001111, B11001100, B11110110, B01100000, B01100001, B10110000, B11011011, B00011110, B01100000, B11001111, |
Pokitto | 0:e8b8f36b4505 | 177 | B00110000, B11011000, B01101100, B11100110, B11000000, B01100001, B10110000, B11011011, B00011110, B01100001, B10001111, |
Pokitto | 0:e8b8f36b4505 | 178 | B00011001, B10011000, B01101100, B11000110, B11000000, B01100011, B10110001, B10011011, B00001110, B00110011, B00001111, |
Pokitto | 0:e8b8f36b4505 | 179 | B00001111, B10110000, B01111000, B11000110, B11111111, B01111110, B00011111, B00011011, B00000110, B00011110, B00001111, |
Pokitto | 0:e8b8f36b4505 | 180 | }; |
Pokitto | 0:e8b8f36b4505 | 181 | |
Pokitto | 0:e8b8f36b4505 | 182 | #endif // GBCOMPATIBILITY_H |
Pokitto | 0:e8b8f36b4505 | 183 |