Exemplo n.º 1
0
/*---------------------------------------------------------------------------*/
int UEZCmdWAVPlay(void *aWorkspace, int argc, char *argv[])
{
    T_uezError error;

    if (argc == 2) {
        UEZWAVConfig(48);
        error = UEZWAVPlayFile(argv[1]);
        if (error) {
            FDICmdPrintf(aWorkspace, "FAIL: Error %d\n", error);
            return error;
        } else {
            // Wait for it to start playing
            while (!UEZWAVGetStatus()) {
                UEZTaskDelay(1);
            }
            
            // Wait for it to end
            while (UEZWAVGetStatus()) {
                UEZTaskDelay(1);
            }
            UEZWAVCleanUp();
            FDICmdPrintf(aWorkspace, "PASS: OK\n");
        }
    } else {
        FDICmdSendString(aWorkspace,
            "FAIL: Incorrect parameters.\nWAVPLAY <wav file>\n");
    }

    return UEZ_ERROR_NONE;
}
Exemplo n.º 2
0
/*---------------------------------------------------------------------------*/
void MainMenu(void)
{
    T_uezDevice lcd;
    char line[100];
    TUInt32 size;
    T_uezDevice flash;

    NVSettingsLoad();

    // Open the LCD and get the pixel buffer
    UEZLCDOpen("LCD", &lcd);

    // Setup the LCD, setup the window, and clear the screen
    ScreenInit();

    //Calibrate();

    //UEZQueueCreate(1, sizeof(T_uezInputEvent), &G_tsQueue);
    //UEZTSOpen("Touchscreen", &G_ts, &G_tsQueue);

    print("Clearing receive area ...\n");
    PNFClearArea(IMAGE_ADDR, IMAGE_SIZE);

    sprintf(line, "Waiting for image at 0x%08lX ... \n", IMAGE_ADDR);
    print(line);

    // Wait for an image to appear
    JLINK_MODE = 0;
    while (JLINK_MODE != 1) {
        UEZTaskDelay(10);
    }

    print("Image received.\n");

    print("Determing size ... ");
    size = PNFGetSize(IMAGE_ADDR, IMAGE_SIZE);
    sprintf(line, "%u bytes\n", size);
    print(line);

    print("Erasing ...");
    UEZFlashOpen("Flash0", &flash);
    UEZFlashBlockErase(flash, 0, size);
    print("done.\n");

    print("Writing ...");
    UEZFlashWrite(flash, 0, (void *)IMAGE_ADDR, size);
    print("done.\n");
    UEZFlashClose(flash);

    print("\n** NOR Flash Programming Complete. **\n");

    JLINK_MODE = 2;

    while (1) {
        UEZTaskDelay(10);
    }
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------------*
 * Task:  Heartbeat
 *---------------------------------------------------------------------------*
 * Description:
 *      Blink heartbeat LED
 * Inputs:
 *      T_uezTask aMyTask            -- Handle to this task
 *      void *aParams               -- Parameters.  Not used.
 * Outputs:
 *      TUInt32                     -- Never returns.
 *---------------------------------------------------------------------------*/
TUInt32 Heartbeat(T_uezTask aMyTask, void *aParams)
{
	UEZGPIOOutput(GPIO_PD0);
	
    // Blink
    for (;;) {
        UEZGPIOSet(GPIO_PD0);
        UEZTaskDelay(250);
        UEZGPIOClear(GPIO_PD0);
        UEZTaskDelay(250);
    }

    return 0;
}
Exemplo n.º 4
0
/*---------------------------------------------------------------------------*
 * Routine:  Open
 *---------------------------------------------------------------------------*
 * Description:
 *     Initalizes pins for the audio amp 
 *     turns it on
 *     sets the level to the default
 * Inputs:
 *      void *aWorkSpace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError AudioAmp_8551T_Open(void *aWorkSpace)
{
    T_AudioAmp_8551T_Workspace *p = (T_AudioAmp_8551T_Workspace *)aWorkSpace;
    TUInt8 i, setLevel;

    UEZSemaphoreGrab(p->iSem, UEZ_TIMEOUT_INFINITE);

    p->iNumOpen++;

    if (!(p->iIsOn)) {
        setLevel = ((p->iLevel * (p->iMaxLevel - p->iMinLevel))/0xFF) + p->iMinLevel;
        p->iIsOn = ETrue;
        UEZGPIOOutput(p->iModeGPIO);
        UEZGPIOSetMux(p->iModeGPIO, 0); // set to GPIO
        UEZGPIOClear(p->iModeGPIO); // Turn on the amp
        UEZGPIOOutput(p->iVolumeGPIO);
        UEZGPIOSetMux(p->iVolumeGPIO, 0); // set to GPIO

        for (i = HIGH_LEVEL; i > 0; i--) {
            UEZGPIOClear(p->iVolumeGPIO); // set low to go down
            UEZGPIOOutput(p->iVolumeGPIO); // set to output
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOSet(p->iVolEnableGPIO);
            UEZTaskDelay(1);
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOClear(p->iVolEnableGPIO);
            UEZGPIOInput(p->iVolumeGPIO); // set to input
            UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
            UEZTaskDelay(1);
        }

        for (i = LOW_LEVEL; i < setLevel; i++) {
            UEZGPIOSet(p->iVolumeGPIO); // set low to go down
            UEZGPIOOutput(p->iVolumeGPIO); // set to output
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOSet(p->iVolEnableGPIO);
            UEZTaskDelay(1);
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOClear(p->iVolEnableGPIO);
            UEZGPIOInput(p->iVolumeGPIO); // set to input
            UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
            UEZTaskDelay(1);
        }
    }
    if (p->iVolEnableGPIO != GPIO_NONE)
        UEZGPIOClear(p->iVolEnableGPIO);

    UEZSemaphoreRelease(p->iSem);
    return UEZ_ERROR_NONE;
}
Exemplo n.º 5
0
/*---------------------------------------------------------------------------*
 * Routine: SetLevel
 *---------------------------------------------------------------------------*
 * Description: 
 *      Set the gain of the audio amp to the desired level
 * Inputs:
 *      void *aWorkspace
 *      TUInt8 aLevel             --new level to set the amp to
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError AudioAmp_8551T_SetLevel(void *aWorkSpace, TUInt8 aLevel)
{
    T_AudioAmp_8551T_Workspace *p = (T_AudioAmp_8551T_Workspace *)aWorkSpace;
    TUInt8 i, setLevel, oldLevel;

    UEZSemaphoreGrab(p->iSem, UEZ_TIMEOUT_INFINITE);

    oldLevel = ((((p->iLevel * 100) / (0xFF)) * (p->iMaxLevel - p->iMinLevel))/100) + p->iMinLevel;
    p->iLevel = aLevel;
    setLevel = ((p->iLevel * (p->iMaxLevel - p->iMinLevel))/0xFF) + p->iMinLevel;

    UEZGPIOSetMux(p->iVolumeGPIO, 0); // set to GPIO

    if (setLevel != oldLevel) {
        if (oldLevel < setLevel) {
            for (i = oldLevel; i < setLevel; i++) {
                UEZGPIOSet(p->iVolumeGPIO); //set High to go up
                UEZGPIOOutput(p->iVolumeGPIO); //set to output
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOSet(p->iVolEnableGPIO);
                UEZTaskDelay(1);
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOClear(p->iVolEnableGPIO);
                UEZGPIOInput(p->iVolumeGPIO);
                UEZGPIOClear(p->iVolumeGPIO);
                UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
                UEZTaskDelay(1);
            }
        } else {
            for (i = oldLevel; i > setLevel; i--) {
                UEZGPIOClear(p->iVolumeGPIO); //set low to go down
                UEZGPIOOutput(p->iVolumeGPIO); //set to output
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOSet(p->iVolEnableGPIO);
                UEZTaskDelay(1);
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOClear(p->iVolEnableGPIO);
                UEZGPIOInput(p->iVolumeGPIO);
                UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
                UEZTaskDelay(1);
            }
        }
        p->iLevel = aLevel;
    }

    if (p->iVolEnableGPIO != GPIO_NONE)
        UEZGPIOClear(p->iVolEnableGPIO);
    UEZSemaphoreRelease(p->iSem);
    return UEZ_ERROR_NONE;
}
static void Host_ResetPort(void *aWorkspace)
{
    T_LPC17xx_40xx_USBHost_Workspace *p = (T_LPC17xx_40xx_USBHost_Workspace *)aWorkspace;

    UEZTaskDelay(100);

    // Apply port reset
    *p->iPortStatus |= OR_RH_PORT_PRS;

    // Wait for 100 MS after port reset
    UEZTaskDelay(100);

    // Default max packet size to 8 to ensure compatibility
    EDCtrl->Control = (8 << 16);
}
Exemplo n.º 7
0
TUInt32 TestVCNL4010Task(T_uezTask aMyTask, void *aParameters)
{
    TUInt8 cmd[2];
    TUInt8 data[4];
    TUInt32 ambient;
    TUInt32 proximity;
    int count = 0;

// Set Current to 20
    cmd[0] = REGISTER_PROX_CURRENT;
    cmd[1] = 20; // 20 x 10 = 200 mA, max
    UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 2, 1000);

    for(count = 0; count < 100; count++) {
        printf("Reading ... ");
        // Request to trigger both ALS and Proximity
        cmd[0] = REGISTER_COMMAND;
        cmd[1] = 0x18;
        UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 2, 1000);

        do {
            printf("?");
            // Now read back the status (after writing command index)
            cmd[0] = REGISTER_COMMAND;
            UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 1, 1000);
            UEZI2CRead(G_i2cBus, G_i2cAddr, I2C_SPEED, data, 1, 1000);

            // Is it ready?
            if (data[0] & (COMMAND_MASK_PROX_DATA_READY | COMMAND_MASK_AMBI_DATA_READY))
                break;

            // Not ready yet, pause and try again in a moment
            UEZTaskDelay(10);
        } while (1);

        // Now read the data
        cmd[0] = REGISTER_AMBI_VALUE;
        UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 1, 1000);
        UEZI2CRead(G_i2cBus, G_i2cAddr, I2C_SPEED, data, 4, 1000);

        ambient = (data[0] << 8) | data[1];
        proximity = (data[2] << 8) | data[3];
        printf("Ambient: %04X, Proximity: %04X\n", ambient, proximity);

        UEZTaskDelay(100);
    }
    return UEZ_ERROR_NONE;
}
Exemplo n.º 8
0
/*---------------------------------------------------------------------------*
 * Routine:  MainMenu
 *---------------------------------------------------------------------------*
 * Description:
 *      Present the main menu
 *---------------------------------------------------------------------------*/
void MainMenu(void)
{
    T_uezDevice lcd;
    T_pixelColor *pixels;

    // Open the LCD and get the pixel buffer
    if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE)  {
        UEZLCDGetFrame(lcd, 0, (void **)&pixels);

#if (!FAsT_STARTUP)
        // Clear the screen
        TitleScreen();
        //while(1);
        PlayAudio(523, 100);
        PlayAudio(659, 100);
        PlayAudio(783, 100);
        PlayAudio(1046, 100);
        PlayAudio(783, 100);
        PlayAudio(659, 100);
        PlayAudio(523, 100);

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

        UEZTaskDelay(1000);
#else
        UEZLCDBacklight(lcd, 255);
        Calibrate(FALSE);
#endif
        AppMenu(&mainmenu);
        UEZLCDClose(lcd);
    }
}
Exemplo n.º 9
0
TUInt32 AccelerometerMonitor(T_uezTask aMyTask, void *aParams)
{
    T_uezDevice Accel;
    double x, y, z;
    int i;
    AccelerometerReading ar;

    if (UEZAccelerometerOpen("Accel0", &Accel) == UEZ_ERROR_NONE) {
        while (1) {
            // The device opened properly
            x = y = z = 0;
            for (i=0; i<8; i++) {
                if (UEZAccelerometerReadXYZ(Accel, &ar, 10) != UEZ_ERROR_NONE) {
                    UEZFailureMsg("Accelerometer failed to read!");
                    break;
                }
                x += ar.iX;
                y += ar.iY;
                z += ar.iZ;
            }
            // Convert from signed 15.16 fixed format to doubles over 8 samples
            // The value is in g's.  For example, the x, y, z is
            // (0.0, 0.0, -1.0) when at rest on a table.
            x /= 65536.0 * 8;
            y /= 65536.0 * 8;
            z /= 65536.0 * 8;
            DataLogXYZ(x, y, z);

            // Sleep before next reading
            UEZTaskDelay(1000);
        }
    }
    return 0;
}
/*---------------------------------------------------------------------------*
 * Routine:  LCD_UMSH_8596MD_20T_On
 *---------------------------------------------------------------------------*
 * Description:
 *      Turns on the LCD display.
 * Inputs:
 *      void *aW                -- Workspace
 * Outputs:
 *      T_uezError               -- If successful, returns UEZ_ERROR_NONE.
 *---------------------------------------------------------------------------*/
