- UID
- 1095
- 麦力
- 2491
- 注册时间
- 2016-7-12
- 最后登录
- 2017-7-7
- 精华
- 0
- 阅读权限
- 100
- 在线时间
- 97 小时
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "maibu_sdk.h"
#include "maibu_res.h"
static int32_t g_window_id = -1;
static int8_t g_layer_id_1 = -1;
static int8_t g_layer_id_2 = -1;
void GPS_phone_recv_callback(enum ERequestPhone type, void *context)
{
P_Window p_window = app_window_stack_get_window_by_id(g_window_id);
char url1[50];
char url2[50];
SGpsAltitude g_gps_altitude;
memcpy(&g_gps_altitude, (SGpsAltitude *)context, sizeof(SGpsAltitude));
sprintf(url1, "纬度%s", g_gps_altitude.lat);
sprintf(url2, "经度%s", g_gps_altitude.lon);
P_Layer p_layer_1 = app_window_get_layer_by_id(p_window, g_layer_id_1);
P_Layer p_layer_2 = app_window_get_layer_by_id(p_window, g_layer_id_2);
app_layer_set_text_text(p_layer_1, url1);
app_layer_set_text_text(p_layer_2, url2);
app_window_update(p_window);
}
void GPS_timer_callback(date_time_t tick_time, uint32_t millis, void *context)
{ P_Window p_window = app_window_stack_get_window_by_id(g_window_id);
P_Layer p_layer_1 = app_window_get_layer_by_id(p_window, g_layer_id_1);
P_Layer p_layer_2 = app_window_get_layer_by_id(p_window, g_layer_id_2);
app_layer_set_text_text(p_layer_1, "AA");
app_layer_set_text_text(p_layer_2, "BB");
app_window_update(p_window);
maibu_comm_request_phone(ERequestPhoneGPSAltitude, NULL,0);
}
int main()
{
//simulator_init();
P_Window pPP_window = app_window_create();
if (NULL == pPP_window)
{
return 0;
}
maibu_comm_register_phone_callback(GPS_phone_recv_callback);
GRect frame1 = {{0, 45}, {40, 128}};
LayerText text1 = {"AA", frame1, GAlignCenter, U_GBK_SIMSUNBD_16};
GRect frame2 = {{0, 80}, {40, 128}};
LayerText text2 = {"BB", frame2, GAlignCenter, U_GBK_SIMSUNBD_16};
P_Layer layer1 = app_layer_create_text(&text1);
g_layer_id_1=app_window_add_layer(pPP_window, layer1);
P_Layer layer2 = app_layer_create_text(&text2);
g_layer_id_2=app_window_add_layer(pPP_window, layer2);
g_window_id=app_window_stack_push(pPP_window);
app_window_timer_subscribe(pPP_window, 5000, GPS_timer_callback, (void *)pPP_window);
//simulator_wait();
return 1;
}
|
|