Start Programming

This commit is contained in:
BlubbFish 2020-10-30 23:22:11 +01:00
parent 879ef241cb
commit 2a2ba7693e
10 changed files with 440 additions and 118 deletions

View File

@ -20,10 +20,10 @@
<OverrideVtor>false</OverrideVtor> <OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash> <CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam> <ProgFlashFromRam>true</ProgFlashFromRam>
<RamSnippetAddress /> <RamSnippetAddress>0x20000000</RamSnippetAddress>
<UncachedRange /> <UncachedRange />
<preserveEEPROM>true</preserveEEPROM> <preserveEEPROM>true</preserveEEPROM>
<OverrideVtorValue /> <OverrideVtorValue>exception_table</OverrideVtorValue>
<BootSegment>2</BootSegment> <BootSegment>2</BootSegment>
<ResetRule>0</ResetRule> <ResetRule>0</ResetRule>
<eraseonlaunchrule>0</eraseonlaunchrule> <eraseonlaunchrule>0</eraseonlaunchrule>
@ -153,6 +153,15 @@
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="io\AudioSwitcher.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\Comperator.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\LED.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\ports\pin.hpp"> <Compile Include="io\ports\pin.hpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
@ -165,6 +174,15 @@
<Compile Include="io\ports\portd.hpp"> <Compile Include="io\ports\portd.hpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="io\PTT.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\Relais.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\Timer.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.cpp"> <Compile Include="main.cpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>

View File

@ -8,24 +8,50 @@
#define F_CPU 8000000 #define F_CPU 8000000
#include "peripheral.h" #include "peripheral.h"
#include "io/AudioSwitcher.hpp"
#include "io/LED.hpp"
template <int delay_plus> template <int delay_plus>
class ProgrammT { class ProgrammT {
private:
void ResetTimer() {
led.SetColor(Led::CYAN);
if(!this->timer_running) {
audio.SetFunk();
}
this->timer_running = true;
}
void TimerEnd() {
audio.SetRadio();
this->timer_running = false;
}
protected:
public: public:
ProgrammT() { ProgrammT() : timer_running(false) {
} }
void Setup() { void Setup() {
led.SetColor(Led::RED);
} }
void Loop() { void Loop() {
if(this->timer_running) {
led.SetColor(Led::YELLOW);
} else {
led.SetColor(Led::GREEN);
}
} }
void PttVect() { void Vect_Ptt() {
this->ResetTimer();
} }
private:
AudioSwitcher audio;
Led led;
protected:
bool timer_running;
public:
}; };
typedef ProgrammT<settings_prog_delay_plus> Programm; typedef ProgrammT<settings_prog_delay_plus> Programm;

View File

@ -0,0 +1,56 @@
/*
* AudioSwitcher.hpp
*
* Created: 30.10.2020 19:47:31
* Author: netz
*/
#ifndef AUDIOSWITCHER_HPP_
#define AUDIOSWITCHER_HPP_
#include "Relais.hpp"
#include "ports/pin.hpp"
#include "ports/portb.hpp"
#include "ports/portd.hpp"
template<typename Relais1, typename Relais2>
class AudioSwitcherT {
// Methods
public:
AudioSwitcherT() {
this->SetRadio();
}
/**
* \brief
* Set the Relais to Radio output
*
* \return void
*/
void SetRadio() {
relais_right.Reset();
relais_left.Reset();
}
/**
* \brief
* Set the Relais to Funk output
*
* \return void
*/
void SetFunk() {
relais_right.Set();
relais_left.Set();
}
// Variables
private:
Relais1 relais_right;
Relais2 relais_left;
};
typedef AudioSwitcherT<RelaisT<blubblib::portb, PINB6, PINB7>, RelaisT<blubblib::portd, PIND3, PIND4> > AudioSwitcher;
#endif /* AUDIOSWITCHER_HPP_ */

View File

@ -0,0 +1,24 @@
/*
* Comperator.hpp
*
* Created: 30.10.2020 19:01:31
* Author: netz
*/
#ifndef COMPERATOR_HPP_
#define COMPERATOR_HPP_
class Comperator {
// Methods
private:
protected:
public:
// Variables
private:
protected:
public:
};
#endif /* COMPERATOR_HPP_ */

View File