T_uezError LCD_UMSH_8596MD_20T_On(void *aW)
{
    // Turn back on to the remembered level
    T_UMSH_8596MD_20TWorkspace *p = (T_UMSH_8596MD_20TWorkspace *)aW;
#if UEZ_LCD_POWER_GPIO_PIN
    HAL_GPIOPort **p_gpio = p->iPowerGPIOPort;
#endif
    
#if UEZ_LCD_POWER_GPIO_PIN
    if (p_gpio) {
        (*p_gpio)->SetOutputMode(p_gpio, 1UL<<UEZ_LCD_POWER_GPIO_PIN);
        (*p_gpio)->SetMux(p_gpio, UEZ_LCD_POWER_GPIO_PIN, 0); // set to GPIO
        (*p_gpio)->Clear(p_gpio, 1UL<<UEZ_LCD_POWER_GPIO_PIN);
    }
#endif

    (*p->iLCDController)->On(p->iLCDController);

    UEZTaskDelay(200);//added delay to match timing in datasheet

    if (p->iBacklight)
        (*p->iBacklight)->On(p->iBacklight);

    return UEZ_ERROR_NONE;
}
/*---------------------------------------------------------------------------*
 * Routine:  LCD_UMSH_8596MD_20T_Off
 *---------------------------------------------------------------------------*
 * Description:
 *      Turns off the LCD display.
 * Inputs:
 *      void *aW                -- Workspace
 * Outputs:
 *      T_uezError               -- If successful, returns UEZ_ERROR_NONE.
 *---------------------------------------------------------------------------*/
