Compare commits

...

5 Commits
master ... asb

Author SHA1 Message Date
asb
dee3a59115 V2.5 2022-09-25 21:30:44 +10:00
asb
f1f837bc9e V2.3 2022-09-25 21:29:30 +10:00
asb
86c884be4a V2 2022-09-15 21:09:26 +10:00
asb
c93a221401 Dir Fix 2022-09-15 16:03:18 +10:00
3ef25bc177 ASB version 2022-09-15 15:58:47 +10:00
2 changed files with 509 additions and 153 deletions

View File

@ -1,153 +0,0 @@
//Recommend reading: https://www.arduino.cc/reference/en/
//Buttons go 1-4 from Top to bottom
//This project uses an Arduino Pro Micro (also known as an Arduino Leonardo)
//Includes
//These can be installed in the arduino IDE by clicking on tools in the top bar, then manage libraries.
#include <EasyButton.h> //Used to define a button and debounces it
#include "HID-Project.h" //Lets us simulate keyboard presses.
//Pin Definitions. These numbers refer to the physical GPIO pins on the board
//LEDS
#define LED1 3
#define LED2 5
#define LED3 6
#define LED4 9
//Buttons
#define BUTTON1 A3
#define BUTTON2 A2
#define BUTTON3 A1
#define BUTTON4 A0
unsigned long ledTickTime = 0;
unsigned long lastPressTime = 0;
uint8_t ledBrightness = 100;
bool ledOn = false;
//Using the EasyButton library we create 4 buttons, with each button being connected to a GPIO pin as defined above, and having a 35ms debounce time. From memory, these do not have internal pullup resistors, and are not inverted. Hence the two falses.
EasyButton button1(BUTTON1, 35, false, false);
EasyButton button2(BUTTON2, 35, false, false);
EasyButton button3(BUTTON3, 35, false, false);
EasyButton button4(BUTTON4, 35, false, false);
//Standard Arduino setup function. Code that only needs to run once goes here
void setup() {
Keyboard.begin();
//LEDS - Setting the LED pins to be outputs. Normally, the buttons would be set as inputs, but they are handled by that library.
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
//Here we output a PWM signal to the LEDs, where 0 will be off, and 255 is brightest
analogWrite(LED1, ledBrightness);
analogWrite(LED2, ledBrightness);
analogWrite(LED3, ledBrightness);
analogWrite(LED4, ledBrightness);
//BUTTONS - setup buttons using library.
button1.begin();
button2.begin();
button3.begin();
button4.begin();
}
//Code that is run constantly goes here
void loop() {
//Read all the buttons
button1.read();
button2.read();
button3.read();
button4.read();
//This should be pretty self explanitory. Make sure to always release a button.
if(button1.isPressed())
{
Keyboard.press(KEY_LEFT_ALT);
lastPressTime = millis();
}
else if(button1.wasReleased())
{
Keyboard.release(KEY_LEFT_ALT);
lastPressTime = millis();
}
if(button2.isPressed())
{
Keyboard.press(KEY_LEFT_CTRL);
lastPressTime = millis();
}
else if(button2.wasReleased())
{
Keyboard.release(KEY_LEFT_CTRL);
lastPressTime = millis();
}
if(button3.isPressed())
{
Keyboard.press(KEY_LEFT_SHIFT);
lastPressTime = millis();
}
else if(button3.wasReleased())
{
Keyboard.release(KEY_LEFT_SHIFT);
lastPressTime = millis();
}
if(button4.isPressed())
{
Keyboard.press(KEY_SPACE);
lastPressTime = millis();
}
else if(button4.wasReleased())
{
Keyboard.release(KEY_SPACE);
lastPressTime = millis();
}
if((millis() - lastPressTime) > 10000)
{
ledOn = false;
}
else
{
ledOn = true;
}
if ((millis() - ledTickTime) > 10)
{
ledTickTime = millis();
if(!ledOn && (ledBrightness > 0))
{
ledBrightness=ledBrightness-1;
}
else if(ledOn && (ledBrightness < 100))
{
ledBrightness=ledBrightness+10;
}
analogWrite(LED1, ledBrightness);
analogWrite(LED2, ledBrightness);
analogWrite(LED3, ledBrightness);
analogWrite(LED4, ledBrightness);
}
// Serial.print("Led Brightness = ");
// Serial.print(ledBrightness);
// Serial.print("\t Led State = ");
// Serial.println(ledOn);
}