@ -0,0 +1,66 @@
/*
* LED.hpp
*
* Created: 30.10.2020 22:05:41
* Author: netz
*/
#ifndef LED_HPP_
#define LED_HPP_
#include "ports/pin.hpp"
#include "ports/portc.hpp"
template<typename led_pin_r, typename led_pin_g, typename led_pin_b>
class LedT {
//ENUMS
public:
enum Led_Color {
BLACK = 0,
RED = 1,
GREEN = 2,
YELLOW = 3,
BLUE = 4,
MAGENTA = 5,
CYAN = 6,
WHITE = 7
};
// Methods
private:
void Init() {
led_r.MakeLow();
led_g.MakeLow();
led_b.MakeLow();
}
protected:
public:
LedT() {
this->Init();
}
/**
* \brief
* Set a color in the RGB Led
* \param color
*
* \return void
*/
void SetColor(Led_Color color) {
led_r.Set(color & (1<<0) ? true : false);
led_g.Set(color & (1<<1) ? true : false);
led_b.Set(color & (1<<2) ? true : false);
}
// Variables
private:
led_pin_r led_r;
led_pin_g led_g;
led_pin_b led_b;
protected:
public:
};
typedef LedT<blubblib::pin<blubblib::portc, PINC1>, blubblib::pin<blubblib::portc, PINC2>, blubblib::pin<blubblib::portc, PINC0> > Led;
#endif /* LED_HPP_ */

View File

@ -0,0 +1,26 @@
/*
* PTT.hpp
*
* Created: 30.10.2020 22:03:26
* Author: netz
*/
#ifndef PTT_HPP_
#define PTT_HPP_
class PttT {
// Methods
private:
protected:
public:
// Variables
private:
protected:
public:
};
#endif /* PTT_HPP_ */

View File

@ -0,0 +1,54 @@
/*
* Relais.hpp
*
* Created: 30.10.2020 19:46:30
* Author: netz
*/
#ifndef RELAIS_HPP_
#define RELAIS_HPP_
#include <util/delay.h>
#include "ports/pin.hpp"
template <typename relais_port, int relais_pin_set, int relais_pin_reset>
class RelaisT {
// Methods
public:
RelaisT() {
r_set::MakeLow();
r_reset::MakeLow();
}
/**
* \brief
* Trigger the Set Pin
*
* \return void
*/
void Set() {
r_set::SetHigh();
_delay_ms(10);
r_set::SetLow();
}
/**
* \brief
* Trigger the Reset Pin
*
* \return void
*/
void Reset() {
r_reset::SetHigh();
_delay_ms(10);
r_reset::SetLow();
}
// Variables
private:
const typedef blubblib::pin<relais_port, relais_pin_set> r_set;
const typedef blubblib::pin<relais_port, relais_pin_reset> r_reset;
};
#endif /* RELAIS_HPP_ */

View File

@ -0,0 +1,26 @@
/*
* Timer.h
*
* Created: 30.10.2020 19:46:04
* Author: netz
*/
#ifndef TIMER_H_
#define TIMER_H_
class Timer {
// Methods
private:
protected:
public:
// Variables
private:
protected:
public:
};
#endif /* TIMER_H_ */

View File

@ -13,6 +13,13 @@
namespace blubblib { namespace blubblib {
template <typename PortT, uint8_t Pin> template <typename PortT, uint8_t Pin>
struct pin { struct pin {
/**
* \brief
* Set or Unset the Output
* \param value
* true = set, false = unset
* \return void
*/
static void Set(bool value = true) { static void Set(bool value = true) {
if (value) { if (value) {
PortT::Port(PortT::Port() | (1<<Pin)); PortT::Port(PortT::Port() | (1<<Pin));
@ -58,6 +65,12 @@ namespace blubblib {
Clear(); Clear();
} }
/**
* \brief
* Set Output and Low
*
* \return void
*/
static void MakeLow() { static void MakeLow() {
Clear(); Clear();
Output(true); Output(true);
@ -72,10 +85,23 @@ namespace blubblib {
Set(value); Set(value);
} }
/**
* \brief
* Set High
*
* \return void
*/
static void SetHigh() { static void SetHigh() {
Set(true); Set(true);
} }
/**
* \brief
* Set Low
*
* \return void
*/
static void SetLow() { static void SetLow() {
Set(false); Set(false);
} }

View File

@ -19,5 +19,5 @@ int main(void) {
} }
ISR(INT0_vect) { ISR(INT0_vect) {
p.PttVect(); p.Vect_Ptt();
} }