Example #1
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{
#if COMPILE_OPTION_USB_SDCARD_DISK
    T_USBMSDriveCallbacks usbMSDiskCallbacks = { 0 };
#endif

    //printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner

    // Load the settings from non-volatile memory
    if (NVSettingsLoad() != UEZ_ERROR_NONE) {
        //printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }

#if COMPILE_OPTION_USB_SDCARD_DISK
    // Setup the USB MassStorage device to connect to MS1 (the SD Card)
    USBMSDriveInitialize(
        &usbMSDiskCallbacks,
        0,
        "MS1");
#endif

    // Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    AudioStart();

    // Pass control to the main menu
    MainMenu();

    // We should not exit main unless we want to reset the board
    return 0;
}
Example #2
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{
#if COMPILE_OPTION_USB_SDCARD_DISK
    T_USBMSDriveCallbacks usbMSDiskCallbacks = { 0 };
#endif

    printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner

    // Load the settings from non-volatile memory
    if (NVSettingsLoad() != UEZ_ERROR_NONE) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }

#if COMPILE_OPTION_USB_SDCARD_DISK
    // Setup the USB MassStorage device to connect to MS1 (the SD Card)
    USBMSDriveInitialize(
        &usbMSDiskCallbacks,
        0,
        "MS1");
#endif

    // Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    AudioStart();


  // initialize command console for test commands
  //UEZGUITestCmdsInit();

#include "UEZGainSpan.h"
    // Gainspan here:
    char rxBuf[128];
    void *G_UEZGUIWorkspace;
    G_UEZGUIWorkspace = 0;

   char* argv[2];
   argv[0]= "gainspan";
    argv[1] = "program";
//    argv[1] = "check";

UEZGUIGainSpan(G_UEZGUIWorkspace,
               2,
               (char **)argv,
               (char *)&rxBuf);

    // Pass control to the main menu
    MainMenu();

    // We should not exit main unless we want to reset the board
    return 0;
}
Example #3
0
/*---------------------------------------------------------------------------*/
int MainTask(void)
{
    // Output a start up banner
    printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n");

    // Start up the heart beat of the LED
    UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0);

    // Load any non-volatile settings from the data flash.
    NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }

    // Setup the glyph API to the LCD and draw the title screen.
    GlyphOpen(&G_glyphLCD, 0);
    IDrawTitle();

    // Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    // Play startup tones
    PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);

    // Wait in an infinite loop.
    while(1) {
        UEZTaskDelay(10000);
    }

    return 0;
}
Example #4
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{	
	printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner
	
	// Start up the heart beat of the LED
    UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0);
	
    NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }

    // Delete old log file
    UEZFileDelete("0:/ACCELLOG.TXT");
    	
	// Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    GlyphOpen(&G_glyphLCD, 0);
	IDrawTitle();

    // Play tones	
	PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);	
	
	while(1) {
		UEZTaskDelay(500);
	}

    return 0;
}
/*-------------------------------------------------------------------------*
 * Prototypes:
 *-------------------------------------------------------------------------*/
uint8_t NVSettingsLoad(NVSettings_t *settings)
{
    uint8_t failed;

    NV_Open();
    failed = NV_Read(0, (uint8_t *)settings, sizeof(*settings));
    if (!failed)
        if (NVSettingsChecksum(settings) != settings->checksum)
            failed = 1;

    // If the above fails, make sure to re-initialize the data
    if (failed)
        NVSettingsInit(settings);

    return failed;
}
Example #6
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
void MainTask(void)
{
#if COMPILE_OPTION_USB_SDCARD_DISK
    T_USBMSDriveCallbacks usbMSDiskCallbacks = {0};
#endif

    printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner

    // Load the settings from non-volatile memory
    if (NVSettingsLoad() != UEZ_ERROR_NONE) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }

    // Start up the heart beat of the LED
    UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0);

#if UEZ_ENABLE_USB_DEVICE_STACK
    if (G_usbIsDevice) {
        // Setup the USB MassStorage device to connect to MS1 (the SD Card)
        USBMSDriveInitialize(
                &usbMSDiskCallbacks,
                0,
                "MS1");
    }
