Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
linpot doc comments, color palettes
Browse files Browse the repository at this point in the history
  • Loading branch information
crsz20 committed Dec 16, 2023
1 parent cfbbb86 commit dec97e8
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Linear Potentiometer
* Authors: Cristian Cruz
* Manuel DJC
* Linear Potentiometer SLS1300
* Author: Manuel DJC
* Cristian Cruz
*
* Email: [email protected]
* [email protected]
* Email: [email protected]
* [email protected]
*
* (c) 2022 Dallas Formula Racing - Embedded Firmware Team
* Formula SAE International Collegiate Chapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Linear Potentiometer SLS1300
* Author: Manuel DJC
* Modified By: Cristian Cruz
* Author: Manuel DJC
* Cristian Cruz
*
* Email: [email protected]
* [email protected]
* Email: [email protected]
* [email protected]
*
* (c) 2022 Dallas Formula Racing - Embedded Firmware Team
* Formula SAE International Collegiate Chapter
Expand All @@ -28,16 +28,16 @@ float SLS1322::DisplacementMillimeters() {
return displacement_ratio * kMaxLengthMillimeters;
}

float SLS1322::DisplacementRatio() {
uint32_t quantized_count = ReadQuantizedInput();
float retraction_ratio = (float)(quantized_count) / kMaxResolution;
return 1 - retraction_ratio;
}

uint32_t SLS1322::ReadQuantizedInput() {
HAL_ADC_Start(&adc_);
HAL_ADC_PollForConversion(&adc_, 1);
return HAL_ADC_GetValue(&adc_);
}

