Kaynağa Gözat

Pause button

anfractuosity 3 yıl önce
ebeveyn
işleme
becfba1d74
2 değiştirilmiş dosya ile 10 ekleme ve 1 silme
  1. 2 0
      README.md
  2. 8 1
      scenes/scope_scene_run.c

+ 2 - 0
README.md

@@ -12,6 +12,8 @@ cd ..
 
 Provide signal to pin 16/C0, with a voltage ranging from 0V to 3.3V.
 
+Press the 'ok' button (button in the centre of joypad) to pause/unpause the waveform display.
+
 ## To Do
 
 * Customisable input pin

+ 8 - 1
scenes/scope_scene_run.c

@@ -34,6 +34,7 @@ const uint32_t APBPrescTable[8UL]  = {0UL, 0UL, 0UL, 0UL, 1UL, 2UL, 3UL, 4UL};
 const uint32_t MSIRangeTable[16UL] = {100000UL, 200000UL, 400000UL, 800000UL, 1000000UL, 2000000UL, \
                                       4000000UL, 8000000UL, 16000000UL, 24000000UL, 32000000UL, 48000000UL, 0UL, 0UL, 0UL, 0UL}; /* 0UL values are incorrect cases */
 double time;
+uint8_t pause=0;
 
 void Error_Handler()
 {
@@ -205,7 +206,8 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef * hadc)
         mvoltWrite[tmp_index] = __ADC_CALC_DATA_VOLTAGE(VDDA_APPLI, aADCxConvertedData[tmp_index]);
     }
     ubDmaTransferStatus = 1;
-    swap(&mvoltWrite, &mvoltDisplay);
+    if(!pause)
+        swap(&mvoltWrite, &mvoltDisplay);
 }
 
 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef * hadc)
@@ -263,6 +265,8 @@ void scope_scene_run_on_enter(void* context) {
     time = app->time;
     UNUSED(app);
 
+    pause = 0;
+
     __disable_irq();
     memcpy(ramVector, (uint32_t*)(FLASH_BASE | SCB->VTOR), sizeof(uint32_t) * TABLE_SIZE);
     SCB->VTOR = (uint32_t)ramVector;
@@ -330,6 +334,9 @@ void scope_scene_run_on_enter(void* context) {
                         break;
                     case InputKeyDown:
                         break;
+                    case InputKeyOk:
+                        pause ^= 1;
+                        break;
                     default:
                         running = false;
                         break;