Beispiel #1
0
/*********************************************************************
*
*       _OnTouch
*/
static void _OnTouch(RADIO_Handle hObj, RADIO_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification;
  int Hit = 0;
  GUI_PID_STATE* pState = (GUI_PID_STATE*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (pState->Pressed) {
      int y, Sel;
      y   = pState->y;
      Sel = y   / pObj->Spacing;
      y  -= Sel * pObj->Spacing;
      if (y <= pObj->Height) {
        RADIO_SetValue(hObj, Sel);
      }
      if (WM_IsFocussable(hObj)) {
        WM_SetFocus(hObj);
      }
      Notification = WM_NOTIFICATION_CLICKED;
    } else {
      Hit = 1;
      Notification = WM_NOTIFICATION_RELEASED;
    }
  } else {
    Notification = WM_NOTIFICATION_MOVED_OUT;
  }
  WM_NotifyParent(hObj, Notification);
  if (Hit == 1) {
    GUI_DEBUG_LOG("RADIO: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
}
Beispiel #2
0
/*********************************************************************
*
*       _OnButtonReleased
*/
static void _OnButtonReleased(BUTTON_Handle hObj, BUTTON_Obj* pObj, int Notification) {
  WIDGET_AndState(hObj, BUTTON_STATE_PRESSED);
  if (Notification == WM_NOTIFICATION_RELEASED) {
    GUI_DEBUG_LOG("BUTTON: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
  if (pObj->Widget.Win.Status & WM_SF_ISVIS) {
    WM_NotifyParent(hObj, Notification);
  }
}
Beispiel #3
0
static WM_RESULT cbBackWin( WM_MESSAGE* pMsg) {
  WM_KEY_INFO* pKeyInfo;
  switch (pMsg->MsgId) {
  case WM_KEY:
    pKeyInfo = (WM_KEY_INFO*)pMsg->Data.p;
    if (pKeyInfo->PressedCnt == 0) {
      GUI_StoreKey(pKeyInfo->Key);
    }
    break;
  case WM_PAINT:
    if (WM__BkColor != GUI_INVALID_COLOR) {
      GUI_SetBkColor(WM__BkColor);
      GUI_Clear();
    }
  default:
    WM_DefaultProc(pMsg);
  }
}
Beispiel #4
0
/*********************************************************************
*
*       _OnTouch
*/
static void _OnTouch(BUTTON_Handle hObj, BUTTON_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification;
  int Hit = 0;
  GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (pState->Pressed) {
      WIDGET_OrState(hObj, BUTTON_STATE_PRESSED);
      Notification = WM_NOTIFICATION_CLICKED;
      WM_SetFocus(hObj);
    } else {
      Hit =1;
      Notification = WM_NOTIFICATION_RELEASED;
      WIDGET_AndState(hObj, BUTTON_STATE_PRESSED);
    }
  } else {
    Notification = WM_NOTIFICATION_MOVED_OUT;
    WIDGET_AndState(hObj, BUTTON_STATE_PRESSED);
  }
  WM_NotifyParent(hObj, Notification);
  if (Hit == 1) {
    GUI_DEBUG_LOG("BUTTON: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
}
Beispiel #5
0
/*********************************************************************
*
*       _OnTouch
*/
static void _OnTouch(CHECKBOX_Handle hObj, CHECKBOX_Obj* pObj, WM_MESSAGE*pMsg) {
  int Notification = 0;
  int Hit = 0;
  const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (!WM_HasCaptured(hObj)) {
      if (pState->Pressed) {
        WM_SetCapture(hObj, 1);
        CHECKBOX_SetState(hObj, (pObj->CurrentState + 1) % pObj->NumStates);
        Notification = WM_NOTIFICATION_CLICKED;
      } else {
        Hit =1;
        Notification = WM_NOTIFICATION_RELEASED;
      }
    }
  } else {
    Notification = WM_NOTIFICATION_MOVED_OUT;
  }
  WM_NotifyParent(hObj, Notification);
  if (Hit == 1) {
    GUI_DEBUG_LOG("CHECKBOX: Hit\n");
    GUI_StoreKey(pObj->Widget.Id);
  }
}
Beispiel #6
0
extern "C" void RunKeyboardTask(void)
{
  int  task_timer;
  U16  temp, temp1;
  int  right_arrow_key_counter = 0;
  bool right_arrow_key         = false;
  bool right_arrow_key_rep     = false;
  int  question_key_counter    = 0;
  bool question_key            = false;
  bool question_key_rep        = false;
  int  contrast_key_counter    = 0;
  bool contrast_key            = false;
  bool contrast_key_rep        = false;
  int  plus_key_counter        = 0;
  bool plus_key                = false;
  bool plus_key_rep            = false;
  int  minus_key_counter       = 0;
  bool minus_key               = false;
  bool minus_key_rep           = false;
  int  home_key_counter        = 0;
  bool home_key                = false;
  bool home_key_rep            = false;
  int  up_key_counter          = 0;
  bool up_key                  = false;
  bool up_key_rep              = false;
  int  down_key_counter        = 0;
  bool down_key                = false;
  bool down_key_rep            = false;
  int  ok_key_counter          = 0;
  bool ok_key                  = false;
  bool ok_key_rep              = false;
  int  esc_key_counter         = 0;
  bool esc_key                 = false;
  bool esc_key_rep             = false;
  int  plus_key_rep_number     = 0;
  int  minus_key_rep_number    = 0;
  U16  temp_keys                = 0;
  int  number_of_keys;
  int plus_key_repeated        = 0;
  int minus_key_repeated       = 0;

  InitKeyboardHw();

  while (1)
  {
    task_timer = OS_GetTime();

    temp  = REGISTER16(KIUDAT0_MPC);
    temp1 = REGISTER16(KIUDAT1_MPC);
    temp_keys = 0;
    number_of_keys = 0;

    if (!(temp & 0x0001))      // >
    {
      temp_keys |= 0x0001;
      HandleKey(right_arrow_key,right_arrow_key_counter,right_arrow_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(right_arrow_key,right_arrow_key_counter,right_arrow_key_rep,false);
    }

    if (!(temp & 0x0100))     // ?
    {
      temp_keys |= 0x0002;
      HandleKey(question_key,question_key_counter,question_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(question_key,question_key_counter,question_key_rep,false);
    }

    if (!(temp & 0x0002))      // +
    {
      temp_keys |= 0x0010;
      HandleKey(plus_key,plus_key_counter,plus_key_rep,true);
      number_of_keys++;

      plus_key_repeated = 0;
    }
    else if (!plus_key_rep || ++plus_key_repeated > KEY_REP_IDLE_IN_COUNTS)
    {
      HandleKey(plus_key,plus_key_counter,plus_key_rep,false);
      plus_key_rep_number = 0;

      plus_key_repeated = 0;
    }

    if (!(temp & 0x0200))      // -
    {
      temp_keys |= 0x0020;
      HandleKey(minus_key,minus_key_counter,minus_key_rep,true);
      number_of_keys++;

      minus_key_repeated = 0;
    }
    else if (!minus_key_rep || ++minus_key_repeated > KEY_REP_IDLE_IN_COUNTS)
    {
      HandleKey(minus_key,minus_key_counter,minus_key_rep,false);
      minus_key_rep_number = 0;

      minus_key_repeated = 0;
    }

    if (!(temp & 0x0004))      // home
    {
      temp_keys |= 0x0100;
      HandleKey(home_key,home_key_counter,home_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(home_key,home_key_counter,home_key_rep,false);
    }

    if (!(temp & 0x0400))      // contrast
    {
      temp_keys |= 0x0200;
      HandleKey(contrast_key,contrast_key_counter,contrast_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(contrast_key,contrast_key_counter,contrast_key_rep,false);
    }

    if (!(temp1 & 0x0001))      // up
    {
      temp_keys |= 0x0004;
      HandleKey(up_key,up_key_counter,up_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(up_key,up_key_counter,up_key_rep,false);
    }

    if (!(temp1 & 0x0100))     // down
    {
      temp_keys |= 0x0008;
      HandleKey(down_key,down_key_counter,down_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(down_key,down_key_counter,down_key_rep,false);
    }

    if (!(temp1 & 0x0002))      // esc
    {
      temp_keys |= 0x0040;
      HandleKey(esc_key,esc_key_counter,esc_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(esc_key,esc_key_counter,esc_key_rep,false);
    }

    if (!(temp1 & 0x0200))      // ok
    {
      temp_keys |= 0x0080;
      HandleKey(ok_key,ok_key_counter,ok_key_rep,true);
      number_of_keys++;
    }
    else
    {
      HandleKey(ok_key,ok_key_counter,ok_key_rep,false);
    }

    keys = temp_keys;

    if ( number_of_keys == 1 )
    {
      if (contrast_key)
      {
        GUI_StoreKey('c');
        contrast_key = false;
      }
      if (ok_key)
      {
        GUI_StoreKey(GUI_KEY_ENTER);
        ok_key = false;
      }
      if (esc_key)
      {
        GUI_StoreKey(GUI_KEY_ESCAPE);
        esc_key = false;
      }
      if (home_key)
      {
        GUI_StoreKey(GUI_KEY_HOME);
        home_key = false;
      }
      if (right_arrow_key)
      {
        GUI_StoreKey(GUI_KEY_RIGHT);
        right_arrow_key = false;
      }
      if (question_key)
      {
        GUI_StoreKey('?');
        question_key = false;
      }
      if (up_key)
      {
        GUI_StoreKey(GUI_KEY_UP);
        up_key = false;
      }
      if (down_key)
      {
        GUI_StoreKey(GUI_KEY_DOWN);
        down_key = false;
      }
      if (plus_key)
      {
        if ( plus_key_rep )
        {
          if (++plus_key_rep_number > KEY_REP_NUMBER_IN_COUNTS)
          {
            GUI_StoreKey('*');
            plus_key_rep_number =  KEY_REP_NUMBER_IN_COUNTS;
          }
          else
          {
            GUI_StoreKey('+');
          }
        }
        else
        {
          GUI_StoreKey('+');
        }
        plus_key = false;
      }
      if (minus_key)
      {
        if ( minus_key_rep )
        {
          if (++minus_key_rep_number > KEY_REP_NUMBER_IN_COUNTS)
          {
            GUI_StoreKey('/');
            minus_key_rep_number = KEY_REP_NUMBER_IN_COUNTS;
          }
          else
          {
            GUI_StoreKey('-');
          }
        }
        else
        {
          GUI_StoreKey('-');
        }
        minus_key = false;
      }
    }

    if (contrast_key)
    {
      contrast_key_down = true;
    }
    else
    {
      contrast_key_down = false;
    }

    REGISTER16(KIUSCANREP_MPC) = 0x8036;  // new scan start
    OS_DelayUntil (task_timer + KEYBORAD_SAMPLE_TIME);
  }
}
Beispiel #7
0
/*****************************************************************************
 * Function HandleGeniTestData
 * DESCRIPTION:
 *****************************************************************************/
void GeniAppTestMode::HandleGeniTestData(void)
{
  static bool firmware_update_started = false;
  static bool io_simulation_mode_enable = false;

  G_ge_io_simulation_status = mpIOSimulationStatus->GetValue();

  /* Handle G_ge_test_config */
  HandleTestConfig(G_ge_test_config);

  if (G_ge_io_simulation_mode_enable != IO_SIMULATION_ENABLED)
  {
    if (io_simulation_mode_enable == true)
    {
      mpIOSimulationDisable->SetEvent();
      HandleIOSimulation();  // To clear simulation data
      io_simulation_mode_enable = false;
    }
    // Normal test functions
    /* Handle G_ge_dig_out */
    IobComDrv::GetInstance()->SetDigitalOutputTestMode(G_ge_dig_out_ref);
    // Display
    mpDisplayContrast->SetValueAsPercent(G_ge_display_contrast/2.54f);
    mpDisplayBacklight->SetValueAsPercent(G_ge_display_backlight/2.54f);
  }
  else
  {
    // Handle IO simulation
    if (io_simulation_mode_enable == false)
    {
      mpIOSimulationEnable->SetEvent();
      io_simulation_mode_enable = true;
    }
    HandleIOSimulation();
  }


  /* Handle G_ge_error_log_control */
  if (TEST_BIT_HIGH(G_ge_error_log_control, 0)) //Reset ErrorLog
  {
    SET_BIT_LOW(G_ge_error_log_control, 0);
    ErrorLog::GetInstance()->ResetErrorLog();
  }

  /* Handle G_ge_firmware_update_state */
  if (G_ge_firmware_update_state == FIRMWARE_UPDATE_STATE_START && firmware_update_started == false)
  {
    mpFirmwareUpdateState->SetValue(FIRMWARE_UPDATE_STATE_START);
    firmware_update_started = true;
  }
  else if (G_ge_firmware_update_state == FIRMWARE_UPDATE_STATE_STARTBL && firmware_update_started == false)
  {
    mpFirmwareUpdateState->SetValue(FIRMWARE_UPDATE_STATE_STARTBL);
    firmware_update_started = true;
  }
  G_ge_firmware_update_state = mpFirmwareUpdateState->GetValue();

  if (G_ge_firmware_update_state != FIRMWARE_UPDATE_STATE_START && G_ge_firmware_update_state != FIRMWARE_UPDATE_STATE_STARTBL)
  {
    firmware_update_started = false;
  }

  /* Handle G_ge_test_loop_displays */
  if (G_ge_test_loop_displays == 1)

  {
    G_ge_test_loop_displays = 0;

    mpc::display::DisplayController::GetInstance()->TestLoopDisplays();
  }
  /* Handle G_ge_emwin_key_input */
  else if (G_ge_emwin_key_input != 255)
  {
    GUI_StoreKey(G_ge_emwin_key_input);
    G_ge_emwin_key_input = 255;
  }

  if (mpIobBoardId.IsUpdated())
  {
    G_ge_iob_board_id = mpIobBoardId->GetValue();
  }
  if (mpIobTemperature.IsUpdated())
  {
    G_ge_iob_temperature = (U16)(mpIobTemperature->GetValue() + 273.15f + 0.5f); // K
  }
  if (mpIobPressure.IsUpdated())
  {
    G_ge_iob_pressure = (U16)(mpIobPressure->GetValue()*0.01f + 0.5f); // Scale from Pa to mbar;
  }
  if (mpIobBatteryVoltage.IsUpdated())
  {
    G_ge_iob_battery_voltage = (U16)(mpIobBatteryVoltage->GetValue()*1000.0f + 0.5f); // Scale from V to mV
  }
  if (mpIobBusModulePressent.IsUpdated())
  {
    G_ge_iob_bus_module_pressent = mpIobBusModulePressent->GetValue();
  }
  if (mpIobSupplyStatus.IsUpdated())
  {
    G_ge_iob_supply_status = mpIobSupplyStatus->GetValue();
  }
  if (mpIobBatteryStatus.IsUpdated())
  {
    G_ge_iob_battery_status = mpIobBatteryStatus->GetValue();
  }
  if (mpAnalogInput0.IsUpdated())
  {
    G_ge_ana_in_raw_0 = mpAnalogInput0->GetValue();
  }
  if (mpAnalogInput1.IsUpdated())
  {
    G_ge_ana_in_raw_1 = mpAnalogInput1->GetValue();
  }
  if (mpAnalogInput2.IsUpdated())
  {
    G_ge_ana_in_raw_2 = mpAnalogInput2->GetValue();
  }
  if (mpAnalogInput3.IsUpdated())
  {
    G_ge_ana_in_raw_3 = mpAnalogInput3->GetValue();
  }
  if (mpAnalogInput4.IsUpdated())
  {
    G_ge_ana_in_raw_4 = mpAnalogInput4->GetValue();
  }
  if (mpAnalogInput5.IsUpdated())
  {
    G_ge_ana_in_raw_5 = mpAnalogInput5->GetValue();
  }
  if (mpDigitalInput.IsUpdated())
  {
    G_ge_dig_in = mpDigitalInput->GetValue();
  }
}
Beispiel #8
0
extern "C" void DisplayMainTask(void)
{
  int  start_task_time, end_task_time, task_time_diff;
#ifndef __PC__
  int i;

  for (i = 4*INITIAL_BACKLIGHT; i > 0; i -= 4)
  {
    SetDutyCycleHW_1(i);
    GUI_Delay(1);
  }
#endif

  #ifdef __PC__ // Kill the rest of the system running on PC
  HWND main_wnd_handle = PcDevToolService::GetInstance()->GetControllerWindow();
  if(main_wnd_handle)
  {
    ShowWindow(main_wnd_handle, SW_SHOWNORMAL);
  }
  #endif // __PC__

  while (display_running)
  {
    start_task_time = OS_GetTime();
    mpc::display::DisplayController::GetInstance()->Run();
    GUI_Delay(5);

    #ifdef __PC__
    if( HasOSMessage() )
    {
      OS_EnterRegion();
      OS_IncDI();
      OSMessage* msg;

      // Get message from queue without removing it.
      msg = PeekOSMessage();
      switch(msg->message)
      {
      case 0:
        break;
      case OSMSG_LOAD_DISPLAY:
        msg->rc = PcDevToolService::GetInstance()->LoadDisplay((const char*)(msg->data));
        break;
      case OSMSG_LOAD_DISPLAY_ID:
        msg->rc = PcDevToolService::GetInstance()->LoadDisplay(*(int*)(msg->data));
        break;
      case OSMSG_SET_LANGUAGE:
        Languages::GetInstance()->SetLanguage(*((LANGUAGE_TYPE*)msg->data));
        msg->rc = 0;
        break;
      case OSMSG_GET_LANGUAGE:
        msg->rc = Languages::GetInstance()->GetLanguage();        
        break;
      case OSMSG_DUMP_SCREEN:
        mpc::display::DisplayDumper::GetInstance()->DumpScreen(false);
        msg->rc = 0;
        break;
      case OSMSG_DUMP_SCREENS:
        mpc::display::DisplayDumper::GetInstance()->DumpScreens(true, false);
        msg->rc = 0;
        break;
      case OSMSG_SET_SUBJECT_VALUE:
        msg->rc = PcDevToolService::GetInstance()->SetSubjectValue( ((SubjectValueParameters*)msg->data) );
        break;
      case OSMSG_GET_SUBJECT_VALUE_AS_FLOAT:
        msg->rc = PcDevToolService::GetInstance()->GetSubjectValue( ((SubjectValueParameters*)msg->data) );
        break;
      case OSMSG_SET_SUBJECT_QUALITY:
        msg->rc = PcDevToolService::GetInstance()->SetSubjectQuality( ((QualityParameters*)msg->data) );
        break;
      case OSMSG_SET_DI_VALUE:
        msg->rc = PcSimulatorService::GetInstance()->SetDiValue( ((DiParameters*)msg->data) );
        break;
      case OSMSG_SET_AI_VALUE_PERCENT:
        msg->rc = PcSimulatorService::GetInstance()->SetAiValueInPercent( ((AiParameters*)msg->data) );
        break;
      case OSMSG_SET_AI_VALUE_INTERNAL:
        msg->rc = PcSimulatorService::GetInstance()->SetAiValueInInternalUnit( ((AiParameters*)msg->data) );
        break;
      case OSMSG_SELECT_LISTVIEW_ITEM_BY_INDEX:
        msg->rc = PcDevToolService::GetInstance()->SelectListViewItem(*(int*)(msg->data));
        break;
      case OSMSG_KEY_PRESS:
        GUI_StoreKey(*(int*)(msg->data));
        msg->rc = 0;
        break;
      case OSMSG_SET_ERROR_PRESENT:
        msg->rc = PcSimulatorService::GetInstance()->SimulateAlarm( ((AlarmParameters*)msg->data) );
        break;
      case OSMSG_EXPORT_STRING_LENGTHS:
        mpc::display::StringWidthCalculator::GetInstance()->ExportStringWidths((const char*)(msg->data));
        msg->rc = 0;
        break;
      case OSMSG_EXPORT_STRING_LENGTHS_ADV:
        mpc::display::StringWidthCalculator::GetInstance()->ExportStringWidthsAdv(((mpc::display::StringWidthParameters*)(msg->data)));
        msg->rc = 0;
        break;
      case OSMSG_SET_IO111_VALUES:
        msg->rc = PcSimulatorService::GetInstance()->SetIO111Values( ((Io111Parameters*)msg->data) );
        break;
      default:
        msg->rc = -1;
        break;
      }
      // Remove message from queue
      DisposeOSMessage();

      OS_DecRI();
      OS_LeaveRegion();
      OS_Delay(1);
    }
    #endif //__PC__

    // calculate time to wait
    end_task_time = OS_GetTime();
    task_time_diff = end_task_time - start_task_time;

    if( task_time_diff <= 1 )
      OS_WaitSingleEventTimed( POWER_DOWN_EVENT, DISPLAY_SAMPLE_TIME );         // We will skip ...
    else if ( task_time_diff > (DISPLAY_SAMPLE_TIME-1) )
      OS_WaitSingleEventTimed( POWER_DOWN_EVENT, 1 );                          // Run again, now
    else
      OS_WaitSingleEventTimed( POWER_DOWN_EVENT, DISPLAY_SAMPLE_TIME - task_time_diff );
  }
#ifndef __PC__
  LCDPowerDown();                     // TODO: Check the for-loops !! It takes a lot of time
#endif
  SignalEventToPowerDown(DISPLAY_POWERED_DOWN_EVENT);
#ifndef __PC__
  while (1)                                                                    // We will die anyway
  {
    GUI_Delay(1000);
  }
#endif
}