首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pebble time颜色配置

pebble time颜色配置
EN

Stack Overflow用户
提问于 2015-08-06 04:34:14
回答 1查看 155关注 0票数 0

我试着优化我的pebble time手表的配置。为了避免字符串比较,我将所有GColor值放入一个数组中,但它根本不起作用:(

数组:

代码语言:javascript
复制
static uint8_t colors[] = {
GColorInchwormARGB8,    //1
GColorSpringBudARGB8,    //2
GColorBrightGreenARGB8,    //3
GColorMintGreenARGB8,    //4
GColorScreaminGreenARGB8,    //5
GColorGreenARGB8,    //6
GColorMalachiteARGB8,    //7
};

从配置中读取数据:

代码语言:javascript
复制
static void in_recv_handler(DictionaryIterator *iterator, void *context)
{

  Tuple *t = dict_read_first(iterator);

  while (t != NULL){
    switch (t -> key){
      //++++++ background color +++++++
      case bgColor:
       persist_write_int(bgColor, t->value->int8);
      break;
      //++++++ time color ++++++
      case timeColor:
        persist_write_int(timeColor, t->value->int8);
      break;
    } 
     t = dict_read_next(iterator);
  } 
}

我尝试过uint8、uint16、uint32、int8、int16和int32。如果我使用int32,手表就会崩溃。

设置图层的颜色:

代码语言:javascript
复制
time_color = (GColor)colors[persist_read_int(timeColor)];

当我使用:

代码语言:javascript
复制
time_color = (GColor)colors[4];

此时将显示正确的颜色。

html页面的值:

代码语言:javascript
复制
 <select id="bg_select">
          <option class="inchworm" value="0">Inchworm</option>
          <option class="springBud" value="1">Spring Bud</option>
          <option class="brightGreen" value="2">Bright Green</option>
          <option class="mintGreen" value="3">Mint Green</option>
    </select>

有没有人有解决这个问题的建议?我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2015-08-29 23:08:24

根据事件的确切顺序,颜色值可能尚未保存。您是否正在检查该值是否存在?

代码语言:javascript
复制
if(persist_exists(timeColor)) {
  time_color = (GColor)colors[persist_read_int(timeColor)];
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31842302

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档