|
贴个代码,ECG模拟
- static FT8 beats_Incr[10] = {-10,10,5,-5,-20,20,12,-12,-5,5};
复制代码
- /**
- * brief Heartbeat
- * note 心率
- * param None
- * retval None
- */
- FTVOID Heartbeat(FTVOID)
- {
- x += rate;
- if (x > QVGA_WIDTH) {
- x = 0;
- temp_p = 0;
- temp_y = 0;
- y = QVGA_HIGH/2;
- en = 0;
- temp_x = 0;
- }
- tx = 5*rate;
- tx = ((temp_p+1)*tx) + temp_p*temp_x;
- if (tx <= x){
- if (0 == en) en = 1;
- }
-
- if (en == 1){
- if (y != beats[temp_y]) {
- y += beats_Incr[temp_y] * 5;
- if (y==(QVGA_HIGH/2)+beats_Incr[4] * 5) {
- Play_Sound((108<<8 | 0x10), 100);
- }
- } else {
- temp_y++;
- if (temp_y > 9) {
- temp_y = 0;
- temp_p++;
- en = 0;
- temp_x = x - tx;
- }
- }
- }
- HAL_Write32(RAM_G+(x/rate)*4, VERTEX2F(x*16,y*16));
-
- }
复制代码- /* ========Display list start======================================== */
- HAL_CmdBufIn( CMD_DLSTART );
- HAL_CmdBufIn( CLEAR_COLOR_RGB(0, 0, 0) );
- HAL_CmdBufIn( CLEAR(1,1,1) );
- HAL_CmdBufIn( COLOR_RGB(0,0,0) );
-
- HAL_CmdBufIn( BITMAP_SOURCE(2048L));
- HAL_CmdBufIn( BITMAP_LAYOUT(L8,1,QVGA_HIGH) );
- HAL_CmdBufIn( BITMAP_SIZE(NEAREST, REPEAT, BORDER, QVGA_WIDTH, QVGA_HIGH) );
- HAL_CmdBufIn( BEGIN(BITMAPS) );
- HAL_CmdBufIn( TAG(0) );
- HAL_CmdBufIn( VERTEX2F(0,0) );
- HAL_CmdBufIn( COLOR_RGB(0x1B,0xE0,0x67) );
- HAL_CmdBufIn( LINE_WIDTH(2*16) );
- HAL_CmdBufIn( BEGIN(LINE_STRIP) );
- Gpu_CoCmd_Append( RAM_G,(x/rate)*4 );
- HAL_CmdBufIn( END() );
-
- HAL_CmdBufIn( BEGIN(LINE_STRIP) );
- if ((x/rate)<(QVGA_WIDTH/rate)-(50/rate)) {
- Gpu_CoCmd_Append( RAM_G+(x/rate)*4+((50/rate)*4), ((QVGA_WIDTH/rate)*4)-((x/rate)*4)-((50/rate)*4) );
- }
- HAL_CmdBufIn( END() );
-
- HAL_CmdBufIn( POINT_SIZE(6*16) );
- HAL_CmdBufIn( BEGIN(FTPOINTS) );
- HAL_CmdBufIn( VERTEX2F(x*16,y*16) );
- HAL_CmdBufIn( END() );
- HAL_CmdBufIn( COLOR_RGB(255,255,255) );
- HAL_CmdBufIn( COLOR_A(100) );
- HAL_CmdBufIn( BEGIN(EDGE_STRIP_R) );
- HAL_CmdBufIn( VERTEX2F((hide_x+QVGA_WIDTH-80)*16,0) );
- HAL_CmdBufIn( VERTEX2F((hide_x+QVGA_WIDTH-80)*16,QVGA_HIGH*16) );
- HAL_CmdBufIn( COLOR_A(255) );
-
- Gpu_Radiobutton( hide_x+QVGA_WIDTH-70,QVGA_HIGH-48,0xffffff,0,8,3,opt );
- Gpu_Radiobutton( hide_x+QVGA_WIDTH-70,QVGA_HIGH-28,0xffffff,0,8,4,opt );
- Gpu_Radiobutton( hide_x+QVGA_WIDTH-70,QVGA_HIGH-8 ,0xffffff,0,8,5,opt );
- Gpu_Radiobutton( hide_x+QVGA_WIDTH-70,QVGA_HIGH-68,0xffffff,0,8,6,opt );
-
- Gpu_CoCmd_Text( (hide_x+QVGA_WIDTH-60),QVGA_HIGH-48,26,OPT_CENTERY,"Sine" );
- Gpu_CoCmd_Text( (hide_x+QVGA_WIDTH-60),QVGA_HIGH-28,26,OPT_CENTERY,"Sawtooth" );
- Gpu_CoCmd_Text( (hide_x+QVGA_WIDTH-60),QVGA_HIGH-8 ,26,OPT_CENTERY,"Triangle" );
- Gpu_CoCmd_Text( (hide_x+QVGA_WIDTH-60),QVGA_HIGH-68,26,OPT_CENTERY,"ECG" );
- Gpu_CoCmd_Text( (hide_x+QVGA_WIDTH-60),20,30,OPT_CENTERY|OPT_CENTERX,"-" );
- Gpu_CoCmd_Text( (hide_x+QVGA_WIDTH-20),20,30,OPT_CENTERY|OPT_CENTERX,"+" );
-
- Gpu_CoCmd_Text ( (hide_x+QVGA_WIDTH-80),50,28,0, "Rate:" );
- Gpu_CoCmd_Number( (hide_x+QVGA_WIDTH-30),50,28,0, rate );
- Gpu_CoCmd_Text ( (hide_x+QVGA_WIDTH-80),80,28,0, "Pk:" );
- Gpu_CoCmd_Number( (hide_x+QVGA_WIDTH-40),80,28,0, amp );
-
- HAL_CmdBufIn( COLOR_A(50) );
- HAL_CmdBufIn( POINT_SIZE(15*16) );
- HAL_CmdBufIn( BEGIN(FTPOINTS) );
- HAL_CmdBufIn( TAG(1) );
- HAL_CmdBufIn( VERTEX2F((hide_x+QVGA_WIDTH-60)*16,20*16) );
- HAL_CmdBufIn( TAG(2));
- HAL_CmdBufIn( VERTEX2F((hide_x+QVGA_WIDTH-20)*16,20*16) );
-
- /* DL显示结束 */
- HAL_CmdBufIn( DISPLAY() );
- HAL_CmdBufIn( CMD_SWAP );
- HAL_BufToReg( RAM_CMD, 0 );
复制代码
|
|