Creation - SimpleTemperature

I just posted SimpleTemperature on Creations. Feel free to discuss and make suggestions here.

5 Likes

nice one… I like :slight_smile:

I ordered 2 of these with sockets and the $1.50 shipping and so for $15 I got 2 very nice temperature modules and gave them a quickie test as they have some very nice features


using System;
using Gadgeteer.Modules.GHIElectronics;
using Gadgeteer.Modules.StablePoint;
using Microsoft.SPOT;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;


namespace SimpleTempTest
{
    public partial class Program
    {
        private readonly GT.Timer _timer = new GT.Timer(60000);
 
        private void ProgramStarted()
        {
            Debug.Print("Program Started");

            simpleTemperature.AlertEvent += simpleTemperature_AlertEvent;

            simpleTemperature.SetHysteresis(SimpleTemperature.Hysteresis.OneAndHalf);
            simpleTemperature.SetResolution(SimpleTemperature.Resolution.OneSixteenthDegree);

            simpleTemperature.SetAlertLower(20);
            simpleTemperature.SetAlertUpper(25);

            //simpleTemperature.Disable();
            //simpleTemperature.Enable();

            led7C.SetColor(LED7C.Color.Green);

            simpleTemperature.EnableAlerts();

            _timer.Tick += _timer_Tick;
            _timer.Start();
        }

        private void _timer_Tick(GT.Timer timer)
        {
            var t1 = simpleTemperature.GetTemperature();

            characterDisplay.Clear();
            characterDisplay.Print(t1.ToString());
            characterDisplay.SetCursorPosition(1, 0);

            //simpleTemperature.EnableAlerts();
        }

        private void simpleTemperature_AlertEvent(SimpleTemperature sender, DateTime time)
        {
            var t = sender.GetTemperature();

            Debug.Print("Alert " + time + "  " + t);

            if (t > 22)
                led7C.SetColor(LED7C.Color.Red);
            else
            {
                led7C.SetColor(LED7C.Color.Blue);
            }

            //simpleTemperature.DisableAlerts();
        }
    }
}

3 Likes

@ Duke Nukem - Love the fact that it surfaces alerts as a configurable event…that’s very handy, and a great example of the kinds of abstractions that make me love Gadgeteer.

Nice job on the driver @ iamin!

1 Like