Exemplo n.º 1
0
OSStatus user_modules_init(void)
{
  OSStatus err = kUnknownErr;
  
  // init DC Motor(GPIO)
  dc_motor_init();
  dc_motor_set(0);   // off
  
  // init RGB LED(P9813)
  hsb2rgb_led_init();
  hsb2rgb_led_open(0, 0, 0);  // off
  
  // init OLED
  OLED_Init();
  //OLED_Clear();
  LCD_Clear(0x00);
  OLED_ShowString(20,0,"M X C H I P");
  OLED_ShowString(20,3,(uint8_t*)DEFAULT_DEVICE_NAME); 
  OLED_ShowString(0,6,"T: 0C  H: 0%");
  
  // init Light sensor(ADC)
  light_sensor_init();
  
  // init infrared sensor(ADC)
  infrared_reflective_init();
  
  // init user key1 && key2
  user_key1_init();
  user_key2_init();
  
  err = kNoErr;
 
  return err;
}
/**@brief Signals alert event from Immediate Alert or Link Loss services.
 *
 * @param[in]   alert_level  Requested alert level.
 */
static void alert_signal(uint8_t alert_level)
{
    switch (alert_level)
    {
        case BLE_CHAR_ALERT_LEVEL_NO_ALERT:
            m_is_link_loss_alerting = false;
            alert_led_blink_stop();
				     #if OLED096_Func 
					       	OLED_ShowString(48,16, (uint8_t*)"   ");
	               OLED_Refresh_Gram();
					       #endif	
            break;

        case BLE_CHAR_ALERT_LEVEL_MILD_ALERT:
            alert_led_blink_start();
            break;

        case BLE_CHAR_ALERT_LEVEL_HIGH_ALERT:
            alert_led_blink_stop();
            nrf_gpio_pin_set(ALERT_PIN_NO);
				    #if OLED096_Func 
					       	OLED_ShowString(48,16, (uint8_t*)"ALT");
	               OLED_Refresh_Gram();
					       #endif	
            break;
            
        default:
            break;
    }
}
Exemplo n.º 3
0
void menu_Showtime()
{	
		OLED_ShowNum(0,0,Time/3600,2,16,0);
//		OLED_ShowString(16,0,":");
		OLED_ShowNum(24,0,Time%3600/60,2,16,0);
//		OLED_ShowString(40,0,":");
		OLED_ShowNum(48,0,Time%60,2,16,0);
	
			OLED_ShowNum(0,2,img.CerPtx,3,16,1);
			OLED_ShowNum(32,2,img.CerPty,3,16,1);			
			OLED_ShowNum(64,2,img.CerR,3,16,1);
			OLED_ShowNum(98,2,img.rate,3,16,1);
	
			OLED_ShowNum(0,4,img.Line[0].pt1x,3,16,1);
			OLED_ShowNum(32,4,img.Line[0].pt1y,3,16,1);		
			OLED_ShowNum(64,4,img.Line[0].pt2x,3,16,1);
			OLED_ShowNum(98,4,img.Line[0].pt2y,3,16,1);
			
			
	
	    switch(FLYMODE)
			{
				case CTRLP:
					OLED_ShowString(50,6,"CTRLP");
				break;
				case _A_B_:
					OLED_ShowString(50,6,"_A_B_");
				break;
			}
}
Exemplo n.º 4
0
void mico_system_delegate_config_success( mico_config_source_t source )
{
  config_delegate_log_trace();
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif
  
  config_delegate_log( "Wi-Fi configed by: %d", source );

  MicoGpioOutputLow((mico_gpio_t)MICO_SYS_LED);  
  
#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  if(CONFIG_BY_AIRKISS == source){
    snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Airkiss success ");
  }else if(CONFIG_BY_SOFT_AP == source){
    snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"SoftAP success  ");
  }else if(CONFIG_BY_WAC == source){
    snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"WAC success     ");
  }else if( (CONFIG_BY_EASYLINK_V2 == source) || (CONFIG_BY_EASYLINK_PLUS == source) || 
           (CONFIG_BY_EASYLINK_MINUS == source) ){
    snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Easylink success");
  }else{
    snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Unknown         ");
  }
  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*)"                ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)"                ");
