|
|
@@ -142,12 +142,16 @@ static int is_ph3_in(menu_handle_t *h)
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
-static int is_ph3_out(menu_handle_t *h)
|
|
|
+static int is_ph3_2_out(menu_handle_t *h)
|
|
|
{
|
|
|
paras_data_t *p=paras_get();
|
|
|
- if (p->prod.type == PDU_AC_I3O3) {
|
|
|
+ if (p->prod.type == PDU_AC_I3O3)
|
|
|
+ {
|
|
|
return 1;
|
|
|
- }
|
|
|
+ }else if(p->prod.type == PDU_AC_I3O2)
|
|
|
+ {
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
static int get_input(menu_handle_t *h, int ph, total_t *ttl)
|
|
|
@@ -158,7 +162,10 @@ static int get_input(menu_handle_t *h, int ph, total_t *ttl)
|
|
|
if(all.chs==0 || !ttl) {
|
|
|
return -1;
|
|
|
}
|
|
|
- *ttl = all.ttl.total[ph];
|
|
|
+ if(ph > 0)
|
|
|
+ *ttl = all.ttl.total[ph-1];
|
|
|
+ else
|
|
|
+ *ttl = all.ttl.total[ph];
|
|
|
return 0;
|
|
|
}
|
|
|
static int get_output(menu_handle_t *h, int ch, int ph, power_ch_t *pwr_ch)
|
|
|
@@ -242,7 +249,7 @@ static void menu_input_paint(menu_handle_t *h, int font1, int font2, int item_h,
|
|
|
r = get_input(h, h->ph_in, pttl);
|
|
|
if(r==0) {
|
|
|
if(h->menu.menu_lv==1 && h->ph_in>0) {
|
|
|
- sprintf(tmp, "%s-L%d", lang_get_str(h->lang, STR_ID_INPUT), h->ph_in);
|
|
|
+ sprintf(tmp, "%s - L%d", lang_get_str(h->lang, STR_ID_INPUT), h->ph_in);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -325,6 +332,26 @@ static void menu_output_paint(menu_handle_t *h, int font1, int font2, int item_h
|
|
|
}
|
|
|
|
|
|
if(h->ch_out_max>0) {
|
|
|
+ if(h->menu.menu_lv == 1)
|
|
|
+ {
|
|
|
+ if(all->ttl.type == PDU_AC_I3O2)
|
|
|
+ {
|
|
|
+ if(h->ph_out == 1)
|
|
|
+ {
|
|
|
+ sprintf(tmp, "%s CH%d - L%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1,all->pch[h->ch_out+1].info.ph_id);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ sprintf(tmp, "%s CH%d - L%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1,all->pch[h->ch_out+1].info.ph_val);
|
|
|
+ }
|
|
|
+ }else if(all->ttl.type == PDU_AC_I3O3)
|
|
|
+ {
|
|
|
+ sprintf(tmp, "%s CH%d - L%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1,h->ph_out);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ sprintf(tmp, "%s CH%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
sprintf(tmp, "%s CH%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1);
|
|
|
}else
|
|
|
{
|
|
|
@@ -366,34 +393,99 @@ static void menu_output_paint(menu_handle_t *h, int font1, int font2, int item_h
|
|
|
lcd_draw_string(LCD_WIDTH/2, item_h, LCD_WIDTH/2, item_h, tmp, font2, COLOR_RED, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
}
|
|
|
|
|
|
+ float current = 0.0;
|
|
|
+ float power = 0.0;
|
|
|
+ float factor = 0.0;
|
|
|
+ float consumer = 0.0;
|
|
|
+
|
|
|
+ if(all->ttl.type == PDU_AC_I3O1 || all->ttl.type == PDU_AC_I3O1_H)
|
|
|
+ {
|
|
|
+ uint8_t id = all->pch[h->ch_out+1].info.ph_id - 1;
|
|
|
+ current = all->pch[h->ch_out+1].power[id].current/100.0;
|
|
|
+ power = all->pch[h->ch_out+1].power[id].power/100.0;
|
|
|
+ factor = all->pch[h->ch_out+1].power[id].factor/100.0;
|
|
|
+ consumer = all->pch[h->ch_out+1].power[id].consump/100.0;
|
|
|
+ }else if(all->ttl.type == PDU_AC_I3O3)
|
|
|
+ {
|
|
|
+ if(h->menu.menu_lv == 1)
|
|
|
+ {
|
|
|
+ uint8_t id = h->ph_out - 1;
|
|
|
+ current = all->pch[h->ch_out+1].power[id].current/100.0;
|
|
|
+ power = all->pch[h->ch_out+1].power[id].power/100.0;
|
|
|
+ factor = all->pch[h->ch_out+1].power[id].factor/100.0;
|
|
|
+ consumer = all->pch[h->ch_out+1].power[id].consump/100.0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ current = all->pch[h->ch_out+1].power[0].current/100.0;
|
|
|
+ power = all->pch[h->ch_out+1].power[0].power/100.0;
|
|
|
+ factor = all->pch[h->ch_out+1].power[0].factor/100.0;
|
|
|
+ consumer = all->pch[h->ch_out+1].power[0].consump/100.0;
|
|
|
+ }
|
|
|
+ }else if(all->ttl.type == PDU_AC_I3O2)
|
|
|
+ {
|
|
|
+ if(h->menu.menu_lv == 1)
|
|
|
+ {
|
|
|
+ if(h->ph_out == 1)
|
|
|
+ {
|
|
|
+ uint8_t id = all->pch[h->ch_out+1].info.ph_id -1;
|
|
|
+ current = all->pch[h->ch_out+1].power[id].current/100.0;
|
|
|
+ power = all->pch[h->ch_out+1].power[id].power/100.0;
|
|
|
+ factor = all->pch[h->ch_out+1].power[id].factor/100.0;
|
|
|
+ consumer = all->pch[h->ch_out+1].power[id].consump/100.0;
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ uint8_t id = all->pch[h->ch_out+1].info.ph_val -1;
|
|
|
+ current = all->pch[h->ch_out+1].power[id].current/100.0;
|
|
|
+ power = all->pch[h->ch_out+1].power[id].power/100.0;
|
|
|
+ factor = all->pch[h->ch_out+1].power[id].factor/100.0;
|
|
|
+ consumer = all->pch[h->ch_out+1].power[id].consump/100.0;
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ uint8_t id = all->pch[h->ch_out+1].info.ph_id - 1;
|
|
|
+ current = all->pch[h->ch_out+1].power[id].current/100.0;
|
|
|
+ power = all->pch[h->ch_out+1].power[id].power/100.0;
|
|
|
+ factor = all->pch[h->ch_out+1].power[id].factor/100.0;
|
|
|
+ consumer = all->pch[h->ch_out+1].power[id].consump/100.0;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ current = all->pch[h->ch_out+1].power[0].current/100.0;
|
|
|
+ power = all->pch[h->ch_out+1].power[0].power/100.0;
|
|
|
+ factor = all->pch[h->ch_out+1].power[0].factor/100.0;
|
|
|
+ consumer = all->pch[h->ch_out+1].power[0].consump/100.0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
sprintf(tmp, "%s(A) :",lang_get_str(h->lang, STR_ID_CURRENT));
|
|
|
lcd_draw_string(5, item_h*2, LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
- sprintf(tmp, "%0.2f", ((float)all->pch[h->ch_out+1].power[0].current)/100.0);
|
|
|
+ sprintf(tmp, "%0.2f",current);
|
|
|
lcd_draw_string(LCD_WIDTH/2, item_h*2, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(tmp, "%s(W) :",lang_get_str(h->lang, STR_ID_POWER));
|
|
|
lcd_draw_string(5, item_h*3, LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
- sprintf(tmp, "%0.2f", ((float)all->pch[h->ch_out+1].power[0].power)/100.0);
|
|
|
+ sprintf(tmp, "%0.2f", power);
|
|
|
lcd_draw_string(LCD_WIDTH/2, item_h*3, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
|
|
|
|
|
|
sprintf(tmp, "%s(F) :",lang_get_str(h->lang, STR_ID_FACTOR));
|
|
|
lcd_draw_string(5, item_h*4, LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
- sprintf(tmp, "%0.2f", ((float)all->pch[h->ch_out+1].power[0].factor)/100.0);
|
|
|
+ sprintf(tmp, "%0.2f", factor);
|
|
|
lcd_draw_string(LCD_WIDTH/2, item_h*4, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
|
|
|
|
|
|
#endif
|
|
|
sprintf(tmp, "%s(kW):",lang_get_str(h->lang, STR_ID_CONSUMP));
|
|
|
lcd_draw_string(5, item_h*5, LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
- float cosumer = ((float)all->pch[h->ch_out+1].power[0].consump)/100.0;
|
|
|
- if(cosumer > 9999999.0)
|
|
|
+ if(consumer > 9999999.0)
|
|
|
{
|
|
|
- cosumer = 9999999.0;
|
|
|
+ consumer = 9999999.0;
|
|
|
}
|
|
|
- sprintf(tmp, "%0.2f", cosumer);
|
|
|
+ sprintf(tmp, "%0.2f", consumer);
|
|
|
lcd_draw_string(LCD_WIDTH/2, item_h*5, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
//lcd_refresh();
|
|
|
|
|
|
@@ -2106,7 +2198,7 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
h->menu.menu_id++;
|
|
|
}
|
|
|
}
|
|
|
- else if(kv->key==KEY_OK && kv->type==TYPE_SHORT) {
|
|
|
+ else if(kv->key==KEY_OK && kv->type==TYPE_LONG) {
|
|
|
if(is_ph3_in(h)) {
|
|
|
h->ph_in = 1;
|
|
|
h->menu.menu_lv = 1;
|
|
|
@@ -2140,7 +2232,11 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
h->ph_in = 1;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }else if(kv->key==KEY_OK && kv->type==TYPE_SHORT)
|
|
|
+ {
|
|
|
+ h->ph_in = 0;
|
|
|
+ h->menu.menu_lv = 0;
|
|
|
+ }
|
|
|
else if(h->uflag&UFLAG_FLIP) {
|
|
|
if(h->ph_in<3) {
|
|
|
h->ph_in++;
|
|
|
@@ -2155,8 +2251,7 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
//
|
|
|
}
|
|
|
else {
|
|
|
- h->ph_in = 0;
|
|
|
- h->menu.menu_lv = 0;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2164,7 +2259,9 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
|
|
|
case MENU_OUTPUT:
|
|
|
{
|
|
|
- if(h->uflag&UFLAG_FLIP || ((kv->key==KEY_UP || kv->key==KEY_DOWN) && kv->type==TYPE_SHORT)) {
|
|
|
+ if(h->menu.menu_lv==0) {
|
|
|
+ if(h->uflag&UFLAG_FLIP || ((kv->key==KEY_UP || kv->key==KEY_DOWN) && kv->type==TYPE_SHORT))
|
|
|
+ {
|
|
|
if(kv->key==KEY_UP) {
|
|
|
if(h->ch_out>0) {
|
|
|
h->ch_out--;
|
|
|
@@ -2183,8 +2280,103 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
h->menu.menu_id++;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ }else if(kv->key==KEY_UP && kv->type==TYPE_LONG)
|
|
|
+ {
|
|
|
+ int val = is_ph3_2_out(h);
|
|
|
+ if(val == 1)
|
|
|
+ {
|
|
|
+ h->menu.menu_lv = 1;
|
|
|
+ h->ph_out = 1;
|
|
|
+ }else if(val == 2)
|
|
|
+ {
|
|
|
+ h->menu.menu_lv = 1;
|
|
|
+ h->ph_out = 1;
|
|
|
+ }
|
|
|
+ }else if(h->uflag&UFLAG_FLIP)
|
|
|
+ {
|
|
|
+// if(h->ph_in<3) {
|
|
|
+// h->ph_in++;
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// h->ph_in = 0;
|
|
|
+// h->menu.menu_lv = 0;
|
|
|
+// h->menu.menu_id++;
|
|
|
+// }
|
|
|
+ } else if(h->uflag&UFLAG_REFRESH)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ } else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }else if(h->menu.menu_lv == 1)
|
|
|
+ {
|
|
|
+ int val = is_ph3_2_out(h);
|
|
|
+ if(kv->key==KEY_UP && kv->type==TYPE_SHORT)
|
|
|
+ {
|
|
|
+ if(val == 1)
|
|
|
+ {
|
|
|
+ if(h->ph_out>1) // 3 ph
|
|
|
+ {
|
|
|
+ h->ph_out--;
|
|
|
+ } else {
|
|
|
+ h->ph_out = 3;
|
|
|
+ }
|
|
|
+ }else if(val == 2) //double fire
|
|
|
+ {
|
|
|
+ // h->ph_out = h->ph_out ? 0 : 1;
|
|
|
+ if(h->ph_out > 0)
|
|
|
+ {
|
|
|
+ h->ph_out --;
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ h->ph_out = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(kv->key==KEY_DOWN && kv->type==TYPE_SHORT)
|
|
|
+ {
|
|
|
+ if(val == 1)
|
|
|
+ {
|
|
|
+ if(h->ph_out < 3) // 3 ph
|
|
|
+ {
|
|
|
+ h->ph_out++;
|
|
|
+ } else {
|
|
|
+ h->ph_out = 1;
|
|
|
+ }
|
|
|
+ }else if(val == 2) //double fire
|
|
|
+ {
|
|
|
+ if(h->ph_out < 2)
|
|
|
+ {
|
|
|
+ h->ph_out ++;
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ h->ph_out = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(kv->key == KEY_OK && kv->type==TYPE_SHORT)
|
|
|
+ {
|
|
|
+ h->menu.menu_lv = 0;
|
|
|
+ h->ph_out = 0;
|
|
|
+ }else if(h->uflag&UFLAG_FLIP)
|
|
|
+ {
|
|
|
+// if(h->ph_in<3) {
|
|
|
+// h->ph_in++;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// h->ph_in = 0;
|
|
|
+// h->menu.menu_lv = 0;
|
|
|
+// h->menu.menu_id++;
|
|
|
+// }
|
|
|
+ } else if(h->uflag&UFLAG_REFRESH)
|
|
|
+ {
|
|
|
+ //
|
|
|
+ } else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
|
|
|
case MENU_MODBUS:
|