#endif

    AudioStart();
    // Force calibration?
    Calibrate(CalibrateTestIfTouchscreenHeld());

    if(!GUIManager_Start_emWin_PF()){
        GUIManager_Create_All_Active_Windows_PF();
        //start the main window.
        if(G_SystemWindows_PF[HOME_SCREEN]){
            GUIManager_Show_Window_PF(HOME_SCREEN);
            GUI_ExecCreatedDialog(G_SystemWindows_PF[HOME_SCREEN]);
        } else {
            UEZFailureMsg("Failed to create windows!");
        }
    } else {
        UEZFailureMsg("emWin Failed to Start!");
    }
    // We should not exit main unless we want to reset the board
}
Example #7
0
/*---------------------------------------------------------------------------*
* Task:  main
*---------------------------------------------------------------------------*
* Description:
*      In the uEZ system, main() is a task.  Do not exit this task
*      unless you want to the board to reset.  This function should
*      setup the system and then run the main loop of the program.
* Outputs:
*      int                     -- Output error code
*---------------------------------------------------------------------------*/
int MainTask(void)
{
#if COMPILE_OPTION_USB_SDCARD_DISK
     T_USBMSDriveCallbacks usbMSDiskCallbacks = {0};
#endif
     
     printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner
     
     // Load the settings from non-volatile memory
     if (NVSettingsLoad() != UEZ_ERROR_NONE) {
          printf("EEPROM Settings\n");
          NVSettingsInit();
          NVSettingsSave();
     }
#if UEZ_ENABLE_USB_DEVICE_STACK
     if (G_usbIsDevice) {
          // Setup the USB MassStorage device to connect to MS1 (the SD Card)

          USBMSDriveInitialize(
                               &usbMSDiskCallbacks,
                               0,
                               "MS1");
     }
#endif
     
     // Setup any additional misc. tasks (such as the heartbeat task)
     SetupTasks();
     
     AudioStart();
     
#if UEZGUI_EXP_DK_FCT_TEST
      // no command console so functional test can run
#else
     // initialize command console for test commands
     UEZGUITestCmdsInit();
#endif
     
     // Pass control to the main menu
     MainMenu();
     // We should not exit main unless we want to reset the board
     return 0;
}
Example #8
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{	
	T_uezDevice temp;
	T_uezDevice accel;
	T_uezError tempDeviceError;
	T_uezError accelDeviceError;
	TUInt8 displayString[100];
	TInt32 tempValue;
	float tempFloatValue;
	AccelerometerReading accelReading;
	
	printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner
	
	// Start up the heart beat of the LED
    UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0);
	
    NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }
	
	// Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    GlyphOpen(&G_glyphLCD, 0);
	IDrawTitle();
	
	PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);	
	
	tempDeviceError = UEZTemperatureOpen("Temp0", &temp);
	if (tempDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Temperature Device Open\n");
    } else {
        printf("MainTask: Failed to Open Temperature Device\n");
    }
	
	accelDeviceError = UEZAccelerometerOpen("Accel0", &accel);
	if (accelDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Accelerometer Device Open\n");
    } else {
        printf("MainTask: Failed to Open Accelerometer Device\n");
    }
	
	while(1) {
		
		if ( tempDeviceError == UEZ_ERROR_NONE ) {
			if (UEZTemperatureRead(temp, &tempValue) == UEZ_ERROR_NONE) {
				tempFloatValue = tempValue/65536.0;
				sprintf((char *)displayString, "Temp: %.2f C", tempFloatValue);
				GlyphSetXY(G_glyphLCD, 0, 0);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
            }
		}
		
		if ( accelDeviceError == UEZ_ERROR_NONE ) {
			if(UEZAccelerometerReadXYZ(accel, &accelReading, 10) == UEZ_ERROR_NONE )
			{				
				sprintf((char *)displayString, "ACCEL X: %d", accelReading.iX);
				GlyphSetXY(G_glyphLCD, 0, 16);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Y: %d", accelReading.iY);
				GlyphSetXY(G_glyphLCD, 0, 24);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Z: %d", accelReading.iZ);
				GlyphSetXY(G_glyphLCD, 0, 32);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
			}
		}
		
		UEZTaskDelay(500);
	}

    return 0;
}
Example #9
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{	
	T_uezDevice adc;
	T_uezDevice temp;
	T_uezDevice accel;
	T_uezError adcDeviceError;
	T_uezError tempDeviceError;
	T_uezError accelDeviceError;
	ADC_RequestSingle adcRequest;
	TUInt32 adcReading;
	TUInt8 displayString[100];
	TInt32 tempValue;
	float tempFloatValue;
	AccelerometerReading accelReading;
	
	printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n");
	
	NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }
	
	SetupTasks();

	GlyphOpen(&G_glyphLCD, 0);
	IDrawTitle();

	PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);	

	adcDeviceError = UEZADCOpen("ADC_S12AD", &adc);
	if (adcDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: ADC Device Open\n");
	} else {
		printf("MainTask: Failed to Open ADC Device\n");
	}
	
	tempDeviceError = UEZTemperatureOpen("Temp0", &temp);
	if (tempDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Temperature Device Open\n");
    } else {
        printf("MainTask: Failed to Open Temperature Device\n");
    }
	
	accelDeviceError = UEZAccelerometerOpen("Accel0", &accel);
	if (accelDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Accelerometer Device Open\n");
    } else {
        printf("MainTask: Failed to Open Accelerometer Device\n");
    }
	    
	//PORTE.PDR.BIT.B3 = 1;
	while(1) {
		if( adcDeviceError == UEZ_ERROR_NONE )
		{
			// the device opened properly
		    adcRequest.iADCChannel = 2;
		    adcRequest.iBitSampleSize = 12;
		    adcRequest.iTrigger = ADC_TRIGGER_NOW;
		    adcRequest.iCapturedData = &adcReading;
		    if (UEZADCRequestSingle(adc,&adcRequest) == UEZ_ERROR_NONE) {
				printf("MainTask: Potentiometer Reading: %d\n", adcReading);
		    } else {
		        printf("MainTask: Failed to get a Potentiometer Reading\n");
		    }
		}
		
		if ( tempDeviceError == UEZ_ERROR_NONE ) {
			if (UEZTemperatureRead(temp, &tempValue) == UEZ_ERROR_NONE) {
				tempFloatValue = tempValue/65536.0;
				sprintf((char *)displayString, "Temp: %.2f C", tempFloatValue);
				GlyphSetXY(G_glyphLCD, 0, 0);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
            }
		}

		if ( accelDeviceError == UEZ_ERROR_NONE ) {
			if(UEZAccelerometerReadXYZ(accel, &accelReading, 10) == UEZ_ERROR_NONE )
			{				
				sprintf((char *)displayString, "ACCEL X: %d", accelReading.iX);
				GlyphSetXY(G_glyphLCD, 0, 16);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Y: %d", accelReading.iY);
				GlyphSetXY(G_glyphLCD, 0, 24);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Z: %d", accelReading.iZ);
				GlyphSetXY(G_glyphLCD, 0, 32);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
			}
		}

		UEZTaskDelay(1000);
	}
    return 0;
}