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!

Files at this revision

API Documentation at this revision

Comitter:
Pokitto
Date:
Fri Jan 05 02:19:51 2018 +0000
Parent:
27:24970a0c35a8
Child:
29:9467921dec10
Commit message:
Sound level stored in EEPROM, sound output improved

Changed in this revision

POKITTO_CORE/PokittoCore.cpp Show annotated file Show diff for this revision Revisions of this file
POKITTO_HW/PokittoEEPROM.h Show annotated file Show diff for this revision Revisions of this file
POKITTO_HW/iap.cpp Show annotated file Show diff for this revision Revisions of this file
POKITTO_HW/iap.h Show annotated file Show diff for this revision Revisions of this file
Pokitto_settings.h Show annotated file Show diff for this revision Revisions of this file
--- a/POKITTO_CORE/PokittoCore.cpp	Mon Jan 01 10:22:02 2018 +0000
+++ b/POKITTO_CORE/PokittoCore.cpp	Fri Jan 05 02:19:51 2018 +0000
@@ -442,10 +442,18 @@
 void Core::setVolLimit() {
     display.enableDirectPrinting(true);
     display.adjustCharStep = 0;
-    sound.setMaxVol(VOLUME_HEADPHONE_MAX);
+    //sound.setMaxVol(VOLUME_HEADPHONE_MAX);
     int dstate=1;
     bool wipe = true;
     float vol = sound.getVolume(); float tvol;
+    #ifndef POK_SIM
+    vol=eeprom_read_byte((uint16_t*)EESETTINGS_VOL);
+    #endif
+    if (vol>VOLUME_HEADPHONE_MAX) sound.setMaxVol(VOLUME_SPEAKER_MAX);
+    else sound.setMaxVol(VOLUME_HEADPHONE_MAX);
+    for (uint8_t t=0;t<vol;t++) {
+            sound.setVolume(t);
+    }
     volbar_visible=0;
     while (core.isRunning() && dstate){
         switch (dstate) {
@@ -503,7 +511,7 @@
             if (aBtn()) {dstate=0;while(aBtn()){buttons.pollButtons();};break;}
             if (rightBtn()) {
                     if (vol >= VOLUME_HEADPHONE_MAX && vol < VOLUME_HEADPHONE_MAX+1 ) vol += 0.00025f*VINCMULT;
-                    else if (vol >= VOLUME_HEADPHONE_MAX) vol += 0.025f*VINCMULT;
+                    else if (vol >= VOLUME_HEADPHONE_MAX) vol += 0.25f*VINCMULT;
                     else vol += 0.05f*VINCMULT;
                     if (vol > VOLUME_HEADPHONE_MAX + 20) {
                             sound.setMaxVol(VOLUME_SPEAKER_MAX);
@@ -514,7 +522,8 @@
                     break;
                     }
             if (leftBtn()) {
-                    vol -= 0.025f*VINCMULT;
+                    if (vol >= VOLUME_HEADPHONE_MAX) vol -= 0.25f*VINCMULT;
+                    else vol -= 0.05f*VINCMULT;
                     if (vol <= VOLUME_HEADPHONE_MAX) sound.setMaxVol(VOLUME_HEADPHONE_MAX);
                     if (vol < 0) vol=0;
                     sound.setVolume(vol);
@@ -524,6 +533,11 @@
             break;
         }
     }
+    #ifndef POK_SIM
+    eeprom_write_byte((uint16_t*)EESETTINGS_VOL,(uint8_t)vol);
+    #endif
+    sound.setVolume(vol);
+    sound.volumeUp();
 }
 
 void Core::begin() {
@@ -585,6 +599,7 @@
     #endif
 	#if POK_ENABLE_SOUND > 0
         sound.begin();
+        sound.volumeUp();
 
 	//mute when B is held during start up or if battery is low
 	battery.update();
--- a/POKITTO_HW/PokittoEEPROM.h	Mon Jan 01 10:22:02 2018 +0000
+++ b/POKITTO_HW/PokittoEEPROM.h	Fri Jan 05 02:19:51 2018 +0000
@@ -38,12 +38,12 @@
         : index( index )                 {}
 
     //Access/read members.
-    uint8_t operator*() const            { return eeprom_read_byte( (uint8_t*) index ); }
+    uint8_t operator*() const            { return eeprom_read_byte( (uint16_t*) index ); }
     operator uint8_t() const       { return **this; }
 
     //Assignment/write members.
     EERef &operator=( const EERef &ref ) { return *this = *ref; }
-    EERef &operator=( uint8_t in )       { return eeprom_write_byte( (uint8_t*) index, in ), *this;  }
+    EERef &operator=( uint8_t in )       { return eeprom_write_byte( (uint16_t*) index, in ), *this;  }
     EERef &operator +=( uint8_t in )     { return *this = **this + in; }
     EERef &operator -=( uint8_t in )     { return *this = **this - in; }
     EERef &operator *=( uint8_t in )     { return *this = **this * in; }
--- a/POKITTO_HW/iap.cpp	Mon Jan 01 10:22:02 2018 +0000
+++ b/POKITTO_HW/iap.cpp	Fri Jan 05 02:19:51 2018 +0000
@@ -283,7 +283,7 @@
 //Param3: System Clock Frequency (CCLK) in kHz
 //
 //Return Code CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED
-__attribute__((section(".IAP_Code"))) void writeEEPROM( uint8_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount )
+__attribute__((section(".IAP_Code"))) void writeEEPROM( uint16_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount )
 {
 	unsigned int command[5], result[4];
 
@@ -321,7 +321,7 @@
 //Param3: System Clock Frequency (CCLK) in kHz
 //
 //Return Code CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED
-__attribute__((section(".IAP_Code"))) void readEEPROM( uint8_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount )
+__attribute__((section(".IAP_Code"))) void readEEPROM( uint16_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount )
 {
 	unsigned int command[5], result[4];
 
@@ -365,13 +365,13 @@
 	return;
 }
 
-uint8_t eeprom_read_byte(uint8_t* index) {
+uint8_t eeprom_read_byte(uint16_t* index) {
     uint8_t val;
     readEEPROM(index,&val,1);
     return val;
 }
 
-void eeprom_write_byte(uint8_t*index , uint8_t val) {
+void eeprom_write_byte(uint16_t*index , uint8_t val) {
     writeEEPROM(index,&val,1);
 }
 
--- a/POKITTO_HW/iap.h	Mon Jan 01 10:22:02 2018 +0000
+++ b/POKITTO_HW/iap.h	Fri Jan 05 02:19:51 2018 +0000
@@ -6,10 +6,10 @@
 extern char iaptest();
 extern void IAPstacksave();
 #define EEPROM_PROFILE 1
-extern void writeEEPROM( uint8_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount );
-extern void readEEPROM( uint8_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount );
-extern uint8_t eeprom_read_byte(uint8_t*);
-extern void eeprom_write_byte(uint8_t*,uint8_t);
+extern void writeEEPROM( uint16_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount );
+extern void readEEPROM( uint16_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount );
+extern uint8_t eeprom_read_byte(uint16_t*);
+extern void eeprom_write_byte(uint16_t*,uint8_t);
 
 /*****************************************************************************
  * $Id$
--- a/Pokitto_settings.h	Mon Jan 01 10:22:02 2018 +0000
+++ b/Pokitto_settings.h	Fri Jan 05 02:19:51 2018 +0000
@@ -386,5 +386,8 @@
 #define SPRITE_COUNT 4  // The default max sprite count
 #endif
 
+/** SYSTEM SETTINGS ADDRESSES IN EEPROM **/
+#define EESETTINGS_VOL 4000
+
 #endif // POKITTO_SETTINGS_H