mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-09-15 18:08:03 +02:00
implemented basic handling of infrared
This commit is contained in:
22
src/infraredLight/InfraredLED.cpp
Normal file
22
src/infraredLight/InfraredLED.cpp
Normal 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);
|
||||
};
|
6
src/infraredLight/InfraredLight.cpp
Normal file
6
src/infraredLight/InfraredLight.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "InfraredLight.h"
|
||||
|
||||
void InfraredLight::begin(void){
|
||||
bottom.begin();
|
||||
front.begin();
|
||||
}
|
60
src/infraredLight/InfraredLight.h
Normal file
60
src/infraredLight/InfraredLight.h
Normal 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
|
Reference in New Issue
Block a user