返回官网官方微博

麦步社区-论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: MAI 表盘
查看: 4610|回复: 8
打印 上一主题 下一主题

应用模拟都是好的,就是打包后安装成功后没呈现

[复制链接]

10

主题

83

帖子

1538

麦力

精华
0
阅读权限
50
在线时间
45 小时

麦步手表用户

跳转到指定楼层
楼主
发表于 2017-5-9 16:29:22 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 zzes0312 于 2017-5-10 06:45 编辑

求大神救助。。。
模拟功能都能正常使用

下面放代码


  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>


  4. #include "maibu_sdk.h"
  5. #include "maibu_res.h"



  6. /*背景图层位置*/
  7. #define COUNTER_BG_ORIGIN_X                0        
  8. #define COUNTER_BG_ORIGIN_Y                0        
  9. #define COUNTER_BG_SIZE_H                128
  10. #define COUNTER_BG_SIZE_W                128

  11. /*文本图层位置*/
  12. #define COUNTER_TEXT_ORIGIN_X                0        
  13. #define COUNTER_TEXT_ORIGIN_Y                41        
  14. #define COUNTER_TEXT_SIZE_H                42
  15. #define COUNTER_TEXT_SIZE_W                128

  16. /*文本1图层位置*/
  17. #define COUNTER_TEXT1_ORIGIN_X                0        
  18. #define COUNTER_TEXT1_ORIGIN_Y                108        
  19. #define COUNTER_TEXT1_SIZE_H                12
  20. #define COUNTER_TEXT1_SIZE_W                128


  21. /*Web通讯ID*/

  22. static uint32_t g_comm_id_web = 0;

  23. /*Web request地址*/

  24. #define DATA_WEB           "http:// :3000/"
  25. static int32_t g_window_id             = -1;

  26. char path1[30] = "buttonclick1";
  27. char path0[30] = "buttonclick0";
  28. /*文本框图层ID*/
  29. static int8_t g_counter_text_layer_id = -1;

  30. /*提示文本图层ID*/
  31. static int8_t g_counter_hint_layer_id = -1;

  32. /*当前窗口显示的计数*/
  33. static int16_t g_count_index = 0;


  34. void data_request_callback( const uint8_t *buff,  uint16_t size){

  35.         /*根据窗口ID获取窗口句柄*/
  36.         P_Window pwindow = app_window_stack_get_window_by_id(g_counter_text_layer_id);;

  37.         /*更新窗口*/        
  38.         app_window_update(pwindow);
  39. }

  40. static data_request_web(char * method){
  41.         char url[200] = "";
  42.         sprintf(url,"%s",DATA_WEB);

  43.         strncat(url, method, 1000);
  44.          
  45.          maibu_comm_register_web_callback(data_request_callback);
  46.         g_comm_id_web = maibu_comm_request_web(url, NULL, 0);//过滤
  47.         
  48. }


  49. /*定义向上按键事件*/
  50. static void counter_select_up(void *context)
  51. {
  52.         P_Window p_window = (P_Window)context;
  53.         data_request_web(path1);
  54.         if (NULL != p_window)
  55.         {
  56.                 /*根据图层ID获取图层句柄*/
  57.                 P_Layer p_layer = app_window_get_layer_by_id(p_window, g_counter_text_layer_id);
  58.                 P_Layer p_hint_layer = app_window_get_layer_by_id(p_window, g_counter_hint_layer_id);

  59.                

  60.                 if ((p_layer != NULL) && (p_hint_layer != NULL))
  61.                 {
  62.                         g_count_index=1;
  63.                         
  64.                
  65.                         /*设置文本图层新的文本内容并更新显示*/        
  66.                         char text[6] = "";
  67.                         sprintf(text, "%d", g_count_index);
  68.                         app_layer_set_text_text(p_layer, text);        

  69.                         
  70.                         /*更改提示*/        
  71.                         char hint[20] = "";
  72.                         if (g_count_index == 0)
  73.                         {
  74.                                 sprintf(hint, "%s", "按上下键控制");
  75.                         }
  76.                         else
  77.                         {
  78.                                 sprintf(hint, "%s", "治电科技");
  79.                         }
  80.                         app_layer_set_text_text(p_hint_layer, hint);        

  81.                         app_window_update(p_window);


  82.                 }
  83.         }
  84.         
  85. }


  86. /*定义向下按键事件*/
  87. static void counter_select_down(void *context)
  88. {
  89.         P_Window p_window = (P_Window)context;
  90.                 data_request_web(path0);
  91.         if (NULL != p_window)
  92.         {
  93.                 /*根据图层ID获取图层句柄*/
  94.                 P_Layer p_layer = app_window_get_layer_by_id(p_window, g_counter_text_layer_id);
  95.                 P_Layer p_hint_layer = app_window_get_layer_by_id(p_window, g_counter_hint_layer_id);

  96.         

  97.                 if ((p_layer != NULL) && (p_hint_layer != NULL))
  98.                 {
  99.                         g_count_index=0;

  100.                
  101.                         /*设置文本图层新的文本内容并更新显示*/        
  102.                         char text[6] = "";
  103.                         sprintf(text, "%d", g_count_index);
  104.                         app_layer_set_text_text(p_layer, text);               

  105.                         /*更改提示*/        
  106.                         char hint[20] = "";
  107.                         if (g_count_index == 0)
  108.                         {
  109.                                 sprintf(hint, "%s", "按上下键控制");
  110.                         }
  111.                         else
  112.                         {
  113.                                 sprintf(hint, "%s", "治电科技");
  114.                         }
  115.                         app_layer_set_text_text(p_hint_layer, hint);        

  116.                         app_window_update(p_window);

  117.                         
  118.                 }
  119.         }
  120. }




  121. /*定义后退按键事件*/
  122. static void counter_select_back(void *context)
  123. {
  124.         P_Window p_window = (P_Window)context;
  125.         if (NULL != p_window)
  126.         {
  127.                 app_window_stack_pop(p_window);
  128.         }
  129. }


  130. /*
  131. *--------------------------------------------------------------------------------------
  132. *     function:  counter_init_window
  133. *    parameter:
  134. *       return:
  135. *  description:  初始化窗口
  136. *           other:
  137. *--------------------------------------------------------------------------------------
  138. */
  139. static P_Window counter_init_window()
  140. {
  141.         P_Window p_window = NULL;

  142.         /*创建窗口*/
  143.         p_window = app_window_create();
  144.         if (NULL == p_window)
  145.         {
  146.                 return NULL;
  147.         }

  148. /*--------添加状态栏显示时间-------*/
  149.         /*获取当前时间信息*/
  150.         struct date_time dt;
  151.         app_service_get_datetime(&dt);        
  152.         


  153. /*--------添加图片图层------------*/
  154.         /*添加黑色背景图片*/
  155.         /*图片显示位置*/
  156.         GRect frame_bmp = {{COUNTER_BG_ORIGIN_X, COUNTER_BG_ORIGIN_Y}, {COUNTER_BG_SIZE_H, COUNTER_BG_SIZE_W}};
  157.         
  158.         /*获取用户定义图片*/
  159.         GBitmap bitmap;
  160.         res_get_user_bitmap(RES_BITMAP_WATCHAPP_COUNTER_BG, &bitmap);

  161.         /*定义图片显示相关结构*/
  162.         LayerBitmap lb = { bitmap, frame_bmp, GAlignLeft};        

  163.         /*创建图片图层*/
  164.         P_Layer layer_bmp = app_layer_create_bitmap(&lb);

  165.         /*添加图层到窗口*/
  166.         app_window_add_layer(p_window, layer_bmp);
  167.         
  168.         
  169.         
  170.                 /*添加状态栏, 显示时间*/
  171.         app_plug_status_bar_create(p_window, NULL, NULL, NULL);
  172.         app_plug_status_bar_add_time(p_window);
  173.         
  174.         

  175. /*---------添加显示文本图层---------------*/

  176.         /*显示文本位置*/
  177.         GRect frame_text = {{COUNTER_TEXT_ORIGIN_X, COUNTER_TEXT_ORIGIN_Y}, {COUNTER_TEXT_SIZE_H, COUNTER_TEXT_SIZE_W}};

  178.         /*定义文本显示结构*/
  179.         char text[6] = "";
  180.         sprintf(text, "%d", g_count_index);
  181.         LayerText lt = {text, frame_text, GAlignTop, U_ASCII_ARIAL_42};

  182.         /*创建文本图层*/
  183.         P_Layer layer_text = app_layer_create_text(<);

  184.         /*添加图层到窗口*/
  185.         g_counter_text_layer_id = app_window_add_layer(p_window, layer_text);


  186. /*---------添加显示文本图层---------------*/

  187.         /*显示文本位置*/
  188.         GRect frame1_text = {{COUNTER_TEXT1_ORIGIN_X, COUNTER_TEXT1_ORIGIN_Y}, {COUNTER_TEXT1_SIZE_H, COUNTER_TEXT1_SIZE_W}};

  189.         /*定义文本显示结构*/
  190.         char text1[20] = "";
  191.         if (g_count_index == 0)
  192.         {
  193.                 sprintf(text1, "%s", "按上下键加减");
  194.         }
  195.         else
  196.         {
  197.                 sprintf(text1, "%s", "治电科技");
  198.         }
  199.         LayerText lt1 = {text1, frame1_text, GAlignTop, U_GBK_SIMSUN_12};

  200.         /*创建文本图层*/
  201.         P_Layer layer_text1 = app_layer_create_text(<1);
  202.         app_layer_set_bg_color(layer_text1, GColorBlack);

  203.         /*添加图层到窗口*/
  204.         g_counter_hint_layer_id = app_window_add_layer(p_window, layer_text1);

  205.         
  206.         /*添加窗口按键事件*/
  207.         app_window_click_subscribe(p_window, ButtonIdDown, counter_select_down);
  208.         app_window_click_subscribe(p_window, ButtonIdUp, counter_select_up);

  209.         app_window_click_subscribe(p_window, ButtonIdBack, counter_select_back);
  210.         return (p_window);

  211. }

  212. int main()
  213. {
  214. //simulator_init();
  215.         /*APP编写*/
  216.         /*创建日期时间设置窗口*/
  217.         P_Window p_window = counter_init_window();

  218.         /*放入窗口栈显示*/
  219.         app_window_stack_push(p_window);
  220. //simulator_wait();
  221.         return 0;

  222. }