View File

@ -0,0 +1,509 @@
//#########################################################################################################
//# PROGRAM NAME: 'ClareButtons'
//#########################################################################################################
//# Purpose : Controlled by an Arduino Board, this code programs preset actions on up to 6 Buttons (currently only 4 defined).
//# For example, the buttons may be defined as:
//# * 'Keyboard Keys' (eg. Ctrl, Alt, Shift)
//# * 'KeyBoard combinations' shortcuts (eg. Crtl + C, Crtl + V)
//# * 'Whole Text' (eg. "Hello World")
//# Code Type : MAIN PROGRAM: C - Arduino Leonardo (Arduino IDE)
//# Usage : Ideal for one-handed keyboard usage
//# Prereqs : 1) May Require 'USB Driver' for Arduio Board (Chinese Board):
//# * CH341SER_EXE (from http://www.wch-ic.com/downloads/CH341SER_EXE.html)
//# 2) Requires 'Board' Selection via Tools > Board: If the Board is not in the dropdown list the install\update via 'Tools > Board > Board Manager'.
//# * Arduino Leonardo (Arduino Pro Micro)
//# 3) Requires 'Port' to be specified. 'Tools > Port' (The 'Board' should be clearly identified with the corresponding Port):
//# * eg. COM3(Arduino Leonardo)
//# 4) Requires 'Librarys' to be Installed via 'Sketch > Incldue Library > Manage Libraries':
//# * EasyButton.h
//# * HID-Project.h
//# Author(s) : Zachery Seibel-Barnes and Anthony Seibel-Barnes
//# Date : 23/09/2022 (Ver 2.2)
//# Notes : 1) Hardware: Buttons are defined as '1' to '4' from Top (furthest from USB lead) to Bottom (closest to USB lead)
//# 2) IMPORTANT: A 'Button Press' action needs to have corresponding a 'Button Release' action (either 'implicidly defined' or as a generic 'release all')
//# 2) Testing: To check parameters values (as generated by run code), use 'Serial Monitor' (Ctrl+Shft+M). Examples:
//# Serial.print("Led Brightness = ");
//# Serial.print(ledBrightness);
//# Serial.print("\t Led State = ");
//# Serial.println(ledOn);
//#########################################################################################################
//*********************************************
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
//* INITIALISE *
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
//*********************************************
//////////////////////
// LIBRARIES //
//////////////////////
#include <EasyButton.h> //Used to define a button and debounces it
#include "HID-Project.h" //Lets us simulate keyboard presses.
//////////////////////
// DEFINITIONS //
//////////////////////
//These PIN numbers refer to the physical GPIO pins on the board.
//LEDS
#define LED1 3
#define LED2 5
#define LED3 6
#define LED4 9
//Buttons
#define BUTTON1 A3
#define BUTTON2 A2
#define BUTTON3 A1
#define BUTTON4 A0
//////////////////////
// Global Constants //
//////////////////////
const int cintLedOffTime = 10000; //LED 'OFF' time (milliseconds) is how long LED will remain on for after a button was pressed (For reference: 60,000 = 1 minute). This only relevant if 'cblnLEDsToDimCycle = False'.
const int cintLedMaxBrightness = 100; //LED Maximum brightness level (0 will be off, and 255 is brightest... like the SUN !!)
const int cintLedMinBrightness = 1; //LED Minimum brightness level (0 will be off, and 255 is brightest)
const int cintLedDimmerStepTime = 100; //Time interval for LED Dimmer (milliseconds) (Higher=slow fade ; Lower=quick fade). NOTE: 'cintLedDimmerStep' is relative (linked) to this & will also influence how fast/slow actions occur.
const int cintLedDimmerStep = 1; //Step interval for LED Dimmer (1=very smooth fades ; >10=stepped fades). NOTE: 'cintLedDimmerStepTime' is relative (linked) to this and will also influence how fast/slow this action occurs.
const bool cblnLEDsToDimCycle = true; //Used to set when 'LEDs' are required to CYCLE back to Max after the LEDs are Minimised - even when NO Button Activity has occurred.
//When TRUE, it will (forever) cycle LEDS brightness - GRADUALLY cycling UP (using cintLedDimmerStep) from 'Mimimum' (cintLedMinBrightness) to 'Max ' (cintLedMaxBrightness),
//then 'Dimming' back down to the Mimimum.
//Whem FALSE, the LEDs will simply Dim to the Minimum (cintLedMinBrightness) until next button press.
const int cintDebounceTime = 180; //DebounceTime (milliseconds) is used with the 'Delay' function to pause code after a button press. This helps to slow 'extra' commands from
//a Button like 'PASTING repeated data'). Increase the 'time' if wishing to 'hold' an action from happening (or repeating) for longer.
//This is currently only used when 'blnDelayActions' is set to 'true'. If it is 'false', then the delay is effectively 'zero'.
//////////////////////
// Global Variables //
//////////////////////
unsigned long ledTickTime = 0;
unsigned long lastPressTime = 0;
uint8_t ledBrightness = cintLedMaxBrightness;
bool blnLEDsOn = true; //Used to flag when 'LEDs' are ON at any Brightness level (ie. when LEDs are NOT off). Initated to True for initial illumination.
bool blnButtonActivty = false; //Used to flag when a Button action has actually occured. This is used primarily so it can correctly turn off LEDs after the specified activity time (ie. indirectly works with 'cintLedOffTime')
bool blnLEDsAreCyclingUp = false; //Only used when 'cblnLEDsDimCycle' is TRUE - It identifies when LEDs are in the process of 'Cycling UP' (to LEDs Max On) or when False they will 'Cycle Down' first.
//Using the EasyButton library we create 4 buttons, with each button being connected to a GPIO pin as defined above, and having a 35ms debounce time. From memory, these do not have internal pullup
//resistors, and are not inverted. Hence the two falses.
EasyButton button1(BUTTON1, 35, false, false);
EasyButton button2(BUTTON2, 35, false, false);
EasyButton button3(BUTTON3, 35, false, false);
EasyButton button4(BUTTON4, 35, false, false);
//*********************************************
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
//* MAIN *
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
//*********************************************
//Standard Arduino setup function. Code that only needs to 'run once' goes here.
void setup()
{
// Send a clean report to the host. This is important on any Arduino type.
Keyboard.begin();
Keyboard.end();
//LEDS - Setting the LED pins to be outputs. Normally, the buttons would be set as inputs, but they are handled by that library.
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
//Here we output a PWM signal to the LEDs. This is the INITIAL LEDs illumination when the device is plugged in (prior to any button actions or dimming checks occur).
analogWrite(LED1, ledBrightness);
analogWrite(LED2, ledBrightness);
analogWrite(LED3, ledBrightness);
analogWrite(LED4, ledBrightness);
//BUTTONS - setup buttons using library.
button1.begin();
button2.begin();
button3.begin();
button4.begin();
}
//*********************************************
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
//* MAIN LOOP *
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
//*********************************************
//Code that is 'runs constantly' goes here.
void loop() {
//Reset 'Button Activity' flag (when False it sits in a wait-state for someone to press a button)
blnButtonActivty=false;
//Read all the buttons
button1.read();
button2.read();
button3.read();
button4.read();
//---------------------------------
//--- Button Activity ---
//---------------------------------
if(button1.isPressed())
{
blnButtonActivty = ButtonPressAction(1);
}
else if(button1.wasReleased())
{
blnButtonActivty = ButtonReleaseAction(1,true);
}
if(button2.isPressed())
{
blnButtonActivty = ButtonPressAction(2);
}
else if(button2.wasReleased())
{
blnButtonActivty = ButtonReleaseAction(2,true);
}
if(button3.isPressed())
{
blnButtonActivty = ButtonPressAction(3);
}
else if(button3.wasReleased())
{
blnButtonActivty = ButtonReleaseAction(3,true);
}
if(button4.isPressed())
{
blnButtonActivty = ButtonPressAction(4);
}
else if(button4.wasReleased())
{
blnButtonActivty = ButtonReleaseAction(4,false);
}
//---------------------------------------------------------
//--- LED Illumination: Full ON (when Button Activity) ---
//---------------------------------------------------------
// Check if a 'Button action' has recently occurred.
switch (blnButtonActivty)
{
case true:
// A 'Button Activty' HAS occurred.
//Reset the 'lastPressTime' timer variable to current time(r).
lastPressTime = millis();
//Increase LEDs to 'MAX Brightness'
if(ledBrightness < cintLedMaxBrightness)
{
ledBrightness = cintLedMaxBrightness;
}
break;
default:
// A 'Button Activty' HAS NOT Occurred. No need to do anything - This will also retain the 'lastPressTime' time value.
break;
}
//---------------------------------------------------------
//--- LED Illumination: Minimised or DIMMING CYCLING ---
//---------------------------------------------------------
if((millis() - lastPressTime) > cintLedOffTime)
{
//The maximun 'LED on' time has elapsed since the last Button Press (or initial on). Check if 'Dimming Cycling' is set to occur, otherwise simply MINIMISE LEDs.
switch (cblnLEDsToDimCycle) //Global Constant 'cblnLEDsToDimCycle' determines if 'DIMMING CYCLING' occurs.
{
case true:
//Call LED Dimming function (to Cycle LED Brightness)
ledBrightness = GetLEDsDimCycleValue(ledBrightness);
break;
case false:
//If LEDs are ON (at ANY Brightness level ... LEDS should now be MINIMISED.
if(blnLEDsOn)
{
//MINIMISE LEDs: MAX time has ELAPSED for LEDs to be on Max Brightness.
lastPressTime = 0; //Reset for 'No Button Activity'
ledBrightness = cintLedMinBrightness; //Set LEDs to 'Minimum Brightness'
}
break;
default:
//Should not ever get here, but 'break' out just in case.
break;
}
}
//---------------------------------------------------------
//--- WRITE LED Values ---
//---------------------------------------------------------
if (blnLEDsOn)
{
//Write LED brightness level to the LEDs.
analogWrite(LED1, ledBrightness);
analogWrite(LED2, ledBrightness);
analogWrite(LED3, ledBrightness);
analogWrite(LED4, ledBrightness);
}
//---------------------------------------------------------
//--- RESET LED Variables for MAIN LOOP ---
//---------------------------------------------------------
if(ledBrightness > cintLedMinBrightness)
{
//LED's ON:
if (!blnLEDsOn)
{
blnLEDsOn=true;
}
}
else if(ledBrightness <= cintLedMinBrightness)
{
//LED's at MINIMUM: Minimun LED Brightness has been reached (this is considered as 'LED Off', but they may not be FULLY Off - it depends on the constant cintLedMinBrightness)
if (blnLEDsOn)
{
blnLEDsOn = false;
}
if (cblnLEDsToDimCycle)
{
//Reset the flag to begin 'LED cycle Up' process (This is only relevant when cblnLEDsToDimCycle = true)
blnLEDsAreCyclingUp = true;
}
}
// LOOP MAIN
}
//********************************************************************************************
//* FUNCTION NAME: 'ButtonPressAction'
//********************************************************************************************
//* Purpose : Performs pre-defined action(s) when an Arduino Board button is PRESSED.
//* Code Type : FUCTION CALL: C - Arduino Leonardo (Arduino IDE)
//* Usage : Can be called anytime. Function call example: blnButtonActivty = ButtonPressAction(1);
//* Where: * 'ButtonPressAction(1)' specifies the button for which the defined action(s) will execute.
//* * 'blnButtonActivty' receives the return result (treated as 'success' or 'fail'). It should
//* only fail when the 'Button ID is not 1-6'.
//* Returns : 'True' if successful, otherwise 'False' where button is undefined.
//* Parameters: 'intButtonNumber' - Corresponds to the Arduino Board button ID number.
//* Prereqs : Requires the following Libraries set in the Main (Libraries) Code:
//* *Keyboard Libray - HID-Project.h
//* Requires the following GLOBAL Contants or Variables set in the Main (Initialisation) Code:
//* * Constant 'cintDebounceTime' specifies DELAY before preformaing additional buttion actions.
//* Author : A. Seibel-Barnes (from original source by Z. Seibel-Barnes)
//* Date : 17/09/2022 (Ver 1.0)
//* Notes : 'Keyboard.press' code options (examples for reference)
//* * Keyboard.press(KEY_LEFT_CTRL)
//* * Keyboard.press(KEY_LEFT_ALT)
//* * Keyboard.press(KEY_LEFT_SHIFT)
//'**********************************************************************************************
bool ButtonPressAction(int intButtonNumber)
{
bool blnButtonActioned = false;
bool blnDelayActions = false; //Used to SLOW 'button actions' from repeating (ie. it is a simple debounce to retard 'extra' or 'unwanted' actions from Buttons).
// Perform 'Button PRESS' action
switch (intButtonNumber)
{
case 1:
// DEFINITION: PASTE COMMAND (Ctrl+v)
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.write('v');
blnDelayActions = true;
blnButtonActioned = true;
break;
case 2:
// DEFINITION: COPY COMMAND (Ctrl+c)
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.write('c');
blnDelayActions = false;
blnButtonActioned = true;
break;
case 3:
// DEFINITION: 'SHIFT' KEY (Only)
Keyboard.press(KEY_LEFT_SHIFT);
blnDelayActions = false;
blnButtonActioned = true;
break;
case 4:
// DEFINITION: CUSTOM TEXT (Message)
//Keyboard.println("Hi");
//Keyboard.println;
Keyboard.print("Tracking progress applies on business days as it processes through Postal and Customs facilities.");
//Keyboard.println("Just confirming that your item is in the mail (and may have already been delivered)... See pics.");
//Keyboard.println();
//Keyboard.println("Tracking is available via Australia Post: TMP40083004070052454xxxxx");
//Keyboard.println("Tracking progress applies on business days as it processes through Australia Post facilities..");
//Keyboard.println();
//Keyboard.print("Thank-you and All the best ;)");
blnDelayActions = true;
blnButtonActioned = true;
break;
case 5:
// DEFINITION: TBA
blnDelayActions = false;
blnButtonActioned = true;
break;
case 6:
// DEFINITION: TBA
blnDelayActions = false;
blnButtonActioned = true;
break;
default:
//Returns a 'fail' if the 'Button ID' was not specified between 1-6.
break;
}
// Check if a 'Pause' is required while performing 'Button' action(s): This stops (or rather 'SLOWS') 'repeated button actions' if a button is 'held down too long' (eg. helps stop extra 'PASTE data' commands)
switch (blnDelayActions)
{
case true:
// Pause
delay(cintDebounceTime);
blnDelayActions = false;
break;
default:
// No Delay, or maybe repeat action(s)
delay(0);
break;
}
//Return the fuctions result
return blnButtonActioned;
}
//********************************************************************************************
//* FUNCTION NAME: 'ButtonReleaseAction'
//********************************************************************************************
//* Purpose : Performs pre-defined action(s) when an Arduino Board button is RELEASED.
//* Code Type : FUCTION CALL: C - Arduino Leonardo (Arduino IDE)
//* Usage : Can be called anytime. Function call example: blnButtonActivty = ButtonReleaseAction(1,false);
//* Where: * 'ButtonReleaseAction(1,false)' specifies the button for which the implicidly defined Key-release action(s) will execute (when false specified). Or,
//* (when true) 'Releases ALL keys' irrelevant of which 'Button ID' was released.
//* * 'blnButtonActivty' receives the return result (treated as 'success' or 'fail'). Should only fail when 'blnReleaseALLKeys is false' AND the 'Button ID is not 1-6'.
//* Returns : 'True' if successful, otherwise 'False' where button is undefined.
//* Parameters: 'intButtonNumber' - Corresponds to the Arduino Board 'Button ID' number (1-6)
//* 'blnReleaseALLKeys' - When 'true' it simply 'Releases ALL Keys' (and ignores the 'Button ID' since there are no specific Key-release requirements).
//* When 'false' it requires that specific Key(s) are implicidly released.
//* Prereqs : Keyboard Library (HID-Project.h) should be set in the Main (Libraries) Code.
//* Author : A. Seibel-Barnes (from original source by Z. Seibel-Barnes)
//* Date : 17/09/2022 (Ver 1.0)
//* Notes : 'Keyboard.release' code options (for use when blnReleaseALLKeys = false)
//* * Keyboard.release(KEY_SPACE)
//* * Keyboard.release(KEY_LEFT_CTRL)
//'**********************************************************************************************
bool ButtonReleaseAction(int intButtonNumber, bool blnReleaseALLKeys)
{
bool blnButtonActioned = false;
// Check if ALL Keyboard Keys should now be released (Usually 'true', but perhaps 'false' if 'multi-button hold combinations' are required)
switch (blnReleaseALLKeys)
{
case true:
// SIMPLE - 'Release 'ALL Keyboard Keys' (this should almost always be the case).
Keyboard.releaseAll();
blnButtonActioned = true;
break;
default:
// SPECIFIC - 'Implicidly set what Key(s)' need to be released. This is REQUIRED when Key-hold combination are required.
switch (intButtonNumber)
{
case 1:
// DEFINITION: TBA
blnButtonActioned = true;
break;
case 2:
// DEFINITION: TBA
blnButtonActioned = true;
break;
case 3:
// DEFINITION: 'SHIFT' KEY (Only)
Keyboard.release(KEY_LEFT_SHIFT);
blnButtonActioned = true;
break;
case 4:
// DEFINITION: TBA
blnButtonActioned = true;
break;
case 5:
// DEFINITION: TBA
blnButtonActioned = true;
break;
case 6:
// DEFINITION: TBA
blnButtonActioned = true;
break;
default:
//Returns a 'fail' if the 'Button ID' was not specified between 1-6.
break;
}
break;
}
//Return the fuctions result
return blnButtonActioned;
}
//********************************************************************************************
//* FUNCTION NAME: 'GetLEDsDimCycleValue'
//********************************************************************************************
//* Purpose : Determines the LED Brightness 'Dimming Cycle' Value.
//* Code Type : FUCTION CALL: C - Arduino Leonardo (Arduino IDE)
//* Usage : Can be called anytime. Function call example: ledBrightness = GetLEDsDimCycleValue(ledBrightness);
//* Where: * 'GetLEDsDimCycleValue(ledBrightness)' calls the fuction and specifies the CURRENT LED Brigtness Value.
//* * 'ledBrightness=' would receive the RETURN LED Brightness Value.
//* Returns : An integer value to specify the new LED Brightness.
//* Parameters: 'intCurrentLEDBrightnessValue' - Is the current / existing LED Brightness value.
//* Prereqs : Requires the following GLOBAL Contants or Variables set in the Main (Initialisation) Code:
//* * Constant 'cblnLEDsToDimCycle' to be set to TRUE in MAIN PROGRAM (and evaluated as TRUE with an 'If or Switch Statement' in the main code)
//* * Constant 'cintLedDimmerStep' is used to moderate the LED Brightness change (in steps)
//* * Constant 'cintLedMinBrightness' specifies the MINIMUM LED brightness to DIM to.
//* * Variable 'ledTickTime' keeps track of the LED Timer between LED Brightness value changes.
//* Author : A. Seibel-Barnes
//* Date : 23/09/2022 (Ver 1.0)
//* Notes : Live Long and Propser _\//
//'**********************************************************************************************
int GetLEDsDimCycleValue(int intCurrentLEDBrightnessValue)
{
int intLEDBrightnessValue; //LED brightness level to return to Main Code
intLEDBrightnessValue = intCurrentLEDBrightnessValue;
//Begin to 'Cycle LED DIMMING' (Up or DOWN) - even if there has been NO Button Activity.
if(!blnLEDsAreCyclingUp)
{
//CYCLE LEDs DOWN: Adjust LEDs brightness Down. LEDs are not in the process of Cycling up to Max ... So, DIM LEDs brightness (slowly 'Dim step DOWN' to Off)
if ((millis() - ledTickTime) > cintLedDimmerStepTime)
{
ledTickTime = millis();
if(intLEDBrightnessValue > cintLedMinBrightness)
{
intLEDBrightnessValue = intLEDBrightnessValue - cintLedDimmerStep;
}
}
}
else if(blnLEDsAreCyclingUp)
{
//CYCLE LEDs UP: Adjust LEDs brightness Up (slowly 'Dim step UP' to Max)
if ((millis() - ledTickTime) > cintLedDimmerStepTime)
{
ledTickTime = millis();
if(intLEDBrightnessValue < cintLedMaxBrightness)
{
intLEDBrightnessValue = intLEDBrightnessValue + cintLedDimmerStep;
}
else if(intLEDBrightnessValue >= cintLedMaxBrightness)
{
//Max LED Brightness has been reached (Reset the flag to begin 'LED cycle Down' process)
blnLEDsAreCyclingUp = false;
}
}
}
else if(intLEDBrightnessValue = cintLedMaxBrightness)
{
blnLEDsAreCyclingUp = false;
}
//Return the fuctions result
return intLEDBrightnessValue;
}