<commit_before>/*

OpenDECK library v1.3
File: LEDs.cpp
Last revision date: 2014-12-25
Author: <NAME>

*/

#include "OpenDeck.h"
#include <avr/eeprom.h>
#include <util/delay.h>
#include "LEDsettings.h"

//LED blink/constant state determination
#define LED_VELOCITY_C_OFF               0x00
#define LED_VELOCITY_B_OFF               0x3F

#ifdef BOARD_TANNIN
    //tannin 2 specific start-up routine
    void tannin2startup()   {

        uint16_t startUpLEDswitchTime = eeprom_read_byte((uint8_t*)EEPROM_LEDS_HW_P_START_UP_SWITCH_TIME) * 10;
        boardObject.setLEDTransitionSpeed(1);

        boardObject.setLEDstate(6, ledOn);
        boardObject.setLEDstate(30, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(5, ledOn);
        boardObject.setLEDstate(29, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(28, ledOn);
        boardObject.setLEDstate(4, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(31, ledOn);
        boardObject.setLEDstate(7, ledOn);

        boardObject.newDelay(startUpLEDswitchTime);

        boardObject.setLEDstate(22, ledOn);
        boardObject.setLEDstate(14, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(21, ledOn);
        boardObject.setLEDstate(13, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(20, ledOn);
        boardObject.setLEDstate(12, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(23, ledOn);
        boardObject.setLEDstate(15, ledOn);

        boardObject.newDelay(startUpLEDswitchTime);

        boardObject.setLEDstate(31, ledOff);
        boardObject.setLEDstate(7, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(28, ledOff);
        boardObject.setLEDstate(4, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(29, ledOff);
        boardObject.setLEDstate(5, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(30, ledOff);
        boardObject.setLEDstate(6, ledOff);

        boardObject.newDelay(startUpLEDswitchTime);

        boardObject.setLEDstate(23, ledOff);
        boardObject.setLEDstate(15, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(20, ledOff);
        boardObject.setLEDstate(12, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(21, ledOff);
        boardObject.setLEDstate(13, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(22, ledOff);
        boardObject.setLEDstate(14, ledOff);

        boardObject.newDelay(1000);

        boardObject.setLEDTransitionSpeed(eeprom_read_byte((uint8_t*)EEPROM_LEDS_HW_P_FADE_SPEED));
        boardObject.resetLEDtransitions();

    }
#endif


void OpenDeck::startUpRoutine() {

    //boardObject.setUpTimer();

    //turn off all LEDs before starting animation
    allLEDsOff();

    #ifdef BOARD_TANNIN
        tannin2startup();
    #else

    switch (eeprom_read_byte((uint8_t*)EEPROM_LEDS_HW_P_START_UP_ROUTINE))  {

        case 1:
        openDeck.oneByOneLED(true, true, true);
        openDeck.oneByOneLED(false, false, true);
        openDeck.oneByOneLED(true, false, false);
        openDeck.oneByOneLED(false, true, true);
        openDeck.oneByOneLED(true, false, true);
        openDeck.oneByOneLED(false, false, false);
        break;

        case 2:
        openDeck.oneByOneLED(true, false, true);
        openDeck.oneByOneLED(false, false, false);
        break;

        case 3:
        openDeck.oneByOneLED(true, true, true);
        openDeck.oneByOneLED(false, true, true);
        break;

        case 4:
        openDeck.oneByOneLED(true, false, true);
        openDeck.oneByOneLED(true, false, false);
        break;

        case 5:
        openDeck.oneByOneLED(true, false, true);
        break;

        default:
        break;

    }
    #endif
    openDeck.allLEDsOff(); delay(1000); //boardObject.disconnectTimer();

}

void OpenDeck::oneByOneLED(bool ledDirection, bool singleLED, bool turnOn)  {

    /*

    Function accepts three boolean arguments.

    ledDirection:   true means that LEDs will go from left to right, false from right to left
    singleLED:      true means that only one LED will be active at the time, false means that LEDs
                    will turn on one by one until they're all lighted up

    turnOn:         true means that LEDs will be turned on, with all previous LED states being 0
                    false means that all LEDs are lighted up and they turn off one by one, depending<commit_msg>replace delay with newDelay, remove comments<commit_after>/*

OpenDECK library v1.3
File: LEDs.cpp
Last revision date: 2014-12-25
Author: <NAME>

*/

#include "OpenDeck.h"
#include <avr/eeprom.h>
#include <util/delay.h>
#include "LEDsettings.h"

//LED blink/constant state determination
#define LED_VELOCITY_C_OFF               0x00
#define LED_VELOCITY_B_OFF               0x3F

#ifdef BOARD_TANNIN
    //tannin 2 specific start-up routine
    void tannin2startup()   {

        uint16_t startUpLEDswitchTime = eeprom_read_byte((uint8_t*)EEPROM_LEDS_HW_P_START_UP_SWITCH_TIME) * 10;
        boardObject.setLEDTransitionSpeed(1);

        boardObject.setLEDstate(6, ledOn);
        boardObject.setLEDstate(30, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(5, ledOn);
        boardObject.setLEDstate(29, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(28, ledOn);
        boardObject.setLEDstate(4, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(31, ledOn);
        boardObject.setLEDstate(7, ledOn);

        boardObject.newDelay(startUpLEDswitchTime);

        boardObject.setLEDstate(22, ledOn);
        boardObject.setLEDstate(14, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(21, ledOn);
        boardObject.setLEDstate(13, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(20, ledOn);
        boardObject.setLEDstate(12, ledOn);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(23, ledOn);
        boardObject.setLEDstate(15, ledOn);

        boardObject.newDelay(startUpLEDswitchTime);

        boardObject.setLEDstate(31, ledOff);
        boardObject.setLEDstate(7, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(28, ledOff);
        boardObject.setLEDstate(4, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(29, ledOff);
        boardObject.setLEDstate(5, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(30, ledOff);
        boardObject.setLEDstate(6, ledOff);

        boardObject.newDelay(startUpLEDswitchTime);

        boardObject.setLEDstate(23, ledOff);
        boardObject.setLEDstate(15, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(20, ledOff);
        boardObject.setLEDstate(12, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(21, ledOff);
        boardObject.setLEDstate(13, ledOff);
        boardObject.newDelay(startUpLEDswitchTime);
        boardObject.setLEDstate(22, ledOff);
        boardObject.setLEDstate(14, ledOff);

        boardObject.newDelay(1000);

        boardObject.setLEDTransitionSpeed(eeprom_read_byte((uint8_t*)EEPROM_LEDS_HW_P_FADE_SPEED));
        boardObject.resetLEDtransitions();

    }
#endif


void OpenDeck::startUpRoutine() {

    //turn off all LEDs before starting animation
    allLEDsOff();

    #ifdef BOARD_TANNIN
        tannin2startup();
    #else

    switch (eeprom_read_byte((uint8_t*)EEPROM_LEDS_HW_P_START_UP_ROUTINE))  {

        case 1:
        openDeck.oneByOneLED(true, true, true);
        openDeck.oneByOneLED(false, false, true);
        openDeck.oneByOneLED(true, false, false);
        openDeck.oneByOneLED(false, true, true);
        openDeck.oneByOneLED(true, false, true);
        openDeck.oneByOneLED(false, false, false);
        break;

        case 2:
        openDeck.oneByOneLED(true, false, true);
        openDeck.oneByOneLED(false, false, false);
        break;

        case 3:
        openDeck.oneByOneLED(true, true, true);
        openDeck.oneByOneLED(false, true, true);
        break;

        case 4:
        openDeck.oneByOneLED(true, false, true);
        openDeck.oneByOneLED(true, false, false);
        break;

        case 5:
        openDeck.oneByOneLED(true, false, true);
        break;

        default:
        break;

    }
    #endif
    openDeck.allLEDsOff(); boardObject.newDelay(500);

}

void OpenDeck::oneByOneLED(bool ledDirection, bool singleLED, bool turnOn)  {

    /*

    Function accepts three boolean arguments.

    ledDirection:   true means that LEDs will go from left to right, false from right to left
    singleLED:      true means that only one LED will be active at the time, false means that LEDs
                    will turn on one by one until they're all lighted up

    turnOn:         true means that LEDs will be turned on, with all previous LED states being 0
                    false means that all LEDs are lighted up and they turn off one by one, depending
{'fraction_non_alphanumeric': 0.09285341679707877, 'fraction_numerical': 0.01992696922274387, 'mean_word_length': 2.974295190713101, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5732624', 'n_tokens_mistral': 3156, 'n_tokens_neox': 2979, 'n_words': 586}