Skip to content

Commit

Permalink
arduino-pulsoxy: Fix trailing whitespace in all files
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Nuernberger <[email protected]>
  • Loading branch information
snue committed Mar 14, 2020
1 parent 36ef3f7 commit c90b6d6
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/ADC.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 07.03.2018 16:02:45
* Author: Moritz Klimt
*/
*/

#include <avr/io.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 07.03.2018 16:02:54
* Author: Moritz Klimt
*/
*/



Expand Down
18 changes: 9 additions & 9 deletions Source_codes/SPO2/arduino-pulsoxy/AGC.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 04.04.2018 15:22:19
* Author: Moritz Klimt
*/
*/

#include <avr/io.h>
#include <stdint.h>
Expand Down Expand Up @@ -73,7 +73,7 @@ void AGC(volatile uint32_t *TimingGain, volatile uint32_t *TimingEnvelope)
*TimingEnvelope = 0;
}
if((*TimingEnvelope) >= 200){

if((PPGRACDCmax - PPGRACDCmin)>(PPGIRACDCmax - PPGIRACDCmin))
{
PPGpeakpeak = PPGRACDCmax - PPGRACDCmin;
Expand All @@ -82,20 +82,20 @@ void AGC(volatile uint32_t *TimingGain, volatile uint32_t *TimingEnvelope)
{
PPGpeakpeak = PPGIRACDCmax - PPGIRACDCmin;
}

newRAGC = ((400/(PPGpeakpeak)));

if(newRAGC>=100)
{
{
newRAGC = 100;
}
if(newRAGC<=1)
{
newRAGC = 1;
}

MeanRAGC = 0;

if (RAGCDataPoints < 10)
{
RAGCDataPoints++;
Expand All @@ -108,7 +108,7 @@ void AGC(volatile uint32_t *TimingGain, volatile uint32_t *TimingEnvelope)
RAGCValues[9] = newRAGC;
MeanRAGC += RAGCValues[9];
MeanRAGC = MeanRAGC/RAGCDataPoints;

if(MeanRAGC > RAGC)
{
PORTB |= (1 << UD);
Expand Down Expand Up @@ -137,7 +137,7 @@ void AGC(volatile uint32_t *TimingGain, volatile uint32_t *TimingEnvelope)
PPGIRACDCmin = 1023;
PPGRACDCmax = -1023;
PPGRACDCmin = 1023;

}
}
}
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/AGC.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 04.04.2018 15:22:32
* Author: Moritz Klimt
*/
*/

extern uint8_t RAGC;
extern uint8_t *RAGCValues_p;
Expand Down
14 changes: 7 additions & 7 deletions Source_codes/SPO2/arduino-pulsoxy/LEDControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 04.04.2018 11:49:26
* Author: Moritz Klimt
*/
*/

#include <avr/io.h>
#include <stdint.h>
Expand All @@ -28,9 +28,9 @@ int FingerIn_Out()

/*
* LEDBrightnessUP(); is a function to increase the LED brightness.
* The address of the GainDelay variable is passed to it via a pointer
* The address of the GainDelay variable is passed to it via a pointer
* in order to delay the control slightly via the value stored at this address.
* If the value of the DC signals is below 600 (approx. 3V),
* If the value of the DC signals is below 600 (approx. 3V),
* the PWM duty cycle is increased until the DC signal is at 3V or the PWM duty cycle of 100% is reached.
*/

Expand All @@ -42,12 +42,12 @@ void LEDBrightnessUP(uint32_t *Timing)
if (PPGRDCsig<500)
{
PWMR+=2;
*Timing = 0;
*Timing = 0;
}
else
{
PWMR++;
*Timing = 0;
*Timing = 0;
}
}
if(PWMR>=4094){
Expand Down Expand Up @@ -75,9 +75,9 @@ void LEDBrightnessUP(uint32_t *Timing)

/*
* LEDBrightnessDOWN(); is a function to decrease the LED brightness.
* The address of the GainDelay variable is passed to it via a pointer
* The address of the GainDelay variable is passed to it via a pointer
* in order to delay the control slightly via the value stored at this address.
* If the value of the DC signals is above 600 (approx. 3V),
* If the value of the DC signals is above 600 (approx. 3V),
* the PWM duty cycle is decreased until the DC signal is at 3V or the PWM duty cycle of 6,5% is reached.
*/

Expand Down
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/LEDControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 04.04.2018 11:49:49
* Author: Moritz Klimt
*/
*/


#ifndef LEDCONTROL_H_
Expand Down
4 changes: 2 additions & 2 deletions Source_codes/SPO2/arduino-pulsoxy/TC1_PWM_4kHz.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 13.03.2018 11:53:10
* Author: Moritz Klimt
*/
*/

#include <avr/io.h>

Expand All @@ -22,5 +22,5 @@ void init_TC1_PWM_4kHz()
ICR1 = 4095; //Set The Input Capture Register to 4095 for a 12-Bit resolution of the PWM
OCR1A = 675; //Set PWM-Duty-Cycle to 16%
OCR1B = 675; //Set PWM-Duty-Cycle to 16%

}
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/TC1_PWM_4kHz.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 14.03.2018 08:50:40
* Author: Moritz Klimt
*/
*/


#ifndef TC1_PWM_31KHZ_H_
Expand Down
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/TC2_8b_2ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 07.03.2018 17:15:33
* Author: Moritz Klimt
*/
*/

#include <avr/io.h>

Expand Down
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/TC2_8b_2ms.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 07.03.2018 17:16:00
* Author: Moritz Klimt
*/
*/


#ifndef TC2_8B_2MS_H_
Expand Down
3 changes: 1 addition & 2 deletions Source_codes/SPO2/arduino-pulsoxy/UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 14.03.2018 12:21:11
* Author: Moritz Klimt
*/
*/

#ifndef F_CPU
#define F_CPU 16000000UL
Expand Down Expand Up @@ -42,4 +42,3 @@ void SendData(int16_t data)
while ((UCSR0A & (1 << UDRE0)) == 0);
UDR0 = 0x0A;
}

