天道酬勤,学无止境

pebble-sdk

How to store byte arrays in C?

This seems such a basic question, but I cannot find an answer anywhere on SO. I know that C/C++ do not have a byte datatype. I know that sizeof(char) == 1. I'm trying to store 12 transmissions, each of 96 bytes on Pebble, as transmitted from my Android app. Due to limitation in the transmission size, I'm sending one at a time. Each one should be 'appended' to the last, as they should end up forming sequential space in memory, for reading as an image (one bit per pixel). I'm trying to do something like this: int transNum = 0; uint8_t image[][] = new uint8t[12][12] //not sure about uint8_t, and

2021-11-26 01:44:15    分类:问答    c   pebble-watch   pebble-sdk

What does this dot syntax mean in the Pebble watch development tutorial? [duplicate]

This question already has answers here: What does dot (.) mean in a struct initializer? (4 answers) Closed 7 years ago. I came across following code in Pebble watch app development tutorial: // Set handlers to manage the elements inside the Window window_set_window_handlers(s_main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload }); I cant understand this assignment to .load and .unload. Is this standard C? I don't think I have ever seen similar syntax before.

2021-11-25 10:41:15    分类:问答    c   pebble-sdk

试图用文本掩盖 APNG 背景(Trying to mask APNG background with text)

问题 我以 Pebble 为例,使用 APNG 并尝试用透明文本对其进行遮罩,因此位图将仅显示直通文本,但无论我尝试哪种遮罩/复合模式,位图都显示为黑白(原始动画是如果我不绘制文本,则以彩色显示) 这是我在回调 SP 中为绘制文本的图层使用的示例代码: //creating background and text graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(0, 0, 144, 168), 0, GCornerNone); graphics_context_set_text_color(ctx, GColorWhite); graphics_draw_text(ctx, "08:39", fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49), GRect(0,50,144,118), GTextOverflowModeFill, GTextAlignmentCenter, NULL); //drawing bitmap (extracted from bitmap_sequence elsewhere) graphics_context_set_compositing_mode(ctx, GCompOpClear

2021-10-23 20:37:36    分类:技术分享    pebble-watch   pebble-sdk   cloudpebble

Trying to mask APNG background with text

