<commit_before>/*
 * Project IoTBox
 * Description: A internet-connected box which can be opened from API
 * Author: Peacemoon
 * Date: 17.09.2017
 */

 PRODUCT_ID(5673);
 PRODUCT_VERSION(1);

 STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));
 SYSTEM_MODE(AUTOMATIC)
 SYSTEM_THREAD(ENABLED);

#include "clickButton.h"
#include "ContactSwitch.h"
#include "Display.h"
#include "ConfigurationTime.h"
#include "OpenOperation.h"
#include "Buzzer.h"

#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)

#define BUTTONPIN D2 // Button reserved for further usage
#define BUZZERPIN D3 // Buzzer reserved for further usage
#define RELAYPIN D4 // Relay to drive the electromagnetic lock.
#define SWITCHPIN D6 // Switch for "LOCKED" or "OPEN" status.
#define LEDPIN D7 // Status LED.

unsigned long lastSync = millis();

int switchState = LOW; // HIGH = locked, LOW = open
volatile bool requestDisplayStatus = true;
volatile bool requestDisplayTime = false;
volatile bool requestDisplayConfigurationTime = true;
volatile bool requestDisplayReminderTime = true;
volatile bool requestOpeningOperation = false;

float timeZone = 0.0;

Display display;
Buzzer buzzer(BUZZERPIN);

Timer clockTimer(1000, updateTime); // timer used to display the clock on the lcd display

OpenOperation openOperation(RELAYPIN, LEDPIN);

volatile int hour;
volatile int minute;
volatile int second;

int configureTime(String time);
void syncTimeWithCloudIfNeeded();

ConfigurationTime openTime;
ConfigurationTime reminderTime;

const char *PUBLISH_EVENT_NAME = "status";

ClickButton button(BUTTONPIN, LOW);
ContactSwitch switchButton(SWITCHPIN);

bool isStarting = true;

void setup() {
    // Ouput pins
    pinMode(LEDPIN, OUTPUT);
    pinMode(RELAYPIN, OUTPUT);

    // Setup switchButton timers (all in milliseconds / ms)
    switchButton.debounceTime = 1000;   // Debounce timer in ms

    // Setup button timers (all in milliseconds / ms)
    button.debounceTime   = 20;   // Debounce timer in ms
    button.multiclickTime = 250;  // Time limit for multi clicks
    button.longClickTime  = 1000; // time until "held-down clicks" register

    // Do not open the box when system is turned on
    digitalWrite(RELAYPIN, LOW);

    // Setup the lcd
    display.setup();

    // Setup timezone
    Time.zone(+1.00);

    // Register the status of the box to Particle Cloud
    switchState = digitalRead(SWITCHPIN);
    Particle.variable("switchState", switchState);

    // Register the configureTime as a cloud function
    Particle.function("timeZone", configureTimeZone);

    // Register the configureTime as a cloud function
    Particle.function("time", configureTime);

    // Register the configureReminderTime as a cloud function
    Particle.function("reminderTime", configureReminderTime);

    // Register the startOpenOperation as a cloud function
    Particle.function("open", startOpenOperation);

    // Get the open time from EEPROM, set it to default if not saved
    EEPROM.get(0, timeZone);
    if (timeZone == 0xFFFFFFFF) {
        // EEPROM was empty -> initialize value
        timeZone = 0.0;<commit_msg>FW-FIXBUG: Remove unnescessary timeZone call<commit_after>/*
 * Project IoTBox
 * Description: A internet-connected box which can be opened from API
 * Author: Peacemoon
 * Date: 17.09.2017
 */

 PRODUCT_ID(5673);
 PRODUCT_VERSION(1);

 STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));
 SYSTEM_MODE(AUTOMATIC)
 SYSTEM_THREAD(ENABLED);

#include "clickButton.h"
#include "ContactSwitch.h"
#include "Display.h"
#include "ConfigurationTime.h"
#include "OpenOperation.h"
#include "Buzzer.h"

#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)

#define BUTTONPIN D2 // Button reserved for further usage
#define BUZZERPIN D3 // Buzzer reserved for further usage
#define RELAYPIN D4 // Relay to drive the electromagnetic lock.
#define SWITCHPIN D6 // Switch for "LOCKED" or "OPEN" status.
#define LEDPIN D7 // Status LED.

unsigned long lastSync = millis();

int switchState = LOW; // HIGH = locked, LOW = open
volatile bool requestDisplayStatus = true;
volatile bool requestDisplayTime = false;
volatile bool requestDisplayConfigurationTime = true;
volatile bool requestDisplayReminderTime = true;
volatile bool requestOpeningOperation = false;

float timeZone = 0.0;

Display display;
Buzzer buzzer(BUZZERPIN);

Timer clockTimer(1000, updateTime); // timer used to display the clock on the lcd display

OpenOperation openOperation(RELAYPIN, LEDPIN);

volatile int hour;
volatile int minute;
volatile int second;

int configureTime(String time);
void syncTimeWithCloudIfNeeded();

ConfigurationTime openTime;
ConfigurationTime reminderTime;

const char *PUBLISH_EVENT_NAME = "status";

ClickButton button(BUTTONPIN, LOW);
ContactSwitch switchButton(SWITCHPIN);

bool isStarting = true;

void setup() {
    // Ouput pins
    pinMode(LEDPIN, OUTPUT);
    pinMode(RELAYPIN, OUTPUT);

    // Setup switchButton timers (all in milliseconds / ms)
    switchButton.debounceTime = 1000;   // Debounce timer in ms

    // Setup button timers (all in milliseconds / ms)
    button.debounceTime   = 20;   // Debounce timer in ms
    button.multiclickTime = 250;  // Time limit for multi clicks
    button.longClickTime  = 1000; // time until "held-down clicks" register

    // Do not open the box when system is turned on
    digitalWrite(RELAYPIN, LOW);

    // Setup the lcd
    display.setup();

    // Register the status of the box to Particle Cloud
    switchState = digitalRead(SWITCHPIN);
    Particle.variable("switchState", switchState);

    // Register the configureTime as a cloud function
    Particle.function("timeZone", configureTimeZone);

    // Register the configureTime as a cloud function
    Particle.function("time", configureTime);

    // Register the configureReminderTime as a cloud function
    Particle.function("reminderTime", configureReminderTime);

    // Register the startOpenOperation as a cloud function
    Particle.function("open", startOpenOperation);

    // Get the open time from EEPROM, set it to default if not saved
    EEPROM.get(0, timeZone);
    if (timeZone == 0xFFFFFFFF) {
        // EEPROM was empty -> initialize value
        timeZone = 0.0;
{'fraction_non_alphanumeric': 0.09132271693207669, 'fraction_numerical': 0.017062073448163795, 'mean_word_length': 4.008136696501221, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4249495', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1781, 'n_words': 608}