예제 #1
0
void
ItemColorChannel::process_action(const MenuAction& action)
{
  switch (action)
  {
    case MenuAction::REMOVE:
      remove_char();
      break;

    case MenuAction::LEFT:
      *m_number = truncf(*m_number * 10.0f) / 10.0f;
      *m_number -= 0.1f;
      *m_number = math::clamp(*m_number, 0.0f, 1.0f);
      set_text(float_to_string(*m_number));
      break;


    case MenuAction::RIGHT:
      *m_number = truncf(*m_number * 10.0f) / 10.0f;
      *m_number += 0.1f;
      *m_number = math::clamp(*m_number, 0.0f, 1.0f);
      set_text(float_to_string(*m_number));
      break;

    default:
      break;
  }
}
예제 #2
0
 void cPath_State::Save_To_Savegame(cSave_Level_Object *save_object)
 {
     save_object->m_properties.push_back(cSave_Level_Object_Property("new_pos_x", float_to_string(pos_x)));
     save_object->m_properties.push_back(cSave_Level_Object_Property("new_pos_y", float_to_string(pos_y)));
     
     save_object->m_properties.push_back(cSave_Level_Object_Property("current_segment", int_to_string(current_segment)));
     
     save_object->m_properties.push_back(cSave_Level_Object_Property("current_segment_pos", float_to_string(current_segment_pos)));
     
     save_object->m_properties.push_back(cSave_Level_Object_Property("forward", int_to_string(static_cast<int>(forward)))); 
 }
// 接收机PWM占空比通过4个20mS中断读取
void TIM2_IRQHandler(void) {
  tim_throttle.PWM_Input_Handler();
#ifdef _DEBUG_WITH_LCD
  uint8_t tmp2[80];
  uint8_t tmp3[80];
  float_to_string(tim_throttle.DutyCycle,tmp2);
  float_to_string(receiver.stick_throttle_.convert_duty_,tmp3);
  uint8_t tmp1[80] = "throttle:";
  GUI_Text(0,0,tmp1,White,Blue);
  GUI_Text(0,LCD_LINE_SPACE,tmp2,White,Blue);
  GUI_Text(0,2*LCD_LINE_SPACE,tmp3  ,White,Blue);
#endif
}
예제 #4
0
ItemColorChannel::ItemColorChannel(float* input, Color channel, int id) :
  MenuItem(float_to_string(*input), id),
  m_number(input),
  m_flickw(static_cast<int>(Resources::normal_font->get_text_width("_"))),
  m_channel(channel)
{
}
예제 #5
0
파일: rokko.cpp 프로젝트: Clever-Boy/TSC
void cRokko::Editor_Activate(void)
{
    CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();

    // direction
    CEGUI::Combobox* combobox = static_cast<CEGUI::Combobox*>(wmgr.createWindow("TaharezLook/Combobox", "editor_rokko_direction"));
    Editor_Add(UTF8_("Direction"), UTF8_("Direction it moves into."), combobox, 100, 110);

    combobox->addItem(new CEGUI::ListboxTextItem("left"));
    combobox->addItem(new CEGUI::ListboxTextItem("right"));
    combobox->addItem(new CEGUI::ListboxTextItem("up"));
    combobox->addItem(new CEGUI::ListboxTextItem("down"));

    combobox->setText(Get_Direction_Name(m_start_direction));
    combobox->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber(&cRokko::Editor_Direction_Select, this));

    // speed
    CEGUI::Editbox* editbox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "editor_rokko_speed"));
    Editor_Add(UTF8_("Speed"), UTF8_("Speed when activated"), editbox, 120);

    editbox->setValidationString("[+]?[0-9]*\\.?[0-9]*");
    editbox->setText(float_to_string(m_speed, 6, 0));
    editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cRokko::Editor_Speed_Text_Changed, this));

    // init
    Editor_Init();
}
static void lcd_menu_change_material_select_material_details_callback(uint8_t nr)
{
    char buffer[32];
    char* c = buffer;

    if (led_glow_dir)
    {
        c = float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)), c, PSTR("mm"));
        while(c < buffer + 10) *c++ = ' ';
        strcpy_P(c, PSTR("Flow:"));
        c += 5;
        c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)), c, PSTR("%"));
    }else{
        c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)), c, PSTR("C"));
#if TEMP_SENSOR_BED != 0
        *c++ = ' ';
        c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)), c, PSTR("C"));