T_uezError LCD_UMSH_8596MD_20T_Off(void *aW)
{
    // Turn off, but don't remember the level
    T_UMSH_8596MD_20TWorkspace *p = (T_UMSH_8596MD_20TWorkspace *)aW;
#if UEZ_LCD_POWER_GPIO_PIN
    HAL_GPIOPort **p_gpio = p->iPowerGPIOPort;
#endif
    
    //changed order and added delay to match timing diagram in datasheet.
    if (p->iBacklight)
        (*p->iBacklight)->Off(p->iBacklight);
    
    UEZTaskDelay(200);

#if UEZ_LCD_POWER_GPIO_PIN
    if (p_gpio) {
        (*p_gpio)->SetOutputMode(p_gpio, 1UL<<UEZ_LCD_POWER_GPIO_PIN);
        (*p_gpio)->SetMux(p_gpio, UEZ_LCD_POWER_GPIO_PIN, 0); // set to GPIO
        (*p_gpio)->Set(p_gpio, 1UL<<UEZ_LCD_POWER_GPIO_PIN);
    }
#endif
    (*p->iLCDController)->Off(p->iLCDController);    

    return UEZ_ERROR_NONE;
}
Exemplo n.º 12
0
/*---------------------------------------------------------------------------*
 * Routine:  LCD_LQ104V1DG28_Open
 *---------------------------------------------------------------------------*
 * Description:
 *      Start the LCD screen.  If this is the first open, initialize the
 *      screen.
 * Inputs:
 *      void *aW                -- Workspace
 * Outputs:
 *      T_uezError               -- If the device is opened, returns
 *                                  UEZ_ERROR_NONE.
 *---------------------------------------------------------------------------*/
static T_uezError LCD_LQ104V1DG28_Open(void *aW)
{
  T_LQ104V1DG28Workspace *p = (T_LQ104V1DG28Workspace *)aW;
  HAL_LCDController **plcdc;
  T_uezError error = UEZ_ERROR_NONE;
  
  p->aNumOpen++;
  
  if (p->aNumOpen == 1) {
    plcdc = p->iLCDController;
    if (!error) {
      switch (p->iConfiguration->iColorDepth) {
      case UEZLCD_COLOR_DEPTH_8_BIT:
        LCD_LQ104V1DG28_settings = LCD_LQ104V1DG28_params8bit;
        break;
      default:
      case UEZLCD_COLOR_DEPTH_16_BIT:
        LCD_LQ104V1DG28_settings = LCD_LQ104V1DG28_params16bit;
        break;
      case UEZLCD_COLOR_DEPTH_I15_BIT:
        LCD_LQ104V1DG28_settings = LCD_LQ104V1DG28_paramsI15bit;
        break;
      }
      LCD_LQ104V1DG28_settings.iBaseAddress = p->iBaseAddress;
      
      // start DOTCLK immediately
      error = (*plcdc)->Configure(plcdc, &LCD_LQ104V1DG28_settings);
      // start HSYNC and VSYNC (same as UEZLCDOn(lcd))
      (*p->iLCDController)->On(p->iLCDController);
      UEZTaskDelay(10); // delay before turning backlight on, min 10 frame
      (*p->iBacklight)->On(p->iBacklight); // turn backlight on 
    }
  }
  return error;
}
Exemplo n.º 13
0
/*-------------------------------------------------------------------------*
 * Prototypes:
 *-------------------------------------------------------------------------*/
