Beispiel #1
0
static void DemoSineWave(void) {
  PARAM Param;
  I16 * pStart;
  int t0, Cnt = 0;
  GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
  GUI_HMEM hMem = GUI_ALLOC_Alloc(405 * sizeof(I16));
  GUI_SetColor(GUI_WHITE);
  GUI_SetBkColor(GUI_RED);
  GUI_ClearRect(0, 0, LCD_XSIZE, 60);
  GUI_SetFont(&GUI_FontComic18B_1);
  GUI_DispStringAt("Sine wave", 10, 20);
  pStart = GUI_ALLOC_h2p(hMem);
  GetSineData(pStart, 405);
  GUI_SetFont(&GUI_Font6x8);
  t0 = GUI_GetTime();
  while((GUI_GetTime() - t0) < 10000) {
    int t1, tDiff2;
    if (Cnt++ % 90) {
      Param.aY++;
    } else {
      Param.aY = pStart;
    }
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, Draw2, &Param, 0, 0);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
  }
  GUI_ALLOC_Free(hMem);
}
Beispiel #2
0
//-----------------------------------------------------------------------------
// Program entry-point function
//-----------------------------------------------------------------------------
int main (int argc, char *argv[])
{
	int						ddcError = 0;
	DDCFileHandle			file = 0;
	DDCChannelGroupHandle	group;
	DDCChannelHandle		channels[2];
	double					channel1Data[NUM_DATA_PTS], channel2Data[NUM_DATA_PTS];
	
	// If file exists, delete it.
	remove (FILE_PATH);

	printf ("Generating data file...\n");
	
	// Create file and add channel group and channels.
	ddcChk (DDC_CreateFile (FILE_PATH, "TDM", FILE_NAME, FILE_DESC, "", "", &file));
	ddcChk (DDC_AddChannelGroup (file, GROUP_NAME, GROUP_DESC, &group));
	ddcChk (DDC_AddChannel (group, DDC_Double, CHANNEL1_NAME, 
		CHANNEL1_DESC, CHANNEL1_UNITS, &channels[0]));
	ddcChk (DDC_AddChannel (group, DDC_Double, CHANNEL2_NAME, 
		CHANNEL2_DESC, CHANNEL2_UNITS, &channels[1]));
		
	GetSineData (NUM_DATA_PTS, channel1Data);
	GetRandomData (NUM_DATA_PTS, channel2Data);

	// Write the data in the channels
	ddcChk (DDC_SetDataValues (channels[0], channel1Data, NUM_DATA_PTS));
	ddcChk (DDC_SetDataValues (channels[1], channel2Data, NUM_DATA_PTS));
		
	// Save the file
	ddcChk (DDC_SaveFile (file));
	
Error:
	// Close the file and report any errors
	if (file)
		DDC_CloseFile (file);
	if (ddcError < 0)
		printf ("\nError: %s\n", DDC_GetLibraryErrorDescription(ddcError));
	else
		printf ("\nNo errors.\n");
	printf("End of program, press Enter key to quit\n");
	getchar();
	return 0;
}
Beispiel #3
0
static void DemoOrData(void) {
  int i;
  PARAM Param;
  GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
  GUI_HMEM hMem = GUI_ALLOC_Alloc(405 * sizeof(I16));
  GUI_SetColor(GUI_WHITE);
  GUI_SetBkColor(GUI_RED);
  GUI_ClearRect(0, 0, LCD_XSIZE, 60);
  GUI_SetFont(&GUI_FontComic18B_1);
  GUI_DispStringAt("Several waves...",0,20);
  Param.aY = GUI_ALLOC_h2p(hMem);
  GetSineData(Param.aY, 405);
  GUI_MEMDEV_Draw(&Rect, Draw, &Param, 0, 0);
  for (i = 0; (i < 90); i++) {
    DrawOrData(GUI_GREEN, ++Param.aY);
    GUI_Delay(10);
  }
  GUI_ALLOC_Free(hMem);
}