I am taking Pebble example of working with APNG and trying to mask it with transparent text, so bitmap will show only thru text, but no matter what mask/composite mode I try, bitmap is shown as black-and-white (original animation is in color and shows in color if I don't draw text) Here's a sample code I use in callback SP for the layer that draws text: //creating background and text graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, GRect(0, 0, 144, 168), 0, GCornerNone); graphics_context_set_text_color(ctx, GColorWhite); graphics_draw_text(ctx, "08:39", fonts_get

2021-10-23 16:36:58    分类:问答    pebble-watch   pebble-sdk   cloudpebble

是否可以使用 Pebble.js 和 CloudPebble 显示设置页面并与手机通信?(Is it possible to display a settings page and communicate with a phone using Pebble.js and CloudPebble?)

问题 是否可以仅使用 Pebble.js 和 CloudPebble 在手机上获取用户输入并对其进行处理,然后将一些结果显示到 Pebble Watch 上? 对于这种情况,我想我需要 PebbleKit JS 或 PebbleKit Android/iOS 才能在手机和手表之间进行通信……对吗? 回答1 Pebble.js 是使用 PebbleKit JS 构建的,因此您可以使用 PebbleKit JS 执行的任何操作都可以在 Pebble.js 中完成,包括设置页面。 回答2 要使用 CloudPebble,您必须对配置页面进行一些更改。 首先,您将像使用常规应用程序一样在网络上托管页面。 但是,对于 Pebble.js 和 CloudPebble 测试,您需要使用从 CloudPebble 传递给您的 return_to 查询字符串值将配置数据发送回您的模拟器。 这是一个示例(在顶部脚本部分的配置网页上) function getQuerystring(key, default_) { if (default_ == null) default_ = ""; key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regex = new RegExp("[\\?&]" + key + "=([^&#]*)

2021-10-18 19:22:21    分类:技术分享    pebble-sdk   cloudpebble

Is it possible to display a settings page and communicate with a phone using Pebble.js and CloudPebble?

Is it possible to get user input on the phone and do something with it and then display some result onto the pebble watch using only Pebble.js and the CloudPebble? For this case I think I would need PebbleKit JS or PebbleKit Android/iOS in order to communicate between the phone and watch.. right?

2021-10-18 12:21:04    分类:问答    pebble-sdk   cloudpebble

初始化元素不是常量?(initializer element not constant?)

问题 我对 C 比较了解,只学习了它的一部分来发布一个 Pebble C/PebbleKitJS 应用程序来跟踪公共汽车。 到目前为止,我已经在 Node 服务器上处理了数据,我正准备让 JS 文件处理数据。 然而,我的一个问题在于 C 代码。 此代码处理存储在从 JS 发送的 Key Dictionary 中的数据,并将其分配给一个变量以供下面使用。 通过使用 #define var 9,我可以成功地将 .high 值设置为 9。但是通过 int var,它失败并抛出错误:初始化元素不是常量? . 这个错误是什么意思,如果我没有定义它,静态和常量之间到底有什么区别。 显然静态变量不返回任何东西? 一些帮助将不胜感激。 更新:问题仍未解决。 除了初始值设定项之外,还会出现以下新错误消息。 error: (near initialization for 's_data_points[0].high') int key0_buffer; void process_tuple(Tuple *t) { //Get key int key = t->key; //Get integer value, if present int value = t->value->int32; //Get string value, if present char string_value[32]

2021-09-20 21:47:22    分类:技术分享    c   pebble-sdk

iOS:找不到“PebbleKit/PebbleKit.h”文件问题(iOS: 'PebbleKit/PebbleKit.h' file not found Issue)

问题 我正在处理一个包含 Pebble Kit 框架的项目。 我在同一个项目中有两个目标。 当我在设备上运行项目时,它工作正常。 但是当我归档同一个项目以创建 IPA 时,它显示以下错误, PebbleWatch.h 文件中的词法或预处理器错误, 找不到“PebbleKit/PebbleKit.h”文件。 我多次清理项目并通过选择两个项目的参考两个重新在项目中包含相同的框架。 如何解决?

2021-09-16 00:49:07    分类:技术分享    ios   frameworks   pebble-watch   pebble-sdk

XMLHttpRequest 无法通过基本身份验证(XMLHttpRequest fails basic authentication)

问题 知道为什么在 Pebble JS Framework 中使用正确凭据的XMLHttpRequest在 Android 上无法进行基本身份验证,但在 iOS 上可以正常工作吗? 完全相同的代码,沿着以下几行: var req = new XMLHttpRequest(); req.open(method, url, true, user, pass); req.send(data); req.onreadystatechange = function() { ... } 从 Android Pebble 应用程序返回 401,但在 iOS 中正确验证。 回答1 我找到了一个在 Android 上对我有用的解决方法。 不知道为什么,但直接经过身份验证的请求: req.open(method, fullurl, true, user, pass); req.send(data); 对我不起作用 - 它总是返回 401。所以我尝试通过标头设置基本身份验证: req.open(method, fullurl, true); req.setRequestHeader("Authorization", "Basic " + Base64.encode(user + ":" + pass)); req.send(data); (Base64 取自此处:https:/

2021-08-31 08:23:43    分类:技术分享    ajax   xmlhttprequest   pebble-watch   pebble-sdk

initializer element not constant?

I am relatively knew to C and only learning pieces of it to publish a Pebble C/PebbleKitJS app to track buses. So far I have the data being processed on a Node server, and I am getting ready to have the data processed by a JS File. MY one problem however lies within the C Code. This code process data stored in a Key Dictionary sent from JS and assigns it to a variable for use below. By using #define var 9, I can successfully have the .high value set to 9. But through an int var, it fails and throws the error:initializer element not constant?? . What does this error mean, and what exactly is

2021-08-30 12:54:57    分类:问答    c   pebble-sdk