2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/UART.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 14.03.2018 12:21:33
* Author: Moritz Klimt
*/
*/


#ifndef UART_H_
Expand Down
4 changes: 2 additions & 2 deletions Source_codes/SPO2/arduino-pulsoxy/Update_Signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
*
* Created: 12.03.2018 17:28:43
* Author: Moritz Klimt
*/
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ADC.h"

/*
* Variables for updating the AC and DC-PPG Signals
* Variables for updating the AC and DC-PPG Signals
*/

#define PPGIRDC 0
Expand Down
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/Update_Signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 12.03.2018 17:28:53
* Author: Moritz Klimt
*/
*/


#ifndef UPDATE_SIGNALS_H_
Expand Down
34 changes: 17 additions & 17 deletions Source_codes/SPO2/arduino-pulsoxy/arduino-pulsoxy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 07.03.2018 15:49:20
* Author : Moritz Klimt
*/
*/

#ifndef F_CPU
#define F_CPU 16000000UL
Expand Down Expand Up @@ -33,7 +33,7 @@ volatile uint32_t *GainDelay_p = &GainDelay;
volatile uint32_t EnvelopeBufferTime = 0; //Variable for timing the Envelope detection.
volatile uint32_t *EnvelopeBufferTime_p = &EnvelopeBufferTime;

uint8_t FingerDetection = 0; //Variable set to 1 if a finger is detected and 0 if not
uint8_t FingerDetection = 0; //Variable set to 1 if a finger is detected and 0 if not

volatile uint8_t BufferTimer = 0; //Variable for setting the time intervals in which values for the SpO2 calculation are written to the buffer

