<commit_before>var mraa = require('mraa');
var groveSensors = require('jsupm_grove');
var groveMoisture = require('jsupm_grovemoisture');
var gasSensorLibrary = require('jsupm_gas');
var GAS_THRESHOLD = 400;

// Sensors
var platformStatus = {
    temperature: [],
    gas: [],
    light: [],
    moisture: [],
    water: [],
    airQuality: [],
    music: []
};

// Analog sensors
var airQualitySensor;  // (A0)
var lightSensor = new groveSensors.GroveLight(1);
var tempSensor = new groveSensors.GroveTemp(2);
var moistureSensor = new groveMoisture.GroveMoisture(3);
var gasSensor = new gasSensorLibrary.MQ5(4);

// Digital sensors
var touchSensor = new mraa.Gpio(2);
var waterSensor = new mraa.Gpio(4);  
var ledSensor = new groveSensors.GroveLed(5);
var buzzerSensor = new mraa.Gpio(6);

// Configure GPIO direction
touchSensor.dir(mraa.DIR_IN);
waterSensor.dir(mraa.DIR_IN);
buzzerSensor.dir(mraa.DIR_OUT);

//
var buzzerState = 0;
var panicMode = false;
var intervalPanicMode;
var ledState = 'off';

// Initialize sensors
buzzerSensor.write(0);
ledSensor.off();

module.exports = {
    platformStatus: platformStatus,
    sensors: {
        temperature: tempSensor,
        light: lightSensor,
        gas: gasSensor,
        led: ledSensor,
        moisture: moistureSensor,
        buzzer: buzzerSensor,
        touch: touchSensor
    },
    monitor: (io) => {
        setInterval(function(){
            var now = new Date().getTime();
            var tempValue = tempSensor.value();
            var gasValue = gasSensor.getSample();
            var lightValue = lightSensor.value();
            var touchValue = touchSensor.read();
            var moistureValue = moistureSensor.value();
            var waterValue = (waterSensor.read()) ? false : true;  // read() == 1 => dry, read() == 0 => wet/water
            console.log(`>> T: ${tempValue}ºC, L: ${lightValue}LUX, M: ${moistureValue}, W: ${waterValue}, G: ${gasValue}, T2: ${touchValue}`);

            // Update the status of the platform
            platformStatus.temperature.push({x: now, y: tempValue});
            platformStatus.gas.push({x: now, y: gasValue});
            platformStatus.light.push({x: now, y: lightValue});

            // Check the alert for the panic mode
            if(gasValue > GAS_THRESHOLD && !panicMode) {
                panicMode = true;
                intervalPanicMode = setInterval(() => {<commit_msg>Added air quality sensor<commit_after>var mraa = require('mraa');
var groveSensors = require('jsupm_grove');
var groveMoisture = require('jsupm_grovemoisture');
var gasSensorLibrary = require('jsupm_gas');
var GAS_THRESHOLD = 400;

// Sensors
var platformStatus = {
    temperature: [],
    gas: [],
    light: [],
    moisture: [],
    water: [],
    airQuality: [],
    music: []
};

// Analog sensors
var airQualitySensor = new mraa.Aio(0);
var lightSensor = new groveSensors.GroveLight(1);
var tempSensor = new groveSensors.GroveTemp(2);
var moistureSensor = new groveMoisture.GroveMoisture(3);
var gasSensor = new gasSensorLibrary.MQ5(4);

// Digital sensors
var touchSensor = new mraa.Gpio(2);
var waterSensor = new mraa.Gpio(4);  
var ledSensor = new groveSensors.GroveLed(5);
var buzzerSensor = new mraa.Gpio(6);

// Configure GPIO direction
touchSensor.dir(mraa.DIR_IN);
waterSensor.dir(mraa.DIR_IN);
buzzerSensor.dir(mraa.DIR_OUT);

//
var buzzerState = 0;
var panicMode = false;
var intervalPanicMode;
var ledState = 'off';

// Initialize sensors
buzzerSensor.write(0);
ledSensor.off();

module.exports = {
    platformStatus: platformStatus,
    sensors: {
        airQuality: airQualitySensor,
        buzzer: buzzerSensor,
        gas: gasSensor,
        led: ledSensor,
        light: lightSensor,
        moisture: moistureSensor,
        temperature: tempSensor,
        touch: touchSensor,
        water: waterSensor
    },
    monitor: (io) => {
        setInterval(function(){
            var now = new Date().getTime();
            var airQualityValue = airQualitySensor.read();
            var gasValue = gasSensor.getSample();
            var lightValue = lightSensor.value();
            var moistureValue = moistureSensor.value();
            var tempValue = tempSensor.value();
            var touchValue = touchSensor.read();
            var waterValue = (waterSensor.read()) ? false : true;  // read() == 1 => dry, read() == 0 => wet/water
            console.log(`>> ` + 
                `A: ${airQualityValue}` +
                `G: ${gasValue}, ` +
                `L: ${lightValue}LUX, ` +
                `M: ${moistureValue}, ` +
                `T: ${tempValue}ºC, ` +
                `T2: ${touchValue}` +
                `W: ${waterValue}`);

            // Update the status of the platform
            platformStatus.temperature.push({x: now, y: tempValue});
            platformStatus.gas.push({x: now, y: gasValue});
            platformStatus.light.push({x: now, y: lightValue});

            // Check the alert for the panic mode
            if(gasValue > GAS_THRESHOLD && !panicMode) {
                panicMode = true;
                intervalPanicMode = setInterval(() => {
{'fraction_non_alphanumeric': 0.1332422941865002, 'fraction_numerical': 0.00702301989855638, 'mean_word_length': 2.6700071581961344, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '303652', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1649, 'n_words': 375}