예제 #1
0
파일: tmr.c 프로젝트: rongfengyu/WiFiMCU
//tmr.start(id,interval,function)
//id:1~16
static int ltmr_start( lua_State* L )
{
  unsigned id = luaL_checkinteger( L, 1 )-1;
  MOD_CHECK_ID( tmr, id+1 );
  
  unsigned interval = luaL_checkinteger( L, 2 );
  if ( interval <= 0 ) 
    return luaL_error( L, "wrong arg range" );
  
  if (lua_type(L, 3) == LUA_TFUNCTION || lua_type(L, 3) == LUA_TLIGHTFUNCTION)
  {
    lua_pushvalue(L, 3);  // copy argument (func) to the top of stack
    if(tmr_cb_ref[id] != LUA_NOREF)
    {
      luaL_unref(L, LUA_REGISTRYINDEX, tmr_cb_ref[id]);
    }
    gL = L;
    tmr_cb_ref[id] = luaL_ref(L, LUA_REGISTRYINDEX);
    mico_stop_timer(&_timer[id]);
    mico_deinit_timer( &_timer[id] );
    mico_init_timer(&_timer[id], interval, _tmr_handler, (void*)id);
    mico_start_timer(&_timer[id]);    
  }
  else
    return luaL_error( L, "callback function needed" );
  
  return 0;
}
예제 #2
0
void ConfigSoftApWillStart(mico_Context_t * const inContext )
{
  OSStatus err;
  mico_uart_config_t uart_config;

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  
  sppProtocolInit(inContext);
  
   /*UART receive thread*/
  uart_config.baud_rate    = inContext->flashContentInRam.appConfig.USART_BaudRate;
  uart_config.data_width   = DATA_WIDTH_8BIT;
  uart_config.parity       = NO_PARITY;
  uart_config.stop_bits    = STOP_BITS_1;
  uart_config.flow_control = FLOW_CONTROL_DISABLED;
  ring_buffer_init  ( (ring_buffer_t *)&rx_buffer, (uint8_t *)rx_data, UART_BUFFER_LENGTH );
  MicoUartInitialize( UART_FOR_APP, &uart_config, (ring_buffer_t *)&rx_buffer );
  err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "UART Recv", uartRecv_thread, STACK_SIZE_UART_RECV_THREAD, (void*)inContext );
  require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the uart recv thread.") );

 if(inContext->flashContentInRam.appConfig.localServerEnable == true){
   err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "Local Server", localTcpServer_thread, STACK_SIZE_LOCAL_TCP_SERVER_THREAD, (void*)inContext );
   require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the local server thread.") );
 }