#endif
  
  return;
}
Exemplo n.º 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;
}
Exemplo n.º 6
0
void osd_iris_val_disp(u8 irisv)
{
	if(iris_mode>1)
		iris_mode = 1;

	u8 tmp;
	u8 no_val_str[]={"---"};



	if(iris_motor_mode > 4)
		{
		OLED_ShowString(OSD_IRIS_X_START,OSD_LINE3_Y_POS,(u8*)iris_msg_osd[5],16); 
	}
	else
		{
		OLED_ShowString(OSD_IRIS_X_START,OSD_LINE3_Y_POS,(u8*)iris_msg_osd[iris_motor_mode],16); 

		}

#if 0
	iris_motor_mode = 1;
	iris_mode = 1;
	iris_val = 50;
#endif

	if(0 == iris_motor_mode)
	{

		memset(iris_val_osd_buf,0,10);
//		strcat(iris_val_osd_buf,no_val_str);
//
//		OLED_ShowString(88,OSD_LINE3_Y_POS,iris_val_osd_buf,16); 
			
	}
	else
	{
			
		memset(iris_val_osd_buf,0,10);
		strcat(iris_val_osd_buf,iris_mode_osd[iris_mode]);
		
		if(iris_mode)
		{
			if(iris_val == 0xff)
			{
				strcat(iris_val_osd_buf,no_val_str);
			}
			else
			{
				num_to_string_ex((u16)iris_val,iris_val_osd_buf+1,3);
			}
			
		}
		OLED_ShowString(88,OSD_LINE3_Y_POS,iris_val_osd_buf,16); 

	}
	


}
Exemplo n.º 7
0
extern void Mode_Idle_Init(void)
{
#ifdef INCLUDE_OLED12832
	uint8_t timeTemp[17];
	sprintf((char *)timeTemp, "%02d:%02d:%02d 2016/4", sysTime.Hour, sysTime.Minute, sysTime.Second);
	OLED_ShowString(0, 0, "Tag Test");  
	OLED_ShowString(0, 16, timeTemp);
#endif	
}
Exemplo n.º 8
0
void osd_baudrate_disp(u16 data)
{
	if(data > 3)
		return;
	
	OLED_ShowString(OSD_LINE1_X_POS,OSD_BAUDRATE_ID_Y_POS,(u8 *)baudrate_string[data],16);
	OLED_ShowString(OSD_LINE1_X_POS+32,OSD_BAUDRATE_ID_Y_POS,"BPS",16);  


	
}
Exemplo n.º 9
0
void ShowHomePageInit(void)
{
	OLED_ShowString(0, 0, "Roll:  0.0    ");
	OLED_ShowString(0, 2, "Pitch: 0.0    ");
	OLED_ShowString(0, 4, "Yaw:   0.0    ");
	OLED_ShowString(0, 6, "Power: 0.0V   ");
	ShowBattery();
	ShowLockStat();
	ShowRuning();
	OLED_DrawBMP(112, 6, 128, 8, BLACK_FILL_BMP);
}
Exemplo n.º 10
0
void osd_para_mode_disp_xy(u8 mode,u8 x,u8 y)
{
	u8 *mstr="Mode";
	u8 pp;

	if(mode > 8)
		return;
	OLED_ShowString(OSD_PARA_MODE_X_START,OSD_PARA_MODE_Y,mstr,16); 
	
	pp = mode+0x31;
	OLED_ShowString(OSD_SET_PARA_START_ADDR,0,&pp,16); 
}
Exemplo n.º 11
0
void osd_para_mode_disp(u8 mode)
{
	u8 *mstr="Mode";
	u8 pp;

	if(mode > 8)
		return;
	OLED_ShowString(OSD_PARA_MODE_X_START,OSD_PARA_MODE_Y,mstr,16); 
	
	pp = mode+0x31;
	OLED_ShowString(OSD_PARA_MODE_X_START+32,OSD_PARA_MODE_Y,&pp,16); 
}
Exemplo n.º 12
0
void osd_iris_mode_disp(u8 mode)
{
	if(mode == 0xff)
	{
		OLED_ShowString(OSD_IRIS_MODE_X_START,OSD_IRIS_MODE_Y,(u8*)iris_msg_string[IRIS_MSG_ITERMS_MAX-1],16); 

		return;
	}
	if(mode > IRIS_MSG_ITERMS_MAX-1)
		return;
	OLED_ShowString(OSD_IRIS_MODE_X_START,OSD_IRIS_MODE_Y,(u8*)iris_msg_string[mode],16); 

}
Exemplo n.º 13
0
void osd_iris_mode_disp_xy(u8 mode,u8 x,u8 y)
{
	if(mode == 0xff)
	{
		OLED_ShowString(OSD_IRIS_MODE_X_START,OSD_IRIS_MODE_Y,(u8*)iris_msg_string[IRIS_MSG_ITERMS_MAX-1],16); 

		return;
	}
	if(mode > IRIS_MSG_ITERMS_MAX-1)
		return;
	OLED_ShowString(OSD_SET_PARA_START_ADDR,0,(u8*)iris_msg_string[mode],16); 

}
Exemplo n.º 14
0
void osd_shutter_val_disp(u8 sv)
{
	if(sv)
	{
	OLED_ShowString(0,OSD_LINE3_Y_POS,(u8*)osd_shutter_string,16); 

	}
	else
	{
	OLED_ShowString(0,OSD_LINE3_Y_POS,(u8*)osd_shutter_string,16); 
	OLED_ShowString(16,OSD_LINE3_Y_POS,(u8*)auto_string,16); 

	}
}
Exemplo n.º 15
0
void osd_filter_mode_disp_xy(u8 mode,u8 x,u8 y)
{
	if(mode == 0xff)
	{
		OLED_ShowString(OSD_FILTER_MODE_X_START,OSD_FILTER_MODE_Y,(u8*)filter_string[4],16); 
		return;
	}

	
	if(mode > 3)
		return;
	OLED_ShowString(OSD_SET_PARA_START_ADDR,0,(u8*)filter_string[mode],16); 

}
Exemplo n.º 16
0
void osd_filter_mode_disp(u8 mode)
{
	if(mode == 0xff)
	{
		OLED_ShowString(OSD_FILTER_MODE_X_START,OSD_FILTER_MODE_Y,(u8*)filter_string[4],16); 
		return;
	}

	
	if(mode > 3)
		return;
	OLED_ShowString(OSD_FILTER_MODE_X_START,OSD_FILTER_MODE_Y,(u8*)filter_string[mode],16); 

}
Exemplo n.º 17
0
void osd_opt_message_disp(u8 type,u16 wait_s)
{
	if(type > OPT_MSG_ITERMS_MAX-1)
		return;

	osd_line1_val_disp_clear();	

	OLED_ShowString(0,OSD_VAL_START_ADDR_Y,(u8*)opt_msg_string[type],16);  


	u16 k=wait_s;
	while(k--)
	{
		key_from_wait = key_detect();
		if(key_from_wait)
		{
			
			break;
		}
		rt_thread_delay(50);

	}
	osd_line1_val_disp_clear();	

	
}
Exemplo n.º 18
0
extern void Mode_Idle_Proc(uint8_t evt)
{
	uint8_t timeTemp[17];
	
	switch(evt){
		case evtTime1s:
			if (++sysTime.Second >= 60){
				sysTime.Second = 0;
				if (++sysTime.Minute >= 60){
					sysTime.Minute = 0;
					if (++sysTime.Hour >= 24){
						sysTime.Hour = 0;
					}
				}
			}
			#ifdef INCLUDE_OLED12832
			sprintf((char *)timeTemp, "%02d:%02d:%02d 2016/4", sysTime.Hour, sysTime.Minute, sysTime.Second);
			OLED_ShowString(0, 16 , timeTemp);
			//oledShowBmpTest();
			#endif	
			break;
		default:
			
			break;
	}

}
Exemplo n.º 19
0
void menu_key()
{
	switch(Key_Scan())
	{
		case 1:
			menu_Mode = show_time_1;
		break;
		case 2:
			menu_Mode = show_sen_1;
		break;
		case 3:
			menu_Mode = set_sen_1;
		break;
		case 4:
			
		break;
		case 5:
		OLED_ShowString(0,6,"qifei");
		FLYSTATE = 1;
		break;
		case 6:	
			menu_Mode = show_time_1;
		break;
		default:
			break;
	}
}
Exemplo n.º 20
0
void osd_opt_message_disp_iris(u8 val)
{

	osd_line1_val_disp_clear();	

	OLED_ShowString(0,OSD_VAL_START_ADDR_Y,(u8*)iris_msg_osd[val],16);  
	
}
Exemplo n.º 21
0
void osd_cmd_disp(u8 *data)
{
	if(strlen((const char*)data) > 4)
			return;
	
	OLED_ShowString(OSD_CMD_START_ADDR,0,data,16);  

}
Exemplo n.º 22
0
int app_oled_display_timer_handler(ke_msg_id_t const msgid, void const *param,
                               ke_task_id_t const dest_id, ke_task_id_t const src_id)
{

		OLED_ShowString(0,0,"  Firefly Team  ");
		ke_timer_clear(APP_OLED_DISPLAY_TIMER,TASK_APP);
		return(KE_MSG_CONSUMED);
}
Exemplo n.º 23
0
void osd_line1_disp(u8 x)
{
	osd_val_disp(osd_mid_buff,key_val_buffer_cnt);

	OLED_ShowString(0,OSD_VAL_START_ADDR_Y,osd_mid_str_buff,16);  

	
}
Exemplo n.º 24
0
void osd_test(void)
{	u8 t;
		OLED_Init();			//3?¨º??¡¥OLED  
		OLED_Clear()  	; 
	
		t=' ';
		OLED_ShowCHinese(0,0,0);//?D
				OLED_ShowCHinese(18,0,1);//?¡ã
		OLED_ShowCHinese(36,0,2);//?¡ã
		OLED_ShowCHinese(54,0,3);//¦Ì?
		OLED_ShowCHinese(72,0,4);//¡Á¨®
		OLED_ShowCHinese(90,0,5);//??
		OLED_ShowCHinese(108,0,6);//??
	while(1) 
	{		
		OLED_Clear();
		OLED_ShowCHinese(0,0,0);//?D
		OLED_ShowCHinese(18,0,1);//?¡ã
		OLED_ShowCHinese(36,0,2);//?¡ã
		OLED_ShowCHinese(54,0,3);//¦Ì?
		OLED_ShowCHinese(72,0,4);//¡Á¨®
		OLED_ShowCHinese(90,0,5);//??
		OLED_ShowCHinese(108,0,6);//??
		OLED_ShowString(6,3,"0.96' OLED TEST",16);

				OLED_ShowString(6,4,"0.96' OLED TEST",16);
		OLED_ShowString(0,5,"0.96' OLED TEST",16);

		OLED_ShowString(0,6,"0.96' OLED TEST",16);
		OLED_ShowString(1,7,"0.96' OLED TEST",16);

		OLED_ShowString(6,3,"0.96' OLED TEST",16);

		//OLED_ShowString(8,2,"ZHONGJINGYUAN");  
	 //	OLED_ShowString(20,4,"2014/05/01");  
		OLED_ShowString(0,6,"ASCII:",16);  
		OLED_ShowString(63,6,"CODE:",16);  
		OLED_ShowChar(48,6,t,16);//??¨º?ASCII¡Á?¡¤?	   
		t++;
		if(t>'~')t=' ';
		OLED_ShowNum(103,6,t,3,16);//??¨º?ASCII¡Á?¡¤?¦Ì????¦Ì 	
		rt_thread_delay(1000*3);


		OLED_DrawBMP(0,0,128,8,BMP1);  //¨ª?????¨º?(¨ª?????¨º?¨¦¡Â¨®?¡ê?¨¦¨²3¨¦¦Ì?¡Á?¡À¨ª??¡ä¨®¡ê??¨¢??¨®????¨¤????¡ê?FLASH????8K¨°???¨¦¡Â¨®?)
		rt_thread_delay(1000*3);

		OLED_DrawBMP(0,0,128,8,BMP1);
		rt_thread_delay(1000*3);


	}	
	
}
Exemplo n.º 25
0
void osd_opt_message_disp_extend(u8 type)
{
	if(type > OPT_MSG_ITERMS_MAX-1)
		return;

	osd_line1_val_disp_clear();	

	OLED_ShowString(0,OSD_VAL_START_ADDR_Y,(u8*)opt_msg_string[type],16);  
	
}
Exemplo n.º 26
0
void osd_clear_x_y(u8 x_start,u8 x_end,u8 y,u8 sizef)
{
	u8 ii;

	for(ii=x_start;ii<x_end;)
	{
		OLED_ShowString(ii,y," ",sizef);
		ii+=sizef;
	}
}
Exemplo n.º 27
0
/**
  * @brief  This function handles Hard Fault exception.
  * @param  None
  * @retval None
  */
