Добавлен плот не по массиву и экзампл для синуса
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
#include "math.h"
|
||||
int menu_white_theme = 0;
|
||||
|
||||
//#define SINE_EXAMPLE
|
||||
#define ECG_EXAMPLE
|
||||
#define SINE_EXAMPLE
|
||||
//#define ECG_EXAMPLE
|
||||
//#define PLAYER_EXAMPLE
|
||||
|
||||
|
||||
@@ -84,15 +84,18 @@ void Example_OLED_GFX_Update(PlayerTypeDef *player)
|
||||
oled_refresh();
|
||||
}
|
||||
}
|
||||
float sine2plot;
|
||||
float sine_cnt_step = 0.01;
|
||||
int shift = 1;
|
||||
float ecg_cnt = 0;
|
||||
float ecg_cnt_step = 1;
|
||||
float ecg_scale = 16;
|
||||
float sine_cnt = 1;
|
||||
void Example_GFX_CreateFrame(PlayerTypeDef *player)
|
||||
{
|
||||
#if defined(SINE_EXAMPLE) || defined(ECG_EXAMPLE)
|
||||
GFX_Draw_Plotter(oled_buf, &plotter);
|
||||
#if defined(SINE_EXAMPLE)
|
||||
sine2plot = sinf(sine_cnt);
|
||||
GFX_FloatPlotter(oled_buf, &plotter, &sine2plot);
|
||||
sine_cnt += sine_cnt_step;
|
||||
|
||||
#elif defined(ECG_EXAMPLE)
|
||||
GFX_FloatPlotter(oled_buf, &plotter, NULL);
|
||||
|
||||
#elif defined(PLAYER_EXAMPLE)
|
||||
GFX_Clean_Buffer_Frame(oled_buf);
|
||||
@@ -203,14 +206,13 @@ void Example_GFX_PlotterInit(void)
|
||||
plotter.plotYAxis = 1;
|
||||
|
||||
#if defined(SINE_EXAMPLE)
|
||||
|
||||
int pix_y = (int)((float)(sinf(sine_cnt)+shift)*((float)32/(1+shift)));
|
||||
plotter.dataMax = 1.1;
|
||||
plotter.signedData = 1;
|
||||
#elif defined(ECG_EXAMPLE)
|
||||
|
||||
plotter.pDataPtr = ecg_data;
|
||||
plotter.dataMax = 1.1;
|
||||
plotter.dataSize = 550;
|
||||
plotter.signedData = 1;
|
||||
plotter.plotShift = 0;
|
||||
plotter.plotSpeed = 2.5;
|
||||
#endif
|
||||
|
||||
@@ -436,7 +436,7 @@ void GFX_Draw_Arc(uint8_t *Buffer_Frame, GFX_ArcHandleTypeDef *hArc)
|
||||
|
||||
|
||||
/* Функция вывода графика */
|
||||
void GFX_Draw_Plotter(uint8_t *Buffer_Frame, GFX_PlotterFloatHandleTypeDef *hPlot)
|
||||
void GFX_FloatPlotter(uint8_t *Buffer_Frame, GFX_PlotterFloatHandleTypeDef *hPlot, float *numb2plot)
|
||||
{
|
||||
if((Buffer_Frame == NULL) || (hPlot == NULL))
|
||||
return;
|
||||
@@ -444,6 +444,8 @@ void GFX_Draw_Plotter(uint8_t *Buffer_Frame, GFX_PlotterFloatHandleTypeDef *hPlo
|
||||
return;
|
||||
if((hPlot->yPos + hPlot->plotHeight == NULL) || (hPlot->xPos + hPlot->plotWidth == NULL))
|
||||
return;
|
||||
if((numb2plot == NULL) && (hPlot->pDataPtr == NULL))
|
||||
return;
|
||||
|
||||
if(hPlot->__initialized == 0)
|
||||
{
|
||||
@@ -493,7 +495,11 @@ void GFX_Draw_Plotter(uint8_t *Buffer_Frame, GFX_PlotterFloatHandleTypeDef *hPlo
|
||||
|
||||
|
||||
/* Расчет позиции пикселя */
|
||||
float pix_y_float = (hPlot->pDataPtr[(int)hPlot->plotInd]);
|
||||
float pix_y_float;
|
||||
if(numb2plot != NULL)
|
||||
pix_y_float = *numb2plot;
|
||||
else
|
||||
pix_y_float = (hPlot->pDataPtr[(int)hPlot->plotInd]);
|
||||
// масштабирование под размеры графика
|
||||
hPlot->pixY = (pix_y_float/hPlot->dataMax)*(hPlot->plotHeight);
|
||||
// если график должен быть знаковым, то уменьшаем машстаб еще в два раза
|
||||
@@ -534,14 +540,17 @@ void GFX_Draw_Plotter(uint8_t *Buffer_Frame, GFX_PlotterFloatHandleTypeDef *hPlo
|
||||
|
||||
/* Смещение графика далее */
|
||||
hPlot->pixX++;
|
||||
hPlot->prevPixY = hPlot->pixY;
|
||||
// Если используется массив плота
|
||||
if(numb2plot == NULL)
|
||||
{
|
||||
hPlot->plotInd += hPlot->plotSpeed;
|
||||
if(hPlot->plotInd >= hPlot->dataSize)
|
||||
hPlot->plotInd -= hPlot->dataSize;
|
||||
|
||||
if(hPlot->plotInd < 0)
|
||||
hPlot->plotInd += hPlot->dataSize;
|
||||
|
||||
hPlot->prevPixY = hPlot->pixY;
|
||||
}
|
||||
}
|
||||
|
||||
/* Функция инвертирования прямоугольной области */
|
||||
@@ -679,11 +688,7 @@ void __GFX_Draw_Circle_Filled(uint8_t *Buffer_Frame, int8_t xPos, int8_t yPos, i
|
||||
}
|
||||
|
||||
/* функция рисования треугольника */
|
||||
void __GFX_Draw_Triangle(uint8_t *Buffer_Frame,
|
||||
uint8_t xPos1, uint8_t yPos1,
|
||||
uint8_t xPos2, uint8_t yPos2,
|
||||
uint8_t xPos3, uint8_t yPos3,
|
||||
uint8_t pxColor)
|
||||
void __GFX_Draw_Triangle(uint8_t *Buffer_Frame, uint8_t xPos1, uint8_t yPos1, uint8_t xPos2, uint8_t yPos2, uint8_t xPos3, uint8_t yPos3, uint8_t pxColor)
|
||||
{
|
||||
__GFX_Draw_Line(Buffer_Frame, xPos1, yPos1, xPos2, yPos2, pxColor);
|
||||
__GFX_Draw_Line(Buffer_Frame, xPos2, yPos2, xPos3, yPos3, pxColor);
|
||||
|
||||
@@ -126,7 +126,7 @@ void GFX_Draw_Circle(uint8_t *Buffer_Frame, GFX_CircleHandleTypeDef *hCircle);
|
||||
void GFX_Draw_Triangle(uint8_t *Buffer_Frame, GFX_TriangleHandleTypeDef *hTriangle);
|
||||
void GFX_Draw_Arrow(uint8_t *Buffer_Frame, GFX_ArrowHandleTypeDef *hArrow);
|
||||
void GFX_Draw_Arc(uint8_t *Buffer_Frame, GFX_ArcHandleTypeDef *hArc);
|
||||
void GFX_Draw_Plotter(uint8_t *Buffer_Frame, GFX_PlotterFloatHandleTypeDef *hPlot);
|
||||
void GFX_FloatPlotter(uint8_t *Buffer_Frame, GFX_PlotterFloatHandleTypeDef *hPlot, float *numb2plot);
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -148,7 +148,24 @@
|
||||
<Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL010000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>441</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134220274</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\Core\GFX_Lib\gfx_lib.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\gfx_lcd\../Core/GFX_Lib/gfx_lib.c\441</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
||||
Reference in New Issue
Block a user