TUInt32 TestVCNL4010FCT(const char *aI2CName, TUInt8 aI2CAddr,
                        TUInt32 * const ambient, TUInt32 * const proximity)
{
    TUInt8 cmd[2];
    TUInt8 data[4];
	UEZI2COpen(aI2CName, &G_i2cBus);
    G_i2cAddr = aI2CAddr;
 
// Set Current to 20
    cmd[0] = REGISTER_PROX_CURRENT;
    cmd[1] = 20; // 20 x 10 = 200 mA, max
    UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 2, 1000);

    printf("Reading ... ");
    // Request to trigger both ALS and Proximity
        cmd[0] = REGISTER_COMMAND;
        cmd[1] = 0x18;
        UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 2, 1000);

        do {
            printf("?");
            // Now read back the status (after writing command index)
            cmd[0] = REGISTER_COMMAND;
            UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 1, 1000);
            UEZI2CRead(G_i2cBus, G_i2cAddr, I2C_SPEED, data, 1, 1000);

            // Is it ready?
            if (data[0] & (COMMAND_MASK_PROX_DATA_READY | COMMAND_MASK_AMBI_DATA_READY))
                break;

            // Not ready yet, pause and try again in a moment
            UEZTaskDelay(10);
        } while (1);

        // Now read the data
        cmd[0] = REGISTER_AMBI_VALUE;
        UEZI2CWrite(G_i2cBus, G_i2cAddr, I2C_SPEED, cmd, 1, 1000);
        UEZI2CRead(G_i2cBus, G_i2cAddr, I2C_SPEED, data, 4, 1000);

       *ambient = (data[0] << 8) | data[1];
       *proximity = (data[2] << 8) | data[3];
        printf("Ambient: %04X, Proximity: %04X\n", *ambient, *proximity);

        UEZTaskDelay(100);
    return UEZ_ERROR_NONE;
}
Exemplo n.º 14
0
/*---------------------------------------------------------------------------*
 * Routine:  IExitProgramMode
 *---------------------------------------------------------------------------*
 * Description:
 *      Exit programming mode
 * Inputs:
 *      T_Flash_S29GL064N90_Workspace *p -- Workspace
 *---------------------------------------------------------------------------*/
static void IExitProgramMode(T_Flash_Renesas_RX63N_Workspace *p)
{
    if (p->iIsProgramMode) {
        // If we are in programming mode, exit it
    	UEZTaskDelay(1);
        p->iIsProgramMode = EFalse;
    }
}
Exemplo n.º 15
0
 /*---------------------------------------------------------------------------*/
static TUInt32 Heartbeat(T_uezTask aMyTask, void *aParams)
{
    HAL_GPIOPort **p_gpio;
    const TUInt32 pin = 13;
    TBool run = ETrue;

    HALInterfaceFind("GPIO1", (T_halWorkspace **)&p_gpio);

    (*p_gpio)->SetOutputMode(p_gpio, 1<<pin);
    (*p_gpio)->SetMux(p_gpio, pin, 0); // set to GPIO
    // Blink
    while (run) {
        (*p_gpio)->Set(p_gpio, 1<<pin);
        UEZTaskDelay(250);
        (*p_gpio)->Clear(p_gpio, 1<<pin);
        UEZTaskDelay(250);
    }
    return 0;
}
Exemplo n.º 16
0
TUInt32 NetworkStartup(T_uezTask aMyTask, void *aParams)
{
    T_uezError error = UEZ_ERROR_NONE;

#if UEZ_ENABLE_WIRED_NETWORK
    T_uezDevice wired_network;
#endif

#if UEZ_ENABLE_WIRED_NETWORK
    // ----------------------------------------------------------------------
    // Bring up the Wired Network
    // ----------------------------------------------------------------------
    printf("Bringing up wired network: Start\n");

    // First, get the Wireless Network connection
    UEZPlatform_WiredNetwork0_Require();
    error = UEZNetworkOpen("WiredNetwork0", &wired_network);
    if (error)
        UEZFailureMsg("NetworkStartup: Wired failed to start");

    // Configure the type of network desired
    INetworkConfigureWiredConnection(wired_network);

    // Bring up the infrastructure
    error = UEZNetworkInfrastructureBringUp(wired_network);

    // If no problem bringing up the infrastructure, join the network
    if (!error)
        error = UEZNetworkJoin(wired_network, "lwIP", 0, 5000);

    // Let the last messages through (debug only)
    UEZTaskDelay(1000);

    // Report the result
    if (error) {
        printf("Bringing up wired network: **FAILED** (error = %d)\n", error);
    } else {
        printf("Bringing up wired network: Done\n");
    }
#endif

#if UEZ_ENABLE_TCPIP_STACK
    printf("Webserver starting\n");
    error = BasicWebStart(wired_network);
    if (error) {
        printf("Problem starting BasicWeb! (Error=%d)\n", error);
    } else {
        printf("BasicWeb started\n");
    }
#endif

    return 0;
}
Exemplo n.º 17
0
/*---------------------------------------------------------------------------*
 * Routine:  LCD_LMIX0560NTN53V1_On
 *---------------------------------------------------------------------------*
 * Description:
 *      Turns on the LCD display.
 * Inputs:
 *      void *aW                -- Workspace
 * Outputs:
 *      T_uezError               -- If successful, returns UEZ_ERROR_NONE.
 *---------------------------------------------------------------------------*/