复制代码

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信 WeiboWeibo
收藏收藏1 分享分享 顶 踩

2

主题

665

帖子

2884

麦力

精华
0
阅读权限
70
在线时间
93 小时

沙发
发表于 2017-5-9 22:21:41 来自手机 | 只看该作者
源码都漏出来了

23

主题

1532

帖子

9071

麦力

精华
0
阅读权限
80
在线时间
103 小时

板凳
发表于 2017-5-10 00:40:59 | 只看该作者
不懂帮顶
回复

使用道具 举报

66

主题

915

帖子

1万

麦力

精华
8
阅读权限
80
在线时间
1040 小时

麦步极客实验室麦步增强版用户

地板
发表于 2017-5-10 01:54:12 | 只看该作者
65行,那个1000有问题,直接strcat(url,method)

10

主题

83

帖子

1538

麦力

精华
0
阅读权限
50
在线时间
45 小时

麦步手表用户

5#
 楼主| 发表于 2017-5-10 06:39:51 | 只看该作者

我是基于开源代码改的

10

主题

83

帖子

1538

麦力

精华
0
阅读权限
50
在线时间
45 小时

麦步手表用户

6#
 楼主| 发表于 2017-5-10 06:44:49 | 只看该作者
qs100371 发表于 2017-5-10 01:54
65行,那个1000有问题,直接strcat(url,method)

