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:
Tue Oct 23 16:21:01 2018 +0000
Revision:
63:7d1c08cdde5c
Parent:
36:771321e70814
Child:
66:6281a40d73e6
Graphics bug fixed

Who changed what in which revision?

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