<commit_before>﻿using System;
using Gadgeteer;
using Gadgeteer.Modules.Seeed;
using Gadgeteer.Networking;
using Microsoft.SPOT;
using Tinamous.GadgeteerLogger.Core.Components;
using Tinamous.GadgeteerLogger.Core.Components.Interfaces;
using Tinamous.GadgeteerLogger.Core.Web;

namespace Tinamous.GadgeteerLogger.Core
{
    /// <summary>
    /// Responsible for monitoring sensors and periodically sending to Tinamous.
    /// </summary>
    public class Monitor
    {
        private const int StatusYPosition = 130;
        private readonly TemperatureReader _temperatureReader;
        private readonly ILoggerDisplay _loggerDisplay;
        private Timer _timer;
        private bool _hasTemperature;
        private bool _hasLightLevel;
        private bool _hasPressure;

        public Monitor(TemperatureReader temperatureReader, ILoggerDisplay loggerDisplay)
        {
            _temperatureReader = temperatureReader;
            _temperatureReader.MeasurementComplete += TemperatureReaderMeasurementComplete;
            _temperatureReader.LightLevelMeasurementComplete += _temperatureReader_LightLevelMeasurementComplete;
            _loggerDisplay = loggerDisplay;
            _timer = new Timer(new TimeSpan(0, 0, 1, 0));
            _timer.Tick += _timer_Tick;

            Pressure = "2";
            _hasPressure = true;
        }

        void _temperatureReader_LightLevelMeasurementComplete(object sender, Components.EventArguments.LightLevelMeasurementCompleteEventArgs args)
        {
            LightLevel = args.LightLevelPercentage.ToString("f1");
            Debug.Print("Light reader set light as: " + Temperature);
            _hasLightLevel = true;
        }

        void TemperatureReaderMeasurementComplete(TemperatureHumidity sender, double temperature, double relativeHumidity)
        {
            Temperature = temperature.ToString("f2");
            Debug.Print("Temperature reader set temp as: " + Temperature);
            Humidity = temperature.ToString("f2");
            _hasTemperature = true;<commit_msg>Fixed humidity getting set as temperature and also reduced it to 0 decimal places.<commit_after>﻿using System;
using Gadgeteer;
using Gadgeteer.Modules.Seeed;
using Gadgeteer.Networking;
using Microsoft.SPOT;
using Tinamous.GadgeteerLogger.Core.Components;
using Tinamous.GadgeteerLogger.Core.Components.Interfaces;
using Tinamous.GadgeteerLogger.Core.Web;

namespace Tinamous.GadgeteerLogger.Core
{
    /// <summary>
    /// Responsible for monitoring sensors and periodically sending to Tinamous.
    /// </summary>
    public class Monitor
    {
        private const int StatusYPosition = 130;
        private readonly TemperatureReader _temperatureReader;
        private readonly ILoggerDisplay _loggerDisplay;
        private Timer _timer;
        private bool _hasTemperature;
        private bool _hasLightLevel;
        private bool _hasPressure;

        public Monitor(TemperatureReader temperatureReader, ILoggerDisplay loggerDisplay)
        {
            _temperatureReader = temperatureReader;
            _temperatureReader.MeasurementComplete += TemperatureReaderMeasurementComplete;
            _temperatureReader.LightLevelMeasurementComplete += _temperatureReader_LightLevelMeasurementComplete;
            _loggerDisplay = loggerDisplay;
            _timer = new Timer(new TimeSpan(0, 0, 1, 0));
            _timer.Tick += _timer_Tick;

            Pressure = "2";
            _hasPressure = true;
        }

        void _temperatureReader_LightLevelMeasurementComplete(object sender, Components.EventArguments.LightLevelMeasurementCompleteEventArgs args)
        {
            LightLevel = args.LightLevelPercentage.ToString("f1");
            Debug.Print("Light reader set light as: " + Temperature);
            _hasLightLevel = true;
        }

        void TemperatureReaderMeasurementComplete(TemperatureHumidity sender, double temperature, double relativeHumidity)
        {
            Temperature = temperature.ToString("f2");
            Debug.Print("Temperature reader set temp as: " + Temperature);
            Humidity = relativeHumidity.ToString("f0");
            _hasTemperature = true;
{'fraction_non_alphanumeric': 0.06872605363984674, 'fraction_numerical': 0.005507662835249042, 'mean_word_length': 3.0592808551992223, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2862283', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1002, 'n_words': 246}