Exemplo n.º 1
0
//////////////////////////////////////////////////////////////////////////////
// Read Demanded Value | Dependent on Device Type ( Light | Meter | Presence )
//////////////////////////////////////////////////////////////////////////////
uint32_t APP_readDemandValue(void)
{      
    // LIGHT --------------------- 
#if defined( RELAY_BOARD )

    g_ulValue = os_adapt_rand() % 2;
    return g_ulValue;

    // PRESENCE_DETECTOR ------ 
#elif defined( MOTION_DETECTION_BOARD )

    static uint32_t s_ulLastReadTime;

    if( (uint32_t)(os_adapt_time() - s_ulLastReadTime) >= MOTION_TIME_ALLOC ) // 0.5 sec histerezis
    {
        s_ulLastReadTime = os_adapt_time();

        uint32_t pioOutVal=GET_PIO_INPUT_VALUE(PRESENCE_DETECTOR_PIN);

        if( g_LastGpioVal == pioOutVal ) // 2 time consecutives same value
        {
            g_ulValue = pioOutVal;          
        }
        g_LastGpioVal=pioOutVal;
    }

    // APP_controllerProc sends the value to the Light Relay Controller
    return g_ulValue;

    // METER -------------------- METER READ VALUE ----------------------------
#elif defined(METER_BOARD)          
    if (g_stMeterTableToRead.data_length == 0)  // data was processed
    {
        //Post(METER_TASK, PUBLISH_REQ_EVENT);
        OS_SignalEvent(PUBLISH_REQ_EVENT, &TCB_METER_Task);
        return TRUE;
    }
    return FALSE;
#else
    g_ulValue = 1024 + ( os_adapt_rand() & 0xFF );
    return g_ulValue;
#endif      
}
Exemplo n.º 2
0
/****************************************************************************
*    Name        : TransmitSetupUSB                                         *
*                                                                           *
*    Inputs      : None                                                     *
*    Outputs     : None                                                     *
*    Returns     : None                                                     *
*                                                                           *
*    Description : This routine Initiates the USB transmission by sending   *
*                 event to the USB transmit task.                           *
*                                                                           *
*****************************************************************************
*/
GF_UINT8 TransmitSetupUSB(void)
{
  BIT ret_val = FALSE;
  
  if (usb_channel_busy == FALSE)
  {
    /* For handling mis-synchronization */
    usb_tx_idle_active = FALSE;
    usb_tx_idle_cnt = usb_tx_idle_cnt_reset_value * 10; 
    usb_tx_idle_active = TRUE;

    /* Signal USB Transmit Task to start transmission. */
    OS_SignalEvent(USB_TXSETUP_EVENT, &USBTxTaskHandle);

    ret_val = TRUE;
  }
  else
  {
    ret_val = FALSE;//breakpoint
  }
  UsbChannelBusy(TRUE);

  return ret_val;
}
Exemplo n.º 3
0
void GUI_X_SignalEvent(void)    {
  if (_pGUITask) {
    OS_SignalEvent(1, _pGUITask);
  }
}
Exemplo n.º 4
0
//---------------------------------------------------------------------------//
//                                                                           //
//函数:void ShowMenu_Item(unsigned char ,unsigned char,unsigned char)       //
//描述:显示菜单项子函数                                                     //
//参数:index ——菜单项索引                                                 //
//      no    ——显示位置序号                                               //
//      mode  ——显示模式                                                   //
//		                                                             //
//---------------------------------------------------------------------------//
void RunMenu(unsigned char index)
{
  char key,i,Active_Item  = 0x00                                         ;
  OS_U8 Event                                                            ;
  union
  {
    unsigned int  pos[2]                                                 ;
    char byte[4]                                                         ;
  }TPoint                                                                ;
Ini_Background:  
  Color     = Black                                                      ;
  Color_BK  = 0xEF9F                                                     ;
  Clear_LCD(Color_BK)                                                    ;
  DrawRectFill(0,0,240,25,Blue)                                          ;
  DrawRectFill(0,295,240,25,Blue)                                        ;
  Color    = 0xFFFF                                                      ;
  Color_BK = Blue                                                        ;
  PutStringCN16(4,4,(unsigned char *)Menus[index].MenuTitle)             ;
  Color    = Black                                                       ;
  Color_BK = WINDOW_BK_COLOR                                             ;
  for(i=0;i<Menus[index].MenuConfig[0];i++)
  {
    if(i==Active_Item)
      ShowMenu_Item(Menus[index].ItemIndex[i],i,1)                       ;
    else
      ShowMenu_Item(Menus[index].ItemIndex[i],i,0)                       ;      
  }
  for(;;)
  {
//    Event = OS_WaitEvent(EVENT_KEY_PRESSED+EVENT_TP_PRESSED)             ; 
    OS_WaitMail(&MBKey)                                                  ;
//    if(Event&EVENT_KEY_PRESSED)
    {
      OS_GetMail1(&MBKey, &key)                                          ;  
      switch(key)
      {
      case Right:
        InactivateItem(Active_Item)                                      ;
        if(++Active_Item>=Menus[index].MenuConfig[0])
          Active_Item = 0x00                                             ;
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case Left:
        InactivateItem(Active_Item)                                      ;
        if(Active_Item==0) 
          Active_Item = 0x08                                             ;
        else
          Active_Item--                                                  ;
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case 8:
        InactivateItem(Active_Item)                                      ;
        if(Active_Item==0) 
          Active_Item = 0x08                                             ;
        else if(Active_Item==1||Active_Item==2)
          Active_Item = Active_Item+5                                    ;
        else 
          Active_Item = Active_Item-3                                    ;          
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case 0:
        InactivateItem(Active_Item)                                      ;
        if(Active_Item==8) 
          Active_Item = 0x00                                             ;
        else if(Active_Item==6||Active_Item==7)
          Active_Item = Active_Item-5                                    ;
        else 
          Active_Item = Active_Item+3                                    ;          
        ActivateItem(Active_Item)                                        ;
        break                                                            ;
      case Enter:
        OS_PutMail1(&MBFunc, &Active_Item)                               ;
        OS_SignalEvent(EVENT_OP_STARTED,&MENU_OP_TASK_TCB)               ;
        OS_Suspend(&LCD_TASK_TCB)                                        ;
        goto Ini_Background                                              ;
      default:
        break                                                            ;
      }
    }
/*    else
    {
      OS_GetMail(&MBTouch, TPoint.byte)                                  ; 
      for(i=0;i<Menus[index].MenuConfig[0];i++)
      {        
        if(  (TPoint.pos[0]<(60+i%3*80)&&TPoint.pos[0]>(20+i%3*80))
           &&(TPoint.pos[1]<(95+i/3*84)&&TPoint.pos[1]>(55+i/3*82)))
        {
          Active_Item = i                                                ;
          OS_PutMail1(&MBFunc, &Active_Item)                             ;
          OS_SignalEvent(EVENT_OP_STARTED,&MENU_OP_TASK_TCB)             ;
          OS_Suspend(&LCD_TASK_TCB)                                      ;
          goto Ini_Background                                            ;
        }
      }
    }
*/    
  }
}
Exemplo n.º 5
0
void StopDisplay(void)
{
  display_running = false;
  OS_SetPriority(&TCBDisplayMainTask, POWER_DOWN_PRIO);
  OS_SignalEvent(POWER_DOWN_EVENT, &TCBDisplayMainTask);
}