Esempio n. 1
0
static void runnerW_WindowCallback(UI1_Window *window, UI1_Element *element, UI1_EventCallbackKind kind, UI1_Pvoid data) {
  (void)window;
  (void)data; /* unused argument */
  if (kind==UI1_EVENT_CLICK) {
    if (UI1_EqualElement(element, &appWp->iconClose)) {
      FRTOS1_vTaskDelete(xHandleTaskRunner);
      APP_SetApplicationMode(APP_MODE_MAIN_MENU);
      return;
    } else if (UI1_EqualElement(element, &appWp->iconDelLast)) {
      RUNNER_delLastRunner = TRUE;
    }
  }
}
Esempio n. 2
0
static portTASK_FUNCTION(TaskMotorDemo, pvParameters) {
  MOTOR_WindowDesc *ui = (MOTOR_WindowDesc*)pvParameters;
  UIG1_DataPoint data[2], prevData[2];

  appWp = ui;
#if PL_APP_MODE_I2C_LCD
  I2C_ClearBuffers();
#endif
  /* current speed: */
  data[0].color = UI1_COLOR_RED;
  data[0].data = 0;
  /* desired PID speed: */
  data[1].color = UI1_COLOR_BLUE;
  data[1].data = 0;
  /* previous data information */
  prevData[0].color = UI1_COLOR_BLUE;
  prevData[0].data = 0;
  prevData[1].color = UI1_COLOR_RED;
  prevData[1].data = 0;

  for (;;) {
#if PL_HAS_I2C_COMM
    I2C_StoreCmd();
    data[0].data = RangeSpeed(I2C_GetMotorDesiredSpeed());
    data[1].data = RangeSpeed(I2C_GetMotorActualSpeed());
#else
    data[0].data = 50;
    data[1].data = 60;
#endif
    (void)UIG1_AddDataLine((UI1_Element *)&ui->graph, &prevData[0], &data[0], 2);
    /* remember data for next iteration */
    prevData[0].data = data[0].data;
    prevData[1].data = data[1].data;

    if (EVNT1_GetEvent(EVNT1_APP_MODE_CHANGE)) { /* request to close application */
      EVNT1_ClearEvent(EVNT1_APP_MODE_CHANGE); /* reset event flag */
      xHandleTaskMotorDemo = NULL;
      FRTOS1_vTaskDelete(NULL); /* kill ourself */
    }
    FRTOS1_vTaskDelay(20/portTICK_RATE_MS);
  } /* for */
}
Esempio n. 3
0
static portTASK_FUNCTION(TaskAccelDemo, pvParameters) {
    int16_t x,y,z;
    ACCEL_WindowDesc *ui = (ACCEL_WindowDesc*)pvParameters;
    unsigned char buf[sizeof("X: 123")];
    UIG1_DataPoint data[3], prevData[3];

    appWp = ui;
#if PL_APP_MODE_I2C_LCD
    I2C_ClearBuffers();
#endif
    data[0].color = UI1_COLOR_RED;
    data[0].data = 0;
    data[1].color = UI1_COLOR_BLUE;
    data[1].data = 0;
    data[2].color = UI1_COLOR_DARK_GREEN;
    data[3].data = 0;
    prevData[0].color = UI1_COLOR_RED;
    prevData[0].data = 0;
    prevData[1].color = UI1_COLOR_BLUE;
    prevData[1].data = 0;
    prevData[2].color = UI1_COLOR_DARK_GREEN;
    prevData[2].data = 0;
    for (;;) {
        /* we are getting the values in milli-g (means: around -1200 to +1200 */
#if PL_HAS_AUTO_DEMO && PL_HAS_HW_ACCELEROMETER
        /* for demo, make values more interesting */
        x = ACCEL1_GetX();
        y = ACCEL1_GetY();
        z = ACCEL1_GetZ();
        while (z>900) { /* put in range */
            z /= 2;
        }
#else
        x = ACCEL_GetX();
        y = ACCEL_GetY();
        z = ACCEL_GetZ();
#endif
        /* cap to -100..+100 */
        x /= 11; /* little bit more than 10, just to have 1g not always hitting the limit of 100% */
        y /= 11;
        z /= 11;
        /* make sure it is in the -100..+100 range */
        if (x>100) {
            x = 100;
        }
        else if (x<-100) {
            x = -100;
        }
        if (y>100) {
            y = 100;
        }
        else if (y<-100) {
            y = -100;
        }
        if (z>100) {
            z = 100;
        }
        else if (z<-100) {
            z = -100;
        }
        /* midpoint of graph is at 50% */
        x = 50+(x/2); /* scale between 0..100% */
        y = 50+(y/2); /* scale between 0..100% */
        z = 50+(z/2); /* scale between 0..100% */
        UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"X: ");
        UTIL1_strcatNum16s(buf, sizeof(buf), x);
        UI1_ChangeText(&ui->window, (UI1_Element *)&ui->txtX, sizeof(ui->txtBufX), buf);
        UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"Y: ");
        UTIL1_strcatNum16s(buf, sizeof(buf), y);
        UI1_ChangeText(&ui->window, (UI1_Element *)&ui->txtY, sizeof(ui->txtBufY), buf);
        UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"Z: ");
        UTIL1_strcatNum16s(buf, sizeof(buf), z);
        UI1_ChangeText(&ui->window, (UI1_Element *)&ui->txtZ, sizeof(ui->txtBufZ), buf);
        (void)UI1_ChangeBarGraphData(&ui->window, &ui->accelBarGraph, 0, (uint8_t)x);
        (void)UI1_ChangeBarGraphData(&ui->window, &ui->accelBarGraph, 1, (uint8_t)y);
        (void)UI1_ChangeBarGraphData(&ui->window, &ui->accelBarGraph, 2, (uint8_t)z);
        /* graph */
        data[0].data = (uint8_t)x;
        data[1].data = (uint8_t)y;
        data[2].data = (uint8_t)z;
        (void)UIG1_AddDataLine((UI1_Element *)&ui->graph, &prevData[0], &data[0], 3);
        prevData[0].data = data[0].data;
        prevData[1].data = data[1].data;
        prevData[2].data = data[2].data;
        if (EVNT1_GetEvent(EVNT1_APP_MODE_CHANGE)) { /* request to close application */
            EVNT1_ClearEvent(EVNT1_APP_MODE_CHANGE); /* reset event flag */
            FRTOS1_vTaskDelete(NULL); /* kill ourself */
        }
        FRTOS1_vTaskDelay(25/portTICK_RATE_MS);
    } /* for */
}