16bit resolution PWM wave player with SD card, super lite version.

Dependencies:   mbed DirectSPI FastPWM

Supported boards (confirmed):
Nucleo-F030R8
Nucleo-L152RE
Nucleo-F401RE
Nucleo-F411RE

Only compilation is OK (unchecked, but may work):
Nucleo-L073RZ
Nucleo-F334R8
Nucleo-F303RE
Nucleo-F429ZI
Nucleo-F446RE
Nucleo-F446ZE
Nucleo-L476RG

Supported SD card:
SDSC/SDHC card,
FAT16 and FAT32.
(1) At first, format SD card using SD Card Formatter
https://www.sdcard.org/downloads/formatter_4/index.html
(2) Copy PCM wav files to the SD card.
Supported file:
PCM wave file that have file extension ".wav" on root directory.
16bit/8bit, fs(sampling rate)=32kHz,44.1kHz,48kHz.
Stereo/Mono.

Hardware setting:
Refer to the file port_setting.txt
PWM output port:
Left upper(Hi) PWM 8bit out: PB_5 (TM3_CH2)
Right upper(Hi) PWM 8bit out: PB4 (TM3_CH1)
Left lower(Low) PWM 8bit out: PC_9 (TM3_CH4)
Right lower(Low) PWM 8bit out: PC_8 (TM3_CH3)
http://mpu.up.seesaa.net/image/16bit-wave-player-output-schema.png
USER_BUTTON: PC_13(default button)
Next song: One click in Play mode.
Pause : Push long time .
Play : One click from Pause.