T_uezError LCD_LMIX0560NTN53V1_On(void *aW)
{
    // Turn back on to the remembered level
    T_LMIX0560NTN53V1Workspace *p = (T_LMIX0560NTN53V1Workspace *)aW;
    (*p->iLCDController)->On(p->iLCDController);
  
    UEZTaskDelay(50);
    if (p->iBacklight)
        (*p->iBacklight)->On(p->iBacklight);

    return UEZ_ERROR_NONE;
}
/*---------------------------------------------------------------------------*
 * Routine:  ST_Accelo_LIS3LV02DQ_I2C_ReadXYZ
 *---------------------------------------------------------------------------*
 * Description:
 *      Try to get the XYZ reading of the accelerometer
 * Inputs:
 *      void *aW                    -- Workspace
 *      AccelerometerReading *aReading -- Place to store reading
 *      TUInt32 aTimeout            -- Time to wait until reading is ready
 * Outputs:
 *      T_uezError                  -- Error code, UEZ_ERROR_TIMEOUT if no
 *                                      reading.
 *---------------------------------------------------------------------------*/
T_uezError ST_Accelo_LIS3LV02DQ_I2C_ReadXYZ(
        void *aWorkspace, 
        AccelerometerReading *aReading,
        TUInt32 aTimeout)
{
    TUInt32 i;
    TUInt8 status;

    T_uezError error;
    T_ST_Accelo_LIS3LV02DQ_I2C_Workspace *p = 
        (T_ST_Accelo_LIS3LV02DQ_I2C_Workspace *)aWorkspace;
    static TUInt8 accdata[18];

    aReading->iX = 0;
    aReading->iY = 0;
    aReading->iZ = 0;

    // Allow only one transfer at a time
    error = UEZSemaphoreGrab(p->iSem, aTimeout);
    if (error)
        return error;

    for (i=0; i<10; i++) { // try 10 times
        memset(accdata, 0xCC, sizeof(accdata));
        error = IReadData(p, accdata, 0x27, 7, 100);
        status = accdata[0];
        if (status & (1<<3)) {
            aReading->iX = ICalcG(accdata[2], accdata[1]);
            aReading->iY = ICalcG(accdata[4], accdata[3]);
            aReading->iZ = ICalcG(accdata[6], accdata[5]);
            p->iLastReading = *aReading;
            break;  // break if successful 
        }
        UEZTaskDelay(2);
/*
Array Contents After Read
accdata[0] - STATUS_REG (0x27)
accdata[1] - OUTX_L     (0x28)
accdata[2] - OUTX_H     (0x29)
accdata[3] - OUTY_L     (0x2A)
accdata[4] - OUTY_H     (0x2B)
accdata[5] - OUTZ_L     (0x2C)
accdata[6] - OUTZ_H     (0x2D)
*/
    }
    if (i==10) {
        *aReading = p->iLastReading;
    }
    UEZSemaphoreRelease(p->iSem);

    return error;
}
Exemplo n.º 19
0
TBool TestModeSendCmd(TUInt32 aCmd)
{
    // Go into test mode (if not already running)
    G_mmTestMode = ETrue;
    while (!G_mmTestModeRunning) {
        UEZTaskDelay(10);
    }

    // Check if we are running and send command
    if (G_mmTestModeRunning) {
        if (UEZQueueSend(G_mmTestModeQueue, &aCmd, UEZ_TIMEOUT_INFINITE) != UEZ_ERROR_NONE)
            return EFalse;
        return ETrue;
    }
    return EFalse;
}
Exemplo n.º 20
0
/*---------------------------------------------------------------------------*
 * Routine:  PlayAudio
 *---------------------------------------------------------------------------*
 * Description:
 *      Play a tone for the given length, staying here until done.
 * Inptus:
 *      TUInt32 aHz                 -- Tone in Hz
 *      TUInt32 aMS                 -- Duration of tone
 *---------------------------------------------------------------------------*/