#endif
        while(c < buffer + 10) *c++ = ' ';
        strcpy_P(c, PSTR("Fan: "));
        c += 5;
        c = int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)), c, PSTR("%"));
    }
    lcd_lib_draw_string(5, 53, buffer);
}
static void lcd_material_select_details_callback(uint8_t nr)
{
    uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET());
    if (nr == 0)
    {
        
    }
    else if (nr <= count)
    {
        char buffer[32];
        char* c = buffer;
        nr -= 1;
        
        if (led_glow_dir)
        {
            c = float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)), c, PSTR("mm"));
            while(c < buffer + 10) *c++ = ' ';
            strcpy_P(c, PSTR("Flow:"));
            c += 5;
            c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)), c, PSTR("%"));
        }else{
            c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)), c, PSTR("C"));
            *c++ = ' ';
            c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)), c, PSTR("C"));
            while(c < buffer + 10) *c++ = ' ';
            strcpy_P(c, PSTR("Fan: "));
            c += 5;
            c = int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)), c, PSTR("%"));
        }
        lcd_lib_draw_string(5, 53, buffer);
    }else{
        lcd_lib_draw_string_centerP(53, PSTR("Modify the settings"));
    }
}
static void lcd_material_settings_details_callback(uint8_t nr)
{
    char buffer[10];
    buffer[0] = '\0';
    if (nr == 0)
    {
        return;
    }else if (nr == 1)
    {
        int_to_string(material[active_extruder].temperature, buffer, PSTR("C"));
    }else if (nr == 2)
    {
        int_to_string(material[active_extruder].bed_temperature, buffer, PSTR("C"));
    }else if (nr == 3)
    {
        float_to_string(material[active_extruder].diameter, buffer, PSTR("mm"));
    }else if (nr == 4)
    {
        int_to_string(material[active_extruder].fan_speed, buffer, PSTR("%"));
    }else if (nr == 5)
    {
        int_to_string(material[active_extruder].flow, buffer, PSTR("%"));
    }
    lcd_lib_draw_string(5, 53, buffer);
}
static void lcd_material_settings_details_callback(uint8_t nr)
{
    char buffer[10];
    buffer[0] = '\0';
    if (nr == 0)
    {
        return;
    }else if (nr == 1)
    {
        int_to_string(material[active_extruder].temperature, buffer, PSTR("C"));
#if TEMP_SENSOR_BED != 0
    }else if (nr == 2)
    {
        int_to_string(material[active_extruder].bed_temperature, buffer, PSTR("C"));
#endif
    }else if (nr == 2 + BED_MENU_OFFSET)
    {
        float_to_string(material[active_extruder].diameter, buffer, PSTR("mm"));
    }else if (nr == 3 + BED_MENU_OFFSET)
    {
        int_to_string(material[active_extruder].fan_speed, buffer, PSTR("%"));
    }else if (nr == 4 + BED_MENU_OFFSET)
    {
        int_to_string(material[active_extruder].flow, buffer, PSTR("%"));
#ifdef USE_CHANGE_TEMPERATURE
    }else if (nr == 5 + BED_MENU_OFFSET)
    {
        int_to_string(material[active_extruder].change_temperature, buffer, PSTR("C"));
    }else if (nr == 6 + BED_MENU_OFFSET)
    {
        int_to_string(material[active_extruder].change_preheat_wait_time, buffer, PSTR("Sec"));
#endif
    }
    lcd_lib_draw_string(5, 53, buffer);
}
void do_tyreal(float *Kp_t,float *Ki_t,float *Kd_t){

	//�ó‘Ô‘JˆÚ
  	if (ecrobot_is_RUN_button_pressed() == 1) {
		ecrobot_sound_tone(932, 512, VOL);
		systick_wait_ms(100);
		ecrobot_sound_tone(466, 256, VOL);
		systick_wait_ms(10);	
  		systick_wait_ms(10);
		
		if(adjust_param_state==ADJUST_Kp_VAL){
			adjust_param_state=ADJUST_Ki_VAL;	
			}
  		else if(adjust_param_state==ADJUST_Ki_VAL){
			adjust_param_state=ADJUST_Kd_VAL;	
			}
		else if(adjust_param_state==ADJUST_Kd_VAL){
			adjust_param_state=ADJUST_Kp_VAL;	
			}
  	}
  
   	switch(adjust_param_state) {
   	case  (ADJUST_Kp_VAL): *Kp_t=change_float_param(*Kp_t);
   			break;
   	case  (ADJUST_Ki_VAL): *Ki_t=change_float_param(*Ki_t);
   			break;
	case  (ADJUST_Kd_VAL): *Kd_t=change_float_param(*Kd_t);
   			break;

   	default:
   		break;
   	}
	display_clear(1);
   
	float_to_string(*Kp_t,float_string);
	display_show_string("Kp",0,0);
    display_show_string(float_string,0,1);

	float_to_string(*Ki_t,float_string);
 	display_show_string("Ki",0,2);
	display_show_string(float_string,0,3);

	float_to_string(*Kd_t,float_string);
	display_show_string("Kd",0,4);
 	display_show_string(float_string,0,5);
}
예제 #11
0
void lcd_menu_edit_setting()
{
    if (lcd_lib_encoder_pos < lcd_setting_min)
        lcd_lib_encoder_pos = lcd_setting_min;
    if (lcd_lib_encoder_pos > lcd_setting_max)
        lcd_lib_encoder_pos = lcd_setting_max;

    if (lcd_setting_type == 1)
        *(uint8_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
    else if (lcd_setting_type == 2)
        *(uint16_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
    else if (lcd_setting_type == 3)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) / 100.0;
    else if (lcd_setting_type == 4)
        *(int32_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
    else if (lcd_setting_type == 5)
        *(uint8_t*)lcd_setting_ptr = lcd_lib_encoder_pos * 255 / 100;
    else if (lcd_setting_type == 6)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) * 60;
    else if (lcd_setting_type == 7)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) * 100;
    else if (lcd_setting_type == 8)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos);

    lcd_basic_screen();
    lcd_lib_draw_string_centerP(20, lcd_setting_name);
    char buffer[LCD_MAX_TEXT_LINE_LENGTH + 1];          // Longest string: "Prev: 20000mm/sec^2" = 19 characters + 1
    if (lcd_setting_type == 3)
        float_to_string(float(lcd_lib_encoder_pos) / 100.0, buffer, lcd_setting_postfix);
    else
        int_to_string(lcd_lib_encoder_pos, buffer, lcd_setting_postfix);
    lcd_lib_draw_string_center(30, buffer);

    strcpy_P(buffer, PSTR("Prev: "));
    if (lcd_setting_type == 3)
        float_to_string(float(lcd_setting_start_value) / 100.0, buffer + 6, lcd_setting_postfix);
    else
        int_to_string(lcd_setting_start_value, buffer + 6, lcd_setting_postfix);
    lcd_lib_draw_string_center(53, buffer);

    lcd_lib_update_screen();

    if (lcd_lib_button_pressed)
        lcd_change_to_menu(previousMenu, previousEncoderPos);
}
예제 #12
0
void TIM3_IRQHandler(void) {
  tim_pitch.PWM_Input_Handler();
#ifdef _DEBUG_WITH_LCD
  uint8_t tmp2[80];
  float_to_string(tim_pitch.DutyCycle,tmp2);
  uint8_t tmp1[80] = "pitch:";
  GUI_Text(0,2*LCD_LINE_SPACE,tmp1,White,Blue);
  GUI_Text(0,3*LCD_LINE_SPACE,tmp2,White,Blue);
#endif
}
예제 #13
0
format_float::format_float(double p_val,unsigned p_width,unsigned p_prec)
{
	char temp[64];
	float_to_string(temp,64,p_val,p_prec,false);
	temp[63] = 0;
	t_size len = strlen(temp);
	if (len < p_width)
		m_buffer.add_chars(' ',p_width-len);
	m_buffer += temp;
}
예제 #14
0
void TIM5_IRQHandler(void) {
  tim_roll.PWM_Input_Handler();
#ifdef _DEBUG_WITH_LCD
  uint8_t tmp2[80];
  float_to_string(tim_roll.DutyCycle,tmp2);
  uint8_t tmp1[80] = "roll:";
  GUI_Text(0,6*LCD_LINE_SPACE,tmp1,White,Blue);
  GUI_Text(0,7*LCD_LINE_SPACE,tmp2,White,Blue);
#endif
}  
예제 #15
0
파일: rokko.cpp 프로젝트: Clever-Boy/TSC
cRokko::cRokko(XmlAttributes& attributes, cSprite_Manager* sprite_manager)
    : cEnemy(sprite_manager)
{
    cRokko::Init();

    // position
    Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true);

    // direction
    Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction))));

    // speed
    Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed))));
}
static void lcd_retraction_details(uint8_t nr)
{
    char buffer[16];
    if (nr == 0)
        return;
    else if(nr == 1)
        float_to_string(retract_length, buffer, PSTR("mm"));
    else if(nr == 2)
        int_to_string(retract_feedrate / 60 + 0.5, buffer, PSTR("mm/sec"));
#if EXTRUDERS > 1
    else if(nr == 3)
        int_to_string(extruder_swap_retract_length, buffer, PSTR("mm"));
#endif
    lcd_lib_draw_string(5, 53, buffer);
}
void lcd_menu_edit_setting()
{
  if (lcd_lib_encoder_pos < lcd_setting_min)
    lcd_lib_encoder_pos = lcd_setting_min;
  if (lcd_lib_encoder_pos > lcd_setting_max)
    lcd_lib_encoder_pos = lcd_setting_max;

  if (lcd_setting_type == 1)
    *(uint8_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
  else if (lcd_setting_type == 2)
    *(uint16_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
  else if (lcd_setting_type == 3)
    *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) / 100.0;
  else if (lcd_setting_type == 4)
    *(int32_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
  else if (lcd_setting_type == 5)
    *(uint8_t*)lcd_setting_ptr = lround(lcd_lib_encoder_pos * 255 / 100.0);
  else if (lcd_setting_type == 6)
    *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) * 60;
  else if (lcd_setting_type == 7)
    *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) * 100;
  else if (lcd_setting_type == 8)
    *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos);
  else if (lcd_setting_type == 9)
    *(uint8_t*)lcd_setting_ptr = lcd_lib_encoder_pos;

  lcd_lib_clear();
  char buffer[16];
  if (lcd_setting_type == 3)
    float_to_string(float(lcd_lib_encoder_pos) / 100.0, buffer, lcd_setting_postfix);
  else
    int_to_string(lcd_lib_encoder_pos, buffer, lcd_setting_postfix);

  
  lcd_lib_draw_string_centerP(LS(20, 11, 11) , lcd_setting_name);
  lcd_lib_draw_string_center(LS(30, 24, 24) , buffer);

  if (lcd_lib_button_pressed)
  {
    lcd_change_to_menu(previousMenu, previousEncoderPos, MenuBackward);
    lcd_lib_button_up_down_reversed=false;
    if (lcd_setting_type == 9) {
      Config_StoreSettings();
    }
  }

}
예제 #18
0
파일: flyon.cpp 프로젝트: Clever-Boy/TSC
void cFlyon::Editor_Activate(void)
{
    // get window manager
    CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();

    // direction
    CEGUI::Combobox* combobox = static_cast<CEGUI::Combobox*>(wmgr.createWindow("TaharezLook/Combobox", "editor_flyon_direction"));
    Editor_Add(UTF8_("Direction"), UTF8_("Direction it moves into."), combobox, 100, 110);

    combobox->addItem(new CEGUI::ListboxTextItem("up"));
    combobox->addItem(new CEGUI::ListboxTextItem("down"));
    combobox->addItem(new CEGUI::ListboxTextItem("left"));
    combobox->addItem(new CEGUI::ListboxTextItem("right"));

    combobox->setText(Get_Direction_Name(m_start_direction));
    combobox->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber(&cFlyon::Editor_Direction_Select, this));

    // image dir
    CEGUI::Editbox* editbox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "editor_flyon_image_dir"));
    Editor_Add(UTF8_("Image directory"), UTF8_("Directory containing the images"), editbox, 200);

    editbox->setText(path_to_utf8(m_img_dir).c_str());
    editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cFlyon::Editor_Image_Dir_Text_Changed, this));

    // max distance
    editbox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "editor_flyon_max_distance"));
    Editor_Add(UTF8_("Distance"), _("Movable Distance into its direction"), editbox, 90);

    editbox->setValidationString("^[+]?\\d*$");
    editbox->setText(int_to_string(static_cast<int>(m_max_distance)));
    editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cFlyon::Editor_Max_Distance_Text_Changed, this));

    // speed
    editbox = static_cast<CEGUI::Editbox*>(wmgr.createWindow("TaharezLook/Editbox", "editor_flyon_speed"));
    Editor_Add(UTF8_("Speed"), UTF8_("Initial speed when jumping out"), editbox, 120);

    editbox->setValidationString("[+]?[0-9]*\\.?[0-9]*");
    editbox->setText(float_to_string(m_speed, 6, 0));
    editbox->subscribeEvent(CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber(&cFlyon::Editor_Speed_Text_Changed, this));

    // init
    Editor_Init();
}
예제 #19
0
파일: flyon.cpp 프로젝트: Clever-Boy/TSC
cFlyon::cFlyon(XmlAttributes& attributes, cSprite_Manager* sprite_manager)
    : cEnemy(sprite_manager)
{
    cFlyon::Init();

    // position
    Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true);

    // image directory
    Set_Image_Dir(utf8_to_path(attributes.fetch("image_dir", path_to_utf8(m_img_dir))));

    // direction
    Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction))));

    // max distance
    Set_Max_Distance(string_to_int(attributes.fetch("max_distance", int_to_string(m_max_distance))));

    // speed
    Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed))));
}
static void draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context) {

    int event_no = get_event_no_from_row_index(cell_index->row);

    if (!persist_exists(event_no * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_TITLE))
        return;
    
    char event_title[PERSIST_STRING_MAX_LENGTH];
    persist_read_string(event_no * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_TITLE, event_title, PERSIST_STRING_MAX_LENGTH);
    
    char event_subtitle[55];
    char duration_string[10] = "";
    
    if (persist_exists(event_no * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_START_DATE)) {
    
        int start_date = persist_read_int(event_no * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_START_DATE);
    
        if (persist_exists(event_no * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_END_DATE)) {
        
            int end_date = persist_read_int(event_no * PERSIST_EVENT_FIELDCOUNT + PERSIST_EVENT_END_DATE);
        
            int duration = end_date - start_date;
            if (duration / 3600.0 != 24) {
                format_date_time(event_subtitle, 40, (time_t)start_date, 1);
                float_to_string(duration_string, 10, duration / 3600.0);
                strcat(event_subtitle, ", ");
                strcat(event_subtitle, duration_string);
                strcat(event_subtitle, "h");
            } else {
                format_date_time(event_subtitle, 40, (time_t)start_date, 0);
            }
            
        } else {
            format_date_time(event_subtitle, 40, (time_t)start_date, 1);
        }
        
    }
    
    menu_cell_basic_draw(ctx, cell_layer, event_title, event_subtitle, NULL);
    
}
void lcd_menu_edit_setting()
{
    if (lcd_lib_encoder_pos < lcd_setting_min)
        lcd_lib_encoder_pos = lcd_setting_min;
    if (lcd_lib_encoder_pos > lcd_setting_max)
        lcd_lib_encoder_pos = lcd_setting_max;

    if (lcd_setting_type == 1)
        *(uint8_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
    else if (lcd_setting_type == 2)
        *(uint16_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
    else if (lcd_setting_type == 3)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) / 100.0;
    else if (lcd_setting_type == 4)
        *(int32_t*)lcd_setting_ptr = lcd_lib_encoder_pos;
    else if (lcd_setting_type == 5)
        *(uint8_t*)lcd_setting_ptr = lcd_lib_encoder_pos * 255 / 100;
    else if (lcd_setting_type == 6)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) * 60;
    else if (lcd_setting_type == 7)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos) * 100;
    else if (lcd_setting_type == 8)
        *(float*)lcd_setting_ptr = float(lcd_lib_encoder_pos);

    lcd_lib_clear();
    lcd_lib_draw_string_centerP(20, lcd_setting_name);
    char buffer[16];
    if (lcd_setting_type == 3)
        float_to_string(float(lcd_lib_encoder_pos) / 100.0, buffer, lcd_setting_postfix);
    else
        int_to_string(lcd_lib_encoder_pos, buffer, lcd_setting_postfix);
    lcd_lib_draw_string_center(30, buffer);
    lcd_lib_update_screen();

    if (lcd_lib_button_pressed)
        lcd_change_to_menu(previousMenu, previousEncoderPos);
}
예제 #22
0
void float_to_string_for_eus(double in_, char* out, int start){
  float in = (float)in_ ;
  float_to_string(in,out,start) ;
}
예제 #23
0
void ModataUpload(INT8U ModM)
{
  INT8U i,j,k;
  INT8U lm_j,lm_k; //limit
  INT16U lent;
  union
  {
          char a[4];
          float b;
  }Mod_D;
  //INT8U cps[]="DataTime=\0";
  INT8U Flag_N[2]="N\0";
  INT8U NP=0;
  INT8U Negtive[2]="-\0";
  INT8U ftstring[18];

    switch(ModM)
    {
      case Mod_RealD:
        //Symbol.ccc=1;
        //Response(4);
        //Symbol.ccc=0;
        //strcat(CBAG.cbag_dynamic,cps);
        //strcat(CBAG.cbag_dynamic,System_Time);
        for(i=0;i<6;i++)
        {
          lm_j  =Channel_Num[i];
          for(j=0;j<lm_j;j++)
          {
            switch(SPARA.PO_Type[i])
            {
              case 1: //water
                lm_k  =1;
              break;
              case 2: //gas
                lm_k  =4;
              break;
              default:
                lm_k  =0;
              break;
            }
            for(k=0;k<lm_k;k++)
            {
              Mod_D.b =Modbustore[i][j][k];
              if((Mod_D.a[3]&0x80)==0x80)
              {
                Mod_D.a[3]&=0x7f;
                NP=1;
              }

              float_to_string(Mod_D.b,ftstring);
              if(NP)
              {
                insert(ftstring,Negtive,1);
              }
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_PPR[k]);
              if(SPARA.PO_Type[i]==2)
                insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,ftstring);
              MemoryClear(ftstring,sizeof(ftstring));
              //strcat(CBAG.cbag_dynamic,Mod_bagR);
            }
            if(lm_k!=0)
            {
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_PPR[4]);
              if(SPARA.PO_Type[i]==2)
                      insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                      insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,Flag_N);
            }
          }
          /*if(lm_j!=0)
            Add_Send();
          else
            MemoryClear(CBAG.cbag_dynamic,sizeof(CBAG.cbag_dynamic));
          */
        }
      break;
      case Mod_MinD:
      break;
      case Mod_HourD:
        for(i=0;i<6;i++)
        {
          lm_j  =Channel_Num[i];
          for(j=0;j<lm_j;j++)
          {
            switch(SPARA.PO_Type[i])
            {
              case 1: //water
                lm_k  =2;
              break;
              case 2: //gas
                lm_k  =4;
              break;
              default:
                lm_k  =0;
              break;
            }
            //for(k=0;k<lm_k;k++)
            if(lm_k!=0)
            {
              if(dev_mma_H[k].num==0)
                Mod_D.b =0;
              else
                Mod_D.b =dev_mma_H[k].min;
              if((Mod_D.a[3]&0x80)==0x80)
              {
                Mod_D.a[3]&=0x7f;
                NP=1;
              }

              float_to_string(Mod_D.b,ftstring);
              if(NP)
              {
                insert(ftstring,Negtive,1);
              }
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_Phase7); //min
              if(SPARA.PO_Type[i]==2)
                insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,ftstring);
              MemoryClear(ftstring,sizeof(ftstring));

              if(dev_mma_H[k].num==0)
                dev_mma_H[k].avg =0;
              else
                dev_mma_H[k].avg  =dev_mma_H[k].sum/dev_mma_H[k].num;
              Mod_D.b =dev_mma_H[k].avg;
              if((Mod_D.a[3]&0x80)==0x80)
              {
                Mod_D.a[3]&=0x7f;
                NP=1;
              }

              float_to_string(Mod_D.b,ftstring);
              if(NP)
              {
                insert(ftstring,Negtive,1);
              }
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_Phase8);
              if(SPARA.PO_Type[i]==2)
                insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,ftstring);
              MemoryClear(ftstring,sizeof(ftstring));

              if(dev_mma_H[k].num==0)
                Mod_D.b =0;
              else
                Mod_D.b =dev_mma_H[k].max;
              if((Mod_D.a[3]&0x80)==0x80)
              {
                Mod_D.a[3]&=0x7f;
                NP=1;
              }

              float_to_string(Mod_D.b,ftstring);
              if(NP)
              {
                insert(ftstring,Negtive,1);
              }
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_Phase6);
              if(SPARA.PO_Type[i]==2)
                insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,ftstring);
              MemoryClear(ftstring,sizeof(ftstring));

              if(SPARA.PO_Type[i]==2)
              {
                if((SPARA.PO_SerialNum[i][j]==8)||(SPARA.PO_SerialNum[i][j]==9)||(SPARA.PO_SerialNum[i][j]==10)||(SPARA.PO_SerialNum[i][j]==11))
                {
                  if(dev_mma_H[k].num==0)
                    Mod_D.b =0;
                  else
                    Mod_D.b =dev_mma_H[k].sum;
                  if((Mod_D.a[3]&0x80)==0x80)
                  {
                    Mod_D.a[3]&=0x7f;
                    NP=1;
                  }

                  float_to_string(Mod_D.b,ftstring);
                  if(NP)
                  {
                    insert(ftstring,Negtive,1);
                  }
                  lent  =strlen(CBAG.cbag_dynamic);
                  strcat(CBAG.cbag_dynamic,Mod_Phase18);

                    insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);

                  strcat(CBAG.cbag_dynamic,ftstring);
                  MemoryClear(ftstring,sizeof(ftstring));
                }
              }
              //strcat(CBAG.cbag_dynamic,Mod_bagR);

              //if(lm_k!=0)
              /*{
                lent  =strlen(CBAG.cbag_dynamic);
                strcat(CBAG.cbag_dynamic,Mod_PPR[4]);
                if(SPARA.PO_Type[i]==2)
                        insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
                else if(SPARA.PO_Type[i]==1)
                        insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
                strcat(CBAG.cbag_dynamic,Flag_N);
              }*/
            }
          }
        }
        //MemoryClear(dev_mma_H,sizeof(dev_mma_H));
      break;
      case Mod_DayD:
        for(i=0;i<6;i++)
        {
          lm_j  =Channel_Num[i];
          for(j=0;j<lm_j;j++)
          {
            switch(SPARA.PO_Type[i])
            {
              case 1: //water
                lm_k  =2;
              break;
              case 2: //gas
                lm_k  =4;
              break;
              default:
                lm_k  =0;
              break;
            }
            //for(k=0;k<lm_k;k++)
            if(lm_k!=0)
            {
              if(dev_mma_D[k].num==0)
                Mod_D.b =0;
              else
                Mod_D.b =dev_mma_D[k].min;
              if((Mod_D.a[3]&0x80)==0x80)
              {
                Mod_D.a[3]&=0x7f;
                NP=1;
              }

              float_to_string(Mod_D.b,ftstring);
              if(NP)
              {
                insert(ftstring,Negtive,1);
              }
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_Phase7); //min
              if(SPARA.PO_Type[i]==2)
                insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,ftstring);
              MemoryClear(ftstring,sizeof(ftstring));

              if(dev_mma_D[k].num==0)
                dev_mma_D[k].avg =0;
              else
                dev_mma_D[k].avg  =dev_mma_D[k].sum/dev_mma_D[k].num;
              Mod_D.b =dev_mma_H[k].avg;
              if((Mod_D.a[3]&0x80)==0x80)
              {
                Mod_D.a[3]&=0x7f;
                NP=1;
              }

              float_to_string(Mod_D.b,ftstring);
              if(NP)
              {
                insert(ftstring,Negtive,1);
              }
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_Phase8);
              if(SPARA.PO_Type[i]==2)
                insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,ftstring);
              MemoryClear(ftstring,sizeof(ftstring));

              if(dev_mma_D[k].num==0)
                Mod_D.b =0;
              else
                Mod_D.b =dev_mma_D[k].max;
              if((Mod_D.a[3]&0x80)==0x80)
              {
                Mod_D.a[3]&=0x7f;
                NP=1;
              }

              float_to_string(Mod_D.b,ftstring);
              if(NP)
              {
                insert(ftstring,Negtive,1);
              }
              lent  =strlen(CBAG.cbag_dynamic);
              strcat(CBAG.cbag_dynamic,Mod_Phase6);
              if(SPARA.PO_Type[i]==2)
                insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              else if(SPARA.PO_Type[i]==1)
                insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
              strcat(CBAG.cbag_dynamic,ftstring);
              MemoryClear(ftstring,sizeof(ftstring));
              if(SPARA.PO_Type[i]==2)
              {
                if((SPARA.PO_SerialNum[i][j]==8)||(SPARA.PO_SerialNum[i][j]==9)||(SPARA.PO_SerialNum[i][j]==10)||(SPARA.PO_SerialNum[i][j]==11))
                {
                  if(dev_mma_D[k].num==0)
                    Mod_D.b =0;
                  else
                    Mod_D.b =dev_mma_D[k].sum;
                  if((Mod_D.a[3]&0x80)==0x80)
                  {
                    Mod_D.a[3]&=0x7f;
                    NP=1;
                  }

                  float_to_string(Mod_D.b,ftstring);
                  if(NP)
                  {
                    insert(ftstring,Negtive,1);
                  }
                  lent  =strlen(CBAG.cbag_dynamic);
                  strcat(CBAG.cbag_dynamic,Mod_Phase18);

                    insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);

                  strcat(CBAG.cbag_dynamic,ftstring);
                  MemoryClear(ftstring,sizeof(ftstring));
                }
              }

              //strcat(CBAG.cbag_dynamic,Mod_bagR);

              //if(lm_k!=0)
              /*{
                lent  =strlen(CBAG.cbag_dynamic);
                strcat(CBAG.cbag_dynamic,Mod_PPR[4]);
                if(SPARA.PO_Type[i]==2)
                        insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
                else if(SPARA.PO_Type[i]==1)
                        insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2);
                strcat(CBAG.cbag_dynamic,Flag_N);
              }*/
            }
          }
        }
        MemoryClear(dev_mma_D,sizeof(dev_mma_D));
      break;
      default:
      break;
    }
}
예제 #24
0
파일: keyboard.cpp 프로젝트: sKabYY/SMC
bool cKeyboard :: Key_Down( SDLKey key )
{
	// input was processed by the gui system
	if( CEGUI_Handle_Key_Down( key ) )
	{
		return 1;
	}

	// set key to 1
	m_keys[key] = 1;

	// ## first the internal keys

	// game exit
	if( key == SDLK_F4 && pKeyboard->Is_Alt_Down() )
	{
		game_exit = 1;
		return 1;
	}
	// fullscreen toggle
	else if( key == SDLK_RETURN && pKeyboard->Is_Alt_Down() )
	{
		pVideo->Toggle_Fullscreen();
		return 1;
	}
	// GUI copy
	else if( key == SDLK_c && pKeyboard->Is_Ctrl_Down() )
	{
		if( GUI_Copy_To_Clipboard() )
		{
			return 1;
		}
	}
	// GUI cut
	else if( key == SDLK_x && pKeyboard->Is_Ctrl_Down() )
	{
		if( GUI_Copy_To_Clipboard( 1 ) )
		{
			return 1;
		}
	}
	// GUI paste
	else if( key == SDLK_v && pKeyboard->Is_Ctrl_Down() )
	{
		if( GUI_Paste_From_Clipboard() )
		{
			return 1;
		}
	}

	// handle key in the current mode
	if( Game_Mode == MODE_LEVEL )
	{
		// processed by the level
		if( pActive_Level->Key_Down( key ) )
		{
			return 1;
		}
	}
	else if( Game_Mode == MODE_OVERWORLD )
	{
		// processed by the overworld
		if( pActive_Overworld->Key_Down( key ) )
		{
			return 1;
		}
	}
	else if( Game_Mode == MODE_MENU )
	{
		// processed by the menu
		if( pMenuCore->Key_Down( key ) )
		{
			return 1;
		}
	}
	else if( Game_Mode == MODE_LEVEL_SETTINGS )
	{
		// processed by the level settings
		if( pLevel_Editor->m_settings_screen->Key_Down( key ) )
		{
			return 1;
		}
	}

	// set fixed speed factor mode
	if( key == SDLK_F6 )
	{
		float fixed_speedfactor = string_to_float( Box_Text_Input( float_to_string( pFramerate->m_force_speed_factor, 2 ), "Set Fixed Speedfactor", 1 ) );

		// disable
		if( Is_Float_Equal( fixed_speedfactor, 0.0f ) )
		{
			pFramerate->Set_Fixed_Speedfacor( 0.0f );
			pHud_Debug->Set_Text( "Fixed speed factor disabled" );
		}
		// below minimum
		else if( fixed_speedfactor <= 0.04f )
		{
			pHud_Debug->Set_Text( "Fixed speed factor must be greater than 0.04" );
		}
		// enable
		else
		{
			pFramerate->Set_Fixed_Speedfacor( fixed_speedfactor );
			pHud_Debug->Set_Text( "Fixed speed factor enabled" );
		}
	}
	// take a screenshot
	else if( key == pPreferences->m_key_screenshot )
	{
		pVideo->Save_Screenshot();
	}
	// pause the game
	else if( key == SDLK_PAUSE )
	{
		Draw_Static_Text( "Pause", &yellow, &lightgreyalpha64 );
	}
	// load a level
	else if( key == SDLK_l && pKeyboard->Is_Ctrl_Down() && !( Game_Mode == MODE_OVERWORLD && pOverworld_Manager->m_debug_mode ) && Game_Mode != MODE_LEVEL_SETTINGS )
	{
		pLevel_Editor->Function_Load();
	}
	// load an overworld
	else if( key == SDLK_w && pKeyboard->Is_Ctrl_Down() && !( Game_Mode == MODE_OVERWORLD && pOverworld_Manager->m_debug_mode ) && Game_Mode != MODE_LEVEL_SETTINGS )
	{
		pWorld_Editor->Function_Load();
	}
	// sound toggle
	else if( key == SDLK_F10 )
	{
		pAudio->Toggle_Sounds();

		if( !pAudio->m_sound_enabled )
		{
			pHud_Debug->Set_Text( "Sound disabled" );
		}
		else
		{
			pHud_Debug->Set_Text( "Sound enabled" );
		}
	}
	// music toggle
	else if( key == SDLK_F11 )
	{
		pAudio->Toggle_Music();

		if( !pAudio->m_music_enabled )
		{
			pHud_Debug->Set_Text( "Music disabled" );
		}
		else
		{
			pHud_Debug->Set_Text( "Music enabled" );
		}
	}
	// debug mode
	else if( key == SDLK_d && pKeyboard->Is_Ctrl_Down() )
	{
		if( game_debug )
		{
			pHud_Debug->Set_Text( "Debug mode disabled" );
		}
		else
		{
			pFramerate->m_fps_worst = 100000;
			pFramerate->m_fps_best = 0;
			pHud_Debug->Set_Text( "Debug mode enabled" );
		}

		game_debug = !game_debug;
	}
	// performance mode
	else if( key == SDLK_p && pKeyboard->Is_Ctrl_Down() )
	{
		if( game_debug_performance )
		{
			pHud_Debug->Set_Text( "Performance debug mode disabled" );
		}
		else
		{
			pFramerate->m_fps_worst = 100000;
			pFramerate->m_fps_best = 0;
			pHud_Debug->Set_Text( "Performance debug mode enabled" );
		}

		game_debug_performance = !game_debug_performance;
	}

	return 0;
}
예제 #25
0
void ModataUpload(INT8U ModM)
{
  union
  {
          char a[4];
          float b;
  }Mod_D;
  //INT8U cps[]="DataTime=\0";
  //INT8U Flag_N[2]="N\0";
  INT8U NP=0;
  INT8U Negtive[2]="-\0";
  INT8U rtdstr[11]=";011-Rtd=\0";
  INT8U flagstr[13]=",011-Flag=N\0";
  INT8U minstr[11]=";011-Min=\0";
  INT8U avgstr[11]=",011-Avg=\0";
  INT8U maxstr[11]=",011-Max=\0";
  INT8U ftstring[18];
  INT16U i;
  float totaltmp=0,total_b01_tmp=0;
  
  
  if(ModM==Mod_RealD)
  {
    Mod_D.b =Modbustore;
    if((Mod_D.a[3]&0x80)==0x80)
    {
      Mod_D.a[3]&=0x7f;
      NP=1;
    }

    float_to_string(Mod_D.b,ftstring);
    if(NP)
    {
      insert(ftstring,Negtive,1);
    }
    strcat(CBAG.cbag_dynamic,rtdstr);
    strcat(CBAG.cbag_dynamic,ftstring);
    MemoryClear(ftstring,sizeof(ftstring));      
    strcat(CBAG.cbag_dynamic,flagstr);
  }
  else
  {
    MAX_MIN *maxminp;
    switch(ModM)
    {
      case Mod_MinD: 
        maxminp =dev_mma_M;
        if(maxminp->num==0)
          Mod_D.b =0;
        else
          Mod_D.b =maxminp->min;
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
  
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }
        //lent  =strlen(CBAG.cbag_dynamic);
        strcat(CBAG.cbag_dynamic,minstr); //min
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
  
        if(maxminp->num==0)
          maxminp->avg =0;
        else
          maxminp->avg  =maxminp->sum/maxminp->num;
        //Mod_D.b =maxminp->avg; 
        Mod_D.b =maxminp->max; //小时cod的平均值就等于它的测量值(环保局091026)
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }
        strcat(CBAG.cbag_dynamic,avgstr);
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
        
        if(maxminp->num==0)
          Mod_D.b =0;
        else
          Mod_D.b =maxminp->max;
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }        
        strcat(CBAG.cbag_dynamic,maxstr);
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
        
        //Hour_COD_avg[current_hour]=maxminp->max;
      break;
      case Mod_HourD: 
        maxminp =dev_mma_H;
        if(maxminp->num==0)
          Mod_D.b =0;
        else
          Mod_D.b =maxminp->min;
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
  
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }
        //lent  =strlen(CBAG.cbag_dynamic);
        strcat(CBAG.cbag_dynamic,minstr); //min
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
  
        if(maxminp->num==0)
          maxminp->avg =0;
        else
          maxminp->avg  =maxminp->sum/maxminp->num;
        //Mod_D.b =maxminp->avg; 
        Mod_D.b =maxminp->max; //小时cod的平均值就等于它的测量值(环保局091026)
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }
        strcat(CBAG.cbag_dynamic,avgstr);
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
        
        if(maxminp->num==0)
          Mod_D.b =0;
        else
          Mod_D.b =maxminp->max;
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }        
        strcat(CBAG.cbag_dynamic,maxstr);
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
        
        Hour_COD_avg[current_hour]=maxminp->max;
      break;
      case Mod_DayD:
        maxminp =dev_mma_D;
        if(maxminp->num==0)
          Mod_D.b =0;
        else
          Mod_D.b =maxminp->min;
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
  
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }
        //lent  =strlen(CBAG.cbag_dynamic);
        strcat(CBAG.cbag_dynamic,minstr); //min
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
  
        for(i=0;i<24;i++)
        {
          totaltmp += Hour_B01_avg[i]*Hour_COD_avg[i];
          total_b01_tmp +=Hour_B01_avg[i];
        }
        if(total_b01_tmp!=0.0)
        {
          maxminp->avg=totaltmp/total_b01_tmp;
        }
        else
        {
          maxminp->avg=0;
        }
        Mod_D.b =maxminp->avg;
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }
        strcat(CBAG.cbag_dynamic,avgstr);
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
        
        if(maxminp->num==0)
          Mod_D.b =0;
        else
          Mod_D.b =maxminp->max;
        if((Mod_D.a[3]&0x80)==0x80)
        {
          Mod_D.a[3]&=0x7f;
          NP=1;
        }
        float_to_string(Mod_D.b,ftstring);
        if(NP)
        {
          insert(ftstring,Negtive,1);
        }        
        strcat(CBAG.cbag_dynamic,maxstr);
        strcat(CBAG.cbag_dynamic,ftstring);
        MemoryClear(ftstring,sizeof(ftstring));
        
        MemoryClear(Hour_COD_avg,sizeof(Hour_COD_avg));
        MemoryClear(Hour_B01_avg,sizeof(Hour_B01_avg));
      break;
      default:
        maxminp =0;
      break;
    }
  }
}
예제 #26
0
// -----------------------------------------------------------------------------
//  Modify the Header line of the ANG file if necessary
// -----------------------------------------------------------------------------
std::string Hex2SqrConverter::modifyAngHeaderLine(char* buf, size_t length)
{
  std::string line = "";
  if (buf[0] != '#')
  {
    line = buf;
    m_HeaderIsComplete = true;
    return line;
  }
  // Start at the first character and walk until you find another non-space character
  size_t i = 1;
  while(buf[i] == ' ')
  {
    ++i;
  }
  size_t wordStart = i;
  size_t wordEnd = i+1;
  while(1)
  {
    if (buf[i] == 45 || buf[i] == 95) { ++i; } // "-" or "_" character
    else if (buf[i] >= 65 && buf[i] <=90) { ++i; } // Upper case alpha character
    else if (buf[i] >= 97 && buf[i] <=122) {++i; } // Lower case alpha character
    else { break;}
  }
  wordEnd = i;

  std::string word( &(buf[wordStart]), wordEnd - wordStart);

  if (word.size() == 0)
  {
    line = buf;
    return line;
  }
  if (word.compare(Ebsd::Ang::Grid) == 0)
  {
    line = "# " + word + ": SqrGrid";
  }
  else if (word.compare(Ebsd::Ang::XStep) == 0)
  {
    line = "# " + word + ": " + float_to_string(m_XResolution);
  }
  else if (word.compare(Ebsd::Ang::YStep) == 0)
  {
    line = "# " + word + ": " + float_to_string(m_YResolution);
  }
  else if (word.compare(Ebsd::Ang::NColsOdd) == 0)
  {
    line = "# " + word + ": " + int_to_string(m_NumCols);
  }
  else if (word.compare(Ebsd::Ang::NColsEven) == 0)
  {
    line = "# " + word + ": " + int_to_string(m_NumCols);
  }
  else if (word.compare(Ebsd::Ang::NRows) == 0)
  {
    line = "# " + word + ": " + int_to_string(m_NumRows);
  }
  else
  {
    line = buf;
  }
  return line;
}
예제 #27
0
std::string Vector2D::Str(char sep) const {
	return float_to_string(x) + sep + float_to_string(y);
}
void lcd_sd_menu_details_callback(uint8_t nr)
{
    if (nr == 0)
    {
        return;
    }
    for(uint8_t idx=0; idx<LCD_CACHE_COUNT; idx++)
    {
        if (LCD_CACHE_ID(idx) == nr)
        {
            if (LCD_CACHE_TYPE(idx) == 1)
            {
                lcd_lib_draw_string_centerP(53, PSTR("Folder"));
            }else{
                char buffer[64];
                if (LCD_DETAIL_CACHE_ID() != nr)
                {
                    card.getfilename(nr - 1);
                    if (card.errorCode())
                    {
                        card.clearError();
                        return;
                    }
                    LCD_DETAIL_CACHE_ID() = nr;
                    LCD_DETAIL_CACHE_TIME() = 0;
                    for(uint8_t e=0; e<EXTRUDERS; e++)
                        LCD_DETAIL_CACHE_MATERIAL(e) = 0;
                    card.openFile(card.filename, true);
                    if (card.isFileOpen())
                    {
                        for(uint8_t n=0;n<8;n++)
                        {
                            card.fgets(buffer, sizeof(buffer));
                            buffer[sizeof(buffer)-1] = '\0';
                            while (strlen(buffer) > 0 && buffer[strlen(buffer)-1] < ' ') buffer[strlen(buffer)-1] = '\0';
                            if (strncmp_P(buffer, PSTR(";TIME:"), 6) == 0)
                                LCD_DETAIL_CACHE_TIME() = atol(buffer + 6);
                            else if (strncmp_P(buffer, PSTR(";MATERIAL:"), 10) == 0)
                                LCD_DETAIL_CACHE_MATERIAL(0) = atol(buffer + 10);
#if EXTRUDERS > 1
                            else if (strncmp_P(buffer, PSTR(";MATERIAL2:"), 11) == 0)
                                LCD_DETAIL_CACHE_MATERIAL(1) = atol(buffer + 11);
#endif
                        }
                    }
                    if (card.errorCode())
                    {
                        //On a read error reset the file position and try to keep going. (not pretty, but these read errors are annoying as hell)
                        card.clearError();
                        LCD_DETAIL_CACHE_ID() = 255;
                    }
                }
                
                if (LCD_DETAIL_CACHE_TIME() > 0)
                {
                    char* c = buffer;
                    if (led_glow_dir)
                    {
                        strcpy_P(c, PSTR("Time: ")); c += 6;
                        c = int_to_time_string(LCD_DETAIL_CACHE_TIME(), c);
                    }else{
                        strcpy_P(c, PSTR("Material: ")); c += 10;
                        float length = float(LCD_DETAIL_CACHE_MATERIAL(0)) / (M_PI * (material[0].diameter / 2.0) * (material[0].diameter / 2.0));
                        if (length < 10000)
                            c = float_to_string(length / 1000.0, c, PSTR("m"));
                        else
                            c = int_to_string(length / 1000.0, c, PSTR("m"));
#if EXTRUDERS > 1
                        if (LCD_DETAIL_CACHE_MATERIAL(1))
                        {
                            *c++ = '/';
                            float length = float(LCD_DETAIL_CACHE_MATERIAL(1)) / (M_PI * (material[1].diameter / 2.0) * (material[1].diameter / 2.0));
                            if (length < 10000)
                                c = float_to_string(length / 1000.0, c, PSTR("m"));
                            else
                                c = int_to_string(length / 1000.0, c, PSTR("m"));
                        }
#endif
                    }
                    lcd_lib_draw_string(3, 53, buffer);
                }else{
                    lcd_lib_draw_stringP(3, 53, PSTR("No info available"));
                }
            }
        }
    }
}
static void lcd_menu_material_export()
{
    if (!card.sdInserted)
    {
        LED_GLOW();
        lcd_lib_encoder_pos = MAIN_MENU_ITEM_POS(0);
        lcd_info_screen(lcd_menu_material_select);
        lcd_lib_draw_string_centerP(15, PSTR("No SD-CARD!"));
        lcd_lib_draw_string_centerP(25, PSTR("Please insert card"));
        lcd_lib_update_screen();
        card.release();
        return;
    }
    if (!card.isOk())
    {
        lcd_info_screen(lcd_menu_material_select);
        lcd_lib_draw_string_centerP(16, PSTR("Reading card..."));
        lcd_lib_update_screen();
        card.initsd();
        return;
    }

    card.setroot();
    card.openFile("MATERIAL.TXT", false);
    uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET());
    for(uint8_t n=0; n<count; n++)
    {
        char buffer[32];
        strcpy_P(buffer, PSTR("[material]\n"));
        card.write_string(buffer);

        strcpy_P(buffer, PSTR("name="));
        char* ptr = buffer + strlen(buffer);
        eeprom_read_block(ptr, EEPROM_MATERIAL_NAME_OFFSET(n), 8);
        ptr[8] = '\0';
        strcat_P(buffer, PSTR("\n"));
        card.write_string(buffer);

        strcpy_P(buffer, PSTR("temperature="));
        ptr = buffer + strlen(buffer);
        int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(n)), ptr, PSTR("\n"));
        card.write_string(buffer);

