1
1

22 Commits

Author SHA1 Message Date
7679c3a7ff first blood ... err stripes 2016-01-25 23:47:14 +01:00
517d0180dc further performance improvements 2016-01-24 19:15:40 +01:00
a0454fb1cd code prettifications 2016-01-21 20:36:34 +01:00
2050b8c811 cleaned up types 2016-01-21 02:14:06 +01:00
a291b56e5e Fixed leading zero bug, added localized weekdays 2016-01-20 22:57:49 +01:00
a572e02813 localized weekdays 2016-01-19 23:59:05 +01:00
467173ad9e removed debug line 2016-01-19 21:12:11 +01:00
8913a7699a Bugfix for Battery Saver on 12h watch 2016-01-19 21:11:00 +01:00
48259f4ddc bugfixes, new color, weekday added 2016-01-19 00:55:48 +01:00
aeebe1ef80 added list of debug watches and handling mechanism 2016-01-17 06:56:05 +01:00
163f5ce393 added around-the-clock battery saver code 2016-01-17 02:44:40 +01:00
8cfdb4e198 updated gitignore to exclude xcode files 2016-01-17 02:44:11 +01:00
da68da4fe2 bugfixes for Aplite related to high contrast mode 2016-01-16 23:36:12 +01:00
1388670ce7 fixed bug and bundled up for release 2016-01-16 23:01:19 +01:00
e78178b587 changed is_charging for is_plugged 2016-01-16 05:00:38 +01:00
fdd2addc72 added animation free time 2016-01-16 03:49:16 +01:00
a87339364f fixed slot 0 animation bug, added contrast mode 2016-01-16 02:55:54 +01:00
0191667fa1 added bluetooth vibration alert 2016-01-14 21:53:45 +01:00
dd9251bfa7 added function to combine colors 2016-01-13 15:40:31 +01:00
1b51ee1af4 fixed excessive app_logs in animations 2016-01-11 22:18:39 +01:00
fcedbb11f6 Added option for center aligned date 2016-01-10 03:50:14 +01:00
b684308c34 updated gitignore to ignore build and locks 2016-01-10 01:11:04 +01:00
5 changed files with 834 additions and 170 deletions

33
.gitignore vendored
View File

@@ -30,3 +30,36 @@ Icon
Network Trash Folder
Temporary Items
.apdisk
.lock-waf_darwin_build
build
# Created by https://www.gitignore.io/api/xcode
### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.pbxproj
*.xcworkspacedata

View File

@@ -1,16 +1,25 @@
{
"appKeys": {
"background_color": 4,
"backlight": 17,
"btvibe": 12,
"center": 11,
"contrast": 13,
"debugwatch": 50,
"eu_date": 1,
"invert": 9,
"large_mode": 0,
"leading_zero": 3,
"monochrome": 10,
"nightsaver": 14,
"ns_start": 15,
"ns_stop": 16,
"number_base_color": 5,
"number_variation": 6,
"ornament_base_color": 7,
"ornament_variation": 8,
"quick_start": 2
"quick_start": 2,
"weekday": 18
},
"capabilities": [
"configurable"
@@ -29,7 +38,7 @@
"chalk"
],
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
"versionLabel": "4.1",
"versionLabel": "4.11",
"watchapp": {
"watchface": true
}

109
src/intersection.h Normal file
View File

@@ -0,0 +1,109 @@
#include <pebble.h>
#define DONT_INTERSECT 0
#define DO_INTERSECT 1
#define COLLINEAR 2
#define SAME_SIGNS( a, b ) \
(((long) ((unsigned long) a ^ (unsigned long) b)) >= 0 )
int lines_intersect(
x1, y1,
x2, y2,
x3, y3,
x4, y4,
x,
y
)
long x1, y1, x2, y2, x3, y3, x4, y4, *x, *y;
{
long a1, a2, b1, b2, c1, c2; /* Coefficients of line eqns. */
long r1, r2, r3, r4; /* 'Sign' values */
long denom, offset, num; /* Intermediate values */
a1 = y2 - y1;
b1 = x1 - x2;
c1 = x2 * y1 - x1 * y2;
r3 = a1 * x3 + b1 * y3 + c1;
r4 = a1 * x4 + b1 * y4 + c1;
if ( r3 != 0 &&
r4 != 0 &&
SAME_SIGNS( r3, r4 ))
return ( DONT_INTERSECT );
a2 = y4 - y3;
b2 = x3 - x4;
c2 = x4 * y3 - x3 * y4;
r1 = a2 * x1 + b2 * y1 + c2;
r2 = a2 * x2 + b2 * y2 + c2;
if ( r1 != 0 &&
r2 != 0 &&
SAME_SIGNS( r1, r2 ))
return ( DONT_INTERSECT );
denom = a1 * b2 - a2 * b1;
if ( denom == 0 )
return ( COLLINEAR );
offset = denom < 0 ? - denom / 2 : denom / 2;
num = b1 * c2 - b2 * c1;
*x = ( num < 0 ? num - offset : num + offset ) / denom;
num = a2 * c1 - a1 * c2;
*y = ( num < 0 ? num - offset : num + offset ) / denom;
return ( DO_INTERSECT );
}
#define INTERSECTION_NONE 0
#define INTERSECTION_PARTIAL 1
#define INTERSECTION_FULL 2
typedef struct {
uint8_t success;
GPoint p1;
GPoint p2;
} Intersection;
Intersection rectintersect(GPoint p1, GPoint p2, GRect rect) {
long x,y;
long x1=0,y1=0,x2=0,y2=0;
bool intersection = false, final_intersection = false;
if (lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x, rect.origin.y, rect.origin.x, rect.origin.y+rect.size.h, &x, &y) == DO_INTERSECT) {
x1 = x; y1 = y; intersection = true;
}
if (lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x, rect.origin.y, rect.origin.x+rect.size.w, rect.origin.y, &x, &y) == DO_INTERSECT) {
if (!intersection) {
x1 = x; y1 = y; intersection = true;
} else if (x != x1 && y != y1) {
x2 = x; y2 = y; final_intersection = true;
}
}
if (!final_intersection && lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x, rect.origin.y+rect.size.h, rect.origin.x+rect.size.w, rect.origin.y+rect.size.h, &x, &y) == DO_INTERSECT) {
if (!intersection) {
x1 = x; y1 = y; intersection = true;
} else if (x != x1 && y != y1) {
x2 = x; y2 = y; final_intersection = true;
}
}
if (!final_intersection && lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x+rect.size.w, rect.origin.y, rect.origin.x+rect.size.w, rect.origin.y+rect.size.h, &x, &y) == DO_INTERSECT) {
if (!intersection) {
x1 = x; y1 = y;
} else if (x != x1 && y != y1) {
x2 = x; y2 = y; final_intersection = true;
}
}
if(final_intersection) {
return (Intersection) { .success = INTERSECTION_FULL, .p1 = (GPoint) { .x = x1, .y = y1 }, .p2 = (GPoint) { .x = x2, .y = y2 } };
} else if (intersection) {
return (Intersection) { .success = INTERSECTION_PARTIAL, .p1 = (GPoint) { .x = x1, .y = y1 }, .p2 = (GPoint) { .x = x2, .y = y2 } };
} else {
return (Intersection) { .success = INTERSECTION_NONE, .p1 = (GPoint) { .x = x1, .y = y1 }, .p2 = (GPoint) { .x = x2, .y = y2 } };
}
}