Expand All @@ -50,28 +50,28 @@ uint8_t SPO2 = 0; //Variable for the calculated SpO2-value
void setup()
{
cli(); //Disable all Interrupts

init_ADC(); //Initializes the ADC
init_TC2_8b_2ms(); //Initializes the TC2 to trigger a timer interrupt every 2ms
init_TC1_PWM_4kHz(); //Initializes the TC1 to generate a PWM with 12bit resolution and 4kHz, to control the red/IR LED brightness
init_UART_115200_8N1(); //Initializes the serial communication via UART, with a baud rate of 115200

sei(); //Enable all Interrupts

init_AGC(GainDelay_p); //Initializes the Auto Gain Control

DDRD |= (1 << PD2); //PIN PD2 Output This Pin is set to HIGH if the LED Brightness is getting adjusted
}

void loop() {
FingerDetection = FingerIn_Out(); //Testing if the finger is in the Fingerclip or not

if (FingerDetection==0) //If no finger was detected, the measurement is reset
{
SendData(0); //Send ERROR-Code 404 "No Finger Detected"
PORTD |= (1 << PD2); //Setting PIN PD2 to HIGH
BufferDataPoint = 0; //Reset the Buffer for the SpO2 calculation
calculateSPO2 = 0;
calculateSPO2 = 0;
for (uint8_t i = 0; i<10 ; i++) //Reset the SpO2-Value and RAGC-Value Buffer
{
*(SPO2Values_p+i) = 0;
Expand All @@ -87,11 +87,11 @@ void loop() {
{
}
}

if (FingerDetection==1) //If a finger was detected, the SpO2 routine starts
{
PORTD &= ~(1 << PD2); //Setting PIN PD2 to LOW

//Control of the LED brightness
if ((PPGIRDCsig >= 800)||(PPGRDCsig >= 800)) //If the LEDs are too bright, they are turned down
{
Expand All @@ -117,18 +117,18 @@ void loop() {
}
RAGCDataPoints = 0;
}

//Adjusting the AC-Gain
AGC(GainDelay_p,EnvelopeBufferTime_p);
//Calculating SPO2

//Calculating SPO2
if ((calculateSPO2==1)&&(RAGCDataPoints > 1))
{
SPO2 = calculatingSPO2(aACIRBuffer_p,aACRBuffer_p,((uint16_t)(sizeof(aACIRBuffer)/sizeof(aACIRBuffer[0]))));
SendData(SPO2); //Transmission of the current SpO2 value
calculateSPO2 = 0;
}

}
}

Expand All @@ -140,17 +140,17 @@ ISR(TIMER2_COMPA_vect)
GainDelay+=2; //Counting the time for the Gain timing
EnvelopeBufferTime+=2; //Counting the time for the envelope detection timing
BufferTimer++; //Counting the ISR calls to write a data point onto the buffer every 20ms

if(BufferTimer == 10) //Write a data point onto the buffer every 20ms
{
BufferTimer = 0;

if ((calculateSPO2 == 0)) //The buffer is only written as long as no new SpO2 value is calculated
{
*(aACIRBuffer_p+BufferDataPoint) = (int16_t)((PPGIRsig*10/PPGIRDCsig));
*(aACRBuffer_p+BufferDataPoint) = (int16_t)((PPGRsig*10/PPGRDCsig));
BufferDataPoint++;

if(BufferDataPoint == ((uint16_t)(sizeof(aACIRBuffer)/sizeof(aACIRBuffer[0])))) //When the buffer is full, the SpO2 value can be calculated
{
BufferDataPoint = 0;
Expand Down
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/calculatingSPO2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 04.04.2018 20:04:46
* Author: Moritz Klimt
*/
*/
#include <stdint.h>
#include <math.h>

Expand Down
2 changes: 1 addition & 1 deletion Source_codes/SPO2/arduino-pulsoxy/calculatingSPO2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created: 04.04.2018 20:05:12
* Author: Moritz Klimt
*/
*/

extern uint8_t SPO2DataPoints;
extern int16_t *SPO2Values_p;
Expand Down

0 comments on commit c90b6d6

Please sign in to comment.