From 40469c80c5411d535e481e9fb48ffc8e959792bc Mon Sep 17 00:00:00 2001 From: Lyubomir Penev Date: Fri, 31 Oct 2025 14:58:54 +0100 Subject: [PATCH] Added comments to potControlls --- include/potControlls.h | 9 +++++++++ src/main.cpp | 3 +++ src/potControlls.cpp | 23 +++++++++++++++++++++++ src/staffFunctions.cpp | 2 +- src/userFunctions.cpp | 2 +- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/potControlls.h b/include/potControlls.h index 096b64b..a9f3c85 100644 --- a/include/potControlls.h +++ b/include/potControlls.h @@ -1,4 +1,13 @@ #pragma once +/** + * @brief This function moves the potentiometer wiper one step to pin A + * + */ void potIncrement(); + +/** + * @brief This function moves the potentiometer wiper one step to pin B + * + */ void potDecrement(); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 38ba34b..4ec4343 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,11 +27,13 @@ void setup() pinMode(REMOTE_C, INPUT); // Remote Button C pinMode(REMOTE_D, INPUT); // Remote Button D + // Potentiometer pinMode(POT_CS, OUTPUT); // D10 - CS pinMode(POT_UD, OUTPUT); // D9 - U/D digitalWrite(POT_CS, HIGH); digitalWrite(POT_UD, LOW); + // Reset the potentiometer for (int i = 0; i < 64; i++) { potIncrement(); @@ -74,6 +76,7 @@ void loop() } // Remote C - Volume Down + // Make sure we are not is a state of mute or lowered if (reader.debounceReadNO(REMOTE_C) && !(oldUserVolume > userVolume)) { volumeDown(&userVolume, &oldUserVolume); diff --git a/src/potControlls.cpp b/src/potControlls.cpp index 434bea1..77bebed 100644 --- a/src/potControlls.cpp +++ b/src/potControlls.cpp @@ -1,7 +1,26 @@ +/** + * @file potControlls.cpp + * @author Lyubomir Penev (me@lpenev.com) + * @brief Here are all the functions responsible for incrementing and decrementing the potentiometer + * @version 0.1 + * @date 2025-10-31 + * + * @copyright Copyright (c) 2025 + * + * Here are all the functions responsible for incrementing and decrementing the MCP4011 digital potentiometer. For more information on the protocol used to control the potentiometer you can look on pages 29 and 31 of the datasheet, and for timing information you can checkout pages 6 and 7. + * + * Datasheet: https://ww1.microchip.com/downloads/en/devicedoc/21978a.pdf + * + */ + #include #include #include +/** + * @brief This function moves the potentiometer wiper one step to pin A + * + */ void potIncrement() { digitalWrite(POT_UD, HIGH); @@ -18,6 +37,10 @@ void potIncrement() digitalWrite(POT_CS, HIGH); } +/** + * @brief This function moves the potentiometer wiper one step to pin B + * + */ void potDecrement() { digitalWrite(POT_UD, LOW); diff --git a/src/staffFunctions.cpp b/src/staffFunctions.cpp index 7982f77..ae035d8 100644 --- a/src/staffFunctions.cpp +++ b/src/staffFunctions.cpp @@ -1,6 +1,6 @@ /** * @file staffFunctions.cpp - * @author Lyubomir Penev + * @author Lyubomir Penev (me@lpenev.com) * @brief Here are all the implementations of the staff functions * @version 1.0 * @date 2025-10-23 diff --git a/src/userFunctions.cpp b/src/userFunctions.cpp index eabe136..558f580 100644 --- a/src/userFunctions.cpp +++ b/src/userFunctions.cpp @@ -1,6 +1,6 @@ /** * @file userFunctions.cpp - * @author Lyubomir Penev + * @author Lyubomir Penev (me@lpenev.com) * @brief Here are all the implementations for the user functions. * @version 1.0 * @date 2025-10-23