感谢大神的帮助,成功了

5

主题

174

帖子

2456

麦力

精华
2
阅读权限
50
在线时间
187 小时

7#
发表于 2017-5-10 18:10:42 来自手机 | 只看该作者
qs100371 发表于 2017-5-10 01:54
65行,那个1000有问题,直接strcat(url,method)

你真狠~~~!

23

主题

1532

帖子

9071

麦力

精华
0
阅读权限
80
在线时间
103 小时

8#
发表于 2017-5-11 01:03:22 | 只看该作者
不懂帮顶
回复

使用道具 举报

3

主题

118

帖子

1223

麦力

精华
1
阅读权限
150
在线时间
59 小时
9#
发表于 2017-5-23 16:57:18 | 只看该作者

麦步OS目前只支持以下标准C库接口:
strlen
strstr
atoi
strncpy
sprintf
sin
cos
memcpy
memset
malloc
strcpy
strcmp
free

暂时不支持 switch语句。
数组定义必须指定大小。
全局结构体必须定义为static类型。
函数也建议使用static修饰。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|麦步官方论坛 ( 粤ICP备12052190号  

GMT+8, 2024-5-7 07:02 , Processed in 0.092286 second(s), 27 queries .

Powered by Discuz! X3.2

© 2012-2021 Comsenz Inc.

快速回复 返回顶部 返回列表