Format everything
The next commit will add this to a `.git-blame-ignore-revs` file which
you can use to ignore this commit when running git blame. Simply run
git blame --ignore-revs-file .git-blame-ignore-revs [...]
Or configure git to persistently ignore the commit:
git config blame.ignoreRevsFile .git-blame-ignore-revs
This commit is contained in:
@ -1,84 +1,74 @@
|
||||
#include "Arduino.h"
|
||||
#include "FT18e_STW_INIT.h"
|
||||
#include "Bounce2.h"
|
||||
#include "RotaryEncoder.h"
|
||||
|
||||
volatile stw_data_type Stw_data = {0}; //alles mit 0 initialisieren
|
||||
volatile vehicle_data_type Vehicle_data = {0}; //alles mit 0 initialisieren
|
||||
bool enc1PinALast, enc1PinANow, enc2PinALast, enc2PinANow;
|
||||
int led[] = {led1, led2, led3, led4, led5, led6, led7, led8, led9, led10, led11, led12, led13, led14, led15, led16};
|
||||
bool entprell;
|
||||
int buttons[] = {PIN_BUTTON_LL, PIN_BUTTON_LR, PIN_BUTTON_RL, PIN_BUTTON_RR, enc1PinS, enc2PinS};
|
||||
Bounce debouncer[8];
|
||||
double val = 0;
|
||||
double val2 = 0;
|
||||
RotaryEncoder encoder(enc1PinA, enc1PinB, 1, 1, 50);
|
||||
RotaryEncoder encoder2(enc2PinA, enc2PinB, 1, 1, 50);
|
||||
///////////////////////////////////////////////////
|
||||
// functions
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
void set_pins()
|
||||
{
|
||||
for (int thisLed = 0; thisLed < sizeof(led) / sizeof(int); thisLed++)
|
||||
{
|
||||
pinMode(led[thisLed], OUTPUT);
|
||||
}
|
||||
pinMode(l, OUTPUT);
|
||||
/*pinMode(button1, INPUT);
|
||||
pinMode(button2, INPUT);
|
||||
pinMode(button3, INPUT);
|
||||
pinMode(button4, INPUT);
|
||||
pinMode(button5, INPUT);
|
||||
pinMode(button6, INPUT);*/
|
||||
pinMode(enc1PinA, INPUT);
|
||||
pinMode(enc1PinB, INPUT);
|
||||
//pinMode(enc1PinS, INPUT);
|
||||
pinMode(enc2PinA, INPUT);
|
||||
pinMode(enc2PinB, INPUT);
|
||||
//pinMode(enc2PinS, INPUT);
|
||||
//Stw_data.i=0;
|
||||
enc1PinALast = LOW;
|
||||
enc1PinANow = LOW;
|
||||
enc2PinALast = LOW;
|
||||
enc2PinANow = LOW;
|
||||
for (int i = 0; i < sizeof(buttons) / sizeof(*buttons); i++)
|
||||
{
|
||||
pinMode(buttons[i], INPUT);
|
||||
debouncer[i].attach(buttons[i]);
|
||||
debouncer[i].interval(10);
|
||||
}
|
||||
}
|
||||
|
||||
void read_buttons()
|
||||
{
|
||||
Stw_data.button_ll = digitalRead(PIN_BUTTON_LL);
|
||||
Stw_data.button_lr = digitalRead(PIN_BUTTON_LR);
|
||||
Stw_data.button_rl = digitalRead(PIN_BUTTON_RL);
|
||||
Stw_data.button_rr = digitalRead(PIN_BUTTON_RR);
|
||||
}
|
||||
|
||||
void read_rotary()
|
||||
{
|
||||
int enc2 = encoder2.readEncoder();
|
||||
if (enc2 != 0)
|
||||
{
|
||||
val2 = val2 + 0.5 * enc2;
|
||||
if (val2 == 1 or val2 == -1)
|
||||
{
|
||||
if ((Stw_data.mode == 1 or Stw_data.mode == 0) and enc2 < 0)
|
||||
{
|
||||
Stw_data.mode = 5;
|
||||
}
|
||||
else if (Stw_data.mode == 5 and enc2 > 0)
|
||||
{
|
||||
Stw_data.mode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Stw_data.mode = Stw_data.mode + enc2;
|
||||
}
|
||||
val2 = 0;
|
||||
}
|
||||
}
|
||||
#include "FT18e_STW_INIT.h"
|
||||
#include "Arduino.h"
|
||||
#include "Bounce2.h"
|
||||
#include "RotaryEncoder.h"
|
||||
|
||||
volatile stw_data_type Stw_data = {0}; // alles mit 0 initialisieren
|
||||
volatile vehicle_data_type Vehicle_data = {0}; // alles mit 0 initialisieren
|
||||
bool enc1PinALast, enc1PinANow, enc2PinALast, enc2PinANow;
|
||||
int led[] = {led1, led2, led3, led4, led5, led6, led7, led8,
|
||||
led9, led10, led11, led12, led13, led14, led15, led16};
|
||||
bool entprell;
|
||||
int buttons[] = {PIN_BUTTON_LL, PIN_BUTTON_LR, PIN_BUTTON_RL,
|
||||
PIN_BUTTON_RR, enc1PinS, enc2PinS};
|
||||
Bounce debouncer[8];
|
||||
double val = 0;
|
||||
double val2 = 0;
|
||||
RotaryEncoder encoder(enc1PinA, enc1PinB, 1, 1, 50);
|
||||
RotaryEncoder encoder2(enc2PinA, enc2PinB, 1, 1, 50);
|
||||
///////////////////////////////////////////////////
|
||||
// functions
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
void set_pins() {
|
||||
for (int thisLed = 0; thisLed < sizeof(led) / sizeof(int); thisLed++) {
|
||||
pinMode(led[thisLed], OUTPUT);
|
||||
}
|
||||
pinMode(l, OUTPUT);
|
||||
/*pinMode(button1, INPUT);
|
||||
pinMode(button2, INPUT);
|
||||
pinMode(button3, INPUT);
|
||||
pinMode(button4, INPUT);
|
||||
pinMode(button5, INPUT);
|
||||
pinMode(button6, INPUT);*/
|
||||
pinMode(enc1PinA, INPUT);
|
||||
pinMode(enc1PinB, INPUT);
|
||||
// pinMode(enc1PinS, INPUT);
|
||||
pinMode(enc2PinA, INPUT);
|
||||
pinMode(enc2PinB, INPUT);
|
||||
// pinMode(enc2PinS, INPUT);
|
||||
// Stw_data.i=0;
|
||||
enc1PinALast = LOW;
|
||||
enc1PinANow = LOW;
|
||||
enc2PinALast = LOW;
|
||||
enc2PinANow = LOW;
|
||||
for (int i = 0; i < sizeof(buttons) / sizeof(*buttons); i++) {
|
||||
pinMode(buttons[i], INPUT);
|
||||
debouncer[i].attach(buttons[i]);
|
||||
debouncer[i].interval(10);
|
||||
}
|
||||
}
|
||||
|
||||
void read_buttons() {
|
||||
Stw_data.button_ll = digitalRead(PIN_BUTTON_LL);
|
||||
Stw_data.button_lr = digitalRead(PIN_BUTTON_LR);
|
||||
Stw_data.button_rl = digitalRead(PIN_BUTTON_RL);
|
||||
Stw_data.button_rr = digitalRead(PIN_BUTTON_RR);
|
||||
}
|
||||
|
||||
void read_rotary() {
|
||||
int enc2 = encoder2.readEncoder();
|
||||
if (enc2 != 0) {
|
||||
val2 = val2 + 0.5 * enc2;
|
||||
if (val2 == 1 or val2 == -1) {
|
||||
if ((Stw_data.mode == 1 or Stw_data.mode == 0) and enc2 < 0) {
|
||||
Stw_data.mode = 5;
|
||||
} else if (Stw_data.mode == 5 and enc2 > 0) {
|
||||
Stw_data.mode = 1;
|
||||
} else {
|
||||
Stw_data.mode = Stw_data.mode + enc2;
|
||||
}
|
||||
val2 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,98 +1,95 @@
|
||||
#include "Arduino.h"
|
||||
#ifndef FT18e_STW_Init
|
||||
#define FT18e_STW_Init
|
||||
|
||||
#define l 78 //test_led
|
||||
#define led1 12 //PD8
|
||||
#define led2 11 //PD7
|
||||
#define led3 9 //PC21
|
||||
#define led4 8 //PC22
|
||||
#define led5 7 //PC23
|
||||
#define led6 6 //PC24
|
||||
#define led7 5 //PC25
|
||||
#define led8 4 //PC26 und PA29
|
||||
#define led9 3 //PC28
|
||||
#define led10 2 //PB25
|
||||
#define led11 10 //PC29 und PA28
|
||||
#define led12 22 //PB26
|
||||
#define led13 19 //PA10
|
||||
#define led14 13 //PB27
|
||||
#define led15 17 //PA12
|
||||
#define led16 18 //PA11
|
||||
#define enc1PinA 37
|
||||
#define enc1PinB 38
|
||||
#define enc1PinS 35
|
||||
#define enc2PinA 40
|
||||
#define enc2PinB 41
|
||||
#define enc2PinS 39
|
||||
|
||||
constexpr int PIN_BUTTON_LL = 47;
|
||||
constexpr int PIN_BUTTON_LR = 48;
|
||||
constexpr int PIN_BUTTON_RL = 46;
|
||||
constexpr int PIN_BUTTON_RR = 44;
|
||||
|
||||
constexpr int16_t RPM_THRESH_1 = 1000;
|
||||
constexpr int16_t RPM_THRESH_2 = 4000;
|
||||
constexpr int16_t RPM_THRESH_3 = 6000;
|
||||
constexpr int16_t RPM_THRESH_4 = 8000;
|
||||
constexpr int16_t RPM_THRESH_5 = 10000;
|
||||
constexpr int16_t RPM_THRESH_6 = 12000;
|
||||
constexpr int16_t RPM_THRESH_7 = 14000;
|
||||
constexpr int16_t RPM_THRESH_8 = 16000;
|
||||
constexpr int16_t RPM_THRESH_9 = 18000;
|
||||
constexpr int16_t RPM_THRESH_10 = 20000;
|
||||
|
||||
constexpr int16_t LED_THRESH_T_MOT = 7000; // 1/100°C
|
||||
constexpr int16_t LED_THRESH_T_INV = 6000; // 1/100°C
|
||||
constexpr int16_t LED_THRESH_T_BAT = 5000; // 1/100°C
|
||||
constexpr uint16_t LED_THRESH_U_BATT = 350; // 1/100V
|
||||
|
||||
void set_pins(void);
|
||||
void read_buttons(void);
|
||||
void read_rotary(void); // read rotary switches
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool button_ll; // Left side, left button
|
||||
bool button_lr; // Left side, right button
|
||||
bool button_rl; // Right side, left button
|
||||
bool button_rr; // Right side, right button
|
||||
uint8_t mode;
|
||||
uint8_t displayindex; //index für Displayanzeige
|
||||
uint8_t error_type; //Extrainfos über Error-LED
|
||||
|
||||
} stw_data_type;
|
||||
|
||||
struct InverterData
|
||||
{
|
||||
bool ready;
|
||||
bool derating;
|
||||
bool warning;
|
||||
bool error;
|
||||
bool on;
|
||||
bool precharge;
|
||||
bool ams_emerg;
|
||||
bool ts_active;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t u_cell_min; // Minimale Zellspannung
|
||||
uint16_t u_batt; // Batteriespannung (pre-AIR-voltage)
|
||||
int16_t t_mot_l; // Motor-Wasser-Temperatur Links
|
||||
int16_t t_mot_r; // Motor-Wasser-Temperatur Rechts
|
||||
int16_t t_cell_max; // Maximale Zelltemperatur
|
||||
int16_t t_inv;
|
||||
int16_t t_wat;
|
||||
int16_t p_wat;
|
||||
uint8_t speed;
|
||||
InverterData inverter;
|
||||
bool rev_lim; // Drehzahllimit Bit
|
||||
int16_t revol; // Drehzahl
|
||||
int16_t wheel_speed;
|
||||
} vehicle_data_type;
|
||||
|
||||
extern volatile stw_data_type Stw_data;
|
||||
extern volatile vehicle_data_type Vehicle_data;
|
||||
|
||||
#include "Arduino.h"
|
||||
#ifndef FT18e_STW_Init
|
||||
#define FT18e_STW_Init
|
||||
|
||||
#define l 78 // test_led
|
||||
#define led1 12 // PD8
|
||||
#define led2 11 // PD7
|
||||
#define led3 9 // PC21
|
||||
#define led4 8 // PC22
|
||||
#define led5 7 // PC23
|
||||
#define led6 6 // PC24
|
||||
#define led7 5 // PC25
|
||||
#define led8 4 // PC26 und PA29
|
||||
#define led9 3 // PC28
|
||||
#define led10 2 // PB25
|
||||
#define led11 10 // PC29 und PA28
|
||||
#define led12 22 // PB26
|
||||
#define led13 19 // PA10
|
||||
#define led14 13 // PB27
|
||||
#define led15 17 // PA12
|
||||
#define led16 18 // PA11
|
||||
#define enc1PinA 37
|
||||
#define enc1PinB 38
|
||||
#define enc1PinS 35
|
||||
#define enc2PinA 40
|
||||
#define enc2PinB 41
|
||||
#define enc2PinS 39
|
||||
|
||||
constexpr int PIN_BUTTON_LL = 47;
|
||||
constexpr int PIN_BUTTON_LR = 48;
|
||||
constexpr int PIN_BUTTON_RL = 46;
|
||||
constexpr int PIN_BUTTON_RR = 44;
|
||||
|
||||
constexpr int16_t RPM_THRESH_1 = 1000;
|
||||
constexpr int16_t RPM_THRESH_2 = 4000;
|
||||
constexpr int16_t RPM_THRESH_3 = 6000;
|
||||
constexpr int16_t RPM_THRESH_4 = 8000;
|
||||
constexpr int16_t RPM_THRESH_5 = 10000;
|
||||
constexpr int16_t RPM_THRESH_6 = 12000;
|
||||
constexpr int16_t RPM_THRESH_7 = 14000;
|
||||
constexpr int16_t RPM_THRESH_8 = 16000;
|
||||
constexpr int16_t RPM_THRESH_9 = 18000;
|
||||
constexpr int16_t RPM_THRESH_10 = 20000;
|
||||
|
||||
constexpr int16_t LED_THRESH_T_MOT = 7000; // 1/100°C
|
||||
constexpr int16_t LED_THRESH_T_INV = 6000; // 1/100°C
|
||||
constexpr int16_t LED_THRESH_T_BAT = 5000; // 1/100°C
|
||||
constexpr uint16_t LED_THRESH_U_BATT = 350; // 1/100V
|
||||
|
||||
void set_pins(void);
|
||||
void read_buttons(void);
|
||||
void read_rotary(void); // read rotary switches
|
||||
|
||||
typedef struct {
|
||||
bool button_ll; // Left side, left button
|
||||
bool button_lr; // Left side, right button
|
||||
bool button_rl; // Right side, left button
|
||||
bool button_rr; // Right side, right button
|
||||
uint8_t mode;
|
||||
uint8_t displayindex; // index für Displayanzeige
|
||||
uint8_t error_type; // Extrainfos über Error-LED
|
||||
|
||||
} stw_data_type;
|
||||
|
||||
struct InverterData {
|
||||
bool ready;
|
||||
bool derating;
|
||||
bool warning;
|
||||
bool error;
|
||||
bool on;
|
||||
bool precharge;
|
||||
bool ams_emerg;
|
||||
bool ts_active;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint16_t u_cell_min; // Minimale Zellspannung
|
||||
uint16_t u_batt; // Batteriespannung (pre-AIR-voltage)
|
||||
int16_t t_mot_l; // Motor-Wasser-Temperatur Links
|
||||
int16_t t_mot_r; // Motor-Wasser-Temperatur Rechts
|
||||
int16_t t_cell_max; // Maximale Zelltemperatur
|
||||
int16_t t_inv;
|
||||
int16_t t_wat;
|
||||
int16_t p_wat;
|
||||
uint8_t speed;
|
||||
InverterData inverter;
|
||||
bool rev_lim; // Drehzahllimit Bit
|
||||
int16_t revol; // Drehzahl
|
||||
int16_t wheel_speed;
|
||||
} vehicle_data_type;
|
||||
|
||||
extern volatile stw_data_type Stw_data;
|
||||
extern volatile vehicle_data_type Vehicle_data;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user