exit:
  return;
}
예제 #3
0
파일: tmr.c 프로젝트: rongfengyu/WiFiMCU
//tmr.stop(id)
//id:1~16
static int ltmr_stop( lua_State* L )
{
  unsigned id = luaL_checkinteger( L, 1 ) - 1;
  MOD_CHECK_ID( tmr, id+1 );
  mico_stop_timer(&_timer[id]);
  return 0;
}
예제 #4
0
void ConfigSoftApWillStart(mico_Context_t * const inContext )
{
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
}
예제 #5
0
void ConfigEasyLinkIsSuccess( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"EasyLink got    ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line);
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%16s", inContext->flashContentInRam.micoSystemConfig.ssid);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)oled_show_line);
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%16s", inContext->flashContentInRam.micoSystemConfig.user_key);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)oled_show_line);
#endif
  return;
}
WEAK void mico_system_delegate_config_will_start( void )
{
    /*Led trigger*/
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  return;
}
예제 #7
0
static void _button_EL_Timeout_handler( void* arg )
{
  (void)(arg);
  _default_start_time = 0;
  MicoGpioEnableIRQ( (mico_gpio_t)EasyLink_BUTTON, IRQ_TRIGGER_FALLING_EDGE, _button_EL_irq_handler, NULL );
  if( MicoGpioInputGet( (mico_gpio_t)EasyLink_BUTTON ) == 0){
    PlatformEasyLinkButtonLongPressedCallback();
  }
  mico_stop_timer(&_button_EL_timer);
}
예제 #8
0
void ConfigWillStop( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  MicoGpioOutputLow((mico_gpio_t)MICO_SYS_LED);
  return;
}
WEAK void mico_system_delegate_config_recv_ssid ( char *ssid, char *key )
{
  UNUSED_PARAMETER(ssid);
  UNUSED_PARAMETER(key);
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  return;
}
예제 #10
0
static void led_sleep_handle(void *inContext)
{
    nearair_Context_t *airContent = inContext;
    static uint8_t count = 0;
    static uint8_t R;
    uint8_t pluse_count = 0;
    if(MODE_SLEEP != airContent->deviceStatus.mode)
    {
        mico_stop_timer(&_led_sleep_timer);
        mico_deinit_timer(&_led_sleep_timer);
    }
    switch(airContent->sensorStatus.light)
    {
    case NIGHT:
      R = 130;
      break;
    case DAY:
      R = 100;
      break;
    default:
      break;
    }
    count += 1;
    if(count > 200)
    {
      count = 0;
      return;
    }
    if(count < 100)
    {
      pluse_count = R - (int)sqrt(R*R - count*count);
    }
    if(count > 100)
    {
      pluse_count = R - (int)sqrt(R*R - (200 - count)*(200 - count));
      
    }
    if(pluse_count < 3)//避免灯灭导致闪烁感
      return;
    set_led_color(0,0,pluse_count);
/*    switch(airContext->airStatus.airclass)
    {
    case AQ_GOOD:
      set_led_color(0,0,pluse_count);
      break;
    case AQ_SOSO:
      set_led_color(pluse_count,2+(int)(0.3*pluse_count),0);
      break;
    case AQ_BAD:
      set_led_color(pluse_count,0,0);
      break;
    default:
      break;
    }*/
}
예제 #11
0
void ConfigAirkissIsSuccess( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  return;
}
예제 #12
0
파일: tmr.c 프로젝트: SergeyPopovGit/MICO
//tmr.stop(id)
//id:0~15
static int ltmr_stop( lua_State* L )
{
  unsigned id = luaL_checkinteger( L, 1 );
  MOD_CHECK_ID( tmr, id );
  if(tmr_is_started[id]==true)
    mico_stop_timer(&_timer[id]);
  tmr_is_started[id]=false;
  if(tmr_cb_ref[id] != LUA_NOREF)
   {
     luaL_unref(L, LUA_REGISTRYINDEX, tmr_cb_ref[id]);
   }
    tmr_cb_ref[id] = LUA_NOREF;
  return 0;
}
예제 #13
0
파일: tmr.c 프로젝트: SergeyPopovGit/MICO
static int ltmr_stopall( lua_State* L )
{
  for(int i=0;i<NUM_TMR;i++)
  {
    if(tmr_is_started[i]==true)
      mico_stop_timer(&_timer[i]);
    tmr_is_started[i]=false;
    if(tmr_cb_ref[i] != LUA_NOREF)
    {
      luaL_unref(L, LUA_REGISTRYINDEX, tmr_cb_ref[i]);
    }
    tmr_cb_ref[i] = LUA_NOREF;
  }
  return 0;
}
예제 #14
0
void _cleanEasyLinkResource( mico_Context_t * const inContext )
{
  if(inContext->micoStatus.easylinkClient_fd!=-1)
    close(inContext->micoStatus.easylinkClient_fd);

  /*module should power down under default setting*/ 
  MICORemoveNotification( mico_notify_WIFI_STATUS_CHANGED, (void *)EasyLinkNotify_WifiStatusHandler );
  MICORemoveNotification( mico_notify_WiFI_PARA_CHANGED, (void *)EasyLinkNotify_WiFIParaChangedHandler );
  MICORemoveNotification( mico_notify_EASYLINK_COMPLETED, (void *)EasyLinkNotify_EasyLinkCompleteHandler );
  MICORemoveNotification( mico_notify_EASYLINK_GET_EXTRA_DATA, (void *)EasyLinkNotify_EasyLinkGetExtraDataHandler );

  mico_rtos_deinit_semaphore(&inContext->micoStatus.easylink_sem);
  inContext->micoStatus.easylink_sem = NULL;
  if(httpHeader) free(httpHeader);
  mico_stop_timer(&_Led_EL_timer);
}
예제 #15
0
static void _button_EL_irq_handler( void* arg )
{
  (void)(arg);

  if (GPIO_ReadInputDataBit(Button_EL_PORT, Button_EL_PIN) == 0) {
    _default_start_time = mico_get_time()+1;
    mico_start_timer(&_button_EL_timer);
  } else {
    if ( (_default_start_time != 0) && (mico_get_time() - _default_start_time) > 50){
      /* EasyLink button clicked once */
      PlatformEasyLinkButtonClickedCallback();
    }
    mico_stop_timer(&_button_EL_timer);
    _default_start_time = 0;
  }
}
예제 #16
0
파일: keys.c 프로젝트: hujg/mico_v2.2.0
static void _user_key2_irq_handler( void* arg )
{
  (void)(arg);
  int interval = -1;
  
  if ( MicoGpioInputGet( (mico_gpio_t)USER_KEY2 ) == 0 ) {
    _default_key2_start_time = mico_get_time()+1;
    mico_start_timer(&_user_key2_timer);
  } else {
    interval = mico_get_time() + 1 - _default_key2_start_time;
    if ( (_default_key2_start_time != 0) && interval > 50 && interval < user_key2_long_press_timeout){
      /* button clicked once */
      user_key2_clicked_callback();
    }
    mico_stop_timer(&_user_key2_timer);
    _default_key2_start_time = 0;
  }
}
예제 #17
0
파일: platform.c 프로젝트: ChinaAmada/MICO
static void _button_EL_irq_handler( void* arg )
{
  (void)(arg);
  int interval = -1;
  
  if ( MicoGpioInputGet( (mico_gpio_t)EasyLink_BUTTON ) == 0 ) {
    _default_start_time = mico_get_time()+1;
    mico_start_timer(&_button_EL_timer);
  } else {
    interval = mico_get_time() + 1 - _default_start_time;
    if ( (_default_start_time != 0) && interval > 50 && interval < RestoreDefault_TimeOut){
      /* EasyLink button clicked once */
      PlatformEasyLinkButtonClickedCallback();
    }
    mico_stop_timer(&_button_EL_timer);
    _default_start_time = 0;
  }
}
예제 #18
0
파일: platform.c 프로젝트: 1220749046/MICO
static void _button_EL_irq_handler( void* arg )
{
  (void)(arg);
  int interval = -1;

  if (GPIO_ReadInputDataBit(Button_EL_PORT, Button_EL_PIN) == 0) {
    _default_start_time = mico_get_time()+1;
    mico_start_timer(&_button_EL_timer);
  } else {
    interval = mico_get_time() + 1 - _default_start_time;
    if ( (_default_start_time != 0) && interval > 50 && interval < RestoreDefault_TimeOut){
      /* EasyLink button clicked once */
      PlatformEasyLinkButtonClickedCallback();
    }
    mico_stop_timer(&_button_EL_timer);
    _default_start_time = 0;
  }
}
예제 #19
0
void ConfigWillStop( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  MicoGpioOutputLow((mico_gpio_t)MICO_SYS_LED);
#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Config          ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, "    Stop.       ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, "                ");
#endif
  return;
}
예제 #20
0
파일: keys.c 프로젝트: MrZANE42/WiFiMCU
static void _user_key1_irq_handler( void* arg )
{
  (void)(arg);
  int interval = -1;
  
  if ( MicoGpioInputGet( (mico_gpio_t)USER_KEY1 ) == 0 ) {
    MicoGpioEnableIRQ( (mico_gpio_t)USER_KEY1, IRQ_TRIGGER_RISING_EDGE, _user_key1_irq_handler, NULL );
    _default_key1_start_time = mico_get_time()+1;
    mico_start_timer(&_user_key1_timer);
  } else {
    interval = mico_get_time() + 1 - _default_key1_start_time;
    if ( (_default_key1_start_time != 0) && interval > 50 && interval < user_key1_long_press_timeout){
      /* button clicked once */
      user_key1_clicked_callback();
    }
    MicoGpioEnableIRQ( (mico_gpio_t)USER_KEY1, IRQ_TRIGGER_FALLING_EDGE, _user_key1_irq_handler, NULL );
    mico_stop_timer(&_user_key1_timer);
    _default_key1_start_time = 0;
  }
}
예제 #21
0
void EasyLinkNotify_EasyLinkCompleteHandler(network_InitTypeDef_st *nwkpara, mico_Context_t * const inContext)
{
  OSStatus err;
  easylink_log_trace();
  easylink_log("EasyLink return @ %d", mico_get_time());
  require_action(inContext, exit, err = kParamErr);
  require_action(nwkpara, exit, err = kTimeoutErr);
  
  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  memcpy(inContext->flashContentInRam.micoSystemConfig.ssid, nwkpara->wifi_ssid, maxSsidLen);
  memcpy(inContext->flashContentInRam.micoSystemConfig.user_key, nwkpara->wifi_key, maxKeyLen);
  inContext->flashContentInRam.micoSystemConfig.user_keyLength = strlen(nwkpara->wifi_key);
  mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex);
  easylink_log("Get SSID: %s, Key: %s", inContext->flashContentInRam.micoSystemConfig.ssid, inContext->flashContentInRam.micoSystemConfig.user_key);
  return;

