|
|
@@ -1,6 +1,5 @@
|
|
|
#include <string.h>
|
|
|
#include <unistd.h>
|
|
|
-#include <time.h>
|
|
|
#include "menu.h"
|
|
|
#include "lcd.h"
|
|
|
#include "led.h"
|
|
|
@@ -12,7 +11,9 @@
|
|
|
#include "lang.h"
|
|
|
#include "timer.h"
|
|
|
#include "cfg.h"
|
|
|
+#include <sys/time.h>
|
|
|
|
|
|
+#define LINES 5
|
|
|
#define REFRESH_TIME 300
|
|
|
//#define TEXT_ALIGN
|
|
|
|
|
|
@@ -162,16 +163,21 @@ static void tmr_stop(menu_handle_t *h)
|
|
|
timer_stop(h->tmr);
|
|
|
h->tmr = -1;
|
|
|
}
|
|
|
-static void get_curtime(char *time, int len)
|
|
|
+static void get_date(char *date, int len, struct tm *t)
|
|
|
{
|
|
|
- struct tm *t=localtime(NULL);
|
|
|
- snprintf(time, len, "%02d%/%02d/%02d %02d:%02d:%02d", (t->tm_year+1900)%100, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
|
|
|
+ snprintf(date, len, "%04d%/%02d/%02d", (t->tm_year+1900), t->tm_mon+1, t->tm_mday);
|
|
|
+}
|
|
|
+static void get_time(char *time, int len, struct tm *t)
|
|
|
+{
|
|
|
+ snprintf(time, len, "%02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec);
|
|
|
}
|
|
|
|
|
|
static void menu_system_paint(menu_handle_t *h, int font1, int font2, int item_h, key_val_t *kv)
|
|
|
{
|
|
|
- char time[40],tmp[60];
|
|
|
-
|
|
|
+ char xxx[40],tmp[60];
|
|
|
+ time_t t=time(NULL);
|
|
|
+ struct tm *tm=localtime(&t);
|
|
|
+
|
|
|
//lcd_fill(COLOR_BLACK);
|
|
|
sprintf(tmp, "SmartPDU");
|
|
|
lcd_draw_string(0, 0, LCD_WIDTH, item_h, tmp, font1, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_CENTER, VERTICAL_CENTER);
|
|
|
@@ -179,12 +185,16 @@ static void menu_system_paint(menu_handle_t *h, int font1, int font2, int item_h
|
|
|
sprintf(tmp, "%s:%s", lang_get_str(h->lang, STR_ID_VER), VERSION);
|
|
|
lcd_draw_string(0, item_h, LCD_WIDTH, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
|
|
|
- get_curtime(time, sizeof(time));
|
|
|
- sprintf(tmp, "%s:%s", lang_get_str(h->lang, STR_ID_TIME), time);
|
|
|
+ get_date(xxx, sizeof(xxx), tm);
|
|
|
+ sprintf(tmp, "%s:%s", lang_get_str(h->lang, STR_ID_DATE), xxx);
|
|
|
lcd_draw_string(0, item_h*2, LCD_WIDTH, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
-
|
|
|
- sprintf(tmp, "IP:%s", "11.11.11.11");//getLocalIpAddress("eth0"));
|
|
|
+
|
|
|
+ get_time(xxx, sizeof(xxx), tm);
|
|
|
+ sprintf(tmp, "%s:%s", lang_get_str(h->lang, STR_ID_TIME), xxx);
|
|
|
lcd_draw_string(0, item_h*3, LCD_WIDTH, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
+
|
|
|
+ sprintf(tmp, "IP:%s", "11.11.11.11");//getLocalIpAddress("e0"));
|
|
|
+ lcd_draw_string(0, item_h*4, LCD_WIDTH, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
|
|
|
//lcd_refresh();
|
|
|
}
|
|
|
static void menu_input_paint(menu_handle_t *h, int font1, int font2, int item_h, key_val_t *kv)
|
|
|
@@ -371,8 +381,8 @@ int menu_init(void)
|
|
|
misc_data_t *misc=¶s_get()->misc;
|
|
|
|
|
|
memset(h, 0, sizeof(menu_handle_t));
|
|
|
- h->lang = lang_id;
|
|
|
- //h->tmr = timer_init();
|
|
|
+ h->lang = paras_get()->sys.lang;
|
|
|
+ h->tmr = timer_init();
|
|
|
h->flip_ms = get_ms();
|
|
|
h->refresh_ms = get_ms();
|
|
|
h->uflag |= UFLAG_REFRESH;
|
|
|
@@ -542,6 +552,7 @@ static int menu_modbus_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
{
|
|
|
int r=0;
|
|
|
+ int menu_id=h->menu.menu_id;
|
|
|
|
|
|
h->ch_out_max = get_ch_out_max(h);
|
|
|
switch(h->menu.menu_id) {
|
|
|
@@ -659,6 +670,10 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ if(menu_id!=h->menu.menu_id) {
|
|
|
+ lcd_fill(COLOR_BLACK);
|
|
|
+ }
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
@@ -670,7 +685,7 @@ int menu_handle(void)
|
|
|
uint64_t cur_ms;
|
|
|
key_val_t kv;
|
|
|
int rotate=lcd_get_rotate();
|
|
|
- int item_h=LCD_HEIGHT/4;
|
|
|
+ int item_h=LCD_HEIGHT/LINES;
|
|
|
int font1=FONT_24,font2=FONT_24;
|
|
|
menu_handle_t *h=&mnHandle;
|
|
|
|