*********************/
#include "lv_obj.h"
#include "lv_indev.h"
+#include "helios_os.h"
/*********************
* DEFINES
/**********************
* STATIC VARIABLES
**********************/
-static lv_event_t * event_head;
+static lv_event_t * event_head = NULL;
/**********************
* MACROS
* GLOBAL FUNCTIONS
**********************/
+static Helios_Mutex_t lv_event_mutex = 0;
+
+
lv_res_t lv_event_send(lv_obj_t * obj, lv_event_code_t event_code, void * param)
{
if(obj == NULL) return LV_RES_OK;
-
+ if(0 == lv_event_mutex) {
+ lv_event_mutex = Helios_Mutex_Create();
+ }
LV_ASSERT_OBJ(obj, MY_CLASS);
+ Helios_Mutex_Lock(lv_event_mutex, HELIOS_WAIT_FOREVER);
lv_event_t e;
e.target = obj;
*called from this `event_cb`.*/
e.prev = event_head;
event_head = &e;
+ Helios_Mutex_Unlock(lv_event_mutex);
/*Send the event*/
lv_res_t res = event_send_core(&e);
/*Remove this element from the list*/
+ Helios_Mutex_Lock(lv_event_mutex, HELIOS_WAIT_FOREVER);
event_head = e.prev;
+ Helios_Mutex_Unlock(lv_event_mutex);
return res;
}
void _lv_event_mark_deleted(lv_obj_t * obj)
{
+
+ if(0 == lv_event_mutex) {
+ lv_event_mutex = Helios_Mutex_Create();
+ }
+ Helios_Mutex_Lock(lv_event_mutex, HELIOS_WAIT_FOREVER);
lv_event_t * e = event_head;
while(e) {
if(e->current_target == obj || e->target == obj) e->deleted = 1;
e = e->prev;
}
+
+ Helios_Mutex_Unlock(lv_event_mutex);
}
self.sec_value = 0
self.min_value = 0
self.s_state = 0
+ self.total_time = 0
+ self.TimeSecond = 0
self.timer = osTimer()
def initialization(self):
if self.s_state == 0:
self.reset(0)
-
+ if self.s_state == 1:
+ date_tmp = utime.localtime()
+ timeSecond = utime.mktime(date_tmp)
+ reduce = timeSecond - self.TimeSecond
+ self.total_time = self.total_time+reduce
+ if self.total_time >= 99*60:
+ self.total_time = 99*60
+ self.ms_value = 0
+ stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.show_value()
+ else:
+ self.timer.start(100,1,self._fun)
+
def start(self, e):
global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
self.s_state = 1
if self.s_state != 2:
self.s_state = 1
- if self.ms_value > 0 or self.sec_value > 0 or self.min_value > 0:
+ if self.total_time >= 99*60:
self.ms_value = 0
self.sec_value = 0
self.min_value = 0
+ self.total_time = 0
self.show_value()
self.timer.start(100,1,self._fun)
stopwatch_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
self.min_value = 0
self.ms_value = 0
self.s_state = 0
+ self.total_time = 0
stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
self.timer.stop()
if self.ms_value > 9:
self.ms_value = 0
self.sec_value += 1
- if self.sec_value > 60:
+ self.total_time+=1
+ if self.sec_value > 59:
self.sec_value = 0
- self.min_value += 1
- if self.min_value > 99:
- self.min_value = 99
+ if self.total_time > 99*60:
+ self.total_time = 99*60
self.timer.stop()
stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
stopwatch_start_imgbtn, stopwatch_stop_img
- if self.min_value >= 99:
- self.min_value = 99
+ if self.total_time >= 99*60:
+ self.total_time = 99*60
+ test_s = self.total_time % 60
+ test_m = self.total_time//60
+ # print("test_s:{} test_m:{} self.total_time:{}".format(test_s,test_m,self.total_time))
stopwatch_label_ms.set_text(str("%d"%(self.ms_value)))
- stopwatch_label_sec.set_text(str("%02d"%(self.sec_value)))
- stopwatch_label_min.set_text(str("%02d"%(self.min_value)))
+ stopwatch_label_sec.set_text(str("%02d"%(test_s)))
+ stopwatch_label_min.set_text(str("%02d"%(test_m)))
+
+ def Close(self):
+ if self.s_state == 1:
+ self.timer.stop()
+ date_tmp = utime.localtime()
+ self.TimeSecond = utime.mktime(date_tmp)
+
+ def lcd_on(self):
+ if self.s_state == 1:
+ date_tmp = utime.localtime()
+ timeSecond = utime.mktime(date_tmp)
+ reduce = timeSecond - self.TimeSecond
+ self.total_time = self.total_time+reduce
+ total = self.total_time // 60
+ if total >= 99:
+ self.total_time = 99*60
+ self.timer.stop()
+ self.s_state = 0
+ self.ms_value = 0
+ stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.show_value()
+ else:
+
+ print("stopwatch reset start:{}".format(self.s_state))
+ #self.timer.start(100, 1, self._fun)
+ self.show_value()
+ self.timer.start(100,1,self._fun)
+ stopwatch_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_start_img.add_flag(lv.obj.FLAG.HIDDEN)
+ # print("ms_value start:{} {} {}".format(self.ms_value,self.sec_value,self.min_value))
+
+ pass
+
+ def lcd_off(self):
+ if self.s_state == 1:
+ date_tmp = utime.localtime()
+ timeSecond = utime.mktime(date_tmp)
+ self.TimeSecond = timeSecond
+ self.timer.stop()
+ pass
def done_return(self):
if self.s_state == 0:
def load_screen(self, topic, msg):
print("msg1={}".format(msg))
- if self.UI_high_priority_flag == 1:
+ if self.UI_high_priority_flag == 1:#电话界面屏蔽其他界面
return
for scr in self.screen_list:
if scr.NAME == msg["screen"]: