Skip to content

Commit

Permalink
initial commit working v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cemheren committed Nov 26, 2022
0 parents commit 212b454
Show file tree
Hide file tree
Showing 18 changed files with 1,680 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
developer_key
bin/**
output/**
venu2plus/**
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "monkeyc",
"request": "launch",
"name": "Run App",
"stopAtLaunch": false,
"device": "${command:GetTargetDevice}"
},
{
"type": "monkeyc",
"request": "launch",
"name": "Run Tests",
"runTests": true,
"device": "${command:GetTargetDevice}"
}
]
}
Binary file added instinct/test2.prg
Binary file not shown.
855 changes: 855 additions & 0 deletions instinct/test2.prg.debug.xml

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. -->
<iq:manifest version="3" xmlns:iq="http://www.garmin.com/xml/connectiq">
<!--
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
to update the application attributes.
-->
<iq:application id="c974075a-d83f-4cd5-bb1d-e8fa1a5e892f" type="watchface" name="@Strings.AppName" entry="test2App" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.3.0">
<!--
Use the following from the Visual Studio Code comand palette to edit
the build targets:
"Monkey C: Set Products by Version" - Lets you add all producs that meet the
minimum SDK version of the application
"Monkey C: Edit Products" - Lets you add or remove any product
-->
<iq:products>
<iq:product id="instinct2s"/>
</iq:products>
<!--
Use "Monkey C: Edit Permissions" from the Visual Studio Code command
palette to update permissions.
-->
<iq:permissions>
<iq:uses-permission id="SensorHistory"/>
<iq:uses-permission id="UserProfile"/>
<iq:uses-permission id="Positioning"/>
</iq:permissions>
<!--
Use "Monkey C: Edit Languages" from the Visual Studio Code command
palette to edit your compatible language list.
-->
<iq:languages/>
<!--
Use "Monkey C: Configure Monkey Barrel" from the Visual Studio Code
command palette to edit the included barrels.
-->
<iq:barrels/>
</iq:application>
</iq:manifest>
1 change: 1 addition & 0 deletions monkey.jungle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
project.manifest = manifest.xml
3 changes: 3 additions & 0 deletions resources/drawables/drawables.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<drawables>
<bitmap id="LauncherIcon" filename="launcher_icon.png" />
</drawables>
Binary file added resources/drawables/launcher_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/layouts/layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<layout id="WatchFace">
<label id="TimeLabel" x="50" y="50" font="Graphics.FONT_LARGE" justification="Graphics.TEXT_JUSTIFY_CENTER" color="Graphics.COLOR_WHITE" />
<label id="HeartRate" x="center" y="center" font="Graphics.FONT_LARGE" justification="Graphics.TEXT_JUSTIFY_CENTER" color="Graphics.COLOR_WHITE" />
</layout>
3 changes: 3 additions & 0 deletions resources/strings/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<strings>
<string id="AppName">test2</string>
</strings>
180 changes: 180 additions & 0 deletions source/coordinate.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
import Toybox.Graphics;

class Coordinate
{
public var X;
public var Y;

public var W;

function initialize(x, y)
{
X = x;
Y = y;
}

function drawLargeTextAt(dc, text)
{
dc.drawText(
X, // gets the width of the device and divides by 2
Y, // gets the height of the device and divides by 2
Graphics.FONT_NUMBER_THAI_HOT, // sets the font size
text, // the String to display
Graphics.TEXT_JUSTIFY_CENTER // sets the justification for the text
);
}

function drawSmallTextAt(dc, text)
{
dc.drawText(
X, // gets the width of the device and divides by 2
Y, // gets the height of the device and divides by 2
2, // sets the font size
text, // the String to display
Graphics.TEXT_JUSTIFY_CENTER // sets the justification for the text
);
}

function drawTinyTextAt(dc, text)
{
dc.drawText(
X, // gets the width of the device and divides by 2
Y, // gets the height of the device and divides by 2
0, // sets the font size
text, // the String to display
Graphics.TEXT_JUSTIFY_CENTER // sets the justification for the text
);
}

function drawHorizontalLine(dc, width, length)
{
dc.setPenWidth(width);
dc.drawLine(X, Y, X + length, Y);
}

function drawVerticalLine(dc, width, length)
{
dc.setPenWidth(width);
dc.drawLine(X, Y, X, Y + length);
}

function drawPercentageCurvedBarChart(dc, height as Double, width as Double, data as PlottableArray)
{
if(data.size() <= 0){return;}

var min = 0;
var max = 100;

// degrees start from 180 and go to 360
var r = 24;
var rLen = 180;
var interval = rLen / (data.data.size() - 1);
var leftAngle = 180;

dc.setPenWidth(1);
// dc.drawLine(X - 4, Y, X - 4, Y + height);
// dc.drawLine(X - 4, Y, X - 2 + width, Y);

dc.drawArc(X, Y, r, 0, leftAngle, leftAngle + rLen);

dc.setPenWidth(1);

var bottomY = Y + height;
var onePercent = r / (max - min);

for (var i = 0; i < data.size(); ++i)
{
var item = data.data[i];
var itemScale = 1 - (item/100.0);

var angle = Math.toRadians(leftAngle + (i * interval));
var x_for_i = X - r * Math.cos(angle);
var y_for_i = Y - r * Math.sin(angle);

var topX = X + ((x_for_i - X) * itemScale);
var topY = Y + ((y_for_i - Y) * itemScale);

dc.drawLine(x_for_i, y_for_i, topX, topY);
}
}

function drawPercentageBarChart(dc, height as Double, width as Double, data as PlottableArray)
{
if(data.data.size() <= 0){return;}

var min = 0;
var max = 100;

dc.setPenWidth(1);
dc.drawLine(X - 4, Y, X - 4, Y + height);
dc.drawLine(X - 4, Y, X - 2 + width, Y);

dc.setPenWidth(2);

var bottomY = Y + height;

var interval = width / data.data.size();
var onePercent = height / (max - min);

for (var i = 0; i < data.data.size(); ++i)
{
var item = data.data[i];
var itemHeight = onePercent * item;

var leftShift = interval * i;

dc.drawLine(X + leftShift, bottomY, X + leftShift, bottomY - itemHeight);
}
}

function drawArray(dc, height as Double, data as PlottableArray, minOverride, maxOverride)
{
var max = data.max > maxOverride ? data.max : maxOverride;
var min = data.min < minOverride ? data.min : minOverride;
var diff = (max - min);
var oneHR = height / diff;

dc.setPenWidth(1);

var eightyP = Y + ((max - 80) * oneHR);
dc.drawLine(X - 1, eightyP, X + 2, eightyP);

var oneTwentyP = Y + ((max - 110) * oneHR);
dc.drawLine(X - 1, oneTwentyP, X + 2, oneTwentyP);

dc.drawLine(X - 1, oneTwentyP, X - 1, eightyP);

dc.setPenWidth(2);

var prevX = -1;
var prevY = -1;

var dX = X + 5;

for (var i = 0; i < data.data.size() && i + dX <= 156; ++i)
{
var item = data.data[i];

if(item == data.INVALID)
{
continue;
}

var hrDiffFromMax = max - item;

var currentHR = oneHR * hrDiffFromMax;

if(prevX == -1)
{
prevX = dX + i;
prevY = Y + currentHR;
dc.drawPoint(dX + i, Y + currentHR);
continue;
}

dc.drawLine(prevX, prevY, dX + i, Y + currentHR);
prevX = dX + i;
prevY = Y + currentHR;
}
}
}
83 changes: 83 additions & 0 deletions source/forecast.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class ForecastResult
{
function initialize(data, rain)
{
Data = data;
Rain = rain;
}

public var Data;
public var Rain;
}

class Forecast
{
using Toybox.Time;
using Toybox.Time.Gregorian;

private static var cacheExpiry;
private static var cacheValue;

private static var HALF_HOUR;

function initialize()
{
HALF_HOUR = new Time.Duration(1800);
}

function getNextEvent(current)
{
var moment = Time.now();

if(cacheExpiry == null || cacheExpiry.compare(moment) < 0)
{
if(current != null)
{
var forecast = Toybox.Weather.getHourlyForecast();
if(forecast != null)
{
var currPrecip = current.precipitationChance;
var graphData = new PlottableArray(-1000);
var rain = false;

for (var i = 0; i < forecast.size(); ++i)
{
graphData.add(forecast[i].precipitationChance);

if(i < 6 && forecast[i].precipitationChance >= 50) //&& forecast[i].precipitationChance > currPrecip
{
rain = true;
// var rainTime = Toybox.Time.Gregorian.info(forecast[i].forecastTime, Time.FORMAT_MEDIUM);
// saliencyAreaLineOneCoor.drawSmallTextAt(dc, "rain @");
// saliencyAreaLineTwoCoor.drawSmallTextAt(dc, Lang.format("$1$:$2$", [rainTime.hour, rainTime.min.format("%02d")]));
// return;
}

if(i > 5 && rain == false)
{
break;
}
}

if(rain)
{
cacheExpiry = moment.add(HALF_HOUR);
cacheValue = new ForecastResult(graphData, true);
// saliencyAreaGraphCoor.drawPercentageBarChart(dc, 25.0 /*height*/, 40.0, graphData);
return cacheValue;
}else
{
cacheExpiry = moment.add(HALF_HOUR);
cacheValue = new ForecastResult(graphData, false);
return cacheValue;
}
}

return new ForecastResult(null, false);
}
return cacheValue;
}else{
return cacheValue;
}
}
}
Loading

0 comments on commit 212b454

Please sign in to comment.