THW-Funk-Audio-Switch/Programm/Audio-Switch/Programm.hpp

78 lines
1.4 KiB
C++
Raw Normal View History

2020-10-19 18:16:51 +02:00
/*
* Programm.hpp
*
* Created: 19.10.2020 18:03:50
* Author: netz
*/
#define F_CPU 8000000
#include "peripheral.h"
2020-10-30 23:22:11 +01:00
#include "io/AudioSwitcher.hpp"
#include "io/LED.hpp"
2020-11-02 00:27:02 +01:00
#include "io/Comperator.hpp"
#include "io/PTT.hpp"
#include "io/Timer.hpp"
2020-10-19 18:16:51 +02:00
2020-11-02 00:27:02 +01:00
class Programm {
2020-10-30 23:22:11 +01:00
private:
void ResetTimer() {
led.SetColor(Led::CYAN);
2020-11-02 00:27:02 +01:00
//timer.Reset();
2020-10-30 23:22:11 +01:00
if(!this->timer_running) {
audio.SetFunk();
2020-11-02 00:27:02 +01:00
//timer.Start();
2020-10-30 23:22:11 +01:00
}
this->timer_running = true;
}
2020-11-02 00:27:02 +01:00
2020-10-30 23:22:11 +01:00
void TimerEnd() {
audio.SetRadio();
2020-11-02 00:27:02 +01:00
//timer.Stop();
2020-10-30 23:22:11 +01:00
this->timer_running = false;
}
2020-10-19 18:16:51 +02:00
public:
2020-11-02 00:27:02 +01:00
Programm() : timer_running(false) {
2020-10-30 23:22:11 +01:00
2020-10-19 18:16:51 +02:00
}
void Setup() {
2020-10-30 23:22:11 +01:00
led.SetColor(Led::RED);
2020-11-02 00:27:02 +01:00
_delay_ms(500);
2020-10-19 18:16:51 +02:00
}
void Loop() {
2020-10-30 23:22:11 +01:00
if(this->timer_running) {
led.SetColor(Led::YELLOW);
2020-11-02 00:27:02 +01:00
if(comp.GetInterruptActivated()) {
this->ResetTimer();
}
if(ptt.GetPttActivated()) {
this->ResetTimer();
}
2020-10-30 23:22:11 +01:00
} else {
led.SetColor(Led::GREEN);
}
2020-10-19 18:16:51 +02:00
}
2020-10-30 23:22:11 +01:00
void Vect_Ptt() {
this->ResetTimer();
2020-10-19 18:16:51 +02:00
}
2020-11-02 00:27:02 +01:00
void Vect_Comp() {
this->ResetTimer();
}
void Vect_Timer() {
this->TimerEnd();
}
2020-10-30 23:22:11 +01:00
private:
AudioSwitcher audio;
Led led;
2020-11-02 00:27:02 +01:00
Comperator comp;
Ptt ptt;
//Timer timer;
2020-10-30 23:22:11 +01:00
protected:
bool timer_running;
public:
2020-11-02 00:27:02 +01:00
};