/*EasyLink is not start*/    
exit:
  easylink_log("ERROR, err: %d", err);
#if defined (CONFIG_MODE_EASYLINK_WITH_SOFTAP)
  EasylinkFailed = true;
  mico_rtos_set_semaphore(&inContext->micoStatus.easylink_sem);
#else
  ConfigWillStop(inContext);
  /*so roll back to previous settings  (if it has) and reboot*/
  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  if(inContext->flashContentInRam.micoSystemConfig.configured != unConfigured){
    inContext->flashContentInRam.micoSystemConfig.configured = allConfigured;
    MICOUpdateConfiguration(inContext);
    PlatformSoftReboot();
  }
  mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex);
  /*module should powd down in default setting*/ 
  wifi_power_down();
  mico_stop_timer(&_Led_EL_timer);
  Platform_LED_SYS_Set_Status(OFF);
#endif

  
  return;
}
예제 #22
0
static void button_irq_handler( void* arg )
{
  button_context_t *_context = arg;

  int interval = -1;
  
  if ( MicoGpioInputGet( _context->gpio ) == 0 ) {
    MicoGpioEnableIRQ( _context->gpio, IRQ_TRIGGER_RISING_EDGE, button_irq_handler, _context );
    _context->start_time = mico_get_time()+1;
    mico_start_timer(&_context->_user_button_timer);
  } else {
    interval = mico_get_time() + 1 - _context->start_time ;
    if ( (_context->start_time  != 0) && interval > 50 && interval < _context->timeout){
      /* button clicked once */
      if( _context->pressed_func != NULL )
        (_context->pressed_func)();
    }
    MicoGpioEnableIRQ( _context->gpio, IRQ_TRIGGER_FALLING_EDGE, button_irq_handler, _context );
    mico_stop_timer(&_context->_user_button_timer);
    _context->start_time  = 0;
  }
}
예제 #23
0
void OTASuccess( mico_Context_t * const inContext )
{
  //config_delegate_log_trace();
  (void)(inContext); 
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif
  
  // led stop
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  MicoSysLed(true);

#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"OTA...          ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)"  Success!      ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)"    reboot...   ");
#endif
  return;
}
예제 #24
0
void ConfigSoftApWillStart(mico_Context_t * const inContext )
{
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
#ifdef USE_MiCOKit_EXT
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", "SoftAP...       ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line);
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, " EasyLink_%c%c%c%c%c%c", 
           inContext->micoStatus.mac[9],  inContext->micoStatus.mac[10],
           inContext->micoStatus.mac[12], inContext->micoStatus.mac[13],
           inContext->micoStatus.mac[15], inContext->micoStatus.mac[16] );
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)oled_show_line);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, "                ");
#endif

  return;
}
예제 #25
0
파일: platform.c 프로젝트: 287631983/MICO
static void _button_EL_irq_handler( void* arg )
{
  (void)(arg);
  int interval = -1;

  mico_start_timer(&_button_EL_timer);
  
  if ( MicoGpioInputGet( (mico_gpio_t)EasyLink_BUTTON ) == 0 ) {
    _default_start_time = mico_get_time()+1;
    mico_start_timer(&_button_EL_timer);
    MicoGpioEnableIRQ( (mico_gpio_t)EasyLink_BUTTON, IRQ_TRIGGER_RISING_EDGE, _button_EL_irq_handler, NULL );
  } else {
    interval = mico_get_time() + 1 - _default_start_time;
    if ( (_default_start_time != 0) && interval > 50 && interval < RestoreDefault_TimeOut){
      /* EasyLink button clicked once */
      PlatformEasyLinkButtonClickedCallback();
      //platform_log("PlatformEasyLinkButtonClickedCallback!");
      MicoGpioOutputLow( (mico_gpio_t)MICO_RF_LED );
      MicoGpioEnableIRQ( (mico_gpio_t)EasyLink_BUTTON, IRQ_TRIGGER_FALLING_EDGE, _button_EL_irq_handler, NULL );
   }
   mico_stop_timer(&_button_EL_timer);
   _default_start_time = 0;
  }
}
예제 #26
0
void mico_system_delegate_config_recv_ssid ( char *ssid, char *key )
{
  config_delegate_log_trace();
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  
#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Got ssid/key    ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line);
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%16s", ssid);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)oled_show_line);
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%16s", key);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)oled_show_line);
#endif
}
예제 #27
0
//停止喝水定时
static void TIMER_stop(void)
{
    mico_stop_timer(&cupTimeObj.cup_timer);
}
void destroy_timer( void )
{
  mico_stop_timer( &timer_handle );
  mico_deinit_timer( &timer_handle );
}
예제 #29
0
void led_thread(void *inContext)
{
    led_log_trace();
    nearair_Context_t *airContext = inContext;
    char mode_old;
    char airclass_old;
    bsp_InitLed();
    mode_old = airContext->deviceStatus.mode;
    airclass_old = airContext->airStatus.airclass;
    
    mico_init_timer(&_led_init_timer, 500,led_init_handle, inContext);
    mico_init_timer(&_led_sleep_timer,20, led_sleep_handle,inContext);
    while(1)
    {
        if(mode_old != airContext->deviceStatus.mode)
        {
            if(mode_old == MODE_INIT)
               mico_stop_timer(&_led_init_timer);
            if(mode_old == MODE_SLEEP)
               mico_stop_timer(&_led_sleep_timer);
            
            mode_old = airContext->deviceStatus.mode;
            
            switch(mode_old)
            {
              case MODE_CLOSE:
                set_led_color(0,0,0);
                break;
              case MODE_INIT:
                mico_start_timer(&_led_init_timer);          
                break;
              case MODE_SMART:
                switch( airContext->airStatus.airclass )
                {
                  case AQ_GOOD:
                    set_led_color(0,0,99);
                    break;
                  case AQ_SOSO:
                    set_led_color(99,33,0);
                    break;
                  case AQ_BAD:
                    set_led_color(99,0,0);
                    break;
                  default:
                    break;            
                }          
                break;
              case MODE_SLEEP:
                mico_start_timer(&_led_sleep_timer);    
                break;
              case MODE_FLY:
                set_led_color(0,99,0);
                break;
              default:
                break;
            }
        }
        if(mode_old == MODE_SMART)
        {
            if(airclass_old != airContext->airStatus.airclass)
            {
                airclass_old = airContext->airStatus.airclass;
                switch( airclass_old )
                {
                  case AQ_GOOD:
                    set_led_color(0,0,99);
                    break;
                  case AQ_SOSO:
                    set_led_color(99,33,0);
                    break;
                  case AQ_BAD:
                    set_led_color(99,0,0);
                    break;
                  default:
                    break;            
                }
            }
        }
        if(airContext->setStatus.led_enable)
        {
          set_led_color(airContext->setStatus.led_r,airContext->setStatus.led_g,\
            airContext->setStatus.led_b);
        }
    }
}