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!
Diff: POKITTO_CORE/PokittoCore.cpp
- Revision:
- 28:958b71c4b92a
- Parent:
- 24:9561281d0378
--- 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();