Skip to content

Commit

Permalink
Initialized repo and monkeyC project
Browse files Browse the repository at this point in the history
  • Loading branch information
Antti Viitala committed Oct 5, 2022
0 parents commit ea6d87c
Show file tree
Hide file tree
Showing 14 changed files with 464 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/mattermetrics-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"settings":[{"key":"BackgroundColor","valueType":"number","defaultValue":0,"configTitle":"BackgroundColorTitle","configPrompt":null,"configType":"list","configError":null,"configHelpUrl":null,"configReadonly":false,"configRequired":false,"configOptions":[{"display":"ColorBlack","value":0},{"display":"ColorDarkGray","value":5592405},{"display":"ColorLightGray","value":11184810},{"display":"ColorWhite","value":16777215}],"configMin":null,"configMax":null,"configMaxLength":null},{"key":"ForegroundColor","valueType":"number","defaultValue":16711680,"configTitle":"ForegroundColorTitle","configPrompt":null,"configType":"list","configError":null,"configHelpUrl":null,"configReadonly":false,"configRequired":false,"configOptions":[{"display":"ColorBlack","value":0},{"display":"ColorBlue","value":255},{"display":"ColorRed","value":16711680},{"display":"ColorWhite","value":16777215}],"configMin":null,"configMax":null,"configMaxLength":null},{"key":"UseMilitaryFormat","valueType":"boolean","defaultValue":false,"configTitle":"MilitaryFormatTitle","configPrompt":null,"configType":"boolean","configError":null,"configHelpUrl":null,"configReadonly":false,"configRequired":false,"configOptions":null,"configMin":null,"configMax":null,"configMaxLength":null}],"supportsLiveValidation":false,"languages":{"valyrian":{"ColorLightGray":"Light Gray","ColorBlue":"Blue","ColorRed":"Red","ForegroundColorTitle":"Foreground Color","BackgroundColorTitle":"Background Color","ColorDarkGray":"Dark Gray","MilitaryFormatTitle":"Military Format for 24 Hour Time","ColorBlack":"Black","ColorWhite":"White","AppName":"mattermetrics"}}}
Binary file added bin/mattermetrics.prg
Binary file not shown.
250 changes: 250 additions & 0 deletions bin/mattermetrics.prg.debug.xml

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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="c5b0c709-5f22-4365-93be-37440458d49e" type="watchface" name="@Strings.AppName" entry="mattermetricsApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.0.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="fenix6pro"/>
</iq:products>
<!--
Use "Monkey C: Edit Permissions" from the Visual Studio Code command
palette to update permissions.
-->
<iq:permissions/>
<!--
Use "Monkey C: Edit Languages" from the Visual Studio Code command
palette to edit your compatible language list.
-->
<iq:languages>
<iq:language>eng</iq:language>
</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">
<drawable class="Background" />
<label id="TimeLabel" x="center" y="center" font="Graphics.FONT_LARGE" justification="Graphics.TEXT_JUSTIFY_CENTER" color="Graphics.COLOR_BLUE" />
</layout>
7 changes: 7 additions & 0 deletions resources/settings/properties.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<properties>

<property id="BackgroundColor" type="number">0x000000</property>
<property id="ForegroundColor" type="number">0xFF0000</property>
<property id="UseMilitaryFormat" type="boolean">false</property>

</properties>
25 changes: 25 additions & 0 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<settings>

<setting propertyKey="@Properties.BackgroundColor" title="@Strings.BackgroundColorTitle">
<settingConfig type="list">
<listEntry value="0x000000">@Strings.ColorBlack</listEntry>
<listEntry value="0x555555">@Strings.ColorDarkGray</listEntry>
<listEntry value="0xAAAAAA">@Strings.ColorLightGray</listEntry>
<listEntry value="0xFFFFFF">@Strings.ColorWhite</listEntry>
</settingConfig>
</setting>

