implemented basic handling of infrared

This commit is contained in:
hhaupt
2024-04-28 01:24:47 +02:00
parent dbe97dc94c
commit 39e424ed13
6 changed files with 94 additions and 76 deletions

View File

@@ -0,0 +1,22 @@
#include "InfraredLight.h"
InfraredLED::InfraredLED(uint8_t pin){
ledPin = pin;
};
void InfraredLED::begin(void){
pinMode(ledPin,OUTPUT);
};
void InfraredLED::turnOn(void){
InfraredLED::setState(true);
};
void InfraredLED::turnOff(void){
InfraredLED::setState(false);
};
void InfraredLED::setState(bool state){
digitalWrite(ledPin,state);
};

View File

@@ -0,0 +1,6 @@
#include "InfraredLight.h"
void InfraredLight::begin(void){
bottom.begin();
front.begin();
}

View File

@@ -0,0 +1,60 @@
/**
* @file InfraredLight.h
* @author Hans Haupt (hans.haupt@dezibot.de)
* @brief Provides basic controls for the infrared LEDs of the robot.
* @version 0.1
* @date 2024-04-27
*
* @copyright Copyright (c) 2024
*
*/
#ifndef InfraredLight_h
#define InfraredLight_h
#include <stdint.h>
#include <Arduino.h>
enum IRLeds{
Bottom,
Front
};
class InfraredLED{
public:
InfraredLED(uint8_t pin);
void begin(void);
/**
* @brief enables selected LED
*
* @param led
*/
void turnOn(void);
/**
* @brief disables selected LED
*
* @param led
*/
void turnOff(void);
/**
* @brief changes state of selected LED depending on the state
*
* @param led which led will be affected
* @param state true if led should be turned on, else false
*/
void setState(bool state);
protected:
uint8_t ledPin;
};
class InfraredLight{
public:
InfraredLED bottom = InfraredLED(IRBottomPin);
InfraredLED front = InfraredLED(IRFrontPin);
void begin(void);
protected:
static const uint8_t IRFrontPin = 14;
static const uint8_t IRBottomPin = 13;
};
#endif //InfraredLight_h