Committer:
mimi3
Date:
Wed Sep 16 20:36:42 2020 +0900
Revision:
19:54aed6200a35
Parent:
18:082bce602af9
Child:
20:c7066a530b1f
bugfix again: mixing PCM data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mimi3 0:9a5c2fb0d96f 1 #include "sys.h"
mimi3 0:9a5c2fb0d96f 2 #include "sd_card.h"
mimi3 0:9a5c2fb0d96f 3 #include "fat_lib.h"
mimi3 0:9a5c2fb0d96f 4 #include "pwm_lib.h"
mimi3 0:9a5c2fb0d96f 5 #include "timers.h"
mimi3 0:9a5c2fb0d96f 6
mimi3 0:9a5c2fb0d96f 7 #define CH_STEREO 2 // 2:STEREO, 1:MONO
mimi3 0:9a5c2fb0d96f 8 #define wREAD_COUNT 512
mimi3 0:9a5c2fb0d96f 9 #define bHEADER_COUNT 44
mimi3 0:9a5c2fb0d96f 10 #define send_ff() spi_read()
mimi3 0:9a5c2fb0d96f 11 #define send_ff16() spi_read16()
mimi3 0:9a5c2fb0d96f 12 #define CUT_LAST_TAG_NOISE (30*1000)
mimi3 11:8dc9fa1e1bdc 13 #if (HAVE_LED_IND_PWM==1) || (HAVE_LED_IND_BLINK==1)
mimi3 0:9a5c2fb0d96f 14 DigitalOut led(IND_LED);
mimi3 0:9a5c2fb0d96f 15 #endif
mimi3 11:8dc9fa1e1bdc 16 #define ind_on() (led = 1)
mimi3 11:8dc9fa1e1bdc 17 #define ind_off() (led = 0)
mimi3 11:8dc9fa1e1bdc 18
mimi3 11:8dc9fa1e1bdc 19 #define pwm_period_timer_music_start() ( pwm_period_timer_start(),fPlaying = true)
mimi3 11:8dc9fa1e1bdc 20 #define pwm_period_timer_music_stop() ( pwm_period_timer_stop(), fPlaying = false)
mimi3 0:9a5c2fb0d96f 21
mimi3 0:9a5c2fb0d96f 22 /******************
mimi3 0:9a5c2fb0d96f 23 varialble definitions
mimi3 0:9a5c2fb0d96f 24 *******************/
mimi3 0:9a5c2fb0d96f 25 #define LED_PERIOD_PLAYNG 75 //[ * 10 msec]
mimi3 0:9a5c2fb0d96f 26 #define LED_PERIOD_PAUSING 10 //[ * 10 msec]
mimi3 0:9a5c2fb0d96f 27 dword ldwSongFileSectors;
mimi3 0:9a5c2fb0d96f 28 dword ldwSample_freq;
mimi3 0:9a5c2fb0d96f 29 word lwReadCount;
mimi3 0:9a5c2fb0d96f 30 byte lbSample_bits = 16;
mimi3 0:9a5c2fb0d96f 31 byte lbCh_mode = CH_STEREO;
mimi3 19:54aed6200a35 32 byte bGainNormalizeFactor;
mimi3 11:8dc9fa1e1bdc 33 bool fPlaying = false;
mimi3 0:9a5c2fb0d96f 34
mimi3 0:9a5c2fb0d96f 35 DigitalIn btn_bit_now(USER_BUTTON,PullUp);
mimi3 0:9a5c2fb0d96f 36
mimi3 0:9a5c2fb0d96f 37 #if TEST_PORT_ENABLE
mimi3 0:9a5c2fb0d96f 38 DigitalOut test_port(TEST_PORT);
mimi3 0:9a5c2fb0d96f 39 #endif
mimi3 0:9a5c2fb0d96f 40
mimi3 0:9a5c2fb0d96f 41 /**********************
mimi3 0:9a5c2fb0d96f 42 Period Timer Interrupt
mimi3 0:9a5c2fb0d96f 43 **********************/
mimi3 0:9a5c2fb0d96f 44 /* HAL callback for PWM Timer Intrrupt * */
mimi3 6:d9ea630e1ba5 45 void OPT_SPEED pwmPeriodIntr( void ){
mimi3 8:e35c1f3add8c 46 if(TIM_PWM->SR & TIM_SR_UIF){
mimi3 0:9a5c2fb0d96f 47 #if TEST_PORT_ENABLE
mimi3 0:9a5c2fb0d96f 48 test_port =1;
mimi3 0:9a5c2fb0d96f 49 #endif
mimi3 0:9a5c2fb0d96f 50 #if PWM16BIT
mimi3 18:082bce602af9 51 byte bL_low,bL_hi,bR_low,bR_hi;
mimi3 0:9a5c2fb0d96f 52 if( lbSample_bits == 16 ) {
mimi3 18:082bce602af9 53 bL_low = bR_low = send_ff();
mimi3 18:082bce602af9 54 bL_hi = bR_hi = send_ff() + 0x80;
mimi3 0:9a5c2fb0d96f 55 lwReadCount -= 2;
mimi3 0:9a5c2fb0d96f 56 if( lbCh_mode == CH_STEREO ) {
mimi3 18:082bce602af9 57 bR_low = send_ff();
mimi3 18:082bce602af9 58 bR_hi = send_ff() + 0x80;
mimi3 0:9a5c2fb0d96f 59 lwReadCount -= 2;
mimi3 0:9a5c2fb0d96f 60 }
mimi3 0:9a5c2fb0d96f 61 }
mimi3 0:9a5c2fb0d96f 62 #if DATA_8BIT_SUPPORT
mimi3 0:9a5c2fb0d96f 63 else { /* 8bit data */
mimi3 18:082bce602af9 64 bL_hi = bR_hi = send_ff();
mimi3 18:082bce602af9 65 bL_low = 0;
mimi3 18:082bce602af9 66 bR_low = 0;
mimi3 0:9a5c2fb0d96f 67 lwReadCount -= 1;
mimi3 0:9a5c2fb0d96f 68 if( lbCh_mode == CH_STEREO ) { /* for stereo */
mimi3 18:082bce602af9 69 bR_hi = send_ff();
mimi3 18:082bce602af9 70 bR_low = 0;
mimi3 0:9a5c2fb0d96f 71 lwReadCount -= 1;
mimi3 0:9a5c2fb0d96f 72 }
mimi3 0:9a5c2fb0d96f 73 }
mimi3 0:9a5c2fb0d96f 74 #endif
mimi3 19:54aed6200a35 75 //# Gain up
mimi3 19:54aed6200a35 76 dword wL = (((word)bL_hi)<<8) + bL_low;
mimi3 19:54aed6200a35 77 dword wR = (((word)bR_hi)<<8) + bR_low;
mimi3 19:54aed6200a35 78 wL <<= bGainNormalizeFactor;
mimi3 19:54aed6200a35 79 wR <<= bGainNormalizeFactor;
mimi3 0:9a5c2fb0d96f 80 //# change pwm duties
mimi3 19:54aed6200a35 81 pwm_dutyL_hi( wL >> 8);
mimi3 19:54aed6200a35 82 pwm_dutyL_low( wL & 0xff);
mimi3 19:54aed6200a35 83 pwm_dutyR_hi( wR >> 8);
mimi3 19:54aed6200a35 84 pwm_dutyR_low( wR & 0xff);
mimi3 0:9a5c2fb0d96f 85
mimi3 0:9a5c2fb0d96f 86 #else // not PWM16BIT
mimi3 0:9a5c2fb0d96f 87 word wL =0,wR = 0;
mimi3 0:9a5c2fb0d96f 88 if( lbSample_bits == 16 ) {
mimi3 0:9a5c2fb0d96f 89 wL = wR = ((word)(send_ff() + (send_ff()<<8) + 0x8000))>>gPcmShifNum;
mimi3 0:9a5c2fb0d96f 90 lwReadCount -= 2;
mimi3 0:9a5c2fb0d96f 91 if( lbCh_mode == CH_STEREO ) {
mimi3 0:9a5c2fb0d96f 92 wR = (word)(send_ff() + (send_ff()<<8) + 0x8000)>>gPcmShifNum;
mimi3 0:9a5c2fb0d96f 93 lwReadCount -= 2;
mimi3 0:9a5c2fb0d96f 94 }
mimi3 0:9a5c2fb0d96f 95 }
mimi3 0:9a5c2fb0d96f 96 #if DATA_8BIT_SUPPORT
mimi3 0:9a5c2fb0d96f 97 else { /* 8bit data */
mimi3 19:54aed6200a35 98 wL = wR = send_ff() << bGainNormalizeFactor;
mimi3 0:9a5c2fb0d96f 99 lwReadCount -= 1;
mimi3 0:9a5c2fb0d96f 100 if( lbCh_mode == CH_STEREO ) { /* for stereo */
mimi3 19:54aed6200a35 101 wR = send_ff() << bGainNormalizeFactor;
mimi3 0:9a5c2fb0d96f 102 lwReadCount -= 1;
mimi3 0:9a5c2fb0d96f 103 }
mimi3 0:9a5c2fb0d96f 104 }
mimi3 0:9a5c2fb0d96f 105 #endif
mimi3 0:9a5c2fb0d96f 106 //# change pwm duties
mimi3 0:9a5c2fb0d96f 107 pwm_dutyL_hi( wL ) ;
mimi3 0:9a5c2fb0d96f 108 pwm_dutyR_hi( wR ) ;
mimi3 0:9a5c2fb0d96f 109 #endif
mimi3 0:9a5c2fb0d96f 110
mimi3 0:9a5c2fb0d96f 111 //; check 512byte sector boundery
mimi3 0:9a5c2fb0d96f 112 if( lwReadCount == 0){
mimi3 0:9a5c2fb0d96f 113 //; end 1 sector
mimi3 0:9a5c2fb0d96f 114 send_ff() ;// dummy read 1st. discard CRC
mimi3 0:9a5c2fb0d96f 115 send_ff() ;// 2nd.
mimi3 0:9a5c2fb0d96f 116 while( send_ff() != 0xFE) {}
mimi3 0:9a5c2fb0d96f 117 lwReadCount = wREAD_COUNT;
mimi3 0:9a5c2fb0d96f 118 ldwSongFileSectors -= 1;
mimi3 13:544349ffb861 119 if(ldwSongFileSectors == 0){
mimi3 13:544349ffb861 120 pwm_period_timer_music_stop();
mimi3 13:544349ffb861 121 }
mimi3 0:9a5c2fb0d96f 122 }
mimi3 0:9a5c2fb0d96f 123 #if TEST_PORT_ENABLE
mimi3 0:9a5c2fb0d96f 124 test_port =0;
mimi3 0:9a5c2fb0d96f 125 #endif
mimi3 5:4aa4cc29d5ef 126
mimi3 8:e35c1f3add8c 127 TIM_PWM->SR &= (~TIM_SR_UIF);
mimi3 0:9a5c2fb0d96f 128 }
mimi3 0:9a5c2fb0d96f 129 }
mimi3 0:9a5c2fb0d96f 130
mimi3 0:9a5c2fb0d96f 131 /******************
mimi3 0:9a5c2fb0d96f 132 wave_player_main
mimi3 0:9a5c2fb0d96f 133 *******************/
mimi3 0:9a5c2fb0d96f 134 void wave_player_main(){
mimi3 19:54aed6200a35 135 bGainNormalizeFactor = calcPcmValidBits() - 8;
mimi3 0:9a5c2fb0d96f 136 word wBtnLowCount = 0;
mimi3 11:8dc9fa1e1bdc 137 #if HAVE_LED_IND_BLINK
mimi3 0:9a5c2fb0d96f 138 byte bTimeout_led = 0;
mimi3 0:9a5c2fb0d96f 139 #endif
mimi3 0:9a5c2fb0d96f 140 sbit btn_bit_prev = true, btn_short_on = false;
mimi3 0:9a5c2fb0d96f 141 sbit btn_long_on = false;
mimi3 0:9a5c2fb0d96f 142 #if HAVE_POWER_OFF_MODE
mimi3 0:9a5c2fb0d96f 143 btn_long_on2 = false;
mimi3 0:9a5c2fb0d96f 144 #endif
mimi3 11:8dc9fa1e1bdc 145
mimi3 0:9a5c2fb0d96f 146 sbit btn_pause_prev = false;
mimi3 11:8dc9fa1e1bdc 147 #define fbtn_next_song_on btn_short_on
mimi3 0:9a5c2fb0d96f 148 #define btn_pause_on btn_long_on
mimi3 0:9a5c2fb0d96f 149 #define btn_power_off_on btn_long_on2
mimi3 0:9a5c2fb0d96f 150
mimi3 11:8dc9fa1e1bdc 151 #if HAVE_LED_IND_PWM // pseudo PWM setting
mimi3 11:8dc9fa1e1bdc 152 const int8_t IND_PERIOD = 125;
mimi3 11:8dc9fa1e1bdc 153 const int8_t IND_DUTY_LOW_SPEED = 1;
mimi3 11:8dc9fa1e1bdc 154 const int8_t IND_DUTY_HI_SPEED = 3;
mimi3 11:8dc9fa1e1bdc 155 int8_t sbIndDuty = 0;
mimi3 11:8dc9fa1e1bdc 156 int8_t sbIndCurrPos = 0;
mimi3 11:8dc9fa1e1bdc 157 int8_t sbIndSpeed = IND_DUTY_LOW_SPEED;
mimi3 11:8dc9fa1e1bdc 158 int8_t sbIndDelta = sbIndSpeed;
mimi3 0:9a5c2fb0d96f 159 #endif
mimi3 0:9a5c2fb0d96f 160
mimi3 0:9a5c2fb0d96f 161 init_tickTimer();
mimi3 0:9a5c2fb0d96f 162
mimi3 0:9a5c2fb0d96f 163 while(1){
mimi3 0:9a5c2fb0d96f 164 //; wait 10msec Ticker flag
mimi3 0:9a5c2fb0d96f 165 while ( !isTickTimer_IF() ) {
mimi3 0:9a5c2fb0d96f 166 if( ldwSongFileSectors == 0 ){ //; found end of file
mimi3 0:9a5c2fb0d96f 167 break; //promptly exit and prepare next song
mimi3 0:9a5c2fb0d96f 168 }
mimi3 11:8dc9fa1e1bdc 169 #if HAVE_LED_IND_PWM
mimi3 11:8dc9fa1e1bdc 170 /*# ---------------------
mimi3 11:8dc9fa1e1bdc 171 # pseudo PWM for LED
mimi3 11:8dc9fa1e1bdc 172 # ---------------------*/
mimi3 11:8dc9fa1e1bdc 173 if(sbIndCurrPos < sbIndDuty) { ind_on();}
mimi3 11:8dc9fa1e1bdc 174 else{ ind_off();}
mimi3 11:8dc9fa1e1bdc 175 sbIndCurrPos++;
mimi3 11:8dc9fa1e1bdc 176 if(sbIndCurrPos == IND_PERIOD){ sbIndCurrPos = 0; }
mimi3 0:9a5c2fb0d96f 177 #endif
mimi3 0:9a5c2fb0d96f 178 } //; end. wait 10msec Ticker flag
mimi3 0:9a5c2fb0d96f 179
mimi3 0:9a5c2fb0d96f 180 //-------------------
mimi3 0:9a5c2fb0d96f 181 tickTimer_IF_clear();
mimi3 0:9a5c2fb0d96f 182 //-------------------
mimi3 0:9a5c2fb0d96f 183
mimi3 0:9a5c2fb0d96f 184 /*-------------------
mimi3 0:9a5c2fb0d96f 185 Next song and start
mimi3 0:9a5c2fb0d96f 186 -------------------*/
mimi3 11:8dc9fa1e1bdc 187 if ( ( ldwSongFileSectors == 0 ) | fbtn_next_song_on ){
mimi3 11:8dc9fa1e1bdc 188 pwm_period_timer_music_stop();
mimi3 11:8dc9fa1e1bdc 189 fbtn_next_song_on = false;
mimi3 11:8dc9fa1e1bdc 190 sd_stop_read();
mimi3 11:8dc9fa1e1bdc 191
mimi3 11:8dc9fa1e1bdc 192 /*# ------------------
mimi3 11:8dc9fa1e1bdc 193 # Search next song
mimi3 11:8dc9fa1e1bdc 194 # ------------------*/
mimi3 0:9a5c2fb0d96f 195 searchNextFile();
mimi3 0:9a5c2fb0d96f 196 //## Seek to Target file sector
mimi3 0:9a5c2fb0d96f 197 sd_start_read( gdwTargetFileSector );
mimi3 0:9a5c2fb0d96f 198
mimi3 11:8dc9fa1e1bdc 199 //; delete about last 30Kbyte to cut tag data in *.wav file
mimi3 11:8dc9fa1e1bdc 200 ldwSongFileSectors = ( (gdwBPB_FileSize - CUT_LAST_TAG_NOISE) )>>9 ; //512 , change to sector
mimi3 11:8dc9fa1e1bdc 201
mimi3 11:8dc9fa1e1bdc 202 /*# ------------------
mimi3 11:8dc9fa1e1bdc 203 # Get wav header info
mimi3 11:8dc9fa1e1bdc 204 # ------------------*/
mimi3 11:8dc9fa1e1bdc 205 sd_read_pulse_byte(22); // pos(22) ## Skip part of WAV header
mimi3 11:8dc9fa1e1bdc 206 lbCh_mode = sd_data_byte();// pos(23)
mimi3 11:8dc9fa1e1bdc 207 sd_data_byte(); // pos(24) # dummy read
mimi3 0:9a5c2fb0d96f 208 ldwSample_freq = sd_data_byte() + (sd_data_byte() << 8) +
mimi3 0:9a5c2fb0d96f 209 (sd_data_byte() << 16) +
mimi3 11:8dc9fa1e1bdc 210 (sd_data_byte() << 24); // pos(28)
mimi3 11:8dc9fa1e1bdc 211 sd_read_pulse_byte(6); // pos(34) ## Skip some headers
mimi3 11:8dc9fa1e1bdc 212 lbSample_bits = sd_data_byte(); // pos(35)
mimi3 11:8dc9fa1e1bdc 213 sd_read_pulse_byte(9) ; // pos(44) ## Skip to last position of header
mimi3 0:9a5c2fb0d96f 214
mimi3 11:8dc9fa1e1bdc 215 /*# ------------------
mimi3 11:8dc9fa1e1bdc 216 # Set sampling frequency
mimi3 11:8dc9fa1e1bdc 217 # ------------------*/
mimi3 11:8dc9fa1e1bdc 218 setPwmPeriod(ldwSample_freq);
mimi3 0:9a5c2fb0d96f 219
mimi3 11:8dc9fa1e1bdc 220 /*# ------------------
mimi3 11:8dc9fa1e1bdc 221 # Music start
mimi3 11:8dc9fa1e1bdc 222 # ------------------*/
mimi3 11:8dc9fa1e1bdc 223 lwReadCount = wREAD_COUNT - bHEADER_COUNT;
mimi3 11:8dc9fa1e1bdc 224 pwm_period_timer_music_start();
mimi3 0:9a5c2fb0d96f 225 }
mimi3 0:9a5c2fb0d96f 226
mimi3 0:9a5c2fb0d96f 227 /*-------------------
mimi3 0:9a5c2fb0d96f 228 LED indicator 1 --- pseudo PWM
mimi3 0:9a5c2fb0d96f 229 -------------------*/
mimi3 11:8dc9fa1e1bdc 230 #if HAVE_LED_IND_PWM
mimi3 11:8dc9fa1e1bdc 231 sbIndDuty += sbIndDelta;
mimi3 11:8dc9fa1e1bdc 232 if(sbIndDuty > IND_PERIOD){ sbIndDelta = -1 * sbIndSpeed;}
mimi3 11:8dc9fa1e1bdc 233 if(sbIndDuty == 0){ sbIndDelta = sbIndSpeed;}
mimi3 11:8dc9fa1e1bdc 234 if(fPlaying){ sbIndSpeed = IND_DUTY_LOW_SPEED;}
mimi3 11:8dc9fa1e1bdc 235 else{ sbIndSpeed = IND_DUTY_HI_SPEED;}
mimi3 0:9a5c2fb0d96f 236 #endif
mimi3 0:9a5c2fb0d96f 237
mimi3 0:9a5c2fb0d96f 238 /*-------------------
mimi3 0:9a5c2fb0d96f 239 LED indicator 2 --- simple ON/OFF
mimi3 0:9a5c2fb0d96f 240 -------------------*/
mimi3 11:8dc9fa1e1bdc 241 #if HAVE_LED_IND_BLINK
mimi3 0:9a5c2fb0d96f 242 if (bTimeout_led == 0){
mimi3 0:9a5c2fb0d96f 243 if( fPlaying ){
mimi3 0:9a5c2fb0d96f 244 bTimeout_led = LED_PERIOD_PLAYNG ;// during Playing, on/off
mimi3 0:9a5c2fb0d96f 245 led = !led;
mimi3 0:9a5c2fb0d96f 246 }else{
mimi3 0:9a5c2fb0d96f 247 #if HAVE_LED_PAUSE_INDICATOR
mimi3 0:9a5c2fb0d96f 248 bTimeout_led = LED_PERIOD_PAUSING ;// during Pause, on/off
mimi3 0:9a5c2fb0d96f 249 led = !led;
mimi3 0:9a5c2fb0d96f 250 #else
mimi3 0:9a5c2fb0d96f 251 bTimeout_led = 1;
mimi3 0:9a5c2fb0d96f 252 led = 0;
mimi3 0:9a5c2fb0d96f 253 #endif
mimi3 0:9a5c2fb0d96f 254 }
mimi3 0:9a5c2fb0d96f 255 }
mimi3 0:9a5c2fb0d96f 256 bTimeout_led = bTimeout_led - 1;
mimi3 0:9a5c2fb0d96f 257 #endif
mimi3 0:9a5c2fb0d96f 258
mimi3 0:9a5c2fb0d96f 259 /*-------------------
mimi3 0:9a5c2fb0d96f 260 button sw input
mimi3 0:9a5c2fb0d96f 261 -------------------*/
mimi3 0:9a5c2fb0d96f 262 #if HAVE_BUTTON_SW
mimi3 0:9a5c2fb0d96f 263 if( btn_bit_prev ^ btn_bit_now) {
mimi3 0:9a5c2fb0d96f 264 if (btn_bit_now){ // ; 0 --> 1: btn released
mimi3 0:9a5c2fb0d96f 265 if( (wBtnLowCount > 10) && (wBtnLowCount < 130)){// ; 100msec < x < 1.3sec
mimi3 0:9a5c2fb0d96f 266 btn_short_on = true;
mimi3 0:9a5c2fb0d96f 267 }
mimi3 0:9a5c2fb0d96f 268 wBtnLowCount = 0;
mimi3 0:9a5c2fb0d96f 269 }
mimi3 0:9a5c2fb0d96f 270 }
mimi3 0:9a5c2fb0d96f 271 btn_bit_prev = btn_bit_now;
mimi3 0:9a5c2fb0d96f 272 if (btn_bit_now == false){
mimi3 0:9a5c2fb0d96f 273 wBtnLowCount = wBtnLowCount + 1;
mimi3 0:9a5c2fb0d96f 274 }
mimi3 0:9a5c2fb0d96f 275 //; recognized pause on
mimi3 0:9a5c2fb0d96f 276 if (wBtnLowCount > 120) { // ; 1.2sec >
mimi3 0:9a5c2fb0d96f 277 btn_long_on = true;
mimi3 0:9a5c2fb0d96f 278 }
mimi3 0:9a5c2fb0d96f 279 #if HAVE_POWER_OFF_MODE
mimi3 0:9a5c2fb0d96f 280 if (wBtnLowCount > 400){ //; 4sec >
mimi3 0:9a5c2fb0d96f 281 //; "long on2" is meaning go to sleep mode
mimi3 0:9a5c2fb0d96f 282 btn_long_on2 = true;
mimi3 0:9a5c2fb0d96f 283 }
mimi3 0:9a5c2fb0d96f 284 #endif
mimi3 11:8dc9fa1e1bdc 285
mimi3 11:8dc9fa1e1bdc 286 /*-------------------
mimi3 11:8dc9fa1e1bdc 287 Pause release
mimi3 11:8dc9fa1e1bdc 288 -------------------*/
mimi3 11:8dc9fa1e1bdc 289 if( fbtn_next_song_on){
mimi3 11:8dc9fa1e1bdc 290 if( !fPlaying){ // ; if during pause
mimi3 11:8dc9fa1e1bdc 291 fPlaying = true ; //release pause
mimi3 11:8dc9fa1e1bdc 292 fbtn_next_song_on = false;
mimi3 11:8dc9fa1e1bdc 293 btn_pause_on = false;
mimi3 11:8dc9fa1e1bdc 294 pwm_period_timer_music_start();
mimi3 11:8dc9fa1e1bdc 295 }
mimi3 11:8dc9fa1e1bdc 296 }
mimi3 11:8dc9fa1e1bdc 297
mimi3 11:8dc9fa1e1bdc 298 /*-------------------
mimi3 11:8dc9fa1e1bdc 299 Pause enter
mimi3 11:8dc9fa1e1bdc 300 -------------------*/
mimi3 11:8dc9fa1e1bdc 301 if( btn_pause_prev ^ btn_pause_on ){
mimi3 11:8dc9fa1e1bdc 302 if( btn_pause_on ){
mimi3 11:8dc9fa1e1bdc 303 fPlaying = false;
mimi3 11:8dc9fa1e1bdc 304 pwm_period_timer_music_stop();
mimi3 11:8dc9fa1e1bdc 305 }
mimi3 11:8dc9fa1e1bdc 306 }
mimi3 11:8dc9fa1e1bdc 307 btn_pause_prev = btn_pause_on;
mimi3 0:9a5c2fb0d96f 308 #endif
mimi3 0:9a5c2fb0d96f 309 } //; [forever loop end]
mimi3 0:9a5c2fb0d96f 310 }
mimi3 0:9a5c2fb0d96f 311
mimi3 0:9a5c2fb0d96f 312