Skip to content

Commit

Permalink
Fix #8 Dynamic graph of time domain not initialized
Browse files Browse the repository at this point in the history
Not related to #7: Stop DMA transmitting when USB unplugged
  • Loading branch information
qqq89513 committed Jan 10, 2021
1 parent 656b0c2 commit 4e74019
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int main(void)
printf("[Info] TouchGFX initialized.\r\n");

MX_USB_DEVICE_Init();
HAL_Delay(200);
HAL_Delay(300);
printf("[Info] USB DEVICE initialized.\r\n");

printf("[Info] Entering while(1)...\r\n");
Expand Down
11 changes: 8 additions & 3 deletions TouchGFX/gui/src/screen_screen/screenView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern SAI_HandleTypeDef haudio_out_sai; // forwarded from stm32746g_di
screenView::screenView()
{
tick_cnt = 0;
graph_t.clear();
}

void screenView::setupScreen()
Expand All @@ -37,9 +38,10 @@ void screenView::handleTickEvent(){
uint16_t size = haudio_out_sai.XferSize/2;
// printf("[Debug] XferSize/2:%d, pBuffPtr:%p\r\n", size, samplePtr);
uint32_t tk_temp = uwTick;
for(int i=0; i<400; i++){
graph_t.addDataPoint(samplePtr[i]/200 + 2);
}
if(size > 0)
for(int i=0; i<400; i++){
graph_t.addDataPoint(samplePtr[i]/200 + 2);
}
// printf("[Debug] Adding datapoint to dynamic graph. Time elapsed:%ldms\r\n", uwTick-tk_temp);
}

Expand All @@ -60,8 +62,11 @@ void screenView::handleTickEvent(){
BSP_AUDIO_OUT_SetVolume(slider1.getValue());
break;
case USBD_STATE_SUSPENDED:
HAL_DMA_Abort(haudio_out_sai.hdmatx);
haudio_out_sai.XferSize = 0;
BSP_AUDIO_OUT_DeInit();
slider1.setValue(0);
graph_t.clear();
default:;
}
}
Expand Down

0 comments on commit 4e74019

Please sign in to comment.