void PlayAudio(TUInt32 aHz, TUInt32 aMS)
{

#if OPTION_USE_GPIO_LINES_FOR_AUDIO
    static HAL_GPIOPort **p_gpio0;
    TUInt32 n;
    TUInt32 start = UEZTickCounterGet();
    TUInt32 count;

    HALInterfaceFind("GPIO0", (T_halWorkspace **)&p_gpio0);
    (*p_gpio0)->SetOutputMode(p_gpio0, (1<<26));

    // Wait for the parameters to be ready
    n = (G_subTickCount*1000/2)/aHz;
    taskDISABLE_INTERRUPTS();
    G_dummyCounter = 0;
    // Wait for first tick count
    while ((T1IR&2)==0)
        {}
    while (aMS--) {
        T1IR = 2;
        while (!(T1IR & 2)) {
            count = n;
            while (count--)
                { G_dummyCounter++; }
            (*p_gpio0)->Clear(p_gpio0, (1<<26));
            count = n;
            while (count--)
                { G_dummyCounter++; }
            (*p_gpio0)->Set(p_gpio0, (1<<26));
        }
    }

    taskENABLE_INTERRUPTS();
#else
    if (!G_tg)
        CalibrateAudioTiming();
    //PWMAudio(aHz, (aMS+10)/10, 0);
    if (G_tg)
        UEZToneGeneratorPlayTone(
                G_tg,
                TONE_GENERATOR_HZ(aHz),
                aMS);
    else
        UEZTaskDelay(aMS);
#endif
}
Exemplo n.º 21
0
/*---------------------------------------------------------------------------*/
void ScreenOn(void)
{
    T_uezDevice lcd;
    int i;

    UEZLCDOpen("LCD", &lcd);
    if (!G_screenOn) {
        UEZLCDBacklight(lcd, 0);
        UEZLCDOn(lcd);
        for (i = 0; i < 255; i++) {
            UEZLCDBacklight(lcd, i);
            UEZTaskDelay(2);
        }
        G_screenOn = ETrue;
    }
    UEZLCDClose(lcd);
}
/*---------------------------------------------------------------------------*
 * Routine:  EEPROM_NXP_LPC17xx_40xx_Write
 *---------------------------------------------------------------------------*
 * Description:
 *      Write bytes into the EEPROM
 * Inputs:
 *      void *aW                    -- Workspace
 *      TUInt32 aAddress            -- Base address into device to write
 *      TUInt8 *aBuffer             -- Pointer to buffer of data
 *      TUInt32 aNumBytes           -- Number of bytes to write
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError EEPROM_NXP_LPC17xx_40xx_Write(
        void *aWorkspace,
        TUInt32 aAddress,
        TUInt8 *aBuffer,
        TUInt32 aNumBytes)
{
    T_EEPROM_NXP_LPC17xx_40xx_Workspace *p = (T_EEPROM_NXP_LPC17xx_40xx_Workspace *)aWorkspace;
    T_uezError error = UEZ_ERROR_NONE;
    TUInt32 size = aNumBytes;
    TUInt32 len;
    const TUInt32 pageSize = LPC17xx_40xx_EEPROM_PAGE_SIZE;
    TUInt32 addr;

    // Allow only one transfer at a time
    UEZSemaphoreGrab(p->iSem, UEZ_TIMEOUT_INFINITE);

    if (!p->iInitialized)
        IInitialize(p);

    while (size) {
        // Determine number of bytes remaining in this page
        len = pageSize-((aAddress+pageSize)&(pageSize-1));
        // Clip to the remaining number of bytes
        if (len > size)
            len = size;

        addr = aAddress & ~(LPC17xx_40xx_EEPROM_PAGE_SIZE-1);
        // Read
        IReadPage(p, addr, p->iPage, 0);
        // Modify
        memcpy(p->iPage + (aAddress & (LPC17xx_40xx_EEPROM_PAGE_SIZE-1)), aBuffer, len);
        // Write
        IWritePage(p, addr, p->iPage, 0);
        
        // Wait the appropriate amount of time
        UEZTaskDelay(p->iConfig.iWriteTime);

        aAddress += len;
        size -= len;
        aBuffer += len;
    }

    UEZSemaphoreRelease(p->iSem);

    return error;
}
Exemplo n.º 23
0
/*---------------------------------------------------------------------------*
 * Routine:  MainMenu
 *---------------------------------------------------------------------------*
 * Description:
 *      Present the main menu
 *---------------------------------------------------------------------------*/
void MainMenu(void)
{
    T_uezDevice lcd;
    T_pixelColor *pixels;

    // Open the LCD and get the pixel buffer
    if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE)  {
        UEZLCDGetFrame(lcd, 0, (void **)&pixels);

#if (!FAsT_STARTUP)
        // Clear the screen
        TitleScreen();
		//while(1);
        PlayAudio(523, 100);
        PlayAudio(659, 100);
        PlayAudio(783, 100);
        PlayAudio(1046, 100);
        PlayAudio(783, 100);
        PlayAudio(659, 100);
        PlayAudio(523, 100);

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

        UEZTaskDelay(1000);

#else
        UEZLCDBacklight(lcd, 255);
        Calibrate(FALSE);
#endif
        
        // Set the screen saver icon
        BouncingLogoSS_Setup(
            (TUInt8 *)G_uEZLogo,
            UEZ_ICON_WIDTH,
            UEZ_ICON_HEIGHT,
            DISPLAY_WIDTH,
            DISPLAY_HEIGHT);
        
        AppMenu(&mainmenu);
        UEZLCDClose(lcd);
    }
}
Exemplo n.º 24
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;
}
Exemplo n.º 25
0
/*---------------------------------------------------------------------------*/
static void IUEZTSMonitorTouchscreensTask(T_uezTask aMyTask, void *aParams)
{
    T_tsDevice *p;
    T_tsQueue *pq;
    T_uezTSReading reading;
    T_uezInputEvent inputEvent;

    for (;;) {
        IUEZTSGrab();
        p = G_tsDevices;
        while (p) {
            if (UEZTSGetReading(p->iDevice, &reading) == UEZ_ERROR_NONE)  {
            
                if(reading.iFlags & TSFLAG_PEN_DOWN) {
                    UEZLCDScreensaverWake();
                    
                    if(UEZLCDScreensaverIsActive())
                        G_WaitForRelease = ETrue;
                }
                
                if(G_WaitForRelease) {
                    if(!(reading.iFlags & TSFLAG_PEN_DOWN)) {
                        // if the pen is released, stop waiting
                        G_WaitForRelease = EFalse;
                    }
                } else {
                    // Apply the reading to all the queues (as last reported)
                    for (pq = p->iQueueList; pq; pq=pq->iNext) {
                        // Send it on the queue.
                        inputEvent = IConvertTSReadingToInputEvent(&reading);
                        UEZQueueSend(pq->iQueue, &inputEvent, 0);
                    }
                }
            }
            p = p->iNext;
        }
        IUEZTSRelease();
        UEZTaskDelay(10);
    }
}
Exemplo n.º 26
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;
}
Exemplo n.º 27
0
/*---------------------------------------------------------------------------*
 * Routine:  TS_EXC7200_Configure
 *---------------------------------------------------------------------------*
 * Description:
 *      The SPI bus and GPIO device are being declared.
 * Inputs:
 *      void *aW                    -- Particular SPI workspace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError TS_EXC7200_Configure(T_uezDeviceWorkspace *aW)
{
    T_EXC7200Workspace *p = (T_EXC7200Workspace *)aW;

    UEZSemaphoreGrab(p->iSemWaitForTouch, 0);

    UEZGPIOSetMux(p->iResetPin, 0);//Set to GPIO
    UEZGPIOOutput(p->iResetPin);
    UEZGPIOClear(p->iResetPin);

    UEZTaskDelay(1);
    UEZGPIOConfigureInterruptCallback(
        UEZ_GPIO_PORT_FROM_PORT_PIN(p->iInteruptPin),
        TS_EXC7200_InterruptISR,
        p);
    UEZGPIOEnableIRQ(p->iInteruptPin, GPIO_INTERRUPT_FALLING_EDGE);

    UEZGPIOSet(p->iResetPin);
    
    T_uezDevice i2c;
    I2C_Request request;
    T_uezError error;
    TUInt8 dataIn[10];
    TUInt8 dataOut[10] = { 0x03, 0x06, 0x0A, 0x04, 0x36, 0x3f, 0x01, 9, 0, 0};

    request.iAddr = EXC7200_I2C_ADDRESS;
    request.iSpeed = EXC7200_I2C_SPEED;
    request.iReadData = dataIn;
    request.iReadLength = 10;
    request.iWriteData = dataOut;
    request.iWriteLength = 10;

    UEZI2COpen(p->iI2CBus, &i2c);
    error = UEZI2CTransaction(i2c, &request);
                      

    return UEZ_ERROR_NONE;
}
Exemplo n.º 28
0
/*---------------------------------------------------------------------------*
 * Routine:  DR_Save
 *---------------------------------------------------------------------------*
 * Description:
 *      Save the currently shown image to the flash drive.
 * Inputs:
 *      const T_choice *aChoice   -- Choice object selected for this action.
 *---------------------------------------------------------------------------*/
