2015-02-10 90 views
2

我在工作中爲服務器製作了一個界面,以驗證打印服務器和打印機是否動態啓動並將其反饋回Pebble。功能很好,我遇到的問題是菜單。我會加載菜單,然後開始向下滾動,並且突然間物品不在那裏。它需要大約6秒鐘,然後他們出現。滾動向上和向下都是真的。有很多菜單選項,但即使在菜單中有六個項目也會這樣做。Pebble.js菜單項渲染速度慢

這僅僅是處理能力或pebble.js腳本的限制,還是我做錯了什麼?

- 更新 - 爲了將來的參考,重新啓動Pebble使渲染顯着加快。新手的錯誤...

var UI = require('ui'); 
 
var ajax = require('ajax'); 
 

 
var main = new UI.Card({ 
 
    title: 'Pebble Interface', 
 
    icon: 'images/mattec.png', 
 
    body: 'Press Top Button to open Cell Picker.' 
 
}); 
 

 
main.show(); 
 

 
main.on('click', 'up', function(e) { 
 
    var menu = new UI.Menu({ 
 
    sections: [{ 
 
     items: [{ 
 
      title: 'ALMSC1' 
 
     }, { 
 
      title: 'ALMSC2' 
 
     }, { 
 
      title: 'DL 1' 
 
     }, { 
 
      title: 'DL 2' 
 
     }, { 
 
      title: 'DL 3' 
 
     }, { 
 
      title: 'DL 4' 
 
     }, { 
 
      title: 'EDGER' 
 
     }, { 
 
      title: 'EPOXYA' 
 
     }, { 
 
      title: 'EPOXYP' 
 
     }, { 
 
      title: 'FORK 1' 
 
     }, { 
 
      title: 'FORK 2' 
 
     }, { 
 
      title: 'HICK 1' 
 
     }, { 
 
      title: 'HICK 2' 
 
     }, { 
 
      title: 'LG 1' 
 
     }, { 
 
      title: 'LG 2' 
 
     }, { 
 
      title: 'LG 3' 
 
     }, { 
 
      title: 'LG 4' 
 
     }, { 
 
      title: 'LG 5' 
 
     }, { 
 
      title: 'LG 6' 
 
     }, { 
 
      title: 'PHD 1' 
 
     }, { 
 
      title: 'PHD 2' 
 
     }, { 
 
      title: 'PHD 3' 
 
     }, { 
 
      title: 'PHD 4' 
 
     }, { 
 
      title: 'SPRLTE' 
 
     }, { 
 
      title: 'STEEL1' 
 
     }, { 
 
      title: 'STEEL2' 
 
     }, { 
 
      title: 'STEEL3' 
 
     }, { 
 
      title: 'STEEL4' 
 
     }, { 
 
      title: 'STEEL5' 
 
     }, { 
 
      title: 'STEEL6' 
 
     }, { 
 
      title: 'SVL 01' 
 
     }, { 
 
      title: 'SVL 02' 
 
     }, { 
 
      title: 'SVL 03' 
 
     }, { 
 
      title: 'SVL 04' 
 
     }, { 
 
      title: 'SVL 05' 
 
     }, { 
 
      title: 'SVL 06' 
 
     }, { 
 
      title: 'SVL 07' 
 
     }, { 
 
      title: 'SVL 08' 
 
     }, { 
 
      title: 'SVL 09' 
 
     }, { 
 
      title: 'SVL 10' 
 
     }, { 
 
      title: 'SVL 11' 
 
     }, { 
 
      title: 'SVL 12' 
 
     }, { 
 
      title: 'SVL 13' 
 
     }, { 
 
      title: 'SVL 14' 
 
     }, { 
 
      title: 'SVL 15' 
 
     }, { 
 
      title: 'SVL 16' 
 
     }, { 
 
      title: 'SVL 17' 
 
     }, { 
 
      title: 'SVL 18' 
 
     }, { 
 
      title: 'SVLCUB' 
 
     }, { 
 
      title: 'TAMP 1' 
 
     }, { 
 
      title: 'TAMP 2' 
 
     }, { 
 
      title: 'WEEDER' 
 
     }] 
 
     }] 
 
    }); 
 
    menu.on('select', function(e) { 
 
     ajax({ url: 'http://myserver/test/pebble/oldpebble.php?cell=' + e.item.title, type:'xml' }, function(data){ 
 
     var istag = data.match(/<istag>(.*?)<\/istag>/)[1]; 
 
      istag = istag.replace(/&quot;/g, "\""); 
 
     var psname = data.match(/<psname>(.*?)<\/psname>/)[1]; 
 
      psname = psname.replace(/&quot;/g, "\""); 
 
     var psip = data.match(/<psip>(.*?)<\/psip>/)[1]; 
 
      psip = psip.replace(/&quot;/g, "\""); 
 
     var upcstatus = data.match(/<upcstatus>(.*?)<\/upcstatus>/)[1]; 
 
      upcstatus = upcstatus.replace(/&quot;/g, "\""); 
 
     var i2of5status = data.match(/<i2of5status>(.*?)<\/i2of5status>/)[1]; 
 
      i2of5status = i2of5status.replace(/&quot;/g, "\""); 
 
     var content = istag + "\n\nPrint Server\n" + psname + "\n" + psip + "\n" + "UPC - " + upcstatus + "\nI2of5 - " + i2of5status; 
 
     var detailCard = new UI.Card({ 
 
      title:e.item.title, 
 
      body: content, 
 
      scrollable: true, 
 
      style: 'small' 
 
     }); 
 
     detailCard.show(); 
 
     }); 
 
    }); 
 
    menu.show(); 
 
});

回答

1

Pebble.js列出的數據流按需觀看。六秒聽起來很多,我沒有看到那麼多的延遲,但沒有什麼可以做到的,你可以做的不多,重新構建與C SDK的應用程序。

+1

謝謝......看起來我可能需要開始學習C. – MattW 2015-02-11 13:27:11

+0

@MattW我覺得你的痛苦,我有完全相同的問題。 – Cj1m 2015-05-14 14:51:44