- UID
- 3644
- 麦力
- 1878
- 注册时间
- 2017-3-21
- 最后登录
- 2022-3-20
- 精华
- 0
- 阅读权限
- 30
- 在线时间
- 73 小时
|
下边的代码,为啥count>100后程序就死掉了(我只在模拟器上跑来着)
编辑器自动生成的变量名称,有些怪,还望凑合着看看
难不成不能用重建窗口的方法来模拟刷新吗?
//-------下边是代码------
//---include
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "maibu_sdk.h"
#include "maibu_res.h"
#include <time.h>
#include <math.h>
P_Window CreateNewWindowByIndex(int8_t windowIndex);//通过序号创建窗口
P_Window CreateWindow_WinWindow1();
void RefreshTimeValue();
void RefreshCurrentWindow();//刷新(重新载入)当前窗口
static int32_t currentWindowId = -1;//当前窗口Id
//时间变量
static double SystemInner_Hour;
static double SystemInner_Minute;
static double SystemInner_Second;
static uint8_t WinWindow1_TgTimer1_Timer_Id;
static uint8_t count;//测试用
//窗口(窗口1)计时器(计时器1)过程
void WinWindow1_TgTimer1_Timer(date_time_t tick,uint32_t millis,void *context)
{
count++;
app_service_timer_unsubscribe(WinWindow1_TgTimer1_Timer_Id);
//RefreshTimeValue();
RefreshCurrentWindow();
}
//刷新时间值
void RefreshTimeValue()
{
struct date_time nowTime;
app_service_get_datetime(&nowTime);
SystemInner_Hour = nowTime.hour;
SystemInner_Minute = nowTime.min;
SystemInner_Second = nowTime.sec;
}
//刷新当前窗口过程
void RefreshCurrentWindow()
{
if(currentWindowId<=0)
{
return;
}
//RefreshTimeValue();
P_Window oldWin = (P_Window)app_window_stack_get_window_by_id(currentWindowId);
P_Window newWin = (P_Window)(P_Window)CreateWindow_WinWindow1();
currentWindowId = app_window_stack_replace_window(oldWin,newWin);
}
//创建窗口(窗口1)的单行文字图层(单行文字1)
P_Layer CreateSingleLineTextLayer_WinWindow1_CtlSLText1()
{
GRect frame_sl_CtlSLText1 = {{11,20}, {28,109}};
unsigned char buf_sl_CtlSLText1[20];
sprintf(buf_sl_CtlSLText1,"%02f",SystemInner_Second);
LayerText text_sl_CtlSLText1 = {buf_sl_CtlSLText1, frame_sl_CtlSLText1, GAlignCenter, U_GBK_SIMSUN_12};
P_Layer retLayer = app_layer_create_text(&text_sl_CtlSLText1);
return retLayer;
}
//创建窗口(窗口1)的单行文字图层(单行文字2)
P_Layer CreateSingleLineTextLayer_WinWindow1_CtlSLText2()
{
GRect frame_sl_CtlSLText1 = {{11,40}, {28,109}};
unsigned char buf_sl_CtlSLText1[20];
sprintf(buf_sl_CtlSLText1,"%02d",count);
LayerText text_sl_CtlSLText1 = {buf_sl_CtlSLText1, frame_sl_CtlSLText1, GAlignCenter, U_GBK_SIMSUN_12};
P_Layer retLayer = app_layer_create_text(&text_sl_CtlSLText1);
return retLayer;
}
//---window
//创建窗口WinWindow1(窗口1)
P_Window CreateWindow_WinWindow1()
{
P_Window p_window = app_window_create();
P_Layer layer;
//载入窗口(窗口1)的单行文字图层(单行文字1)
//app_window_add_layer(p_window, CreateSingleLineTextLayer_WinWindow1_CtlSLText1());
//载入窗口(窗口1)的单行文字图层(单行文字2)
app_window_add_layer(p_window, CreateSingleLineTextLayer_WinWindow1_CtlSLText2());
//注册计时器事件(如果存在)
app_service_timer_unsubscribe(WinWindow1_TgTimer1_Timer_Id);
WinWindow1_TgTimer1_Timer_Id = app_service_timer_subscribe(100,WinWindow1_TgTimer1_Timer,NULL);
//返回
return p_window;
}
//---main
int main()
{
simulator_init();
//压入启动窗口
P_Window p_window = (P_Window)CreateWindow_WinWindow1();
currentWindowId = app_window_stack_push(p_window);
simulator_wait();
}
|
|