void HardFault_Handler(void)
{
  /* Go to infinite loop when Hard Fault exception occurs */
	Moto_PwmUpdate(0,0,0,0);
	OLED_Clear(0,0,127,7);
	OLED_ShowString(0,0,"HardFault_Handler");
  while (1)
  {
  }
}
Exemplo n.º 28
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;
}
Exemplo n.º 29
0
void EXTI3_IRQHandler(void)
{
	if(EXTI_GetITStatus(EXTI_Line3)!=RESET)
	{
	OLED_Clear();
	OLED_ShowString(0,0,"shutdown");
		printf("/r/nshutdown");
	}
	 Board_Down();
	EXTI_ClearITPendingBit(EXTI_Line3);
}
Exemplo n.º 30
0
// set function: send data to uart && OLED
int uart_data_send(struct mico_prop_t *prop, void *arg, void *val, uint32_t val_len)
{
  int ret = 0;
  OSStatus err = kUnknownErr;
  uint32_t send_len = 0;
  char string_display_on_oled[MAX_USER_UART_BUF_SIZE+3] = {'\0'};  // add CR/LF && '\0' to the end for display on uart
  
  if((NULL == val) || (NULL == val_len) || (NULL == prop) || (NULL == arg)){
    return -1;
  }
  
  user_context_t *uct = (user_context_t*)arg;
  
  // display string on OLED (max_len=32bytes)
  send_len = ((val_len > prop->maxStringLen) ? prop->maxStringLen : val_len);
  properties_user_log("Show cloud msg on OLED: [%d][%*.s]", send_len, send_len, (char*)val);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)"From Cloud:     ");
  memset(string_display_on_oled, ' ', MAX_USER_UART_BUF_SIZE);  // clean display char
  memcpy(string_display_on_oled, (uint8_t*)val, send_len);
  string_display_on_oled[MAX_USER_UART_BUF_SIZE] = '\0';  // display end
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)string_display_on_oled);
  ret = 0;  // set always ok
  uct->status.oled_keep_s = 3;   // display 3s
  
  // send data to uart, add CR/LF to the end for display.
  string_display_on_oled[send_len] = '\r';
  string_display_on_oled[send_len+1] = '\n';  // add CR LF for display on uart
  string_display_on_oled[send_len+2] = '\0';  // string end
  
  err = user_uartSend((unsigned char*)string_display_on_oled, send_len+2);
  if(kNoErr == err){
    properties_user_log("uart_data_send: [%d][%s]", send_len+2, (char*)string_display_on_oled);
    ret = 0;  // set ok
  }
  else{
    properties_user_log("ERROR: uart_data_send, err=%d.", err);
    ret = -1; // set failed
  }
  
  return ret;
}