#if TEMP_SENSOR_BED != 0
        strcpy_P(buffer, PSTR("bed_temperature="));
        ptr = buffer + strlen(buffer);
        int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(n)), ptr, PSTR("\n"));
        card.write_string(buffer);
#endif

        strcpy_P(buffer, PSTR("fan_speed="));
        ptr = buffer + strlen(buffer);
        int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(n)), ptr, PSTR("\n"));
        card.write_string(buffer);

        strcpy_P(buffer, PSTR("flow="));
        ptr = buffer + strlen(buffer);
        int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(n)), ptr, PSTR("\n"));
        card.write_string(buffer);

        strcpy_P(buffer, PSTR("diameter="));
        ptr = buffer + strlen(buffer);
        float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(n)), ptr, PSTR("\n\n"));
        card.write_string(buffer);

#ifdef USE_CHANGE_TEMPERATURE
        strcpy_P(buffer, PSTR("change_temp="));
        ptr = buffer + strlen(buffer);
        float_to_string(eeprom_read_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(n)), ptr, PSTR("\n\n"));
        card.write_string(buffer);
        
        strcpy_P(buffer, PSTR("change_wait="));
        ptr = buffer + strlen(buffer);
        float_to_string(eeprom_read_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(n)), ptr, PSTR("\n\n"));
        card.write_string(buffer);