float SLS1322::DisplacementRatio() {
uint32_t quantized_count = ReadQuantizedInput();
float retraction_ratio = (float)(quantized_count) / kMaxResolution;
return 1 - retraction_ratio;
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Linear Potentiometer SLS1300
* Author: Manuel DJC
* Modified By: Cristian Cruz
* Author: Manuel DJC
* Cristian Cruz
*
* Email: [email protected]
* [email protected]
* Email: [email protected]
* [email protected]
*
* (c) 2022 Dallas Formula Racing - Embedded Firmware Team
* Formula SAE International Collegiate Chapter
Expand All @@ -23,32 +23,39 @@

namespace sensor {

/// SLS1322
class SLS1322 : public ILinearPotentiometer {
public:
SLS1322();
SLS1322(ADC_HandleTypeDef& hadc);

/// @param hadc An ADC peripheral from ST's HAL.
SLS1322(ADC_HandleTypeDef &hadc);
virtual ~SLS1322();

/// DisplacementInches
/// @param None
/// @return Displacement as inches HAHAHA HUHH?!
/// Converts the ADC signal to the measured displacement of the potentiometer.
/// @return 0.0 to 3.0 inches.
float DisplacementInches() override;

// Converts the ADC signal to the measured displacement of the potentiometer.
/// @return 0.0 to 76.2 millimeters.
float DisplacementMillimeters() override;

private:
// Returns an ADC reading after the sampling undergoes quantization.
// Range: 0 to ADC resolution
// That is, 0 to 2^(n bits)-1
/// Provides the ADC reading after the sampling undergoes quantization.
/// The accuracy and range varies on the hardware resolution.
/// @return ADC reading in a range of 0 to 2^(n bits)-1.
uint32_t ReadQuantizedInput();
// Returns an ADC reading within a range of 0.0 to 1.0.

/// Represents the quantized input as a ratio.
/// @return ADC reading in a range of 0.0 to 1.0.
float DisplacementRatio();

ADC_HandleTypeDef& adc_;

static constexpr uint16_t kMaxResolution = 0x0FFF; // 2^(12 bits) - 1
/// Resolution for a 12-bit ADC, 2^(12 bits) - 1
static constexpr uint16_t kMaxResolution = 0x0FFF;
static constexpr uint8_t kMaxLengthInches = 3;
static constexpr float kMaxLengthMillimeters = 25.4f * kMaxLengthInches;

/// The ADC peripheral from ST's HAL library.
ADC_HandleTypeDef& adc_;
};

}
Expand Down
Binary file added Project/Docs/_static/autocross_2023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions Project/Docs/_static/breathe.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/* -- breathe specific styles ----------------------------------------------- */

/* So enum value descriptions are displayed inline to the item */
.breatheenumvalues li tt + p {
display: inline;
}

/* So parameter descriptions are displayed inline to the item */
.breatheparameterlist li tt + p {
display: inline;
}

:root {
--color-brand-primary-light: hsl(205deg, 52%, 39%);
--color-brand-primary-dark: hsl(205deg, 65%, 65%);
--breathe-str-char-color-dark: hsl(41, 85%, 46%);
--breathe-str-char-color-light: hsl(41, 89%, 37%);
--breathe-keyword-type-color-dark: hsl(256, 100%, 65%);
--breathe-keyword-type-color-light: hsl(276, 85%, 29%);
--breathe-number-color-dark: hsl(157, 81%, 50%);
--breathe-number-color-light: hsl(157, 93%, 32%);
--breathe-name-color-dark: hsl(88, 72%, 56%);
--breathe-name-color-light: hsl(88, 100%, 28%);
}

/* ************************************************** */
/* rules to uniform color scheme with breathe-doc.org */

body {
--color-brand-primary: var(--color-brand-primary-light);
--color-brand-content: var(--color-brand-primary-light);
--breathe-str-char-color: var(--breathe-str-char-color-light);
--breathe-keyword-type-color: var(--breathe-keyword-type-color-light);
--breathe-number-color: var(--breathe-number-color-light);
--breathe-name-color: var(--breathe-name-color-light);
}

/* Enable dark-mode, if requested. */
body[data-theme="dark"] {
--color-brand-primary: var(--color-brand-primary-dark);
--color-brand-content: var(--color-brand-primary-dark);
--breathe-str-char-color: var(--breathe-str-char-color-dark);
--breathe-keyword-type-color: var(--breathe-keyword-type-color-dark);
--breathe-number-color: var(--breathe-number-color-dark);
--breathe-name-color: var(--breathe-name-color-dark);
}

/* Enable dark mode, unless explicitly told to avoid. */
@media (prefers-color-scheme: dark) {
body:not([data-theme="light"]) {
--color-brand-primary: var(--color-brand-primary-dark);
--color-brand-content: var(--color-brand-primary-dark);
--breathe-str-char-color: var(--breathe-str-char-color-dark);
--breathe-keyword-type-color: var(--breathe-keyword-type-color-dark);
--breathe-number-color: var(--breathe-number-color-dark);
--breathe-name-color: var(--breathe-name-color-dark);
}
}

.mobile-header {
/* background-color: var(--color-header-background); */
background-color: #003c66;
}

.mobile-header .toc-overlay-icon .icon {
/* color: var(--color-foreground-secondary); */
color: white;
}

.mobile-header .header-center a {
/* color: var(--color-header-text); */
color: white;
}

.mobile-header .theme-toggle svg {
/* color: var(--color-foreground-primary); */
color: white;
}

/* C++ specific styling */

.highlight {
/* desaturate that ugly yellow color used by most other theme's code snippets */
background-color: var(--color-api-background); /* for light theme only */
}

.sig.c .k, .sig.c .kt,
.sig.cpp .k, .sig.cpp .kt {
color: var(--breathe-keyword-type-color);
}

.sig.c .m,
.sig.cpp .m {
color: var(--breathe-number-color);
}

.sig.c .s, .sig.c .sc,
.sig.cpp .s, .sig.cpp .sc {
color: var(--breathe-str-char-color);
}

.sig > .n {
color: var(--breathe-name-color);
}

/*
bugfix for multi-lined signatures
(see https://github.com/pradyunsg/furo/discussions/427 )
*/
.sig {
padding-left: 0.5em;
text-indent: revert;
}
Binary file added Project/Docs/_static/cropped-Logo-Updated-PNG-1.webp
Binary file not shown.
45 changes: 43 additions & 2 deletions Project/Docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'Data Acquisition 2.0'
copyright = '2023, Dallas Formula Racing: Embedded Team'
copyright = '2022-2024, Dallas Formula Racing: Embedded Team'
author = 'Dallas Formula Racing: Embedded Team'

# -- General configuration ---------------------------------------------------
Expand All @@ -37,7 +37,7 @@
'sphinx.ext.viewcode',
'sphinx.ext.inheritance_diagram',
'breathe'
# 'myst_parser'
'myst_parser'
]