static void DR_Save(const T_choice *aChoice)
{
    T_uezError error;
    T_uezError errorUSB, errorSD;
    T_uezFile file;
    INT_32 winX, winY;
    T_pixelColor *raster;
    TUInt32 num;
    TUInt16 x, y;

    // Draw line around choice while saving
    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, YELLOW);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);

    // Try to save to the USB drive
    error = errorUSB = UEZFileOpen("0:IMAGE.RAW", FILE_FLAG_WRITE, &file);

    // If an error, try to save to the SD Card
    if (error != UEZ_ERROR_NONE)
        error = errorSD = UEZFileOpen("1:IMAGE.RAW", FILE_FLAG_WRITE, &file);
    else
        errorSD = UEZ_ERROR_UNKNOWN;

    // Any errors?
    if (error == UEZ_ERROR_NONE) {
        raster = (T_pixelColor  *)LOAD_SPACE;
        for (y=0; y<DR_IMAGE_HEIGHT; y++) {
            for (x=0; x<DR_IMAGE_WIDTH; x++) {
                winX = x + DR_IMAGE_LEFT+1;
                winY = y + DR_IMAGE_TOP+1;
                swim_get_physical_xy(&G_drWin, &winX, &winY);
                swim_driver_get_raster(&G_drWin, winX, winY, (COLOR_T *)raster, 1); // get pixel color
                raster++;
            }
        }
        // Save image
        error = UEZFileWrite(
                    file,
                    LOAD_SPACE,
                    DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor),
                    &num);
        if ((error != UEZ_ERROR_NONE) &&
                (num != DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor))) {
            BeepError();
        }
        UEZFileClose(file);
    } else {
        // Had an error, report it
        SUICopyFast32(FRAME(1), FRAME(0), FRAME_SIZE);
        BeepError();
        swim_set_fill_transparent(&G_drWin, 0);
        swim_set_fill_color(&G_drWin, BLACK);
        swim_set_pen_color(&G_drWin, YELLOW);
        swim_put_box(
            &G_drWin,
            DR_IMAGE_LEFT,
            DR_IMAGE_TOP,
            DR_IMAGE_RIGHT,
            DR_IMAGE_TOP+16);
        if (errorUSB == UEZ_ERROR_NOT_FOUND) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write image to USB Drive",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to USB Drive or SD Card",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to USB Drive",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else if (errorUSB == UEZ_ERROR_NOT_READY) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "No USB Drive or SDCard found!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to SD Card!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to SD Card!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else {
            swim_put_text_xy(
                &G_drWin,
                "Write error!",
                DR_IMAGE_LEFT+2,
                DR_IMAGE_TOP+2);
        }
        swim_set_fill_transparent(&G_drWin, 1);
        UEZTaskDelay(2000);
        SUICopyFast32(FRAME(0), FRAME(1), FRAME_SIZE);
    }

    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, BLACK);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);
}
Exemplo n.º 29
0
/*---------------------------------------------------------------------------*
 * Routine:  DR_Load
 *---------------------------------------------------------------------------*
 * Description:
 *      Load an image from the flash drive and show.
 * Inputs:
 *      const T_choice *aChoice   -- Choice object selected for this action.
 *---------------------------------------------------------------------------*/
