split code into more files

This commit is contained in:
2022-02-10 16:41:27 +01:00
parent b5f588bdf6
commit 34ee74c185
7 changed files with 268 additions and 0 deletions

83
abzug.c Normal file
View File

@@ -0,0 +1,83 @@
#include <avr/io.h>
#include "avrIOhelper/io-helper.h"
uint16_t abzug_speed = 100;
void timer3_init()
{
TCCR3A |= (1<<COM3B1);
TCCR3B |= _BV(WGM33);
ICR3 = 100;
OCR3B = 50;
DDRE |= 1 << 4;
}
void send_abzug_speed(void);
void do_rolle(){
if (read_Input(BTN_ABZUG_EIN, RISING)) {
TCCR3B |= _BV(CS31);
set_Output(LED_ABZUG, ON);
#if PLC_MQTT_ENABLED
send_abzug_speed();
#endif
}
if (read_Input(BTN_ABZUG_AUS, RISING)) {
TCCR3B &= ~(_BV(CS31));
set_Output(LED_ABZUG, OFF);
#if PLC_MQTT_ENABLED
send_abzug_speed();
#endif
}
if (read_Input(BTN_ABZUG_PLUS, RISING)) {
if(abzug_speed <= 900)
abzug_speed += 100;
else
abzug_speed = 1000;
#if PLC_MQTT_ENABLED
send_abzug_speed();
#endif
}
if (read_Input(BTN_ABZUG_MINUS, RISING)) {
if(abzug_speed >= 110)
abzug_speed -= 100;
else
abzug_speed = 10;
#if PLC_MQTT_ENABLED
send_abzug_speed();
#endif
}
if (read_Input(BTN_ABZUG_PLUS_FEIN, RISING)) {
if(abzug_speed <= 990)
abzug_speed += 10;
else
abzug_speed = 1000;
#if PLC_MQTT_ENABLED
send_abzug_speed();
#endif
}
if (read_Input(BTN_ABZUG_MINUS_FEIN, RISING)) {
if(abzug_speed >= 20)
abzug_speed -= 10;
else
abzug_speed = 10;
#if PLC_MQTT_ENABLED
send_abzug_speed();
#endif
}
// 16000000/8
ICR3 = ((1.0/abzug_speed)*3.14*42.0*(1.0/5.0))*2.0*500.0*(1/1.03);
OCR3B = ICR3/2;
}