mirror of
https://github.com/google/pebble.git
synced 2025-08-23 08:17:27 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
20
sdk/defaults/rocky/app.js
Normal file
20
sdk/defaults/rocky/app.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// https://developer.pebble.com/docs/pebblekit-js/Pebble/#on
|
||||
Pebble.on('message', function(event) {
|
||||
console.log('Message received from watch:', event.data);
|
||||
});
|
84
sdk/defaults/rocky/index.js
Normal file
84
sdk/defaults/rocky/index.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var rocky = require('rocky');
|
||||
|
||||
// An object to cache our date & time values,
|
||||
// to minimize computations in the draw handler.
|
||||
var clockData = {
|
||||
time: '',
|
||||
date: ''
|
||||
};
|
||||
|
||||
// Every minute
|
||||
// https://developer.pebble.com/docs/rockyjs/rocky/#on
|
||||
rocky.on('minutechange', function(event) {
|
||||
// Current date/time
|
||||
// https://developer.pebble.com/docs/rockyjs/Date/
|
||||
var d = event.date;
|
||||
|
||||
// Get current time, based on 12h or 24h format (01:00 or 1:00 AM)
|
||||
clockData.time = d.toLocaleTimeString().replace(/:\d+($$| )/, '$$1');
|
||||
|
||||
// Day of month
|
||||
var day = d.toLocaleDateString(undefined, ({day: 'numeric'}));
|
||||
|
||||
// Month name
|
||||
var month = d.toLocaleDateString(undefined, ({month: 'long'}));
|
||||
|
||||
// Date
|
||||
clockData.date = (day + ' ' + month);
|
||||
|
||||
// Force screen redraw
|
||||
rocky.requestDraw();
|
||||
});
|
||||
|
||||
// Redraw the screen
|
||||
rocky.on('draw', function(event) {
|
||||
// Drawing canvas
|
||||
var ctx = event.context;
|
||||
|
||||
// Clear the canvas
|
||||
// https://developer.pebble.com/docs/rockyjs/CanvasRenderingContext2D/#Canvas
|
||||
ctx.clearRect(0, 0, ctx.canvas.clientWidth, ctx.canvas.clientHeight);
|
||||
|
||||
// UnobstructedArea
|
||||
// https://developer.pebble.com/docs/rockyjs/CanvasRenderingContext2D/#Canvas
|
||||
var offsetY = (ctx.canvas.clientHeight - ctx.canvas.unobstructedHeight) / 2;
|
||||
var centerX = ctx.canvas.unobstructedWidth / 2;
|
||||
|
||||
// Text formatting
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.textAlign = 'center';
|
||||
|
||||
// Time font
|
||||
// https://developer.pebble.com/docs/rockyjs/CanvasRenderingContext2D/#font
|
||||
ctx.font = '26px bold Leco-numbers-am-pm';
|
||||
|
||||
// Time
|
||||
ctx.fillText(clockData.time, centerX, (66 - offsetY));
|
||||
|
||||
// Date font
|
||||
ctx.font = '18px bold Gothic';
|
||||
|
||||
// Date
|
||||
ctx.fillText(clockData.date, centerX, (94 - offsetY));
|
||||
});
|
||||
|
||||
|
||||
// Send a single message to the Phone
|
||||
// https://developer.pebble.com/docs/rockyjs/rocky/#postMessage
|
||||
rocky.postMessage("This arrives on the phone via bluetooth!");
|
25
sdk/defaults/rocky/package.json
Normal file
25
sdk/defaults/rocky/package.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "${project_name}",
|
||||
"author": "MakeAwesomeHappen",
|
||||
"version": "1.0.0",
|
||||
"keywords": ["pebble-app"],
|
||||
"private": true,
|
||||
"dependencies": {},
|
||||
"pebble": {
|
||||
"main": {
|
||||
"rockyjs": "src/rocky/index.js",
|
||||
"pkjs": "src/pkjs/index.js"
|
||||
},
|
||||
"displayName": "${display_name}",
|
||||
"uuid": "${uuid}",
|
||||
"projectType": "rocky",
|
||||
"sdkVersion": "${sdk_version}",
|
||||
"enableMultiJS": true,
|
||||
"watchapp": {
|
||||
"watchface": true
|
||||
},
|
||||
"resources": {
|
||||
"media": []
|
||||
}
|
||||
}
|
||||
}
|
30
sdk/defaults/rocky/wscript
Normal file
30
sdk/defaults/rocky/wscript
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# This file is the default set of rules to compile a Pebble application.
|
||||
#
|
||||
# Feel free to customize this to your needs.
|
||||
#
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
|
||||
def options(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
|
||||
def configure(ctx):
|
||||
"""
|
||||
This method is used to configure your build. ctx.load(`pebble_sdk`) automatically configures
|
||||
a build for each valid platform in `targetPlatforms`. Platform-specific configuration: add your
|
||||
change after calling ctx.load('pebble_sdk') and make sure to set the correct environment first.
|
||||
Universal configuration: add your change prior to calling ctx.load('pebble_sdk').
|
||||
"""
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
|
||||
def build(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
ctx.pbl_bundle(js=ctx.path.ant_glob(['src/pkjs/**/*.js',
|
||||
'src/pkjs/**/*.json',
|
||||
'src/common/**/*.js']),
|
||||
js_entry_file='src/pkjs/index.js',
|
||||
bin_type='rocky')
|
Loading…
Add table
Add a link
Reference in a new issue