Compare commits
19 Commits
4.4
...
archive/sq
| Author | SHA1 | Date | |
|---|---|---|---|
| 7679c3a7ff | |||
| 517d0180dc | |||
| a0454fb1cd | |||
| 2050b8c811 | |||
| a291b56e5e | |||
| a572e02813 | |||
| 467173ad9e | |||
| 8913a7699a | |||
| 48259f4ddc | |||
| aeebe1ef80 | |||
| 163f5ce393 | |||
| 8cfdb4e198 | |||
| da68da4fe2 | |||
| 1388670ce7 | |||
| e78178b587 | |||
| fdd2addc72 | |||
| a87339364f | |||
| 0191667fa1 | |||
| dd9251bfa7 |
31
.gitignore
vendored
31
.gitignore
vendored
@@ -32,3 +32,34 @@ Temporary Items
|
|||||||
.apdisk
|
.apdisk
|
||||||
.lock-waf_darwin_build
|
.lock-waf_darwin_build
|
||||||
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
|
||||||
|
|||||||
12
appinfo.json
12
appinfo.json
@@ -1,17 +1,25 @@
|
|||||||
{
|
{
|
||||||
"appKeys": {
|
"appKeys": {
|
||||||
"background_color": 4,
|
"background_color": 4,
|
||||||
|
"backlight": 17,
|
||||||
|
"btvibe": 12,
|
||||||
"center": 11,
|
"center": 11,
|
||||||
|
"contrast": 13,
|
||||||
|
"debugwatch": 50,
|
||||||
"eu_date": 1,
|
"eu_date": 1,
|
||||||
"invert": 9,
|
"invert": 9,
|
||||||
"large_mode": 0,
|
"large_mode": 0,
|
||||||
"leading_zero": 3,
|
"leading_zero": 3,
|
||||||
"monochrome": 10,
|
"monochrome": 10,
|
||||||
|
"nightsaver": 14,
|
||||||
|
"ns_start": 15,
|
||||||
|
"ns_stop": 16,
|
||||||
"number_base_color": 5,
|
"number_base_color": 5,
|
||||||
"number_variation": 6,
|
"number_variation": 6,
|
||||||
"ornament_base_color": 7,
|
"ornament_base_color": 7,
|
||||||
"ornament_variation": 8,
|
"ornament_variation": 8,
|
||||||
"quick_start": 2
|
"quick_start": 2,
|
||||||
|
"weekday": 18
|
||||||
},
|
},
|
||||||
"capabilities": [
|
"capabilities": [
|
||||||
"configurable"
|
"configurable"
|
||||||
@@ -30,7 +38,7 @@
|
|||||||
"chalk"
|
"chalk"
|
||||||
],
|
],
|
||||||
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
|
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
|
||||||
"versionLabel": "4.4",
|
"versionLabel": "4.11",
|
||||||
"watchapp": {
|
"watchapp": {
|
||||||
"watchface": true
|
"watchface": true
|
||||||
}
|
}
|
||||||
|
|||||||
109
src/intersection.h
Normal file
109
src/intersection.h
Normal 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 } };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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() {
|
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() {
|
Pebble.addEventListener('showConfiguration', function() {
|
||||||
@@ -7,37 +35,54 @@ Pebble.addEventListener('showConfiguration', function() {
|
|||||||
if(Pebble.getActiveWatchInfo) {
|
if(Pebble.getActiveWatchInfo) {
|
||||||
watch = Pebble.getActiveWatchInfo();
|
watch = Pebble.getActiveWatchInfo();
|
||||||
}
|
}
|
||||||
var url='http://pebble.lastfuture.de/config/squared43/';
|
var url='http://pebble.lastfuture.de/config/squared48/';
|
||||||
|
url += "?model="+watch.model;
|
||||||
if (watch.platform == "basalt") {
|
if (watch.platform == "basalt") {
|
||||||
url += "?rect=true";
|
url += "&rect=true";
|
||||||
} else if (watch.platform == "aplite") {
|
} 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);
|
console.log('Showing configuration page: '+url);
|
||||||
Pebble.openURL(url);
|
Pebble.openURL(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
Pebble.addEventListener('webviewclosed', function(e) {
|
Pebble.addEventListener('webviewclosed', function(e) {
|
||||||
var configData = JSON.parse(decodeURIComponent(e.response));
|
var configData = JSON.parse(decodeURIComponent(e.response));
|
||||||
console.log('Configuration page returned: '+JSON.stringify(configData));
|
console.log('Configuration page returned: '+JSON.stringify(configData));
|
||||||
if (configData.background_color) {
|
var options = {
|
||||||
Pebble.sendAppMessage({
|
large_mode: 0+(configData.large_mode === 'true'),
|
||||||
large_mode: 0+(configData.large_mode === 'true'),
|
eu_date: 0+(configData.eu_date === 'true'),
|
||||||
eu_date: 0+(configData.eu_date === 'true'),
|
quick_start: 0+(configData.quick_start === 'true'),
|
||||||
quick_start: 0+(configData.quick_start === 'true'),
|
leading_zero: 0+(configData.leading_zero === 'true'),
|
||||||
leading_zero: 0+(configData.leading_zero === 'true'),
|
background_color: configData.background_color,
|
||||||
background_color: configData.background_color,
|
number_base_color: configData.number_base_color,
|
||||||
number_base_color: configData.number_base_color,
|
number_variation: configData.number_variation,
|
||||||
number_variation: configData.number_variation,
|
ornament_base_color: configData.ornament_base_color,
|
||||||
ornament_base_color: configData.ornament_base_color,
|
ornament_variation: configData.ornament_variation,
|
||||||
ornament_variation: configData.ornament_variation,
|
invert: 0+(configData.invert === 'true'),
|
||||||
invert: 0+(configData.invert === 'true'),
|
monochrome: 0+(configData.monochrome === 'true'),
|
||||||
monochrome: 0+(configData.monochrome === 'true'),
|
center: 0+(configData.center === 'true'),
|
||||||
center: 0+(configData.center === 'true')
|
btvibe: 0+(configData.btvibe === 'true'),
|
||||||
}, function() {
|
contrast: 0+(configData.contrast === 'true'),
|
||||||
console.log('Send successful!');
|
nightsaver: 0+(configData.nightsaver === 'true'),
|
||||||
}, function() {
|
ns_start: parseInt(configData.ns_start),
|
||||||
console.log('Send failed!');
|
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!');
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
730
src/squared.c
730
src/squared.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user