<setting propertyKey="@Properties.ForegroundColor" title="@Strings.ForegroundColorTitle">
<settingConfig type="list">
<listEntry value="0x000000">@Strings.ColorBlack</listEntry>
<listEntry value="0x0000FF">@Strings.ColorBlue</listEntry>
<listEntry value="0xFF0000">@Strings.ColorRed</listEntry>
<listEntry value="0xFFFFFF">@Strings.ColorWhite</listEntry>
</settingConfig>
</setting>

<setting propertyKey="@Properties.UseMilitaryFormat" title="@Strings.MilitaryFormatTitle">
<settingConfig type="boolean" />
</setting>

</settings>
16 changes: 16 additions & 0 deletions resources/strings/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<strings>

<string id="AppName">mattermetrics</string>

<string id="BackgroundColorTitle">Background Color</string>
<string id="ForegroundColorTitle">Foreground Color</string>
<string id="MilitaryFormatTitle">Military Format for 24 Hour Time</string>

<string id="ColorBlack">Black</string>
<string id="ColorDarkGray">Dark Gray</string>
<string id="ColorLightGray">Light Gray</string>
<string id="ColorWhite">White</string>
<string id="ColorBlue">Blue</string>
<string id="ColorRed">Red</string>

</strings>
33 changes: 33 additions & 0 deletions source/mattermetricsApp.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Toybox.Application;
import Toybox.Lang;
import Toybox.WatchUi;

class mattermetricsApp extends Application.AppBase {

function initialize() {
AppBase.initialize();
}

// onStart() is called on application start up
function onStart(state as Dictionary?) as Void {
}

// onStop() is called when your application is exiting
function onStop(state as Dictionary?) as Void {
}

// Return the initial view of your application here
function getInitialView() as Array<Views or InputDelegates>? {
return [ new mattermetricsView() ] as Array<Views or InputDelegates>;
}

// New app settings have been received so trigger a UI update
function onSettingsChanged() as Void {
WatchUi.requestUpdate();
}

}

function getApp() as mattermetricsApp {
return Application.getApp() as mattermetricsApp;
}
22 changes: 22 additions & 0 deletions source/mattermetricsBackground.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Toybox.Application;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.WatchUi;

class Background extends WatchUi.Drawable {

function initialize() {
var dictionary = {
:identifier => "Background"
};

Drawable.initialize(dictionary);
}

function draw(dc as Dc) as Void {
// Set the background color then call to clear the screen
dc.setColor(Graphics.COLOR_TRANSPARENT, getApp().getProperty("BackgroundColor") as Number);
dc.clear();
}

}
65 changes: 65 additions & 0 deletions source/mattermetricsView.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Toybox.Application;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.System;
import Toybox.WatchUi;

class mattermetricsView extends WatchUi.WatchFace {

function initialize() {
WatchFace.initialize();
}

// Load your resources here
function onLayout(dc as Dc) as Void {
setLayout(Rez.Layouts.WatchFace(dc));
}

// Called when this View is brought to the foreground. Restore
// the state of this View and prepare it to be shown. This includes
// loading resources into memory.
function onShow() as Void {
}

// Update the view
function onUpdate(dc as Dc) as Void {
// Get the current time and format it correctly
var timeFormat = "$1$:$2$";
var clockTime = System.getClockTime();
var hours = clockTime.hour;
if (!System.getDeviceSettings().is24Hour) {
if (hours > 12) {
hours = hours - 12;
}
} else {
if (getApp().getProperty("UseMilitaryFormat")) {
timeFormat = "$1$$2$";
hours = hours.format("%02d");
}
}
var timeString = Lang.format(timeFormat, [hours, clockTime.min.format("%02d")]);

// Update the view
var view = View.findDrawableById("TimeLabel") as Text;
view.setColor(getApp().getProperty("ForegroundColor") as Number);
view.setText(timeString);

// Call the parent onUpdate function to redraw the layout
View.onUpdate(dc);
}

// Called when this View is removed from the screen. Save the
// state of this View here. This includes freeing resources from
// memory.
function onHide() as Void {
}

// The user has just looked at their watch. Timers and animations may be started here.
function onExitSleep() as Void {
}

// Terminate any active timers and prepare for slow updates.
function onEnterSleep() as Void {
}

}

0 comments on commit ea6d87c

Please sign in to comment.