/** * Custom Applications SDK for Mazda Connect Infotainment System * * A mini framework that allows to write custom applications for the Mazda Connect Infotainment System * that includes an easy to use abstraction layer to the JCI system. * * Written by Andreas Schwarz (http://github.com/flyandi/mazda-custom-applications-sdk) * Copyright (c) 2016. All rights reserved. * * WARNING: The installation of this application requires modifications to your Mazda Connect system. * If you don't feel comfortable performing these changes, please do not attempt to install this. You might * be ending up with an unusuable system that requires reset by your Dealer. You were warned! * * This program is free software: you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License along with this program. * If not, see http://www.gnu.org/licenses/ * */ /** * Speedometer Application * * This is an implementation of the famous Speedometer by @serezhka */ CustomApplicationsHandler.register("app.speedometer", new CustomApplication({ /** * (require) * * An object array that defines resources to be loaded such as javascript's, css's, images, etc * * All resources are relative to the applications root path */ require: { /** * (js) defines javascript includes */ js: [], /** * (css) defines css includes */ css: ['app.css'], /** * (images) defines images that are being preloaded * * Images are assigned to an id */ images: { }, }, /** * (settings) * * An object that defines application settings */ settings: { /** * (terminateOnLost) * * If set to 'true' this will remove the stateless life cycle and always * recreate the application once the focus is lost. Otherwise by default * the inital created state will stay alive across the systems runtime. * * Default is false or not set * / // terminateOnLost: false, /** * (title) The title of the application in the Application menu */ title: 'Speedometer', /** * (statusbar) Defines if the statusbar should be shown */ statusbar: true, /** * (statusbarIcon) defines the status bar icon * * Set to true to display the default icon app.png or set a string to display * a fully custom icon. * * Icons need to be 37x37 */ statusbarIcon: true, /** * (statusbarTitle) overrides the statusbar title, otherwise title is used */ statusbarTitle: 'Speedometer', /** * (statusbarHideHomeButton) hides the home button in the statusbar */ // statusbarHideHomeButton: false, /** * (hasLeftButton) indicates if the UI left button / return button should be shown */ hasLeftButton: false, /** * (hasMenuCaret) indicates if the menu item should be displayed with an caret */ hasMenuCaret: false, /** * (hasRightArc) indicates if the standard right car should be displayed */ hasRightArc: false, }, /** * Scales */ scales: { na: { unit: 'mph', unitLabel: 'MPH', transformSpeed: DataTransform.toMPH, scaleMin: 0, // 0 = 0mph scaleMax: 13, // 12 = 120mph scaleMinSpeed: 0, scaleMaxSpeed: 120, scaleStep: 10, // every 10 miles / hour scaleAngle: 148, scaleRadius: 170, scaleOffsetStep: 4.8, scaleOffsetX: -11, scaleOffsetY: 0, scaleWidth: 278, scaleHeight: 241, }, eu: { unit: 'kmh', unitLabel: 'km/h', scaleMin: 0, // 0 = 0mph scaleMax: 13, // 12 = 120km/h scaleMinSpeed: 0, scaleMaxSpeed: 240, scaleStep: 20, // every 20 km/h scaleAngle: 148, scaleRadius: 170, scaleOffsetStep: 4.6, scaleOffsetX: -15, scaleOffsetY: 0, scaleWidth: 278, scaleHeight: 241, }, }, // default scale scale: false, /** * Statistics */ statistics: { topSpeed: 0, speeds: [], averageSpeeds: [], }, /*** *** User Interface Life Cycles ***/ /** * (created) * * Executed when the application gets initialized * * Add any content that will be static here */ created: function() { // create speedometer panel this.speedoMeter = $("
").attr("id", "speedometer").appendTo(this.canvas); this.speedoUnit = $("
").attr("id", "speedounit").appendTo(this.speedoMeter); this.speedoDial = $("
").attr("id", "speedodial").appendTo(this.canvas); this.speedoRPM = $("
").attr("id", "speedorpm").appendTo(this.canvas); this.speedoRPMIndicator = $("
").addClass("circle").appendTo(this.speedoRPM); this.speedoRPMLabel = $("