source_suffix = {
Expand All @@ -56,8 +56,49 @@
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'furo'
html_title = "Data Acquisition (DAQ) System API Documentation"
html_static_path = ['_static']
html_logo = "_static/UPDATED-COLORED-LOGO-DFR-2.png"
html_favicon = "_static/cropped-Logo-Updated-PNG-1.webp"

# -- Furo theme-specific configuration -------------------------------------------------
html_css_files = ["breathe.css"]

html_theme_options = {
"light_css_variables": {
"color-brand-primary": "#C76503",
"color-brand-content": "#C76503",
},

"dark_css_variables": {
"color-brand-primary": "#E87500",
"color-brand-content": "#E87500",
},

"footer_icons": [
{
"name": "RaceCar",
"url": "https://dallasformularacing.com/",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="200px" width="200px">
<path d="M408.29 262.879a35.125 35.125 0 1 0 35.125 35.125 35.17 35.17 0 0 0-35.125-35.125zm0 62.873a27.736 27.736 0 1 1 27.736-27.737 27.736 27.736 0 0 1-27.736 27.748zm8.876-27.737a8.876 8.876 0 1 1-8.876-8.875 8.876 8.876 0 0 1 8.876 8.875zm-265.538 0a35.125 35.125 0 1 0-35.126 35.126 35.17 35.17 0 0 0 35.126-35.126zm-35.126 27.737a27.736 27.736 0 1 1 27.737-27.737 27.736 27.736 0 0 1-27.737 27.748zm345.452-21.823a53.997 53.997 0 1 0-107.617-5.925 53.665 53.665 0 0 0 5.447 23.61H165.008a53.986 53.986 0 1 0-101.849-15.211C37.542 295.64 21 278.033 21 250.186c0-28.846 86.87-69.418 142.122-71.327v34.094a24.83 24.83 0 0 0 24.83 24.83h47.517a24.774 24.774 0 0 0 24.409-20.758s-1.62-21.668-6.813-25.518l3.407-2.54 24.474 28.08h94.104c63.994-.022 115.95 23.42 115.95 52.266 0 13.314-10.973 25.396-29.046 34.616zm-336.576-5.925a8.876 8.876 0 1 1-8.876-8.876 8.876 8.876 0 0 1 8.876 8.887z"></path>
</svg>
""",
"class": "",

},
{
"name": "GitHub",
"url": "https://github.com/DallasFormulaRacing/DataAcquisition2.0",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
"class": "",
},
],
}

# -- Breathe configuration -------------------------------------------------
breathe_projects = {
Expand Down
46 changes: 35 additions & 11 deletions Project/Docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,35 +1,59 @@
.. Data Acquisition 2.0 documentation master file, created by
sphinx-quickstart on Wed Dec 6 10:23:23 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. Data Acquisition 2.0 documentation root file
Welcome to Data Acquisition 2.0's documentation!
================================================
Welcome to DFR's Data Acquisition API documentation!
====================================================

.. image:: _static/autocross_2023.png

.. toctree::
:maxdepth: 2
:caption: Application Layer
:hidden:

data_logger/index


.. toctree::
:maxdepth: 2
:caption: Sensor Layer
:hidden:

linear_potentiometer/index

.. toctree::
:maxdepth: 2
:caption: Platform Layer
:hidden:

peripherals/index

These pages are auto-generated from our source code. Each firmware component is organized as the following. For high-level design and development documentation, go to our repository's `wiki <https://github.com/DallasFormulaRacing/DataAcquisition2.0/wiki/>`_.


Indices and tables
==================
Index Table
-----------

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

Firmware Architecture
---------------------

Application Layer
^^^^^^^^^^^^^^^^^

- High-level code.
- Will mostly consist of logic rather than nitty-gritty details.
- Will not be constrained to a particular product.

Sensor Layer
^^^^^^^^^^^^

- Low-level code.
- Consists of drivers. That is, libraries to support sensors and external devices.
- Product-specific code.

Platform Layer
^^^^^^^^^^^^^^

- Low-level code.
- Access to microcontroller peripherals.
- Platform-specific code. Such as, making use of I2C on an STM32 with the HAL library vs. on a TI microcontroller.
1 change: 1 addition & 0 deletions Project/Docs/linear_potentiometer/interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

Interface
=========

.. doxygenfile:: ilinear_potentiometer.hpp
:project: Data Acquisition 2.0
2 changes: 1 addition & 1 deletion Project/Docs/peripherals/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _peripherals:

Pin Map
Peripherals
====================
.. toctree::
:maxdepth: 2
Expand Down

0 comments on commit dec97e8

Please sign in to comment.