View File

@@ -1,5 +1,33 @@
String.prototype.hashCode = function(){
var hash = 0;
if (this.length === 0) return hash;
for (var i = 0; i < this.length; i++) {
var char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
};
var debugwatches = Array(
1568511776, //c
1135189913, //b
-826258655, //a
-1783317168, //em
91860716, //a sl
-1462573071, //b sl
244993878 //c sl
);
var tokenhash;
Pebble.addEventListener('ready', function() {
console.log('PebbleKit JS ready!');
console.log('PebbleKit JS ready!');
console.log('WatchToken '+Pebble.getWatchToken());
});
Pebble.addEventListener('appmessage', function() {
console.log('got appmessage');
});
Pebble.addEventListener('showConfiguration', function() {
@@ -7,36 +35,54 @@ Pebble.addEventListener('showConfiguration', function() {
if(Pebble.getActiveWatchInfo) {
watch = Pebble.getActiveWatchInfo();
}
var url='http://pebble.lastfuture.de/config/squared40/';
var url='http://pebble.lastfuture.de/config/squared48/';
url += "?model="+watch.model;
if (watch.platform == "basalt") {
url += "?rect=true";
url += "&rect=true";
} else if (watch.platform == "aplite") {
url += "?rect=true&bw=true";
url += "&rect=true&bw=true";
}
tokenhash = Pebble.getWatchToken().hashCode();
if (debugwatches.indexOf(tokenhash) > -1) {
url += "&debug=true";
}
console.log('Showing configuration page: '+url);
Pebble.openURL(url);
});
Pebble.addEventListener('webviewclosed', function(e) {
var configData = JSON.parse(decodeURIComponent(e.response));
console.log('Configuration page returned: '+JSON.stringify(configData));
if (configData.background_color) {
Pebble.sendAppMessage({
large_mode: 0+(configData.large_mode === 'true'),
eu_date: 0+(configData.eu_date === 'true'),
quick_start: 0+(configData.quick_start === 'true'),
leading_zero: 0+(configData.leading_zero === 'true'),
background_color: configData.background_color,
number_base_color: configData.number_base_color,
number_variation: configData.number_variation,
ornament_base_color: configData.ornament_base_color,
ornament_variation: configData.ornament_variation,
invert: 0+(configData.invert === 'true'),
monochrome: 0+(configData.monochrome === 'true')
}, function() {
console.log('Send successful!');
}, function() {
console.log('Send failed!');
});
}
var configData = JSON.parse(decodeURIComponent(e.response));
console.log('Configuration page returned: '+JSON.stringify(configData));
var options = {
large_mode: 0+(configData.large_mode === 'true'),
eu_date: 0+(configData.eu_date === 'true'),
quick_start: 0+(configData.quick_start === 'true'),
leading_zero: 0+(configData.leading_zero === 'true'),
background_color: configData.background_color,
number_base_color: configData.number_base_color,
number_variation: configData.number_variation,
ornament_base_color: configData.ornament_base_color,
ornament_variation: configData.ornament_variation,
invert: 0+(configData.invert === 'true'),
monochrome: 0+(configData.monochrome === 'true'),
center: 0+(configData.center === 'true'),
btvibe: 0+(configData.btvibe === 'true'),
contrast: 0+(configData.contrast === 'true'),
nightsaver: 0+(configData.nightsaver === 'true'),
ns_start: parseInt(configData.ns_start),
ns_stop: parseInt(configData.ns_stop),
backlight: 0+(configData.backlight === 'true'),
weekday: 0+(configData.weekday === 'true'),
};
if (debugwatches.indexOf(tokenhash) > -1) {
console.log('Debug Watch with Hash '+tokenhash+'. Setting debug flag on watchface …');
options.debugwatch = 1;
}
if (configData.background_color) {
Pebble.sendAppMessage(options, function() {
console.log('Send successful!');
}, function() {
console.log('Send failed!');
});
}
});

File diff suppressed because it is too large Load Diff