#endif
    }
    card.closefile();

    currentMenu = lcd_menu_material_export_done;
}
예제 #30
0
void cStaticEnemy :: Editor_Activate( void )
{
	// get window manager
	CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();

	// image
	CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_static_enemy_image" ));
	Editor_Add( UTF8_("Image"), UTF8_("Image filename"), editbox, 200 );

	editbox->setText( m_img_filename.c_str() );
	editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cStaticEnemy::Editor_Image_Text_Changed, this ) );

	// rotation speed
	editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_static_enemy_rotation_speed" ));
	Editor_Add( UTF8_("Rotation Speed"), UTF8_("Rotation Speed"), editbox, 120 );

	editbox->setValidationString( "[-+]?[0-9]*\\.?[0-9]*" );
	editbox->setText( float_to_string( m_rotation_speed ) );
	editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cStaticEnemy::Editor_Rotation_Speed_Text_Changed, this ) );

	// path
	editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_static_enemy_path_identifier" ));
	Editor_Add( UTF8_("Path Identifier"), UTF8_("Name of the Path to move along."), editbox, 120 );

	editbox->setText( m_path_state.m_path_identifier.c_str() );
	editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cStaticEnemy::Editor_Path_Identifier_Text_Changed, this ) );

	// speed
	editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_static_enemy_speed" ));
	Editor_Add( UTF8_("Speed"), UTF8_("Maximum speed"), editbox, 120 );

	editbox->setValidationString( "[-+]?[0-9]*\\.?[0-9]*" );
	editbox->setText( float_to_string( m_speed ) );
	editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cStaticEnemy::Editor_Speed_Text_Changed, this ) );

	// fire resistant
	CEGUI::Combobox *combobox = static_cast<CEGUI::Combobox *>(wmgr.createWindow( "TaharezLook/Combobox", "editor_static_enemy_fire_resistant" ));
	Editor_Add( UTF8_("Fire Resistant"), UTF8_("If it is resistant against fire"), combobox, 120, 80 );

	combobox->addItem( new CEGUI::ListboxTextItem( UTF8_("Enabled") ) );
	combobox->addItem( new CEGUI::ListboxTextItem( UTF8_("Disabled") ) );

	if( m_fire_resistant )
	{
		combobox->setText( UTF8_("Enabled") );
	}
	else
	{
		combobox->setText( UTF8_("Disabled") );
	}

	combobox->subscribeEvent( CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber( &cStaticEnemy::Editor_Fire_Resistant_Select, this ) );

	// ice resistance
	editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_static_enemy_ice_resistance" ));
	Editor_Add( UTF8_("Ice Resistance"), UTF8_("Resistance against Ice (0.0-1.0)"), editbox, 120 );

	editbox->setValidationString( "[+]?[0-9]*\\.?[0-9]*" );
	editbox->setText( float_to_string( m_ice_resistance ) );
	editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cStaticEnemy::Editor_Ice_Resistance_Text_Changed, this ) );
    
	// init
	Editor_Init();
}