Giter VIP home page Giter VIP logo

agent.contrib's Introduction

Agent.Contrib

A set of useful class libraries which should help folks create amazing Faces and Apps for AGENT SmartWatch.

I'm taking pull requests, and ideas for contributions.

If you browse the source real quick I have added a few Samples as to how to start using some of the features:

  • SimpleWatchFace - just a super simple example as to how to print the time on the screen.
  • SimpleWatchFaceWithButtons - simple time on the screen, and responds to the MiddleRight button to toggle showing the date on the screen.

Other highlights:

Documentation:

Drawing class:

  • A bunch of useful methods for drawing watch hands (for analog watch faces)
  • A method to draw a batter, with correct filler depending on the % of battery life
  • Drawing text or images at the center of the screen
  • Measuring Text width, based on fonts

Parse class:

  • All sorts of string to number parsing methods, and converting byte[] to string

GeoLocation class

  • Initial set of interfaces for defining location and position data. If we all can agree on an interface, then it will just make it easier for the entire community to create apps and faces...

Hardware class

  • ButtonHelper class is a threadsafe way for dealing with buttons. Can just wire up an event for the buttons you care about. No need to deal with InterruptPorts, and the class will automatically tell you which button and direction was clicked.

Reflection utilities

  • More advanced class, used to load up other types dynamically, etc..

Sample Usage

  • Download and build the Agent.Contrib project.
  • Create a new "Micro .NET Framework" "Command line" application
  • Import your favourite font as a resource, here we will use NinaB
  • Add a reference to Microsoft.SPOT.Graphics
  • Add a reference to AGENT.Contrib project
  • Add a new file to the project, called "BasicFace.cs"
  • Update BasicFace.cs to the following code:
using System.Globalization;
using Agent.Contrib.Face;
using Agent.Contrib.Settings;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation.Media;

namespace SimpleWatchFace
{
    public class SimpleFace : IFace
    {
        public ISettings Settings { get; set; }
        private Font font = Resources.GetFont(Resources.FontResources.NinaB);
        public void Render(Bitmap screen)
        {
            screen.DrawText(
                Settings.Now.ToString(DateTimeFormatInfo.CurrentInfo.ShortTimePattern),
                font,
                Color.White, 
                0,
                0
                );
        }

        public int UpdateSpeed
        {
            get { return 60*1000; }
        }
    }
}

  • Update Program.cs to the following:
using Agent.Contrib.Face;

namespace SimpleWatchFace
{
    public class Program
    {
        public static void Main()
        {
            var watch = new WatchFace(new SimpleFace());
            watch.Start();
        }
    }
}

Build and run!

Using Multiple Buttons

By default, watch faces only support the middle button the default for the button helper is to only enable the single button. If you want to enable all of the buttons on the right side, just use this prior to any calls to the button helper:

For example, place it at the top of your Main() in Program.cs

        ButtonHelper.ButtonSetup = new Buttons[]
            {
                Buttons.BottomRight, Buttons.MiddleRight, Buttons.TopRight
            };

This will override the default behaviour and enable all three of those buttons.

agent.contrib's People

Contributors

frenchdata avatar nicksi avatar eriknorenrg avatar hector47 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.