static void DR_Load(const T_choice *aChoice)
{
    T_uezError error;
    T_uezError errorUSB, errorSD;
    T_uezFile file;
    INT_32 winX, winY;
    TUInt32 num;
    TUInt16 x, y;

    // Draw line around choice while loading
    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, YELLOW);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);

    // Try to load from the USB drive
    error = errorUSB = UEZFileOpen("0:IMAGE.RAW", FILE_FLAG_READ_ONLY, &file);

    // If an error, try to load from the SD Card
    if (error != UEZ_ERROR_NONE)
        error = errorSD = UEZFileOpen("1:IMAGE.RAW", FILE_FLAG_READ_ONLY, &file);
    else
        errorSD = UEZ_ERROR_UNKNOWN;

    // Continue if no errors
    if (error == UEZ_ERROR_NONE) {
        error = UEZFileRead(
                    file,
                    LOAD_SPACE,
                    DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor),
                    &num);
        UEZFileClose(file);
        if ((error != UEZ_ERROR_NONE) &&
                (num != DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor))) {
            BeepError();
        } else {
            T_pixelColor *raster = (T_pixelColor *)LOAD_SPACE;
            for (y=0; y<DR_IMAGE_HEIGHT; y++) {
                for (x=0; x<DR_IMAGE_WIDTH; x++) {
                    winX = x + DR_IMAGE_LEFT+1;
                    winY = y + DR_IMAGE_TOP+1;
                    swim_get_physical_xy(&G_drWin, &winX, &winY);
                    swim_driver_put_pixel(&G_drWin, winX, winY, raster[x]);
                }
                raster += DR_IMAGE_WIDTH;
            }
        }
    }
    if (error) {
        // Had an error, report it
        SUICopyFast32(FRAME(1), FRAME(0), FRAME_SIZE);
        BeepError();
        swim_set_fill_transparent(&G_drWin, 0);
        swim_set_fill_color(&G_drWin, BLACK);
        swim_set_pen_color(&G_drWin, YELLOW);
        swim_put_box(
            &G_drWin,
            DR_IMAGE_LEFT,
            DR_IMAGE_TOP,
            DR_IMAGE_RIGHT,
            DR_IMAGE_TOP+16);
        if (errorUSB == UEZ_ERROR_NOT_FOUND) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "Image file not found on USB Drive!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
#if UEZ_DEFAULT_LCD_RES_QVGA
                    // Shorter string on QVGA screens
                    "Image file not found on USB or SD Card!",
#else
                    "Image file not found on USB Drive or SD Card!",
#endif
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "Image file not found on USB Drive!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else if (errorUSB == UEZ_ERROR_NOT_READY) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "No USB Drive or SD Card found!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
                    "Image file not found on SD Card!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "No USB Drive or SD Card found!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else {
            swim_put_text_xy(
                &G_drWin,
                "Read error!",
                DR_IMAGE_LEFT+2,
                DR_IMAGE_TOP+2);
        }
        swim_set_fill_transparent(&G_drWin, 1);
        UEZTaskDelay(2000);
        SUICopyFast32(FRAME(0), FRAME(1), FRAME_SIZE);
    }

    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, BLACK);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);
}
Exemplo n.º 30
0
/*********************************************************************
*
*       emWin
*
* Function description:
*   emWin demo application
*
*/
void emWin(const T_choice *aChoice) {


  T_uezDevice    hLCD;
  U32            FrameBufferSize;
  T_uezTask      hTouchTask;

	(void)aChoice;
  FrameBufferSize = UEZ_LCD_DISPLAY_WIDTH * UEZ_LCD_DISPLAY_HEIGHT * GUI_NUM_VIRTUAL_DISPLAYS * GUI_PIXEL_WIDTH;
    GUI_pMem    = (U32*)(GUI_VRAM_BASE_ADDR + FrameBufferSize);
  GUI_MemSize =       (GUI_VRAM_SIZE      - FrameBufferSize);
  memset((void*)GUI_VRAM_BASE_ADDR, 0, GUI_MemSize);//FrameBufferSize);
  //
  // Check that frame buffer memory fits into VRAM memory and we have empty memory left
  //
  if (GUI_VRAM_SIZE <= FrameBufferSize) {
    return;  // Error, not enough memory
  }
  //
  // Assign memory left to emWin memory
  //
  //GUI_pMem    = (U32*)(GUI_VRAM_BASE_ADDR + FrameBufferSize);
  //GUI_MemSize =       (GUI_VRAM_SIZE      - FrameBufferSize);
  //
  // emWin startup
  //
#if EMWIN_LOAD_ONCE
  if(G_emWinLoaded == EFalse)
  {
  WM_SetCreateFlags(WM_CF_MEMDEV);  // Enable memory devices
  

	  GUI_Init();
	  G_emWinLoaded = ETrue;
  }
#else
  WM_SetCreateFlags(WM_CF_MEMDEV);  // Enable memory devices
  GUI_Init();
#endif
  //
  // Open the LCD
  //
  if (UEZLCDOpen("LCD", &hLCD) == UEZ_ERROR_NONE)  {

    //
    // Create touch screen queue
    //
    if (UEZQueueCreate(1, sizeof(T_uezInputEvent), &_hTSQueue) == UEZ_ERROR_NONE) {
      //
      // Open touch screen
      //
      if (UEZTSOpen("Touchscreen", &_hTouchScreen, &_hTSQueue) == UEZ_ERROR_NONE) {
        //
        // Create touch task
        //
        if (UEZTaskCreate((T_uezTaskFunction)_TouchTask, "TouchTask",  1024, 0, UEZ_PRIORITY_VERY_HIGH, &hTouchTask) == UEZ_ERROR_NONE) {

          //
          // emWin application
          //
          GUIDEMO_Main();

          _RequestExit = 1;
          while (_RequestExit == 1) {
            UEZTaskDelay(1);  // Wait for touch task to terminate
          }
        }
        //
        // Close touch screen
        //
        UEZTSClose(_hTouchScreen, _hTSQueue);
      }
      UEZQueueDelete(_hTSQueue);
    }
    //
    // Close the LCD
    //
    UEZLCDClose(hLCD);
  }
  //
  // emWin cleanup
  //
#if !EMWIN_LOAD_ONCE
  GUI_Exit();
#endif
}