Compare commits
26 Commits
7c2e245796
...
getac-chan
| Author | SHA1 | Date | |
|---|---|---|---|
| d362fdd639 | |||
| 661e1a2274 | |||
| 58b0b72c6d | |||
| b5ece154c5 | |||
| 8a05663fbc | |||
| 28b4e15ed2 | |||
| 1a72d6aa0f | |||
| 1fdadd8b85 | |||
| 130a0dde2f | |||
| 6609947618 | |||
| c8e94175d1 | |||
| 197b805f35 | |||
| c5df4d7b79 | |||
| 37123a43e8 | |||
| fc65d22450 | |||
| 4de2baa867 | |||
| c6c0fa987e | |||
| d0afcb6da4 | |||
| 41d3bd907e | |||
| 14b5f6988d | |||
| 3cf68cd3cb | |||
| 894ced16ef | |||
| 5eecc507a0 | |||
| 373266f6be | |||
| f62f264b29 | |||
| 0eeafa9393 |
8
.editorconfig
Normal file
8
.editorconfig
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.{cpp,c,h,hpp}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
2
.git-blame-ignore-revs
Normal file
2
.git-blame-ignore-revs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Format everything
|
||||||
|
41d3bd907e65b484876859b767328e5d81181911
|
||||||
6
.vscode/extensions.json
vendored
6
.vscode/extensions.json
vendored
@ -2,7 +2,9 @@
|
|||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
// for the documentation about the extensions.json format
|
// for the documentation about the extensions.json format
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"platformio.platformio-ide",
|
"platformio.platformio-ide"
|
||||||
"ms-vscode.cpptools-extension-pack"
|
|
||||||
],
|
],
|
||||||
|
"unwantedRecommendations": [
|
||||||
|
"ms-vscode.cpptools-extension-pack"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,7 @@ struct FaultStatusRegisters {
|
|||||||
uint32_t SHCSR;
|
uint32_t SHCSR;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class FaultType {
|
enum class FaultType { HardFault, MemManage, BusFault, UsageFault };
|
||||||
HardFault, MemManage, BusFault, UsageFault
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FlashDump {
|
struct FlashDump {
|
||||||
FaultType type;
|
FaultType type;
|
||||||
@ -48,13 +46,14 @@ size_t uart_print_hex(uint32_t x);
|
|||||||
|
|
||||||
void print_dumped_faults(bool in_irq = false);
|
void print_dumped_faults(bool in_irq = false);
|
||||||
void print_stacked_registers(const uint32_t *stack, bool in_irq = false);
|
void print_stacked_registers(const uint32_t *stack, bool in_irq = false);
|
||||||
void print_fault_registers(const FaultStatusRegisters *fsr, bool in_irq=false);
|
void print_fault_registers(const FaultStatusRegisters *fsr,
|
||||||
|
bool in_irq = false);
|
||||||
|
|
||||||
FaultStatusRegisters get_current_fsr();
|
FaultStatusRegisters get_current_fsr();
|
||||||
|
|
||||||
const char *get_fault_type_name(FaultType type);
|
const char *get_fault_type_name(FaultType type);
|
||||||
void fault_handler(uint32_t *stack_addr, FaultType fault_type,
|
void fault_handler(uint32_t *stack_addr, FaultType fault_type, const int *leds,
|
||||||
const int *leds, unsigned n_leds);
|
unsigned n_leds);
|
||||||
|
|
||||||
void inline busy_wait(size_t iterations) {
|
void inline busy_wait(size_t iterations) {
|
||||||
for (size_t i = 0; i < iterations; i++) {
|
for (size_t i = 0; i < iterations; i++) {
|
||||||
|
|||||||
@ -1,39 +1,39 @@
|
|||||||
|
#include "FT18_STW_DISPLAY.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "EDIPTFT.h"
|
#include "EDIPTFT.h"
|
||||||
#include "FT_2018_STW_CAN.h"
|
|
||||||
#include "FT18_STW_INIT.h"
|
#include "FT18_STW_INIT.h"
|
||||||
#include "FT18_STW_DISPLAY.h"
|
#include "FT_2018_STW_CAN.h"
|
||||||
|
|
||||||
|
String pad_left(String orig, int len, char pad_char) {
|
||||||
|
String result = {orig};
|
||||||
|
for (int i = orig.length(); i < len; i++) {
|
||||||
|
result = pad_char + result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
EDIPTFT tft(true, false);
|
EDIPTFT tft(true, false);
|
||||||
String bezeichnungen[]={"T_mot","T_oil","P_oil","% fa","U_batt","P_wat","T_air",
|
String bezeichnungen[] = {"T_mot", "T_oil", "P_oil", "% fa",
|
||||||
"P_b_front","P_b_rear","Error Type","Speed_fl","Speed_fr","Speed"};
|
"U_batt", "P_wat", "T_air", "P_b_front",
|
||||||
|
"P_b_rear", "Error Type", "Speed_fl", "Speed_fr",
|
||||||
|
"Speed"};
|
||||||
//"Drehzahl","P_fuel","Index"
|
//"Drehzahl","P_fuel","Index"
|
||||||
int vergleichsindex;
|
int led_s[] = {led1, led2, led3, led4, led5, led6, led7, led8,
|
||||||
int sizeaalt;
|
led9, led10, led11, led12, led13, led14, led15, led16};
|
||||||
int sizeaneu;
|
|
||||||
int sizebalt;
|
|
||||||
int sizebneu;
|
|
||||||
int sizecalt;
|
|
||||||
int sizecneu;
|
|
||||||
int sizedalt;
|
|
||||||
int sizedneu;
|
|
||||||
int sizeealt;
|
|
||||||
int sizeeneu;
|
|
||||||
uint8_t clearcounter = 56;
|
|
||||||
uint8_t trcalt = Stw_data.trc;
|
|
||||||
uint8_t modealt = Stw_data.mode;
|
|
||||||
uint8_t trccounter;// = Stw_data.trc;
|
|
||||||
uint8_t modecounter;// = Stw_data.mode;
|
|
||||||
bool trctimer;
|
|
||||||
bool modetimer;
|
|
||||||
int led_s[] = {led1,led2,led3,led4,led5,led6,led7,led8,led9,led10,led11,led12,led13,led14,led15,led16};
|
|
||||||
unsigned long poiltimer;
|
|
||||||
unsigned long tmottimer;
|
|
||||||
unsigned long toiltimer;
|
|
||||||
bool poilbool = true;
|
|
||||||
bool tmotbool = true;
|
|
||||||
bool toilbool = true;
|
|
||||||
|
|
||||||
|
DataBox gear_box(121, 0, 199, 94, 160, 0, EA_SWISS30B, 4, 4, 'C', true);
|
||||||
|
DataBox left_box(0, 25, 119, 94, 110, 25, EA_FONT6X8, 3, 8, 'R', false);
|
||||||
|
DataBox right_box(201, 25, 320, 94, 310, 25, EA_FONT6X8, 3, 8, 'R', false);
|
||||||
|
DataBox autoshift_box(164+50, 184, 240+50, 230, 202+50, 178, EA_FONT7X12, 3, 5, 'C', false);
|
||||||
|
|
||||||
|
TireTempBox fl_box(80, 130, 156, 176, 118, 124, EA_FONT7X12, 3, 5, 'C');
|
||||||
|
TireTempBox fr_box(164, 130, 240, 176, 202, 124, EA_FONT7X12, 3, 5, 'C');
|
||||||
|
TireTempBox rl_box(80, 184, 156, 230, 118, 178, EA_FONT7X12, 3, 5, 'C');
|
||||||
|
TireTempBox rr_box(164, 184, 240, 230, 202, 178, EA_FONT7X12, 3, 5, 'C');
|
||||||
|
|
||||||
|
int testing_page = 0;
|
||||||
|
uint16_t clearcounter = 1;
|
||||||
void init_display() {
|
void init_display() {
|
||||||
pinMode(writeprotect, OUTPUT);
|
pinMode(writeprotect, OUTPUT);
|
||||||
digitalWrite(writeprotect, HIGH);
|
digitalWrite(writeprotect, HIGH);
|
||||||
@ -41,341 +41,300 @@ void init_display() {
|
|||||||
pinMode(disp_cs, OUTPUT);
|
pinMode(disp_cs, OUTPUT);
|
||||||
pinMode(MOSI, OUTPUT);
|
pinMode(MOSI, OUTPUT);
|
||||||
pinMode(MISO, OUTPUT);
|
pinMode(MISO, OUTPUT);
|
||||||
//pinMode(CLK, INPUT);
|
|
||||||
digitalWrite(disp_cs, HIGH);
|
digitalWrite(disp_cs, HIGH);
|
||||||
digitalWrite(MOSI, HIGH);
|
digitalWrite(MOSI, HIGH);
|
||||||
digitalWrite(MISO, HIGH);
|
digitalWrite(MISO, HIGH);
|
||||||
digitalWrite(reset, LOW);
|
digitalWrite(reset, LOW);
|
||||||
//edip.smallProtoSelect(7);
|
|
||||||
//edip.setNewColor(EA_GREY, 0xe3, 0xe3,0xe3); // redefine r-g-b-values of EA_GREY
|
|
||||||
//edip.drawImage(0,50,FASTTUBE_LOGO_PNG);
|
|
||||||
digitalWrite(reset, HIGH);
|
digitalWrite(reset, HIGH);
|
||||||
tft.begin(115200); // start display communication
|
tft.begin(115200); // start display communication
|
||||||
/*int h = 20;
|
|
||||||
char charh[2];
|
|
||||||
String strh = String(h);
|
|
||||||
strh.toCharArray(charh,2);
|
|
||||||
tft.DisplayLight(charh);*/
|
|
||||||
tft.cursorOn(false);
|
tft.cursorOn(false);
|
||||||
tft.terminalOn(false);
|
tft.terminalOn(false);
|
||||||
tft.setDisplayColor(EA_WHITE, EA_BLACK);
|
tft.setDisplayColor(EA_WHITE, EA_BLACK);
|
||||||
tft.setTextColor(EA_WHITE,EA_BLACK);
|
tft.setTextColor(EA_WHITE, EA_TRANSPARENT);
|
||||||
//tft.setTextFont('4');
|
|
||||||
tft.setTextSize(5, 8);
|
tft.setTextSize(5, 8);
|
||||||
tft.clear();
|
tft.clear();
|
||||||
//tft.displayLight('30');
|
|
||||||
tft.drawText(0, 14, 'C', "FaSTTUBe"); //draw some text
|
gear_box.update_label(get_label(VAL_GEAR));
|
||||||
//tft.loadImage(0,0,1);
|
left_box.update_label(get_label(VAL_FIRST_LEFT_BOX));
|
||||||
//delay(2000);
|
right_box.update_label(get_label(VAL_RPM));
|
||||||
|
autoshift_box.update_label("");
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_value(int a){
|
String get_value(Value val) {
|
||||||
double value;
|
switch (val) {
|
||||||
if (a == 0){
|
case VAL_GEAR:
|
||||||
value = Vehicle_data.gear;
|
if (Vehicle_data.gear == 0) {
|
||||||
//}else if (a == 11){
|
return "N";
|
||||||
// value = Stw_data.i;
|
|
||||||
//}else if (a == 1){
|
|
||||||
// value = Vehicle_data.revol/2;
|
|
||||||
}else if (a == 1){
|
|
||||||
value = Vehicle_data.t_mot-40;
|
|
||||||
}else if (a == 5){
|
|
||||||
value = 0.0706949*Vehicle_data.u_batt;
|
|
||||||
}else if (a == 7){
|
|
||||||
value = Vehicle_data.t_air-40;
|
|
||||||
}else if(a == 10){
|
|
||||||
value = Stw_data.error_type;
|
|
||||||
}else if (a == 2){
|
|
||||||
value = Vehicle_data.t_oil-40;
|
|
||||||
}else if (a == 6){
|
|
||||||
value = 0.0514*Vehicle_data.p_wat;
|
|
||||||
//}else if (a == 7){
|
|
||||||
// value = 0.0514*Vehicle_data.p_fuel;
|
|
||||||
}else if (a == 3){
|
|
||||||
value = 0.0514*Vehicle_data.p_oil;
|
|
||||||
}else if (a == 8){
|
|
||||||
value = Vehicle_data.p_brake_front;
|
|
||||||
}else if (a == 9){
|
|
||||||
value = Vehicle_data.p_brake_rear;
|
|
||||||
}else if(a == 4){
|
|
||||||
value = 200*Vehicle_data.p_brake_front/(Vehicle_data.p_brake_rear+(2*Vehicle_data.p_brake_front));
|
|
||||||
}else if (a == 11){
|
|
||||||
value = Vehicle_data.speed_fl;
|
|
||||||
}else if (a == 12){
|
|
||||||
value = Vehicle_data.speed_fr;
|
|
||||||
}else if(a == 13){
|
|
||||||
value = Vehicle_data.speed;
|
|
||||||
}
|
}
|
||||||
return value;
|
return String(Vehicle_data.gear);
|
||||||
|
case VAL_RPM:
|
||||||
|
return String(Vehicle_data.revol / 2);
|
||||||
|
case VAL_TT_FL:
|
||||||
|
return String(Vehicle_data.t_tfl * 0.423529 + 8, 0);
|
||||||
|
case VAL_TT_FR:
|
||||||
|
return String(Vehicle_data.t_tfr * 0.423529 + 0, 0);
|
||||||
|
case VAL_TT_RL:
|
||||||
|
return String(Vehicle_data.t_trl * 0.423529 + 11, 0);
|
||||||
|
case VAL_TT_RR:
|
||||||
|
return String(Vehicle_data.t_trr * 0.423529 + 4, 0);
|
||||||
|
case VAL_LAPTIME: {
|
||||||
|
double time =
|
||||||
|
Vehicle_data.lap_time_sec + Vehicle_data.lap_time_msec / 1000.0;
|
||||||
|
if (time < 100) {
|
||||||
|
return String(time, 2);
|
||||||
|
} else if (time < 1000) {
|
||||||
|
return String(time, 1);
|
||||||
|
} else if (time < 10000) {
|
||||||
|
return String(time, 0);
|
||||||
|
} else {
|
||||||
|
return "2SLOW";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case VAL_UBATT:
|
||||||
|
return String(0.0706949 * Vehicle_data.u_batt, 2);
|
||||||
|
case VAL_TMOT:
|
||||||
|
return String(Vehicle_data.t_mot - 40);
|
||||||
|
case VAL_TAIR:
|
||||||
|
return String(Vehicle_data.t_air - 40);
|
||||||
|
case VAL_TOIL:
|
||||||
|
return String(Vehicle_data.t_oil - 40);
|
||||||
|
case VAL_ERR_TYPE:
|
||||||
|
return String(Stw_data.error_type);
|
||||||
|
case VAL_PFUEL:
|
||||||
|
return String(0.0514 * Vehicle_data.p_fuel, 2);
|
||||||
|
case VAL_PWAT:
|
||||||
|
return String(0.0514 * Vehicle_data.p_wat, 2);
|
||||||
|
case VAL_POIL:
|
||||||
|
return String(0.0514 * Vehicle_data.p_oil, 2);
|
||||||
|
case VAL_PBF:
|
||||||
|
return String(Vehicle_data.p_brake_front);
|
||||||
|
case VAL_PBR:
|
||||||
|
return String(Vehicle_data.p_brake_rear);
|
||||||
|
case VAL_SPEED_FL:
|
||||||
|
return String(Vehicle_data.speed_fl);
|
||||||
|
case VAL_SPEED_FR:
|
||||||
|
return String(Vehicle_data.speed_fr);
|
||||||
|
case VAL_SPEED:
|
||||||
|
return String(Vehicle_data.speed);
|
||||||
|
case VAL_BBAL: {
|
||||||
|
double p_total =
|
||||||
|
Vehicle_data.p_brake_front + Vehicle_data.p_brake_rear / 2.398;
|
||||||
|
double bbal = p_total == 0 ? 0 : 100 * Vehicle_data.p_brake_front / p_total;
|
||||||
|
if (bbal >= 100) {
|
||||||
|
return "100";
|
||||||
|
}
|
||||||
|
return String(bbal, 2);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String get_label(Value val) {
|
||||||
|
switch (val) {
|
||||||
|
case VAL_GEAR:
|
||||||
|
return "GEAR";
|
||||||
|
case VAL_RPM:
|
||||||
|
return "RPM";
|
||||||
|
case VAL_TT_FL:
|
||||||
|
return "TEMP FL";
|
||||||
|
case VAL_TT_FR:
|
||||||
|
return "TEMP FR";
|
||||||
|
case VAL_TT_RL:
|
||||||
|
return "TEMP RL";
|
||||||
|
case VAL_TT_RR:
|
||||||
|
return "TEMP RR";
|
||||||
|
case VAL_LAPTIME:
|
||||||
|
return "LAPTIME";
|
||||||
|
case VAL_UBATT:
|
||||||
|
return "BATT VOLTAGE";
|
||||||
|
case VAL_TMOT:
|
||||||
|
return "TEMP ENG";
|
||||||
|
case VAL_TAIR:
|
||||||
|
return "TEMP AIR";
|
||||||
|
case VAL_TOIL:
|
||||||
|
return "TEMP OIL";
|
||||||
|
case VAL_ERR_TYPE:
|
||||||
|
return "ERROR TYPE";
|
||||||
|
case VAL_PFUEL:
|
||||||
|
return "PRESS FUEL";
|
||||||
|
case VAL_PWAT:
|
||||||
|
return "PRESS WAT";
|
||||||
|
case VAL_POIL:
|
||||||
|
return "PRESS OIL";
|
||||||
|
case VAL_PBF:
|
||||||
|
return "PRESS BRAKE F";
|
||||||
|
case VAL_PBR:
|
||||||
|
return "PRESS BRAKE R";
|
||||||
|
case VAL_SPEED_FL:
|
||||||
|
return "SPEED FL";
|
||||||
|
case VAL_SPEED_FR:
|
||||||
|
return "SPEED FR";
|
||||||
|
case VAL_SPEED:
|
||||||
|
return "SPEED";
|
||||||
|
case VAL_BBAL:
|
||||||
|
return "BBAL";
|
||||||
|
default:
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_alarms() {
|
||||||
|
static uint32_t poil_last_valid, tmot_last_valid, toil_last_valid;
|
||||||
|
uint32_t now = millis();
|
||||||
|
if (Vehicle_data.p_oil >= POIL_ALARM_THRESH || Vehicle_data.speed == 0) {
|
||||||
|
poil_last_valid = now;
|
||||||
|
}
|
||||||
|
if (Vehicle_data.t_mot <= TMOT_ALARM_THRESH ||
|
||||||
|
Vehicle_data.t_mot == TMOT_SAFE_VALUE) {
|
||||||
|
tmot_last_valid = now;
|
||||||
|
}
|
||||||
|
if (Vehicle_data.t_oil <= TOIL_ALARM_THRESH) {
|
||||||
|
toil_last_valid = now;
|
||||||
|
}
|
||||||
|
// bool poil_alarm = now - poil_last_valid >= POIL_ALARM_TIME;
|
||||||
|
bool poil_alarm = false;
|
||||||
|
bool tmot_alarm = now - tmot_last_valid >= TMOT_ALARM_TIME;
|
||||||
|
bool toil_alarm = now - toil_last_valid >= TOIL_ALARM_TIME;
|
||||||
|
bool alarm_active = poil_alarm || tmot_alarm || toil_alarm;
|
||||||
|
|
||||||
|
if (alarm_active) {
|
||||||
|
String alarm_text = "";
|
||||||
|
if (poil_alarm)
|
||||||
|
alarm_text += "PO";
|
||||||
|
if (tmot_alarm)
|
||||||
|
alarm_text += "TM";
|
||||||
|
if (toil_alarm)
|
||||||
|
alarm_text += "TO";
|
||||||
|
alarm(alarm_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
return alarm_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_enc_displays() {
|
||||||
|
static uint8_t trc_old, mode_old;
|
||||||
|
static bool display_trc, display_mode;
|
||||||
|
static uint32_t display_trc_begin, display_mode_begin;
|
||||||
|
|
||||||
|
return check_display(trc_old, Stw_data.trc, display_trc, display_trc_begin,
|
||||||
|
"ARB") ||
|
||||||
|
check_display(mode_old, Stw_data.mode, display_mode,
|
||||||
|
display_mode_begin, "MODE");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_display(uint8_t& val_old, uint8_t val_new, bool& active,
|
||||||
|
uint32_t& begin, const String& title) {
|
||||||
|
if (val_old != val_new) {
|
||||||
|
active = true;
|
||||||
|
begin = millis();
|
||||||
|
val_old = val_new;
|
||||||
|
tft.clear();
|
||||||
|
tft.fillDisplayColor(EA_RED);
|
||||||
|
tft.setTextColor(EA_WHITE, EA_RED);
|
||||||
|
tft.setTextSize(7, 8);
|
||||||
|
String text = title + ":" + val_new;
|
||||||
|
char text_arr[16];
|
||||||
|
text.toCharArray(text_arr, 16);
|
||||||
|
tft.drawText(15, 68, 'C', text_arr);
|
||||||
|
} else if (active && millis() - begin > ENC_DISPLAY_TIME) {
|
||||||
|
tft.setTextColor(EA_WHITE, EA_TRANSPARENT);
|
||||||
|
tft.clear();
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_display() {
|
void update_display() {
|
||||||
if(((millis()-poiltimer)>=20000) and poilbool){
|
static DisplayView view = VIEW_DRIVER;
|
||||||
poilbool = false;
|
static uint32_t last_cleared;
|
||||||
alarm("P_oil");
|
static bool cleared = true;
|
||||||
|
|
||||||
|
if (check_alarms()) {
|
||||||
|
cleared = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(((millis()-tmottimer)>=20000) and tmotbool){
|
if (tft.disconnected) {
|
||||||
tmotbool = false;
|
uint32_t now = millis();
|
||||||
alarm("T_mot");
|
if (now - last_cleared < 1000) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(((millis()-toiltimer)>=10000) and toilbool){
|
digitalWrite(reset, LOW);
|
||||||
toilbool = false;
|
delay(100);
|
||||||
alarm("T_oil");
|
digitalWrite(reset, HIGH);
|
||||||
}
|
tft.disconnected = false;
|
||||||
if((0.0514*Vehicle_data.p_oil)>=0,1 or Vehicle_data.speed == 0){
|
|
||||||
poiltimer = millis();
|
|
||||||
}
|
|
||||||
if(((Vehicle_data.t_mot - 40) <= 0x69) or ((Vehicle_data.t_mot - 40)==0xC8)){
|
|
||||||
tmottimer = millis();
|
|
||||||
}
|
|
||||||
if((Vehicle_data.t_oil - 40) <= 0x96){
|
|
||||||
toiltimer = millis();
|
|
||||||
}
|
|
||||||
if(Stw_data.buttonState1 & Stw_data.buttonState4){
|
|
||||||
alarm("");
|
|
||||||
}
|
|
||||||
if(!tft.disconnected){
|
|
||||||
tft.cursorOn(false);
|
|
||||||
if(trcalt!=Stw_data.trc or trctimer == true or Stw_data.buttonStateEnc1 == HIGH){
|
|
||||||
display_trc();
|
|
||||||
}else if(modealt!=Stw_data.mode or modetimer == true or Stw_data.buttonStateEnc2 == HIGH){
|
|
||||||
display_mode();
|
|
||||||
}else{
|
|
||||||
if(clearcounter>=56){
|
|
||||||
tft.clear();
|
tft.clear();
|
||||||
clearcounter = 0;
|
cleared = true;
|
||||||
|
last_cleared = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check_enc_displays()) {
|
||||||
|
cleared = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t now = millis();
|
||||||
|
// Both buttons have to be pressed at the same time, but we also use the
|
||||||
|
// debounced rises to ensure we don't keep toggling between the views
|
||||||
|
if (Stw_data.buttonState1 && Stw_data.buttonState4 &&
|
||||||
|
(Stw_data.button1_rises > 0 || Stw_data.button4_rises > 0)) {
|
||||||
|
Stw_data.button1_rises = 0;
|
||||||
|
Stw_data.button4_rises = 0;
|
||||||
|
view = (DisplayView)((view + 1) % (VIEW_LAST + 1));
|
||||||
|
tft.clear();
|
||||||
|
cleared = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view == VIEW_DRIVER) {
|
||||||
|
if (cleared) {
|
||||||
|
redraw_view_driver();
|
||||||
|
cleared = false;
|
||||||
|
} else {
|
||||||
|
update_view_driver();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (cleared) {
|
||||||
|
redraw_view_testing();
|
||||||
|
cleared = false;
|
||||||
|
} else {
|
||||||
|
update_view_testing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (clearcounter>= 10000){
|
||||||
|
pinMode(writeprotect, OUTPUT);
|
||||||
|
digitalWrite(writeprotect, HIGH);
|
||||||
|
pinMode(reset, OUTPUT);
|
||||||
|
pinMode(disp_cs, OUTPUT);
|
||||||
|
pinMode(MOSI, OUTPUT);
|
||||||
|
pinMode(MISO, OUTPUT);
|
||||||
|
digitalWrite(disp_cs, HIGH);
|
||||||
|
digitalWrite(MOSI, HIGH);
|
||||||
|
digitalWrite(MISO, HIGH);
|
||||||
|
digitalWrite(reset, LOW);
|
||||||
|
digitalWrite(reset, HIGH);
|
||||||
|
//tft.begin(115200); // start display communication
|
||||||
|
//tft.cursorOn(false);
|
||||||
|
//tft.terminalOn(false);
|
||||||
|
//tft.setDisplayColor(EA_WHITE, EA_BLACK);
|
||||||
|
//tft.setTextColor(EA_WHITE, EA_TRANSPARENT);
|
||||||
|
//tft.setTextSize(5, 8);
|
||||||
|
//tft.clear();
|
||||||
|
|
||||||
|
// gear_box.update_label(get_label(VAL_GEAR));
|
||||||
|
// left_box.update_label(get_label(VAL_FIRST_LEFT_BOX));
|
||||||
|
// right_box.update_label(get_label(VAL_RPM));
|
||||||
|
|
||||||
|
clearcounter = 0; //clearen des display nach definierter Zeit
|
||||||
|
cleared =true;
|
||||||
|
//
|
||||||
}
|
}
|
||||||
clearcounter+=1;
|
clearcounter+=1;
|
||||||
if(Stw_data.buttonState4){
|
|
||||||
if(Stw_data.displayindex>=sizeof(bezeichnungen)/sizeof(String)-3){
|
|
||||||
Stw_data.displayindex = 0;
|
|
||||||
delay(250);
|
|
||||||
}else{
|
|
||||||
Stw_data.displayindex+=1;
|
|
||||||
delay(250);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Stw_data.buttonState1){
|
|
||||||
if(Stw_data.displayindex<=0){
|
|
||||||
Stw_data.displayindex = sizeof(bezeichnungen)/sizeof(String)-3;
|
|
||||||
delay(250);
|
|
||||||
}else{
|
|
||||||
Stw_data.displayindex-=1;
|
|
||||||
delay(250);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(vergleichsindex!=Stw_data.displayindex){
|
|
||||||
tft.clear();
|
|
||||||
vergleichsindex=Stw_data.displayindex;
|
|
||||||
}
|
|
||||||
int a = sizeof(bezeichnungen[Stw_data.displayindex]);
|
|
||||||
int g = sizeof(bezeichnungen[Stw_data.displayindex+1]);
|
|
||||||
int h = sizeof(bezeichnungen[Stw_data.displayindex+2]);
|
|
||||||
char d[a];
|
|
||||||
char e[g];
|
|
||||||
char f[h];
|
|
||||||
bezeichnungen[Stw_data.displayindex].toCharArray(d,a);
|
|
||||||
bezeichnungen[Stw_data.displayindex+1].toCharArray(e,g);
|
|
||||||
bezeichnungen[Stw_data.displayindex+2].toCharArray(f,h);
|
|
||||||
char b[2];
|
|
||||||
char c[5];
|
|
||||||
char i[5];
|
|
||||||
char j[5];
|
|
||||||
char k[5];
|
|
||||||
char m[5];
|
|
||||||
String str=String(int(get_value(0)));
|
|
||||||
if(str.equals(String(0))){
|
|
||||||
str = "N";
|
|
||||||
}
|
|
||||||
String str1;
|
|
||||||
String str2;
|
|
||||||
String str3;
|
|
||||||
if(Stw_data.displayindex+1==0 or Stw_data.displayindex+1==2 or Stw_data.displayindex+1==1 or Stw_data.displayindex+1==10 or Stw_data.displayindex+1==7 or Stw_data.displayindex+1==11 or Stw_data.displayindex+1==12 or Stw_data.displayindex+1==13){
|
|
||||||
str1=String(int(get_value(Stw_data.displayindex+1)));
|
|
||||||
}else{
|
|
||||||
str1=String(get_value(Stw_data.displayindex+1));
|
|
||||||
}
|
|
||||||
if(Stw_data.displayindex+1 == 10){
|
|
||||||
if(str1.equals(String(1))){
|
|
||||||
str1 = "PC";
|
|
||||||
}else if(str1.equals(String(2))){
|
|
||||||
str1 = "BSE";
|
|
||||||
}else if(str1.equals(String(3))){
|
|
||||||
str1 = "APS";
|
|
||||||
}else if(str1.equals(String(4))){
|
|
||||||
str1 = "ETB";
|
|
||||||
}else if(str1.equals(String(0))){
|
|
||||||
str1 = "None";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Stw_data.displayindex+2==0 or Stw_data.displayindex+2==2 or Stw_data.displayindex+2==1 or Stw_data.displayindex+2==10 or Stw_data.displayindex+2==7 or Stw_data.displayindex+2==11 or Stw_data.displayindex+2==12 or Stw_data.displayindex+2==13){
|
|
||||||
str2=String(int(get_value(Stw_data.displayindex+2)));
|
|
||||||
}else{
|
|
||||||
str2=String(get_value(Stw_data.displayindex+2));
|
|
||||||
}
|
|
||||||
if(Stw_data.displayindex+2 == 10){
|
|
||||||
if(str2.equals(String(1))){
|
|
||||||
str2 = "PC";
|
|
||||||
}else if(str2.equals(String(2))){
|
|
||||||
str2 = "BSE";
|
|
||||||
}else if(str2.equals(String(3))){
|
|
||||||
str2 = "APS";
|
|
||||||
}else if(str2.equals(String(4))){
|
|
||||||
str2 = "ETB";
|
|
||||||
}else if(str2.equals(String(0))){
|
|
||||||
str2 = "None";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Stw_data.displayindex+3==0 or Stw_data.displayindex+3==2 or Stw_data.displayindex+3==1 or Stw_data.displayindex+3==10 or Stw_data.displayindex+3==7 or Stw_data.displayindex+3==11 or Stw_data.displayindex+3==12 or Stw_data.displayindex+3==13){
|
|
||||||
str3=String(int(get_value(Stw_data.displayindex+3)));
|
|
||||||
}else{
|
|
||||||
str3=String(get_value(Stw_data.displayindex+3));
|
|
||||||
}
|
|
||||||
if(Stw_data.displayindex+3 == 10){
|
|
||||||
if(str3.equals(String(1))){
|
|
||||||
str3 = "PC";
|
|
||||||
}else if(str3.equals(String(2))){
|
|
||||||
str3 = "BSE";
|
|
||||||
}else if(str3.equals(String(3))){
|
|
||||||
str3 = "APS";
|
|
||||||
}else if(str3.equals(String(4))){
|
|
||||||
str3 = "ETB";
|
|
||||||
}else if(str3.equals(String(0))){
|
|
||||||
str3 = "None";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String str5=String(Vehicle_data.revol/2);
|
|
||||||
String str4=String(0.0514*Vehicle_data.p_fuel);
|
|
||||||
str.toCharArray(b,2);
|
|
||||||
str1.toCharArray(c,5);
|
|
||||||
str2.toCharArray(i,5);
|
|
||||||
str3.toCharArray(j,5);
|
|
||||||
str4.toCharArray(k,5);
|
|
||||||
str5.toCharArray(m,5);
|
|
||||||
sizeaneu = strlen(c);
|
|
||||||
sizebneu = strlen(i);
|
|
||||||
sizecneu = strlen(j);
|
|
||||||
sizedneu = strlen(k);
|
|
||||||
sizeeneu = strlen(m);
|
|
||||||
if(sizeaalt!=sizeaneu){
|
|
||||||
tft.clear();
|
|
||||||
sizeaalt=sizeaneu;
|
|
||||||
}
|
|
||||||
if(sizebalt!=sizebneu){
|
|
||||||
tft.clear();
|
|
||||||
sizebalt=sizebneu;
|
|
||||||
}
|
|
||||||
if(sizecalt!=sizecneu){
|
|
||||||
tft.clear();
|
|
||||||
sizecalt=sizecneu;
|
|
||||||
}
|
|
||||||
if(sizedalt!=sizedneu){
|
|
||||||
tft.clear();
|
|
||||||
sizedalt=sizedneu;
|
|
||||||
}
|
|
||||||
if(sizeealt!=sizeeneu){
|
|
||||||
tft.clear();
|
|
||||||
sizeealt=sizeeneu;
|
|
||||||
}
|
|
||||||
tft.setTextSize(6,8);
|
|
||||||
tft.drawText(132, 0, 'L', b);
|
|
||||||
tft.setTextSize(2,7);
|
|
||||||
tft.drawText(10, 20, 'L', k);
|
|
||||||
tft.drawText(240, 20, 'L', m);
|
|
||||||
tft.drawText(10,130, 'L', c);
|
|
||||||
tft.drawText(120, 130, 'L', i);
|
|
||||||
tft.drawText(240,130, 'L', j);
|
|
||||||
tft.setTextSize(1,1);
|
|
||||||
tft.drawText(136,116, 'L', "Gang");
|
|
||||||
tft.drawText(10,116, 'L', "P_fuel");
|
|
||||||
tft.drawText(240,116, 'L', "Drehzahl");
|
|
||||||
tft.drawText(10,226, 'L', d);
|
|
||||||
tft.drawText(120,226, 'L', e);
|
|
||||||
tft.drawText(240,226, 'L', f);
|
|
||||||
/*if (cleaner){
|
|
||||||
tft.setTextSize(5,8);
|
|
||||||
tft.drawText(0, 14, 'C', "FaSTTUBe"); // draw some text
|
|
||||||
tft.setTextSize(4,4);
|
|
||||||
tft.drawText(24, 120, 'C', "insert coin"); // draw some text
|
|
||||||
tft.drawText(0, 180, 'C', "to continue");
|
|
||||||
cleaner = false;
|
|
||||||
}else{
|
|
||||||
tft.setTextSize(5,8);
|
|
||||||
tft.drawText(0, 14, 'C', "FaSTTUBe"); // draw some text
|
|
||||||
tft.setTextSize(4,4);
|
|
||||||
tft.drawText(24, 120, 'C', " "); // draw some text
|
|
||||||
tft.drawText(0, 180, 'C', " ");
|
|
||||||
cleaner = true;
|
|
||||||
}
|
|
||||||
delay(80);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void display_trc(){
|
|
||||||
if(trcalt!=Stw_data.trc or Stw_data.buttonStateEnc1 == HIGH){
|
|
||||||
tft.clear();
|
|
||||||
tft.setTextSize(7,8);
|
|
||||||
tft.setDisplayColor(EA_WHITE,EA_RED);
|
|
||||||
tft.setTextColor(EA_WHITE,EA_RED);
|
|
||||||
char trcanzeige[7];
|
|
||||||
String str = String("ARB:");
|
|
||||||
if(Stw_data.trc==11){
|
|
||||||
str+="ED";
|
|
||||||
}else{
|
|
||||||
str+=String(Stw_data.trc);
|
|
||||||
}
|
|
||||||
str.toCharArray(trcanzeige,7);
|
|
||||||
tft.drawText(0,0,'L'," ");
|
|
||||||
tft.drawText(0,60,'L'," ");
|
|
||||||
tft.drawText(0,120,'L'," ");
|
|
||||||
tft.drawText(0,180,'L'," ");
|
|
||||||
tft.drawText(15,68,'L',trcanzeige);
|
|
||||||
trccounter = 0;
|
|
||||||
trcalt = Stw_data.trc;
|
|
||||||
trctimer = true;
|
|
||||||
}else if(trccounter >= 255){
|
|
||||||
tft.setDisplayColor(EA_WHITE,EA_BLACK);
|
|
||||||
tft.setTextColor(EA_WHITE,EA_BLACK);
|
|
||||||
tft.clear();
|
|
||||||
trctimer = false;
|
|
||||||
}else{
|
|
||||||
trccounter+=1;
|
|
||||||
delay(5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void display_mode(){
|
|
||||||
if(modealt!=Stw_data.mode or Stw_data.buttonStateEnc2 == HIGH){
|
|
||||||
tft.clear();
|
|
||||||
tft.setTextSize(6,8);
|
|
||||||
tft.setDisplayColor(EA_WHITE,EA_RED);
|
|
||||||
tft.setTextColor(EA_WHITE,EA_RED);
|
|
||||||
char modeanzeige[7];
|
|
||||||
String str = String("MODE:");
|
|
||||||
str+=String(Stw_data.mode);
|
|
||||||
str.toCharArray(modeanzeige,7);
|
|
||||||
tft.drawText(0,0,'L'," ");
|
|
||||||
tft.drawText(0,60,'L'," ");
|
|
||||||
tft.drawText(0,120,'L'," ");
|
|
||||||
tft.drawText(0,180,'L'," ");
|
|
||||||
tft.drawText(15,68,'L',modeanzeige);
|
|
||||||
modecounter = 0;
|
|
||||||
modealt = Stw_data.mode;
|
|
||||||
modetimer = true;
|
|
||||||
}else if(modecounter >= 255){
|
|
||||||
tft.setDisplayColor(EA_WHITE,EA_BLACK);
|
|
||||||
tft.setTextColor(EA_WHITE,EA_BLACK);
|
|
||||||
tft.clear();
|
|
||||||
modetimer = false;
|
|
||||||
}else{
|
|
||||||
modecounter+=1;
|
|
||||||
delay(5);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void alarm(String textstr) {
|
void alarm(String textstr) {
|
||||||
uint8_t x = 1;;
|
uint8_t x = 1;
|
||||||
|
;
|
||||||
char text[7];
|
char text[7];
|
||||||
textstr.toCharArray(text, 7);
|
textstr.toCharArray(text, 7);
|
||||||
tft.setTextSize(8, 8);
|
tft.setTextSize(8, 8);
|
||||||
@ -400,7 +359,226 @@ void alarm(String textstr){
|
|||||||
delay(100);
|
delay(100);
|
||||||
if (Stw_data.buttonState1 & Stw_data.buttonState4) {
|
if (Stw_data.buttonState1 & Stw_data.buttonState4) {
|
||||||
x = 0;
|
x = 0;
|
||||||
|
tft.setTextColor(EA_WHITE, EA_TRANSPARENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void redraw_view_driver() {
|
||||||
|
tft.setTextColor(EA_WHITE, EA_TRANSPARENT);
|
||||||
|
|
||||||
|
// Boxes
|
||||||
|
tft.drawLine(0, 110, 320, 110);
|
||||||
|
tft.drawLine(120, 0, 120, 110);
|
||||||
|
tft.drawLine(200, 0, 200, 110);
|
||||||
|
|
||||||
|
// Tire temperature cross
|
||||||
|
tft.drawLine(80, 180, 240, 180);
|
||||||
|
tft.drawLine(160, 130, 160, 230);
|
||||||
|
|
||||||
|
// Boxes
|
||||||
|
gear_box.redraw();
|
||||||
|
left_box.redraw();
|
||||||
|
right_box.redraw();
|
||||||
|
autoshift_box.redraw();
|
||||||
|
fl_box.redraw();
|
||||||
|
fr_box.redraw();
|
||||||
|
rl_box.redraw();
|
||||||
|
rr_box.redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_view_driver() {
|
||||||
|
uint8_t prev_autoshift = Vehicle_data.autoshift;
|
||||||
|
static Value left_box_value = VAL_FIRST_LEFT_BOX;
|
||||||
|
if (Stw_data.button4_rises > 0) {
|
||||||
|
Stw_data.button4_rises--;
|
||||||
|
if (left_box_value == VAL_LAST) {
|
||||||
|
left_box_value = VAL_FIRST_LEFT_BOX;
|
||||||
|
} else {
|
||||||
|
left_box_value = (Value)(left_box_value + 1);
|
||||||
|
}
|
||||||
|
left_box.update_label(get_label(left_box_value));
|
||||||
|
}
|
||||||
|
if (Stw_data.button1_rises > 0) {
|
||||||
|
Stw_data.button1_rises--;
|
||||||
|
if (left_box_value == VAL_FIRST_LEFT_BOX) {
|
||||||
|
left_box_value = VAL_LAST;
|
||||||
|
} else {
|
||||||
|
left_box_value = (Value)(left_box_value - 1);
|
||||||
|
}
|
||||||
|
left_box.update_label(get_label(left_box_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
// These can change rapidly, which would lead to a lot of flickering if
|
||||||
|
// rendered in the clear-redraw method. So instead, they're simply overwritten
|
||||||
|
// with a black background.
|
||||||
tft.setTextColor(EA_WHITE, EA_BLACK);
|
tft.setTextColor(EA_WHITE, EA_BLACK);
|
||||||
|
left_box.update_value(pad_left(get_value(left_box_value), 5));
|
||||||
|
right_box.update_value(pad_left(get_value(VAL_RPM), 5));
|
||||||
|
// Vehicle_data.autoshift = true;
|
||||||
|
if(Vehicle_data.autoshift == true){
|
||||||
|
tft.drawRectf(164+100, 184, 240+100, 230, TT_COL3);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
tft.drawRectf(164+100, 184, 240+100, 230, EA_BLACK);
|
||||||
|
}
|
||||||
|
autoshift_box.update_value(pad_left(String(Vehicle_data.autoshift), 5));
|
||||||
|
|
||||||
|
// These don't change as rapidly, and would overwrite adjacent elements
|
||||||
|
// (lines/labels) if rendered with a background because of the empty pixels
|
||||||
|
// above/below the characters. So they're rendered using the clear-redraw
|
||||||
|
// method.0
|
||||||
|
tft.setTextColor(EA_WHITE, EA_TRANSPARENT);
|
||||||
|
//gear_box.update_value(get_value(VAL_GEAR));
|
||||||
|
fl_box.update_value(get_value(VAL_TT_FL).toInt());
|
||||||
|
fr_box.update_value(get_value(VAL_TT_FR).toInt());
|
||||||
|
rl_box.update_value(get_value(VAL_TT_RL).toInt());
|
||||||
|
rr_box.update_value(get_value(VAL_TT_RR).toInt());
|
||||||
|
//Vehicle_data.autoshift = true; //For testing only!!
|
||||||
|
if(Vehicle_data.autoshift == true){
|
||||||
|
tft.setTextColor(EA_ORANGE, EA_TRANSPARENT);
|
||||||
|
}
|
||||||
|
gear_box.update_value(get_value(VAL_GEAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
void redraw_view_testing() {
|
||||||
|
tft.clear();
|
||||||
|
tft.setTextFont(EA_FONT7X12);
|
||||||
|
tft.setTextSize(2, 2);
|
||||||
|
int start = 10 * testing_page;
|
||||||
|
|
||||||
|
tft.setTextColor(EA_WHITE, EA_BLACK);
|
||||||
|
for (int i = start; i <= min(VAL_LAST, start + 9); i += 2) {
|
||||||
|
redraw_label_testing(i, EA_BLACK);
|
||||||
|
}
|
||||||
|
tft.setTextColor(EA_WHITE, EA_DARKGREY);
|
||||||
|
for (int i = start + 1; i <= min(VAL_LAST, start + 9); i += 2) {
|
||||||
|
redraw_label_testing(i, EA_DARKGREY);
|
||||||
|
}
|
||||||
|
|
||||||
|
update_view_testing();
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_view_testing() {
|
||||||
|
if (Stw_data.button4_rises > 0) {
|
||||||
|
Stw_data.button4_rises--;
|
||||||
|
testing_page++;
|
||||||
|
if (testing_page * 10 > VAL_LAST) {
|
||||||
|
testing_page = 0;
|
||||||
|
}
|
||||||
|
redraw_view_testing();
|
||||||
|
}
|
||||||
|
if (Stw_data.button1_rises > 0) {
|
||||||
|
Stw_data.button1_rises--;
|
||||||
|
testing_page--;
|
||||||
|
if (testing_page < 0) {
|
||||||
|
testing_page = VAL_LAST / 10;
|
||||||
|
}
|
||||||
|
redraw_view_testing();
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.setTextFont(EA_FONT7X12);
|
||||||
|
tft.setTextSize(2, 2);
|
||||||
|
|
||||||
|
int start = 10 * testing_page;
|
||||||
|
|
||||||
|
tft.setTextColor(EA_WHITE, EA_BLACK);
|
||||||
|
for (int i = start; i <= min(VAL_LAST, start + 9); i += 2) {
|
||||||
|
update_value_testing(i);
|
||||||
|
}
|
||||||
|
tft.setTextColor(EA_WHITE, EA_DARKGREY);
|
||||||
|
for (int i = start + 1; i <= min(VAL_LAST, start + 9); i += 2) {
|
||||||
|
update_value_testing(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void redraw_label_testing(int i, uint8_t color) {
|
||||||
|
String text = get_label((Value)i) + ":";
|
||||||
|
int y = (i % 10) * 24;
|
||||||
|
tft.drawRectf(0, y, 320, y + 23, color);
|
||||||
|
tft.drawText(10, y, 'L', text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void update_value_testing(int i) {
|
||||||
|
String text = pad_left(get_value((Value)i), 5);
|
||||||
|
int y = (i % 10) * 24;
|
||||||
|
tft.drawText(310, y, 'R', text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
DataBox::DataBox(int x1, int y1, int x2, int y2, int text_x, int text_y,
|
||||||
|
int font, int size_x, int size_y, uint8_t justification,
|
||||||
|
bool do_clear)
|
||||||
|
: x1{x1}, y1{y1}, x2{x2}, y2{y2}, text_x{text_x}, text_y{text_y},
|
||||||
|
font{font}, size_x{size_x}, size_y{size_y},
|
||||||
|
justification{justification}, do_clear{do_clear}, value{""}, label{""} {}
|
||||||
|
|
||||||
|
void DataBox::update_value(String val_new) {
|
||||||
|
if (!val_new.equals(value)) {
|
||||||
|
value = val_new;
|
||||||
|
redraw_value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBox::update_label(String label_new) {
|
||||||
|
if (!label_new.equals(label)) {
|
||||||
|
label = label_new;
|
||||||
|
redraw_label();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBox::redraw() {
|
||||||
|
redraw_value();
|
||||||
|
redraw_label();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBox::redraw_value() {
|
||||||
|
tft.setTextFont(font);
|
||||||
|
tft.setTextSize(size_x, size_y);
|
||||||
|
Serial.println("Redrawing value:");
|
||||||
|
if (do_clear) {
|
||||||
|
tft.clearRect(x1, y1, x2, y2);
|
||||||
|
}
|
||||||
|
tft.drawText(text_x, text_y, justification, value.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBox::redraw_label() {
|
||||||
|
tft.setTextFont(EA_FONT7X12);
|
||||||
|
tft.setTextSize(1, 1);
|
||||||
|
Serial.println("Redrawing label:");
|
||||||
|
tft.clearRect(x1, y2 + 1, x2, y2 + 13);
|
||||||
|
tft.drawText((x1 + x2) / 2, y2 + 1, 'C', label.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
TireTempBox::TireTempBox(int x1, int y1, int x2, int y2, int text_x, int text_y,
|
||||||
|
int font, int size_x, int size_y,
|
||||||
|
uint8_t justification)
|
||||||
|
: DataBox{x1, y1, x2, y2, text_x,
|
||||||
|
text_y, font, size_x, size_y, justification,
|
||||||
|
false},
|
||||||
|
num_value{-1} {}
|
||||||
|
|
||||||
|
void TireTempBox::update_value(int val_new) {
|
||||||
|
if (val_new != num_value) {
|
||||||
|
num_value = val_new;
|
||||||
|
if (val_new < TT_THRESH1) {
|
||||||
|
color = TT_COL0;
|
||||||
|
} else if (val_new < TT_THRESH2) {
|
||||||
|
color = TT_COL1;
|
||||||
|
} else if (val_new < TT_THRESH3) {
|
||||||
|
color = TT_COL2;
|
||||||
|
} else {
|
||||||
|
color = TT_COL3;
|
||||||
|
}
|
||||||
|
String val_str = pad_left(String(val_new), 3);
|
||||||
|
DataBox::update_value(val_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TireTempBox::redraw_value() {
|
||||||
|
tft.setTextFont(font);
|
||||||
|
tft.setTextSize(size_x, size_y);
|
||||||
|
tft.drawRectf(x1, y1, x2, y2, color);
|
||||||
|
tft.drawText(text_x, text_y, justification, value.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TireTempBox::redraw_label() {}
|
||||||
@ -1,15 +1,10 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "EDIPTFT.h"
|
#include "EDIPTFT.h"
|
||||||
#include "FT_2018_STW_CAN.h"
|
|
||||||
#include "FT18_STW_INIT.h"
|
#include "FT18_STW_INIT.h"
|
||||||
|
#include "FT_2018_STW_CAN.h"
|
||||||
#ifndef FT18_STW_DISPLAY_h
|
#ifndef FT18_STW_DISPLAY_h
|
||||||
#define FT18_STW_DISPLAY_h
|
#define FT18_STW_DISPLAY_h
|
||||||
|
|
||||||
#define EA_BLACK 1
|
|
||||||
#define EA_RED 3
|
|
||||||
#define EA_GREY 10
|
|
||||||
#define EA_WHITE 8
|
|
||||||
|
|
||||||
#define MOSI 75
|
#define MOSI 75
|
||||||
#define MISO 74
|
#define MISO 74
|
||||||
#define CLK 76
|
#define CLK 76
|
||||||
@ -17,12 +12,106 @@
|
|||||||
#define reset 43
|
#define reset 43
|
||||||
#define writeprotect 52
|
#define writeprotect 52
|
||||||
|
|
||||||
|
#define POIL_ALARM_THRESH ((uint32_t)(0.1 / 0.0514))
|
||||||
|
#define POIL_ALARM_TIME 20000 // ms
|
||||||
|
#define TMOT_ALARM_THRESH (40 + 105)
|
||||||
|
#define TMOT_SAFE_VALUE (40 + 200)
|
||||||
|
#define TMOT_ALARM_TIME 20000 // ms
|
||||||
|
#define TOIL_ALARM_THRESH (40 + 150)
|
||||||
|
#define TOIL_ALARM_TIME 10000 // ms
|
||||||
|
#define ENC_DISPLAY_TIME 1000 // ms
|
||||||
|
|
||||||
|
String pad_left(String orig, int len, char pad_char = ' ');
|
||||||
|
|
||||||
|
enum DisplayView { VIEW_DRIVER, VIEW_TESTING, VIEW_LAST = VIEW_TESTING };
|
||||||
|
|
||||||
|
enum Value {
|
||||||
|
VAL_GEAR,
|
||||||
|
VAL_RPM,
|
||||||
|
VAL_TT_FL,
|
||||||
|
VAL_TT_FR,
|
||||||
|
VAL_TT_RL,
|
||||||
|
VAL_TT_RR,
|
||||||
|
VAL_LAPTIME,
|
||||||
|
VAL_UBATT,
|
||||||
|
VAL_TMOT,
|
||||||
|
VAL_TAIR,
|
||||||
|
VAL_TOIL,
|
||||||
|
VAL_ERR_TYPE,
|
||||||
|
VAL_PFUEL,
|
||||||
|
VAL_PWAT,
|
||||||
|
VAL_POIL,
|
||||||
|
VAL_PBF,
|
||||||
|
VAL_PBR,
|
||||||
|
VAL_SPEED_FL,
|
||||||
|
VAL_SPEED_FR,
|
||||||
|
VAL_SPEED,
|
||||||
|
VAL_BBAL,
|
||||||
|
VAL_FIRST_LEFT_BOX = VAL_LAPTIME,
|
||||||
|
VAL_LAST = VAL_BBAL
|
||||||
|
};
|
||||||
|
String get_value(Value val);
|
||||||
|
String get_label(Value val);
|
||||||
|
|
||||||
void init_display(void);
|
void init_display(void);
|
||||||
void update_display(void);
|
void update_display(void);
|
||||||
double get_value(int a);
|
|
||||||
void display_trc(void);
|
void display_trc(void);
|
||||||
void display_mode(void);
|
void display_mode(void);
|
||||||
void alarm(String text);
|
void alarm(String text);
|
||||||
|
|
||||||
|
bool check_alarms();
|
||||||
|
bool check_enc_displays();
|
||||||
|
bool check_display(uint8_t& val_old, uint8_t val_new, bool& active,
|
||||||
|
uint32_t& begin, const String& title);
|
||||||
|
|
||||||
|
void redraw_view_driver();
|
||||||
|
void update_view_driver();
|
||||||
|
void redraw_view_testing();
|
||||||
|
void update_view_testing();
|
||||||
|
void redraw_label_testing(int i, uint8_t bg_color);
|
||||||
|
void update_value_testing(int i);
|
||||||
|
|
||||||
|
class DataBox {
|
||||||
|
public:
|
||||||
|
DataBox(int x1, int y1, int x2, int y2, int text_x, int text_y, int font,
|
||||||
|
int size_x, int size_y, uint8_t justification, bool do_clear);
|
||||||
|
|
||||||
|
void update_value(String val_new);
|
||||||
|
void update_label(String label_new);
|
||||||
|
|
||||||
|
void redraw();
|
||||||
|
virtual void redraw_value();
|
||||||
|
virtual void redraw_label();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int x1, y1, x2, y2, text_x, text_y, font, size_x, size_y;
|
||||||
|
uint8_t justification;
|
||||||
|
bool do_clear;
|
||||||
|
String value;
|
||||||
|
String label;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define TT_COL0 EA_LIGHTBLUE
|
||||||
|
#define TT_COL1 EA_GREEN
|
||||||
|
#define TT_COL2 EA_ORANGE
|
||||||
|
#define TT_COL3 EA_RED
|
||||||
|
#define TT_THRESH1 40
|
||||||
|
#define TT_THRESH2 60
|
||||||
|
#define TT_THRESH3 70
|
||||||
|
|
||||||
|
class TireTempBox : public DataBox {
|
||||||
|
public:
|
||||||
|
TireTempBox(int x1, int y1, int x2, int y2, int text_x, int text_y, int font,
|
||||||
|
int size_x, int size_y, uint8_t justification);
|
||||||
|
|
||||||
|
void update_value(int val_new);
|
||||||
|
|
||||||
|
void redraw_value() override;
|
||||||
|
void redraw_label() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int color;
|
||||||
|
int num_value;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -7,9 +7,11 @@
|
|||||||
volatile stw_data_type Stw_data = {0}; // alles mit 0 initialisieren
|
volatile stw_data_type Stw_data = {0}; // alles mit 0 initialisieren
|
||||||
volatile vehicle_data_type Vehicle_data = {0}; // alles mit 0 initialisieren
|
volatile vehicle_data_type Vehicle_data = {0}; // alles mit 0 initialisieren
|
||||||
bool enc1PinALast, enc1PinANow, enc2PinALast, enc2PinANow;
|
bool enc1PinALast, enc1PinANow, enc2PinALast, enc2PinANow;
|
||||||
int led[] = {led1,led2,led3,led4,led5,led6,led7,led8,led9,led10,led11,led12,led13,led14,led15,led16};
|
int led[] = {led1, led2, led3, led4, led5, led6, led7, led8,
|
||||||
|
led9, led10, led11, led12, led13, led14, led15, led16};
|
||||||
bool entprell;
|
bool entprell;
|
||||||
int buttons[] = {button1,button2,button3,button4,button5,button6,enc1PinS,enc2PinS};
|
int buttons[] = {button1, button2, button3, button4,
|
||||||
|
button5, button6, enc1PinS, enc2PinS};
|
||||||
constexpr size_t N_BUTTONS = sizeof(buttons) / sizeof(buttons[0]);
|
constexpr size_t N_BUTTONS = sizeof(buttons) / sizeof(buttons[0]);
|
||||||
Bounce2::Button debouncer[N_BUTTONS];
|
Bounce2::Button debouncer[N_BUTTONS];
|
||||||
double val = 0;
|
double val = 0;
|
||||||
@ -46,18 +48,30 @@ void read_buttons(){
|
|||||||
|
|
||||||
// These are only used to send them out via CAN, so they only need to be
|
// These are only used to send them out via CAN, so they only need to be
|
||||||
// high once.
|
// high once.
|
||||||
Stw_data.Stw_neutral = debouncer[1].rose();
|
//Stw_data.Stw_neutral = debouncer[1].rose();
|
||||||
Stw_data.Stw_auto_shift = debouncer[2].rose();
|
//Stw_data.Stw_auto_shift = debouncer[2].isPressed(); //Hold to open DRS
|
||||||
|
// 05.09.: swapped neutral and auto_shift (DRS)
|
||||||
|
Stw_data.Stw_neutral = debouncer[2].rose();
|
||||||
|
Stw_data.Stw_auto_shift = debouncer[1].isPressed(); //Hold to open DRS
|
||||||
Stw_data.Stw_shift_down = debouncer[4].rose();
|
Stw_data.Stw_shift_down = debouncer[4].rose();
|
||||||
Stw_data.Stw_shift_up = debouncer[5].rose();
|
Stw_data.Stw_shift_up = debouncer[5].rose();
|
||||||
|
|
||||||
// These are also used for GUI, so if we set them only at rising edge, they
|
Stw_data.buttonState1 = debouncer[0].isPressed();
|
||||||
// might never be high when checked in the GUI.
|
Stw_data.buttonState4 = debouncer[3].isPressed();
|
||||||
// TODO: Rewrite so we can use debounced values here as well
|
Stw_data.buttonStateEnc1 = debouncer[6].isPressed();
|
||||||
Stw_data.buttonState1 = digitalRead(button1);
|
Stw_data.buttonStateEnc2 = debouncer[7].isPressed();
|
||||||
Stw_data.buttonState4 = digitalRead(button4);
|
if (debouncer[0].rose()) {
|
||||||
Stw_data.buttonStateEnc1 = digitalRead(enc1PinS);
|
Stw_data.button1_rises++;
|
||||||
Stw_data.buttonStateEnc2 = digitalRead(enc2PinS);
|
}
|
||||||
|
if (debouncer[3].rose()) {
|
||||||
|
Stw_data.button4_rises++;
|
||||||
|
}
|
||||||
|
if (debouncer[6].rose()) {
|
||||||
|
Stw_data.enc1_rises++;
|
||||||
|
}
|
||||||
|
if (debouncer[7].rose()) {
|
||||||
|
Stw_data.enc2_rises++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_rotary() {
|
void read_rotary() {
|
||||||
|
|||||||
@ -32,26 +32,23 @@
|
|||||||
#define enc2PinB 41
|
#define enc2PinB 41
|
||||||
#define enc2PinS 39
|
#define enc2PinS 39
|
||||||
|
|
||||||
|
|
||||||
// define Drehzahlgrenzen TODOOOO
|
// define Drehzahlgrenzen TODOOOO
|
||||||
#define RPM_THRES_1 1000
|
#define RPM_THRES_1 6000
|
||||||
#define RPM_THRES_2 6000
|
#define RPM_THRES_2 12000
|
||||||
#define RPM_THRES_3 7000
|
#define RPM_THRES_3 12800
|
||||||
#define RPM_THRES_4 8000
|
#define RPM_THRES_4 13600
|
||||||
#define RPM_THRES_5 10000
|
#define RPM_THRES_5 14400
|
||||||
#define RPM_THRES_6 14000
|
#define RPM_THRES_6 15200
|
||||||
#define RPM_THRES_7 17000
|
#define RPM_THRES_7 16000
|
||||||
#define RPM_THRES_8 18000
|
#define RPM_THRES_8 16800
|
||||||
#define RPM_THRES_9 20000
|
#define RPM_THRES_9 18000
|
||||||
#define RPM_THRES_10 20000
|
#define RPM_THRES_10 18000
|
||||||
|
|
||||||
|
|
||||||
void set_pins(void);
|
void set_pins(void);
|
||||||
void read_buttons(void);
|
void read_buttons(void);
|
||||||
void read_rotary(void); // read rotary switches
|
void read_rotary(void); // read rotary switches
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint8_t Stw_shift_up; // 1 Bit 0
|
uint8_t Stw_shift_up; // 1 Bit 0
|
||||||
uint8_t Stw_shift_down; // 1 Bit 1
|
uint8_t Stw_shift_down; // 1 Bit 1
|
||||||
uint8_t Stw_neutral; // 1 Bit 2
|
uint8_t Stw_neutral; // 1 Bit 2
|
||||||
@ -60,19 +57,24 @@ typedef struct
|
|||||||
uint8_t buttonState4; // 1 Bit 5
|
uint8_t buttonState4; // 1 Bit 5
|
||||||
// bool CAN_toggle;
|
// bool CAN_toggle;
|
||||||
// bool CAN_check;
|
// bool CAN_check;
|
||||||
//uint8_t i; //Index linker Drehschalter
|
// uint8_t i; //Index
|
||||||
|
// linker Drehschalter
|
||||||
uint8_t buttonStateEnc1; // button
|
uint8_t buttonStateEnc1; // button
|
||||||
//uint8_t br; //test mode : mittlere Drehschalter position
|
// uint8_t br; //test
|
||||||
|
// mode : mittlere Drehschalter position
|
||||||
uint8_t buttonStateEnc2; // button
|
uint8_t buttonStateEnc2; // button
|
||||||
uint8_t displayindex; // index für Displayanzeige
|
uint8_t displayindex; // index für Displayanzeige
|
||||||
uint8_t error_type; // Extrainfos über Error-LED
|
uint8_t error_type; // Extrainfos über Error-LED
|
||||||
uint8_t trc;
|
uint8_t trc;
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
|
|
||||||
|
uint8_t button1_rises;
|
||||||
|
uint8_t button4_rises;
|
||||||
|
uint8_t enc1_rises;
|
||||||
|
uint8_t enc2_rises;
|
||||||
} stw_data_type;
|
} stw_data_type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint8_t e_thro; // E-Drossel
|
uint8_t e_thro; // E-Drossel
|
||||||
uint8_t g_auto; // Auto-Shift
|
uint8_t g_auto; // Auto-Shift
|
||||||
uint8_t gear; // Gang
|
uint8_t gear; // Gang
|
||||||
@ -80,8 +82,14 @@ typedef struct
|
|||||||
uint8_t t_oil; // Öl-Motor-Temperatur
|
uint8_t t_oil; // Öl-Motor-Temperatur
|
||||||
uint8_t t_mot; // Wasser-Motor-Temperatur
|
uint8_t t_mot; // Wasser-Motor-Temperatur
|
||||||
uint8_t t_air; // LLK-Temperatur
|
uint8_t t_air; // LLK-Temperatur
|
||||||
|
uint8_t t_tfl; // Tire temp front left
|
||||||
|
uint8_t t_tfr; // Tire temp front right
|
||||||
|
uint8_t t_trl; // Tire temp rear left
|
||||||
|
uint8_t t_trr; // Tire temp rear right
|
||||||
uint8_t u_batt; // Batteriespannung
|
uint8_t u_batt; // Batteriespannung
|
||||||
uint8_t rev_lim; // Drehzahllimit Bit
|
uint8_t rev_lim; // Drehzahllimit Bit
|
||||||
|
bool drs_active; // DRS status from BCU
|
||||||
|
bool autoshift; // Autoshift status from BCU
|
||||||
uint8_t p_wat;
|
uint8_t p_wat;
|
||||||
uint8_t p_fuel;
|
uint8_t p_fuel;
|
||||||
uint8_t p_oil;
|
uint8_t p_oil;
|
||||||
@ -90,12 +98,11 @@ typedef struct
|
|||||||
uint8_t speed_fl;
|
uint8_t speed_fl;
|
||||||
uint8_t speed_fr;
|
uint8_t speed_fr;
|
||||||
uint8_t speed;
|
uint8_t speed;
|
||||||
|
uint8_t lap_time_sec;
|
||||||
|
uint16_t lap_time_msec;
|
||||||
} vehicle_data_type;
|
} vehicle_data_type;
|
||||||
|
|
||||||
|
|
||||||
extern volatile stw_data_type Stw_data;
|
extern volatile stw_data_type Stw_data;
|
||||||
extern volatile vehicle_data_type Vehicle_data;
|
extern volatile vehicle_data_type Vehicle_data;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,8 +1,8 @@
|
|||||||
|
#include "FT18e_STW_DISPLAY.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "EDIPTFT.h"
|
#include "EDIPTFT.h"
|
||||||
#include "FT_2018e_STW_CAN.h"
|
|
||||||
#include "FT18e_STW_INIT.h"
|
#include "FT18e_STW_INIT.h"
|
||||||
#include "FT18e_STW_DISPLAY.h"
|
#include "FT_2018e_STW_CAN.h"
|
||||||
|
|
||||||
EDIPTFT tft(true, false);
|
EDIPTFT tft(true, false);
|
||||||
String bezeichnungen[] = {"Batterieleistung", "Moment", "Batterietemp"};
|
String bezeichnungen[] = {"Batterieleistung", "Moment", "Batterietemp"};
|
||||||
@ -26,7 +26,8 @@ uint8_t trccounter; // = Stw_data.trc;
|
|||||||
uint8_t modecounter; // = Stw_data.mode;
|
uint8_t modecounter; // = Stw_data.mode;
|
||||||
bool trctimer;
|
bool trctimer;
|
||||||
bool modetimer;
|
bool modetimer;
|
||||||
int led_s[] = {led1, led2, led3, led4, led5, led6, led7, led8, led9, led10, led11, led12, led13, led14, led15, led16};
|
int led_s[] = {led1, led2, led3, led4, led5, led6, led7, led8,
|
||||||
|
led9, led10, led11, led12, led13, led14, led15, led16};
|
||||||
unsigned long poiltimer;
|
unsigned long poiltimer;
|
||||||
unsigned long tmottimer;
|
unsigned long tmottimer;
|
||||||
unsigned long toiltimer;
|
unsigned long toiltimer;
|
||||||
@ -34,8 +35,7 @@ bool poilbool = true;
|
|||||||
bool tmotbool = true;
|
bool tmotbool = true;
|
||||||
bool toilbool = true;
|
bool toilbool = true;
|
||||||
|
|
||||||
void init_display()
|
void init_display() {
|
||||||
{
|
|
||||||
pinMode(writeprotect, OUTPUT);
|
pinMode(writeprotect, OUTPUT);
|
||||||
digitalWrite(writeprotect, HIGH);
|
digitalWrite(writeprotect, HIGH);
|
||||||
pinMode(reset, OUTPUT);
|
pinMode(reset, OUTPUT);
|
||||||
@ -48,8 +48,8 @@ void init_display()
|
|||||||
digitalWrite(MISO, HIGH);
|
digitalWrite(MISO, HIGH);
|
||||||
digitalWrite(reset, LOW);
|
digitalWrite(reset, LOW);
|
||||||
// edip.smallProtoSelect(7);
|
// edip.smallProtoSelect(7);
|
||||||
//edip.setNewColor(EA_GREY, 0xe3, 0xe3,0xe3); // redefine r-g-b-values of EA_GREY
|
// edip.setNewColor(EA_GREY, 0xe3, 0xe3,0xe3); // redefine r-g-b-values
|
||||||
//edip.drawImage(0,50,FASTTUBE_LOGO_PNG);
|
// of EA_GREY edip.drawImage(0,50,FASTTUBE_LOGO_PNG);
|
||||||
digitalWrite(reset, HIGH);
|
digitalWrite(reset, HIGH);
|
||||||
tft.begin(115200); // start display communication
|
tft.begin(115200); // start display communication
|
||||||
/*int h = 20;
|
/*int h = 20;
|
||||||
@ -70,36 +70,26 @@ void init_display()
|
|||||||
// delay(2000);
|
// delay(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_value(int a)
|
double get_value(int a) { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_display()
|
void update_display() {
|
||||||
{
|
if (!tft.disconnected) {
|
||||||
if (!tft.disconnected)
|
|
||||||
{
|
|
||||||
tft.cursorOn(false);
|
tft.cursorOn(false);
|
||||||
if (modealt != Stw_data.mode || modetimer == true)
|
if (modealt != Stw_data.mode || modetimer == true) {
|
||||||
{
|
|
||||||
display_mode();
|
display_mode();
|
||||||
}
|
} else {
|
||||||
else
|
if (clearcounter >= 56) {
|
||||||
{
|
|
||||||
if (clearcounter >= 56)
|
|
||||||
{
|
|
||||||
tft.clear();
|
tft.clear();
|
||||||
clearcounter = 0;
|
clearcounter = 0;
|
||||||
}
|
}
|
||||||
clearcounter += 1;
|
clearcounter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// else für neue init?
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_mode()
|
void display_mode() {
|
||||||
{
|
if (modealt != Stw_data.mode) {
|
||||||
if (modealt != Stw_data.mode)
|
|
||||||
{
|
|
||||||
tft.clear();
|
tft.clear();
|
||||||
tft.setTextSize(6, 8);
|
tft.setTextSize(6, 8);
|
||||||
tft.setDisplayColor(EA_WHITE, EA_RED);
|
tft.setDisplayColor(EA_WHITE, EA_RED);
|
||||||
@ -116,54 +106,43 @@ void display_mode()
|
|||||||
modecounter = 0;
|
modecounter = 0;
|
||||||
modealt = Stw_data.mode;
|
modealt = Stw_data.mode;
|
||||||
modetimer = true;
|
modetimer = true;
|
||||||
}
|
} else if (modecounter >= 255) {
|
||||||
else if (modecounter >= 255)
|
|
||||||
{
|
|
||||||
tft.setDisplayColor(EA_WHITE, EA_BLACK);
|
tft.setDisplayColor(EA_WHITE, EA_BLACK);
|
||||||
tft.setTextColor(EA_WHITE, EA_BLACK);
|
tft.setTextColor(EA_WHITE, EA_BLACK);
|
||||||
tft.clear();
|
tft.clear();
|
||||||
modetimer = false;
|
modetimer = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
modecounter += 1;
|
modecounter += 1;
|
||||||
delay(5);
|
delay(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void alarm(String textstr)
|
void alarm(String textstr) {
|
||||||
{
|
|
||||||
uint8_t x = 1;
|
uint8_t x = 1;
|
||||||
;
|
;
|
||||||
char text[7];
|
char text[7];
|
||||||
textstr.toCharArray(text, 7);
|
textstr.toCharArray(text, 7);
|
||||||
tft.setTextSize(8, 8);
|
tft.setTextSize(8, 8);
|
||||||
while (x == 1)
|
while (x == 1) {
|
||||||
{
|
if (!tft.disconnected) {
|
||||||
if (!tft.disconnected)
|
|
||||||
{
|
|
||||||
tft.setTextColor(EA_BLACK, EA_RED);
|
tft.setTextColor(EA_BLACK, EA_RED);
|
||||||
tft.fillDisplayColor(EA_RED);
|
tft.fillDisplayColor(EA_RED);
|
||||||
tft.drawText(5, 68, 'L', text);
|
tft.drawText(5, 68, 'L', text);
|
||||||
}
|
}
|
||||||
for (int j = 0; j < 16; j++)
|
for (int j = 0; j < 16; j++) {
|
||||||
{
|
|
||||||
digitalWrite(led_s[j], HIGH);
|
digitalWrite(led_s[j], HIGH);
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
if (!tft.disconnected)
|
if (!tft.disconnected) {
|
||||||
{
|
|
||||||
tft.setTextColor(EA_BLACK, EA_WHITE);
|
tft.setTextColor(EA_BLACK, EA_WHITE);
|
||||||
tft.fillDisplayColor(EA_WHITE);
|
tft.fillDisplayColor(EA_WHITE);
|
||||||
tft.drawText(5, 68, 'L', text);
|
tft.drawText(5, 68, 'L', text);
|
||||||
}
|
}
|
||||||
for (int j = 0; j < 16; j++)
|
for (int j = 0; j < 16; j++) {
|
||||||
{
|
|
||||||
digitalWrite(led_s[j], LOW);
|
digitalWrite(led_s[j], LOW);
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
if (Stw_data.button_ll & Stw_data.button_rr)
|
if (Stw_data.button_ll & Stw_data.button_rr) {
|
||||||
{
|
|
||||||
x = 0;
|
x = 0;
|
||||||
tft.setTextColor(EA_WHITE, EA_BLACK);
|
tft.setTextColor(EA_WHITE, EA_BLACK);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "EDIPTFT.h"
|
#include "EDIPTFT.h"
|
||||||
#include "FT_2018e_STW_CAN.h"
|
|
||||||
#include "FT18e_STW_INIT.h"
|
#include "FT18e_STW_INIT.h"
|
||||||
|
#include "FT_2018e_STW_CAN.h"
|
||||||
#ifndef FT18e_STW_DISPLAY_h
|
#ifndef FT18e_STW_DISPLAY_h
|
||||||
#define FT18e_STW_DISPLAY_h
|
#define FT18e_STW_DISPLAY_h
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
#include "Arduino.h"
|
|
||||||
#include "FT18e_STW_INIT.h"
|
#include "FT18e_STW_INIT.h"
|
||||||
|
#include "Arduino.h"
|
||||||
#include "Bounce2.h"
|
#include "Bounce2.h"
|
||||||
#include "RotaryEncoder.h"
|
#include "RotaryEncoder.h"
|
||||||
|
|
||||||
volatile stw_data_type Stw_data = {0}; // alles mit 0 initialisieren
|
volatile stw_data_type Stw_data = {0}; // alles mit 0 initialisieren
|
||||||
volatile vehicle_data_type Vehicle_data = {0}; // alles mit 0 initialisieren
|
volatile vehicle_data_type Vehicle_data = {0}; // alles mit 0 initialisieren
|
||||||
bool enc1PinALast, enc1PinANow, enc2PinALast, enc2PinANow;
|
bool enc1PinALast, enc1PinANow, enc2PinALast, enc2PinANow;
|
||||||
int led[] = {led1, led2, led3, led4, led5, led6, led7, led8, led9, led10, led11, led12, led13, led14, led15, led16};
|
int led[] = {led1, led2, led3, led4, led5, led6, led7, led8,
|
||||||
|
led9, led10, led11, led12, led13, led14, led15, led16};
|
||||||
bool entprell;
|
bool entprell;
|
||||||
int buttons[] = {PIN_BUTTON_LL, PIN_BUTTON_LR, PIN_BUTTON_RL, PIN_BUTTON_RR, enc1PinS, enc2PinS};
|
int buttons[] = {PIN_BUTTON_LL, PIN_BUTTON_LR, PIN_BUTTON_RL,
|
||||||
|
PIN_BUTTON_RR, enc1PinS, enc2PinS};
|
||||||
Bounce debouncer[8];
|
Bounce debouncer[8];
|
||||||
double val = 0;
|
double val = 0;
|
||||||
double val2 = 0;
|
double val2 = 0;
|
||||||
@ -18,10 +20,8 @@ RotaryEncoder encoder2(enc2PinA, enc2PinB, 1, 1, 50);
|
|||||||
// functions
|
// functions
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
void set_pins()
|
void set_pins() {
|
||||||
{
|
for (int thisLed = 0; thisLed < sizeof(led) / sizeof(int); thisLed++) {
|
||||||
for (int thisLed = 0; thisLed < sizeof(led) / sizeof(int); thisLed++)
|
|
||||||
{
|
|
||||||
pinMode(led[thisLed], OUTPUT);
|
pinMode(led[thisLed], OUTPUT);
|
||||||
}
|
}
|
||||||
pinMode(l, OUTPUT);
|
pinMode(l, OUTPUT);
|
||||||
@ -42,40 +42,30 @@ void set_pins()
|
|||||||
enc1PinANow = LOW;
|
enc1PinANow = LOW;
|
||||||
enc2PinALast = LOW;
|
enc2PinALast = LOW;
|
||||||
enc2PinANow = LOW;
|
enc2PinANow = LOW;
|
||||||
for (int i = 0; i < sizeof(buttons) / sizeof(*buttons); i++)
|
for (int i = 0; i < sizeof(buttons) / sizeof(*buttons); i++) {
|
||||||
{
|
|
||||||
pinMode(buttons[i], INPUT);
|
pinMode(buttons[i], INPUT);
|
||||||
debouncer[i].attach(buttons[i]);
|
debouncer[i].attach(buttons[i]);
|
||||||
debouncer[i].interval(10);
|
debouncer[i].interval(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_buttons()
|
void read_buttons() {
|
||||||
{
|
|
||||||
Stw_data.button_ll = digitalRead(PIN_BUTTON_LL);
|
Stw_data.button_ll = digitalRead(PIN_BUTTON_LL);
|
||||||
Stw_data.button_lr = digitalRead(PIN_BUTTON_LR);
|
Stw_data.button_lr = digitalRead(PIN_BUTTON_LR);
|
||||||
Stw_data.button_rl = digitalRead(PIN_BUTTON_RL);
|
Stw_data.button_rl = digitalRead(PIN_BUTTON_RL);
|
||||||
Stw_data.button_rr = digitalRead(PIN_BUTTON_RR);
|
Stw_data.button_rr = digitalRead(PIN_BUTTON_RR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_rotary()
|
void read_rotary() {
|
||||||
{
|
|
||||||
int enc2 = encoder2.readEncoder();
|
int enc2 = encoder2.readEncoder();
|
||||||
if (enc2 != 0)
|
if (enc2 != 0) {
|
||||||
{
|
|
||||||
val2 = val2 + 0.5 * enc2;
|
val2 = val2 + 0.5 * enc2;
|
||||||
if (val2 == 1 or val2 == -1)
|
if (val2 == 1 or val2 == -1) {
|
||||||
{
|
if ((Stw_data.mode == 1 or Stw_data.mode == 0) and enc2 < 0) {
|
||||||
if ((Stw_data.mode == 1 or Stw_data.mode == 0) and enc2 < 0)
|
|
||||||
{
|
|
||||||
Stw_data.mode = 5;
|
Stw_data.mode = 5;
|
||||||
}
|
} else if (Stw_data.mode == 5 and enc2 > 0) {
|
||||||
else if (Stw_data.mode == 5 and enc2 > 0)
|
|
||||||
{
|
|
||||||
Stw_data.mode = 1;
|
Stw_data.mode = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Stw_data.mode = Stw_data.mode + enc2;
|
Stw_data.mode = Stw_data.mode + enc2;
|
||||||
}
|
}
|
||||||
val2 = 0;
|
val2 = 0;
|
||||||
|
|||||||
@ -51,8 +51,7 @@ void set_pins(void);
|
|||||||
void read_buttons(void);
|
void read_buttons(void);
|
||||||
void read_rotary(void); // read rotary switches
|
void read_rotary(void); // read rotary switches
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
bool button_ll; // Left side, left button
|
bool button_ll; // Left side, left button
|
||||||
bool button_lr; // Left side, right button
|
bool button_lr; // Left side, right button
|
||||||
bool button_rl; // Right side, left button
|
bool button_rl; // Right side, left button
|
||||||
@ -63,8 +62,7 @@ typedef struct
|
|||||||
|
|
||||||
} stw_data_type;
|
} stw_data_type;
|
||||||
|
|
||||||
struct InverterData
|
struct InverterData {
|
||||||
{
|
|
||||||
bool ready;
|
bool ready;
|
||||||
bool derating;
|
bool derating;
|
||||||
bool warning;
|
bool warning;
|
||||||
@ -75,8 +73,7 @@ struct InverterData
|
|||||||
bool ts_active;
|
bool ts_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint16_t u_cell_min; // Minimale Zellspannung
|
uint16_t u_cell_min; // Minimale Zellspannung
|
||||||
uint16_t u_batt; // Batteriespannung (pre-AIR-voltage)
|
uint16_t u_batt; // Batteriespannung (pre-AIR-voltage)
|
||||||
int16_t t_mot_l; // Motor-Wasser-Temperatur Links
|
int16_t t_mot_l; // Motor-Wasser-Temperatur Links
|
||||||
|
|||||||
@ -2,30 +2,42 @@
|
|||||||
FT_2018_STW_CAN.cpp
|
FT_2018_STW_CAN.cpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "FT_2018_STW_CAN.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "DueTimer.h"
|
#include "DueTimer.h"
|
||||||
#include "due_can.h"
|
|
||||||
#include "FT_2018_STW_CAN.h"
|
|
||||||
#include "FT18_STW_INIT.h"
|
#include "FT18_STW_INIT.h"
|
||||||
|
#include "due_can.h"
|
||||||
|
|
||||||
CAN_FRAME can_0_msg;
|
CAN_FRAME can_0_msg;
|
||||||
// can_1_msg.id = 0x110;
|
// can_1_msg.id = 0x110;
|
||||||
int can_0_temp_data = 0;
|
int can_0_temp_data = 0;
|
||||||
int leds[] = {led1,led2,led3,led4,led5,led6,led7,led8,led9,led10,led11,led12,led13,led14,led15,led16};
|
|
||||||
|
|
||||||
|
int leds[] = {led1, led2, led3, led4, led5, led6, led7, led8,
|
||||||
|
led9, led10, led11, led12, led13, led14, led15, led16};
|
||||||
|
|
||||||
void Init_Can_0() {
|
void Init_Can_0() {
|
||||||
|
|
||||||
Can0.begin(1000000); // set CAN0 baud to 1kbit/s and don`t use enable pin!
|
Can0.begin(1000000); // set CAN0 baud to 1kbit/s and don`t use enable pin!
|
||||||
Can0.setNumTXBoxes(1); // reserves mailbox 0 for tx only 8 mailboxes are available (the other 7 mailboxes are for rx)
|
Can0.setNumTXBoxes(1); // reserves mailbox 0 for tx only 8 mailboxes are
|
||||||
Can0.watchFor(0x502); // set CAN RX filter for ID 0x502 and reserves mailbox 1 for rx
|
// available (the other 7 mailboxes are for rx)
|
||||||
Can0.watchFor(0x504);
|
|
||||||
Can0.watchFor(0x500);
|
// We only have 7 mailboxes, but want to receive 9 messages. This trick should
|
||||||
Can0.watchFor(0x773); // set CAN RX filter for ID 0x773 and reserves mailbox 3 for rx
|
// allow us to receive BCU_APS_BRAKE, BCU_ETC and BCU_SHIFT_CTRL in the same
|
||||||
Can0.watchFor(0x775);
|
// mailbox. It will also let through 0x506, but that shouldn't be much of an
|
||||||
// Can0.watchFor(0x777); // set CAN RX filter for ID 0x777 and reserves mailbox 5 for rx
|
// issue.
|
||||||
Can0.watchFor(0x779); // set CAN RX filter for ID 0x779 and reserves mailbox 6 for rx
|
/*
|
||||||
Can0.watchFor(0x77A);
|
Can0.watchFor(CAN_ID_BCU_APS_BRAKE & CAN_ID_BCU_ETC & CAN_ID_BCU_SHIFT_CTRL,
|
||||||
|
0x7F9);
|
||||||
|
Can0.watchFor(CAN_ID_BCU_TIRES);
|
||||||
|
Can0.watchFor(CAN_ID_BCU_LAP_TIME);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_IGN_REV_ATH);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_SPEED);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_ETC);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_STATES_TEMP_PRESS);
|
||||||
|
|
||||||
Can0.setGeneralCallback(Receive_Can_0);
|
Can0.setGeneralCallback(Receive_Can_0);
|
||||||
|
*/
|
||||||
|
|
||||||
Timer3.attachInterrupt(Send_0x110); // set send interrupt
|
Timer3.attachInterrupt(Send_0x110); // set send interrupt
|
||||||
Timer3.start(10000); // Calls every 10ms
|
Timer3.start(10000); // Calls every 10ms
|
||||||
}
|
}
|
||||||
@ -60,9 +72,15 @@ void Send_0x110(){
|
|||||||
|
|
||||||
void Receive_Can_0(CAN_FRAME *temp_message) {
|
void Receive_Can_0(CAN_FRAME *temp_message) {
|
||||||
switch (temp_message->id) {
|
switch (temp_message->id) {
|
||||||
//g_auto
|
case CAN_ID_BCU_APS_BRAKE: {
|
||||||
case 0x502:{ // eDrossel error bit
|
Vehicle_data.p_brake_front = temp_message->data.byte[1];
|
||||||
Vehicle_data.e_thro = (temp_message->data.byte[0] & 0x80) | (temp_message->data.byte[0] & 0x40) | (temp_message->data.byte[0] & 0x20) | (temp_message->data.byte[0] & 0x10); // bit 4-7
|
Vehicle_data.p_brake_rear = temp_message->data.byte[2];
|
||||||
|
Vehicle_data.drs_active = ((temp_message->data.byte[0] >> 7) & 0b00000001);
|
||||||
|
Vehicle_data.autoshift = ((temp_message->data.byte[7] >> 0) & 0b00000001);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CAN_ID_BCU_ETC: { // eDrossel error bit
|
||||||
|
Vehicle_data.e_thro = (temp_message->data.byte[0] & 0xF0); // bit 4-7
|
||||||
|
|
||||||
if (temp_message->data.byte[0] & 0x80) {
|
if (temp_message->data.byte[0] & 0x80) {
|
||||||
Stw_data.error_type = 1; //"pc_error";
|
Stw_data.error_type = 1; //"pc_error";
|
||||||
@ -76,89 +94,57 @@ void Receive_Can_0(CAN_FRAME *temp_message){
|
|||||||
if (temp_message->data.byte[0] & 0x10) {
|
if (temp_message->data.byte[0] & 0x10) {
|
||||||
Stw_data.error_type = 4; //"etb_error";
|
Stw_data.error_type = 4; //"etb_error";
|
||||||
}
|
}
|
||||||
//can_1_temp_data |= g_etb_e << 4;
|
|
||||||
//can_1_temp_data |= g_aps_e << 5;
|
|
||||||
//can_1_temp_data |= g_bse_e << 6;
|
|
||||||
//can_1_temp_data |= g_pc_e << 7;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x504:{ //autoshift+gear
|
case CAN_ID_BCU_SHIFT_CTRL: { // autoshift+gear
|
||||||
//Vehicle_data.g_auto = (temp_message->data.byte[1]) >> 4;
|
|
||||||
Vehicle_data.gear = (temp_message->data.byte[1]) >> 5;
|
Vehicle_data.gear = (temp_message->data.byte[1]) >> 5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x773:{ // rpm
|
case CAN_ID_BCU_TIRES: { // Tire temps
|
||||||
Vehicle_data.revol = (temp_message->data.byte[4] | temp_message->data.byte[3] << 8);
|
Vehicle_data.t_trl = temp_message->data.byte[1];
|
||||||
|
Vehicle_data.t_trr = temp_message->data.byte[4];
|
||||||
|
Vehicle_data.t_tfl = temp_message->data.byte[5];
|
||||||
|
Vehicle_data.t_tfr = temp_message->data.byte[6];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x779:{ // battery voltage
|
case CAN_ID_BCU_LAP_TIME: { // lap time
|
||||||
Vehicle_data.u_batt = temp_message->data.byte[6];
|
Vehicle_data.lap_time_sec = temp_message->data.byte[1];
|
||||||
|
Vehicle_data.lap_time_msec =
|
||||||
|
temp_message->data.byte[2] | ((temp_message->data.byte[3] & 0b11) << 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*case 0x77A: // revolution limit bit
|
case CAN_ID_MS4_IGN_REV_ATH: { // rpm
|
||||||
Vehicle_data.rev_lim = (temp_message->data.byte[3] & 0x20) >> 4;
|
Vehicle_data.revol =
|
||||||
switch(temp_message->data.byte[0]) {
|
(temp_message->data.byte[4] | temp_message->data.byte[3] << 8);
|
||||||
case 0x02: // temp. intercooler
|
|
||||||
Vehicle_data.t_air = temp_message->data.byte[7];
|
|
||||||
break;
|
|
||||||
case 0x05: // temp. water
|
|
||||||
Vehicle_data.t_mot = temp_message->data.byte[4];
|
|
||||||
break;
|
|
||||||
case 0x04: // temp. oil
|
|
||||||
Vehicle_data.t_oil = temp_message->data.byte[5];
|
|
||||||
case 0x01: {
|
|
||||||
Vehicle_data.p_wat = temp_message->data.byte[6];
|
|
||||||
Vehicle_data.p_fuel = temp_message->data.byte[7];
|
|
||||||
Vehicle_data.p_oil = temp_message->data.byte[5];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
case CAN_ID_MS4_SPEED: { // speed
|
||||||
break;*/
|
|
||||||
case 0x77A:{//temp und p
|
|
||||||
//g_ms4_idle_b = (temp_message->data.byte[2] & 0b10000000) >> 7;
|
|
||||||
//g_ms4_engine_status = (temp_message->data.byte[3] & 0b01000000) >> 6;
|
|
||||||
//g_ms4_ignoff_b = (temp_message->data.byte[3] & 0b10000000) >> 7;
|
|
||||||
// Serial.println("CAN 77A");
|
|
||||||
// for (int i = 0; i < 8; i++) {
|
|
||||||
// Serial.print('[');
|
|
||||||
// Serial.print(i);
|
|
||||||
// Serial.print("] ");
|
|
||||||
// Serial.println(temp_message->data.byte[i], HEX);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ( temp_message->data.byte[0] == 1){
|
|
||||||
Vehicle_data.p_oil = temp_message->data.byte[5];
|
|
||||||
Vehicle_data.p_fuel = temp_message->data.byte[7];
|
|
||||||
}
|
|
||||||
else if ( temp_message->data.byte[0] == 2){
|
|
||||||
Vehicle_data.t_air = temp_message->data.byte[7];
|
|
||||||
}
|
|
||||||
else if ( temp_message->data.byte[0] == 4){
|
|
||||||
Vehicle_data.t_oil = temp_message->data.byte[5];
|
|
||||||
}
|
|
||||||
else if ( temp_message->data.byte[0] == 5){
|
|
||||||
Vehicle_data.t_mot = temp_message->data.byte[4];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 0x775:{//speed
|
|
||||||
Vehicle_data.speed_fl = 2 * (temp_message->data.byte[2]);
|
Vehicle_data.speed_fl = 2 * (temp_message->data.byte[2]);
|
||||||
Vehicle_data.speed_fr = 2 * (temp_message->data.byte[3]);
|
Vehicle_data.speed_fr = 2 * (temp_message->data.byte[3]);
|
||||||
Vehicle_data.speed = (Vehicle_data.speed_fl + Vehicle_data.speed_fr) / 2;
|
Vehicle_data.speed = (Vehicle_data.speed_fl + Vehicle_data.speed_fr) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*case 0x777:{//m4_gear
|
case CAN_ID_MS4_ETC: { // battery voltage
|
||||||
Vehicle_data.gear = temp_message->data.byte[0];
|
Vehicle_data.u_batt = temp_message->data.byte[6];
|
||||||
break;
|
break;
|
||||||
}*/
|
}
|
||||||
case 0x500:{
|
case CAN_ID_MS4_STATES_TEMP_PRESS: { // temp und p
|
||||||
Vehicle_data.p_brake_front = temp_message->data.byte[1];
|
if (temp_message->data.byte[0] == 1) {
|
||||||
Vehicle_data.p_brake_rear = temp_message->data.byte[2];
|
Vehicle_data.p_oil = temp_message->data.byte[5];
|
||||||
|
Vehicle_data.p_fuel = temp_message->data.byte[7];
|
||||||
|
} else if (temp_message->data.byte[0] == 2) {
|
||||||
|
Vehicle_data.t_air = temp_message->data.byte[7];
|
||||||
|
} else if (temp_message->data.byte[0] == 4) {
|
||||||
|
Vehicle_data.t_oil = temp_message->data.byte[5];
|
||||||
|
} else if (temp_message->data.byte[0] == 5) {
|
||||||
|
Vehicle_data.t_mot = temp_message->data.byte[4];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void update_LED() {
|
void update_LED() {
|
||||||
// Copyright Michael Dietzel
|
// Copyright Michael Dietzel
|
||||||
// m.dietzel@fasttube.de
|
// m.dietzel@fasttube.de
|
||||||
@ -171,20 +157,56 @@ void update_LED(){
|
|||||||
// alle Werte als Hex-Werte angegeben
|
// alle Werte als Hex-Werte angegeben
|
||||||
bool t_oil = (Vehicle_data.t_oil - 40) >= 0x96; // 150°C temp.oil
|
bool t_oil = (Vehicle_data.t_oil - 40) >= 0x96; // 150°C temp.oil
|
||||||
bool t_air = (Vehicle_data.t_air - 40) >= 0x3C; // 60°C temp.llk
|
bool t_air = (Vehicle_data.t_air - 40) >= 0x3C; // 60°C temp.llk
|
||||||
bool t_mot = ((Vehicle_data.t_mot - 40) >= 0x69) and ((Vehicle_data.t_mot - 40)!=0xC8); // 105°C temp.water und !=200
|
bool t_mot =
|
||||||
|
((Vehicle_data.t_mot - 40) >= 0x69) and
|
||||||
|
((Vehicle_data.t_mot - 40) != 0xC8); // 105°C temp.water und !=200
|
||||||
|
|
||||||
bool g_auto = Vehicle_data.g_auto;
|
bool g_auto = Vehicle_data.drs_active;
|
||||||
bool u_batt = Vehicle_data.u_batt <= 0xB1; // 12.5V batt.spann.
|
bool u_batt = Vehicle_data.u_batt <= 0xA9; // 11.95V batt.spann.
|
||||||
bool e_dros = Vehicle_data.e_thro; // error-bit
|
bool e_dros = Vehicle_data.e_thro; // error-bit
|
||||||
|
|
||||||
bool rev_lim = Vehicle_data.rev_lim;
|
bool rev_lim = Vehicle_data.rev_lim;
|
||||||
|
|
||||||
uint16_t rev = Vehicle_data.revol;
|
uint16_t rev = Vehicle_data.revol;
|
||||||
|
//uint16_t clearcounter = 1;
|
||||||
|
|
||||||
|
|
||||||
|
// if (clearcounter>= 5000){
|
||||||
|
//Can0.begin(1000000); // set CAN0 baud to 1kbit/s and don`t use enable pin!
|
||||||
|
//Can0.setNumTXBoxes(1); // reserves mailbox 0 for tx only 8 mailboxes are
|
||||||
|
// available (the other 7 mailboxes are for rx)
|
||||||
|
|
||||||
|
// We only have 7 mailboxes, but want to receive 9 messages. This trick should
|
||||||
|
// allow us to receive BCU_APS_BRAKE, BCU_ETC and BCU_SHIFT_CTRL in the same
|
||||||
|
// mailbox. It will also let through 0x506, but that shouldn't be much of an
|
||||||
|
// issue.
|
||||||
|
/* 10.09.2024 - auskommentiert, weil wieso hier nochmal watchfor? */
|
||||||
|
Can0.watchFor(CAN_ID_BCU_APS_BRAKE & CAN_ID_BCU_ETC & CAN_ID_BCU_SHIFT_CTRL, 0x7F9);
|
||||||
|
Can0.watchFor(CAN_ID_BCU_TIRES);
|
||||||
|
Can0.watchFor(CAN_ID_BCU_LAP_TIME);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_IGN_REV_ATH);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_SPEED);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_ETC);
|
||||||
|
Can0.watchFor(CAN_ID_MS4_STATES_TEMP_PRESS);
|
||||||
|
|
||||||
|
//Can0.setGeneralCallback(Receive_Can_0);
|
||||||
|
|
||||||
|
//Timer3.attachInterrupt(Send_0x110); // set send interrupt
|
||||||
|
// Timer3.start(10000); // Calls every 10ms
|
||||||
|
|
||||||
|
// clearcounter = 0; //clearen des display nach definierter Zeit
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// clearcounter+=1;
|
||||||
|
|
||||||
|
|
||||||
/*if(Vehicle_data.rev_lim){
|
/*if(Vehicle_data.rev_lim){
|
||||||
for (int j = 0; j < 10; j++){
|
for (int j = 0; j < 10; j++){
|
||||||
digitalWrite(leds[j], HIGH);
|
digitalWrite(leds[j], HIGH);
|
||||||
//analogWrite(leds[j], STW_data.br); //nur eine der zwei zeilen
|
//analogWrite(leds[j], STW_data.br); //nur eine der zwei
|
||||||
|
zeilen
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
for (int j = 0; j < 10; j++){
|
for (int j = 0; j < 10; j++){
|
||||||
|
|||||||
@ -2,10 +2,22 @@
|
|||||||
FT_2018_STW_CAN.h
|
FT_2018_STW_CAN.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "DueTimer.h"
|
#include "DueTimer.h"
|
||||||
#include "due_can.h"
|
#include "due_can.h"
|
||||||
|
|
||||||
|
#define CAN_ID_BCU_APS_BRAKE 0x500
|
||||||
|
#define CAN_ID_BCU_ETC 0x502
|
||||||
|
#define CAN_ID_BCU_SHIFT_CTRL 0x504
|
||||||
|
#define CAN_ID_BCU_TIRES 0x562
|
||||||
|
#define CAN_ID_BCU_LAP_TIME 0x570
|
||||||
|
#define CAN_ID_MS4_IGN_REV_ATH 0x773
|
||||||
|
#define CAN_ID_MS4_SPEED 0x775
|
||||||
|
#define CAN_ID_MS4_ETC 0x779
|
||||||
|
#define CAN_ID_MS4_STATES_TEMP_PRESS 0x77A
|
||||||
|
|
||||||
void Init_Can_0();
|
void Init_Can_0();
|
||||||
void Send_0x110();
|
void Send_0x110();
|
||||||
void Receive_Can_0(CAN_FRAME *frame);
|
void Receive_Can_0(CAN_FRAME *frame);
|
||||||
|
|||||||
@ -2,22 +2,23 @@
|
|||||||
FT_2018_STW_CAN.cpp
|
FT_2018_STW_CAN.cpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "FT_2018e_STW_CAN.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "DueTimer.h"
|
#include "DueTimer.h"
|
||||||
#include "due_can.h"
|
|
||||||
#include "FT_2018e_STW_CAN.h"
|
|
||||||
#include "FT18e_STW_INIT.h"
|
#include "FT18e_STW_INIT.h"
|
||||||
|
#include "due_can.h"
|
||||||
|
|
||||||
CAN_FRAME can_0_msg;
|
CAN_FRAME can_0_msg;
|
||||||
// can_1_msg.id = 0x110;
|
// can_1_msg.id = 0x110;
|
||||||
int can_0_temp_data = 0;
|
int can_0_temp_data = 0;
|
||||||
int leds[] = {led1, led2, led3, led4, led5, led6, led7, led8, led9, led10, led11, led12, led13, led14, led15, led16};
|
int leds[] = {led1, led2, led3, led4, led5, led6, led7, led8,
|
||||||
|
led9, led10, led11, led12, led13, led14, led15, led16};
|
||||||
|
|
||||||
void Init_Can_0()
|
void Init_Can_0() {
|
||||||
{
|
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Can0.begin(1000000); // set CAN0 baud to 1kbit/s and don`t use enable pin!
|
Can0.begin(1000000); // set CAN0 baud to 1kbit/s and don`t use enable pin!
|
||||||
Can0.setNumTXBoxes(1); // reserves mailbox 0 for tx only 8 mailboxes are available (the other 7 mailboxes are for rx)
|
Can0.setNumTXBoxes(1); // reserves mailbox 0 for tx only 8 mailboxes are
|
||||||
|
// available (the other 7 mailboxes are for rx)
|
||||||
Can0.watchFor(CAN_CELL_STATS_ID);
|
Can0.watchFor(CAN_CELL_STATS_ID);
|
||||||
Can0.watchFor(CAN_BATTERY_STATS_ID);
|
Can0.watchFor(CAN_BATTERY_STATS_ID);
|
||||||
Can0.watchFor(CAN_COOLING_STATS_ID);
|
Can0.watchFor(CAN_COOLING_STATS_ID);
|
||||||
@ -27,8 +28,7 @@ void Init_Can_0()
|
|||||||
Timer3.start(10000); // Calls every 10ms
|
Timer3.start(10000); // Calls every 10ms
|
||||||
}
|
}
|
||||||
|
|
||||||
void Send_0x110()
|
void Send_0x110() {
|
||||||
{
|
|
||||||
read_buttons();
|
read_buttons();
|
||||||
read_rotary();
|
read_rotary();
|
||||||
can_0_msg.id = 0x110;
|
can_0_msg.id = 0x110;
|
||||||
@ -47,10 +47,8 @@ void Send_0x110()
|
|||||||
Can0.sendFrame(can_0_msg);
|
Can0.sendFrame(can_0_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receive_Can_0(CAN_FRAME *temp_message)
|
void Receive_Can_0(CAN_FRAME *temp_message) {
|
||||||
{
|
switch (temp_message->id) {
|
||||||
switch (temp_message->id)
|
|
||||||
{
|
|
||||||
case CAN_CELL_STATS_ID:
|
case CAN_CELL_STATS_ID:
|
||||||
process_cell_stats(temp_message);
|
process_cell_stats(temp_message);
|
||||||
break;
|
break;
|
||||||
@ -70,21 +68,18 @@ void Receive_Can_0(CAN_FRAME *temp_message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_cell_stats(CAN_FRAME *frame)
|
void process_cell_stats(CAN_FRAME *frame) {
|
||||||
{
|
|
||||||
CellStats *data = (CellStats *)&frame->data;
|
CellStats *data = (CellStats *)&frame->data;
|
||||||
Vehicle_data.t_cell_max = data->max_cell_temp;
|
Vehicle_data.t_cell_max = data->max_cell_temp;
|
||||||
Vehicle_data.u_cell_min = data->min_cell_voltage;
|
Vehicle_data.u_cell_min = data->min_cell_voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_battery_stats(CAN_FRAME *frame)
|
void process_battery_stats(CAN_FRAME *frame) {
|
||||||
{
|
|
||||||
BatteryStats *data = (BatteryStats *)&frame->data;
|
BatteryStats *data = (BatteryStats *)&frame->data;
|
||||||
Vehicle_data.u_batt = data->pre_air_voltage;
|
Vehicle_data.u_batt = data->pre_air_voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_cooling_stats(CAN_FRAME *frame)
|
void process_cooling_stats(CAN_FRAME *frame) {
|
||||||
{
|
|
||||||
CoolingStats *data = (CoolingStats *)&frame->data;
|
CoolingStats *data = (CoolingStats *)&frame->data;
|
||||||
Vehicle_data.p_wat = data->water_pressure;
|
Vehicle_data.p_wat = data->water_pressure;
|
||||||
Vehicle_data.t_wat = data->water_temp;
|
Vehicle_data.t_wat = data->water_temp;
|
||||||
@ -92,8 +87,7 @@ void process_cooling_stats(CAN_FRAME *frame)
|
|||||||
Vehicle_data.t_mot_r = data->motor_r_temp;
|
Vehicle_data.t_mot_r = data->motor_r_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_inverter_stats(CAN_FRAME *frame)
|
void process_inverter_stats(CAN_FRAME *frame) {
|
||||||
{
|
|
||||||
InverterStats *data = (InverterStats *)&frame->data;
|
InverterStats *data = (InverterStats *)&frame->data;
|
||||||
uint8_t status = data->status;
|
uint8_t status = data->status;
|
||||||
Vehicle_data.inverter.ready = status & CAN_INVERTER_STATS_READY;
|
Vehicle_data.inverter.ready = status & CAN_INVERTER_STATS_READY;
|
||||||
@ -109,9 +103,9 @@ void process_inverter_stats(CAN_FRAME *frame)
|
|||||||
Vehicle_data.wheel_speed = data->wheel_speed;
|
Vehicle_data.wheel_speed = data->wheel_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_LED()
|
void update_LED() {
|
||||||
{
|
bool t_mot = (Vehicle_data.t_mot_l > LED_THRESH_T_MOT) ||
|
||||||
bool t_mot = (Vehicle_data.t_mot_l > LED_THRESH_T_MOT) || (Vehicle_data.t_mot_r > LED_THRESH_T_MOT);
|
(Vehicle_data.t_mot_r > LED_THRESH_T_MOT);
|
||||||
bool t_inv = Vehicle_data.t_inv > LED_THRESH_T_INV;
|
bool t_inv = Vehicle_data.t_inv > LED_THRESH_T_INV;
|
||||||
bool t_bat = Vehicle_data.t_cell_max > LED_THRESH_T_BAT;
|
bool t_bat = Vehicle_data.t_cell_max > LED_THRESH_T_BAT;
|
||||||
|
|
||||||
|
|||||||
@ -31,32 +31,28 @@ void process_cooling_stats(CAN_FRAME *frame);
|
|||||||
void process_inverter_stats(CAN_FRAME *frame);
|
void process_inverter_stats(CAN_FRAME *frame);
|
||||||
void update_LED(void);
|
void update_LED(void);
|
||||||
|
|
||||||
struct CellStats
|
struct CellStats {
|
||||||
{
|
|
||||||
uint16_t sum_cell_voltage;
|
uint16_t sum_cell_voltage;
|
||||||
int16_t max_cell_temp;
|
int16_t max_cell_temp;
|
||||||
uint16_t max_cell_voltage;
|
uint16_t max_cell_voltage;
|
||||||
uint16_t min_cell_voltage;
|
uint16_t min_cell_voltage;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BatteryStats
|
struct BatteryStats {
|
||||||
{
|
|
||||||
uint16_t battery_current;
|
uint16_t battery_current;
|
||||||
uint16_t pre_air_voltage;
|
uint16_t pre_air_voltage;
|
||||||
uint16_t post_air_voltage;
|
uint16_t post_air_voltage;
|
||||||
uint16_t battery_power;
|
uint16_t battery_power;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CoolingStats
|
struct CoolingStats {
|
||||||
{
|
|
||||||
int16_t water_pressure;
|
int16_t water_pressure;
|
||||||
int16_t water_temp;
|
int16_t water_temp;
|
||||||
int16_t motor_l_temp;
|
int16_t motor_l_temp;
|
||||||
int16_t motor_r_temp;
|
int16_t motor_r_temp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InverterStats
|
struct InverterStats {
|
||||||
{
|
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
uint8_t _reserved;
|
uint8_t _reserved;
|
||||||
uint16_t temp;
|
uint16_t temp;
|
||||||
|
|||||||
@ -25,56 +25,40 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#define DEBUG false
|
#define DEBUG false
|
||||||
|
|
||||||
|
|
||||||
EDIPTFT::EDIPTFT(boolean smallprotocol, boolean disconnected)
|
EDIPTFT::EDIPTFT(boolean smallprotocol, boolean disconnected)
|
||||||
: _smallprotocol{smallprotocol}, disconnected{disconnected} {}
|
: _smallprotocol{smallprotocol}, disconnected{disconnected} {}
|
||||||
|
|
||||||
|
void EDIPTFT::begin(long baud) { SERIAL_DEV.begin(baud); }
|
||||||
|
|
||||||
void EDIPTFT::begin(long baud) {
|
void EDIPTFT::sendByte(char data) { SERIAL_DEV.write(data); }
|
||||||
SERIAL_DEV.begin(baud);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::sendByte(char data) {
|
|
||||||
SERIAL_DEV.write(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char EDIPTFT::readByte() {
|
|
||||||
return SERIAL_DEV.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
char EDIPTFT::readByte() { return SERIAL_DEV.read(); }
|
||||||
|
|
||||||
void EDIPTFT::waitBytesAvailable() {
|
void EDIPTFT::waitBytesAvailable() {
|
||||||
const uint32_t t_start = millis();
|
const uint32_t t_start = millis();
|
||||||
char loop = 0;
|
char loop = 0;
|
||||||
while (loop == 0)
|
while (loop == 0) {
|
||||||
{
|
|
||||||
if (bytesAvailable() != 0) {
|
if (bytesAvailable() != 0) {
|
||||||
loop = 1;
|
loop = 1;
|
||||||
}
|
}
|
||||||
if(t_start + 100 < millis())
|
if (t_start + 100 < millis()) {
|
||||||
{
|
|
||||||
// Serial.println("Error: waited to long!");
|
// Serial.println("Error: waited to long!");
|
||||||
loop = 1;
|
loop = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char EDIPTFT::waitandreadByte() {
|
char EDIPTFT::waitandreadByte() {
|
||||||
waitBytesAvailable();
|
waitBytesAvailable();
|
||||||
char result = readByte();
|
char result = readByte();
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char EDIPTFT::bytesAvailable() {
|
unsigned char EDIPTFT::bytesAvailable() {
|
||||||
return SERIAL_DEV.available();
|
return SERIAL_DEV.available();
|
||||||
//ÄNDERN
|
//ÄNDERN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::sendData(char* data, char len) {
|
void EDIPTFT::sendData(char* data, char len) {
|
||||||
|
|
||||||
/*for(int i=0; i < len; i++) {
|
/*for(int i=0; i < len; i++) {
|
||||||
@ -95,8 +79,7 @@ void EDIPTFT::sendData(char* data, char len) {
|
|||||||
|
|
||||||
if (_smallprotocol) {
|
if (_smallprotocol) {
|
||||||
sendSmall(data, len);
|
sendSmall(data, len);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
unsigned char i;
|
unsigned char i;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
sendByte(data[i]);
|
sendByte(data[i]);
|
||||||
@ -104,7 +87,6 @@ void EDIPTFT::sendData(char* data, char len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::sendSmall(char* data, char len) {
|
void EDIPTFT::sendSmall(char* data, char len) {
|
||||||
if (disconnected) {
|
if (disconnected) {
|
||||||
return;
|
return;
|
||||||
@ -130,12 +112,12 @@ void EDIPTFT::sendSmall(char* data, char len) {
|
|||||||
if (bytesAvailable() > 0) {
|
if (bytesAvailable() > 0) {
|
||||||
char x = readByte();
|
char x = readByte();
|
||||||
// Serial.print(uint16_t(x));
|
// Serial.print(uint16_t(x));
|
||||||
if (x == ACK) ok = 1;
|
if (x == ACK)
|
||||||
|
ok = 1;
|
||||||
else {
|
else {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
delay(200);
|
delay(200);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
@ -146,7 +128,6 @@ void EDIPTFT::sendSmall(char* data, char len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::sendSmallDC2(char* data, char len) {
|
void EDIPTFT::sendSmallDC2(char* data, char len) {
|
||||||
unsigned char i, bcc;
|
unsigned char i, bcc;
|
||||||
char ok = 0;
|
char ok = 0;
|
||||||
@ -163,38 +144,30 @@ void EDIPTFT::sendSmallDC2(char* data, char len) {
|
|||||||
sendByte(bcc);
|
sendByte(bcc);
|
||||||
waitBytesAvailable(); // delay(6); im 17er
|
waitBytesAvailable(); // delay(6); im 17er
|
||||||
if (bytesAvailable() > 0) {
|
if (bytesAvailable() > 0) {
|
||||||
if (readByte() == ACK) ok = 1;
|
if (readByte() == ACK)
|
||||||
else ok = 0;
|
ok = 1;
|
||||||
}
|
else
|
||||||
else {
|
ok = 0;
|
||||||
|
} else {
|
||||||
delay(200);
|
delay(200);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::smallProtoSelect(char address) {
|
void EDIPTFT::smallProtoSelect(char address) {
|
||||||
char command [] = {
|
char command[] = {0x03, 'A', 'S', address};
|
||||||
0x03, 'A', 'S', address
|
|
||||||
};
|
|
||||||
sendSmallDC2(command, sizeof(command));
|
sendSmallDC2(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::smallProtoDeselect(char address) {
|
void EDIPTFT::smallProtoDeselect(char address) {
|
||||||
char command [] = {
|
char command[] = {0x03, 'A', 'D', address};
|
||||||
0x03, 'A', 'D', address
|
|
||||||
};
|
|
||||||
sendSmallDC2(command, sizeof(command));
|
sendSmallDC2(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char EDIPTFT::datainBuffer() {
|
unsigned char EDIPTFT::datainBuffer() {
|
||||||
unsigned char result;
|
unsigned char result;
|
||||||
char command [] = {
|
char command[] = {0x01, 'I'};
|
||||||
0x01, 'I'
|
|
||||||
};
|
|
||||||
sendSmallDC2(command, sizeof(command));
|
sendSmallDC2(command, sizeof(command));
|
||||||
waitandreadByte();
|
waitandreadByte();
|
||||||
waitandreadByte();
|
waitandreadByte();
|
||||||
@ -204,12 +177,9 @@ unsigned char EDIPTFT::datainBuffer() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int EDIPTFT::readBuffer(char* data) { // return void
|
int EDIPTFT::readBuffer(char* data) { // return void
|
||||||
unsigned char len, i; // char in 17er
|
unsigned char len, i; // char in 17er
|
||||||
char command [] = {
|
char command[] = {0x01, 'S'};
|
||||||
0x01, 'S'
|
|
||||||
};
|
|
||||||
sendSmallDC2(command, sizeof(command));
|
sendSmallDC2(command, sizeof(command));
|
||||||
waitandreadByte();
|
waitandreadByte();
|
||||||
len = waitandreadByte();
|
len = waitandreadByte();
|
||||||
@ -222,101 +192,101 @@ int EDIPTFT::readBuffer(char* data) { //return void
|
|||||||
return len; // zeile nicht vorhanden
|
return len; // zeile nicht vorhanden
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::clear() { // vgl 17er
|
void EDIPTFT::clear() { // vgl 17er
|
||||||
this->deleteDisplay();
|
this->deleteDisplay();
|
||||||
this->removeTouchArea(0, 1);
|
this->removeTouchArea(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::deleteDisplay() {
|
void EDIPTFT::deleteDisplay() {
|
||||||
char command [] = {
|
char command[] = {27, 'D', 'L'};
|
||||||
27, 'D', 'L'
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::invert() {
|
void EDIPTFT::invert() {
|
||||||
char command [] = {
|
char command[] = {27, 'D', 'I'};
|
||||||
27, 'D', 'I'
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setDisplayColor(char fg, char bg) {
|
void EDIPTFT::setDisplayColor(char fg, char bg) {
|
||||||
char command [] = {
|
char command[] = {27, 'F', 'D', fg, bg};
|
||||||
27, 'F', 'D', fg, bg
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::fillDisplayColor(char bg) {
|
void EDIPTFT::fillDisplayColor(char bg) {
|
||||||
char command [] = {
|
char command[] = {27, 'D', 'F', bg};
|
||||||
27, 'D', 'F', bg
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::terminalOn(boolean on) {
|
void EDIPTFT::terminalOn(boolean on) {
|
||||||
if (on) {
|
if (on) {
|
||||||
char command[] = {27, 'T', 'E'};
|
char command[] = {27, 'T', 'E'};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
char command[] = {27, 'T', 'A'};
|
char command[] = {27, 'T', 'A'};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::loadImage(int x1, int y1, int nr) {
|
void EDIPTFT::loadImage(int x1, int y1, int nr) {
|
||||||
char command [] = {27, 'U', 'I',
|
char command[] = {
|
||||||
|
27,
|
||||||
|
'U',
|
||||||
|
'I',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
(char)x1, (char)y1,
|
(char)x1,
|
||||||
|
(char)y1,
|
||||||
#else
|
#else
|
||||||
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
|
lowByte(x1),
|
||||||
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
#endif
|
#endif
|
||||||
nr};
|
nr
|
||||||
|
};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::cursorOn(boolean on) {
|
void EDIPTFT::cursorOn(boolean on) {
|
||||||
if (on) {
|
if (on) {
|
||||||
char command[] = {27, 'T', 'C', 1};
|
char command[] = {27, 'T', 'C', 1};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
char command[] = {27, 'T', 'C', 0};
|
char command[] = {27, 'T', 'C', 0};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setCursor(char col, char row) {
|
void EDIPTFT::setCursor(char col, char row) {
|
||||||
char command[] = {27, 'T', 'P', col, row};
|
char command[] = {27, 'T', 'P', col, row};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDIPTFT::displayLight(char no) {
|
void EDIPTFT::displayLight(char no) {
|
||||||
char command [] = {
|
char command[] = {27, 'Y', 'H', no};
|
||||||
27, 'Y', 'H', no
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDIPTFT::defineBargraph(char dir, char no, int x1, int y1, int x2, int y2, byte sv, byte ev, char type, char mst) {
|
void EDIPTFT::defineBargraph(char dir, char no, int x1, int y1, int x2, int y2,
|
||||||
|
byte sv, byte ev, char type, char mst) {
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27, 'B', dir, no,
|
27,
|
||||||
|
'B',
|
||||||
|
dir,
|
||||||
|
no,
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1, x2, y2,
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2,
|
||||||
#else
|
#else
|
||||||
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
|
lowByte(x1),
|
||||||
lowByte(x2), highByte(x2), lowByte(y2), highByte(y2),
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2),
|
||||||
#endif
|
#endif
|
||||||
char(sv),
|
char(sv),
|
||||||
char(ev),
|
char(ev),
|
||||||
@ -327,113 +297,87 @@ void EDIPTFT::defineBargraph(char dir, char no, int x1, int y1, int x2, int y2,
|
|||||||
// mst fehlt 17
|
// mst fehlt 17
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::updateBargraph(char no, char val) {
|
void EDIPTFT::updateBargraph(char no, char val) {
|
||||||
char command [] = {
|
char command[] = {27, 'B', 'A', no, val};
|
||||||
27, 'B', 'A', no, val
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setBargraphColor(char no, char fg, char bg, char fr) {
|
void EDIPTFT::setBargraphColor(char no, char fg, char bg, char fr) {
|
||||||
char command [] = {
|
char command[] = {27, 'F', 'B', no, fg, bg, fr};
|
||||||
27, 'F', 'B', no, fg, bg, fr
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::linkBargraphLight(char no) {
|
void EDIPTFT::linkBargraphLight(char no) {
|
||||||
char command [] = {
|
char command[] = {27, 'Y', 'B', no};
|
||||||
27, 'Y', 'B', no
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::makeBargraphTouch(char no) {
|
void EDIPTFT::makeBargraphTouch(char no) {
|
||||||
char command [] = {
|
char command[] = {27, 'A', 'B', no};
|
||||||
27, 'A', 'B', no
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::deleteBargraph(char no, char n1) {
|
void EDIPTFT::deleteBargraph(char no, char n1) {
|
||||||
char command [] = {
|
char command[] = {27, 'B', 'D', no, n1};
|
||||||
27, 'B', 'D', no, n1
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EDIPTFT::defineInstrument(char no, int x1, int y1, char image, char angle,
|
||||||
void EDIPTFT::defineInstrument(char no, int x1, int y1, char image, char angle, char sv, char ev) {
|
char sv, char ev) {
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27, 'I', 'P', no,
|
27,
|
||||||
|
'I',
|
||||||
|
'P',
|
||||||
|
no,
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1,
|
x1,
|
||||||
|
y1,
|
||||||
#else
|
#else
|
||||||
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
|
lowByte(x1),
|
||||||
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
#endif
|
#endif
|
||||||
image, angle, sv, ev
|
image,
|
||||||
|
angle,
|
||||||
|
sv,
|
||||||
|
ev
|
||||||
};
|
};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::updateInstrument(char no, char val) {
|
void EDIPTFT::updateInstrument(char no, char val) {
|
||||||
char command [] = {
|
char command[] = {27, 'I', 'A', no, val};
|
||||||
27, 'I', 'A', no, val
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::redrawInstrument(char no) {
|
void EDIPTFT::redrawInstrument(char no) {
|
||||||
char command [] = {
|
char command[] = {27, 'I', 'N', no};
|
||||||
27, 'I', 'N', no
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::deleteInstrument(char no, char n1, char n2) {
|
void EDIPTFT::deleteInstrument(char no, char n1, char n2) {
|
||||||
char command [] = {
|
char command[] = {27, 'B', 'D', no, n1, n2};
|
||||||
27, 'B', 'D', no, n1, n2
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setLineColor(char fg, char bg) {
|
void EDIPTFT::setLineColor(char fg, char bg) {
|
||||||
char command [] = {
|
char command[] = {27, 'F', 'G', fg, bg};
|
||||||
27, 'F', 'G', fg, bg
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setLineThick(char x, char y) {
|
void EDIPTFT::setLineThick(char x, char y) {
|
||||||
char command [] = {
|
char command[] = {27, 'G', 'Z', x, y};
|
||||||
27, 'G', 'Z', x, y
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setTextColor(char fg, char bg) {
|
void EDIPTFT::setTextColor(char fg, char bg) {
|
||||||
char command [] = {
|
char command[] = {27, 'F', 'Z', fg, bg};
|
||||||
27, 'F', 'Z', fg, bg
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setTextFont(char font) {
|
void EDIPTFT::setTextFont(char font) {
|
||||||
char command [] = {
|
char command[] = {27, 'Z', 'F', font};
|
||||||
27, 'Z', 'F', font
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,14 +388,12 @@ void EDIPTFT::setTextSize(int xsize, int ysize){
|
|||||||
|
|
||||||
void EDIPTFT::setTextAngle(char angle) {
|
void EDIPTFT::setTextAngle(char angle) {
|
||||||
// 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
|
// 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
|
||||||
char command [] = {
|
char command[] = {27, 'Z', 'W', angle};
|
||||||
27, 'Z', 'W', angle
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EDIPTFT::drawText(uint16_t x1, uint16_t y1, char justification,
|
||||||
void EDIPTFT::drawText(uint16_t x1, uint16_t y1, char justification, const char* text) {
|
const char* text) {
|
||||||
// nicht const 17//
|
// nicht const 17//
|
||||||
byte len = strlen(text);
|
byte len = strlen(text);
|
||||||
byte i;
|
byte i;
|
||||||
@ -470,49 +412,125 @@ void EDIPTFT::drawText(uint16_t x1, uint16_t y1, char justification, const char*
|
|||||||
sendData(helper, sizeof(helper));
|
sendData(helper, sizeof(helper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EDIPTFT::drawTextInRect(int x1, int y1, int x2, int y2, uint8_t align,
|
||||||
|
const char* text) {
|
||||||
|
int len_text = strlen(text);
|
||||||
|
int len = 3 + 8 + 1 + len_text + 1;
|
||||||
|
char data[len] = {27, 'Z', 'B', lowByte(x1),
|
||||||
|
highByte(x1), lowByte(y1), highByte(y1), lowByte(x2),
|
||||||
|
highByte(x2), lowByte(y2), highByte(y2), align};
|
||||||
|
for (int i = 0; i < len_text; i++) {
|
||||||
|
data[3 + 8 + 1 + i] = text[i];
|
||||||
|
}
|
||||||
|
data[len - 1] = 0;
|
||||||
|
|
||||||
|
sendData(data, len);
|
||||||
|
}
|
||||||
|
|
||||||
void EDIPTFT::drawLine(int x1, int y1, int x2, int y2) {
|
void EDIPTFT::drawLine(int x1, int y1, int x2, int y2) {
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27,'G','D',
|
27,
|
||||||
|
'G',
|
||||||
|
'D',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1, x2, y2
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2
|
||||||
#else
|
#else
|
||||||
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
|
lowByte(x1),
|
||||||
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2)
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2)
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::drawRect(int x1, int y1, int x2, int y2) {
|
void EDIPTFT::drawRect(int x1, int y1, int x2, int y2) {
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27,'G','R',
|
27,
|
||||||
|
'G',
|
||||||
|
'R',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1, x2, y2
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2
|
||||||
#else
|
#else
|
||||||
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
|
lowByte(x1),
|
||||||
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2)
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2)
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::drawRectf(int x1, int y1, int x2, int y2, char color) {
|
void EDIPTFT::drawRectf(int x1, int y1, int x2, int y2, char color) {
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27,'R','F',
|
27,
|
||||||
|
'R',
|
||||||
|
'F',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1, x2, y2,
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2,
|
||||||
#else
|
#else
|
||||||
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
|
lowByte(x1),
|
||||||
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2),
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2),
|
||||||
#endif
|
#endif
|
||||||
color
|
color
|
||||||
};
|
};
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EDIPTFT::clearRect(int x1, int y1, int x2, int y2) {
|
||||||
|
Serial.print("Clearing ");
|
||||||
|
Serial.print(x1);
|
||||||
|
Serial.print(", ");
|
||||||
|
Serial.print(y1);
|
||||||
|
Serial.print(", ");
|
||||||
|
Serial.print(x2);
|
||||||
|
Serial.print(", ");
|
||||||
|
Serial.println(y2);
|
||||||
|
char command[] = {
|
||||||
|
27,
|
||||||
|
'R',
|
||||||
|
'L',
|
||||||
|
#if COORD_SIZE == 1
|
||||||
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2
|
||||||
|
#else
|
||||||
|
lowByte(x1),
|
||||||
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2),
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
sendData(command, sizeof(command));
|
||||||
|
}
|
||||||
|
|
||||||
void EDIPTFT::defineTouchKey(int x1, int y1, int x2, int y2, char down, char up,
|
void EDIPTFT::defineTouchKey(int x1, int y1, int x2, int y2, char down, char up,
|
||||||
const char* text) { // text nicht const 17
|
const char* text) { // text nicht const 17
|
||||||
@ -520,42 +538,68 @@ void EDIPTFT::defineTouchKey(int x1, int y1, int x2, int y2, char down, char up,
|
|||||||
byte i;
|
byte i;
|
||||||
char helper[len + 6 + 4 * COORD_SIZE]; // len+13 17
|
char helper[len + 6 + 4 * COORD_SIZE]; // len+13 17
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27, 'A', 'T',
|
27,
|
||||||
|
'A',
|
||||||
|
'T',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1, x2, y2,
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2,
|
||||||
#else
|
#else
|
||||||
lowByte(x1), highByte(x1), lowByte(y1), highByte(y1),
|
lowByte(x1),
|
||||||
lowByte(x2), highByte(x2), lowByte(y2), highByte(y2),
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2),
|
||||||
#endif
|
#endif
|
||||||
down, up
|
down,
|
||||||
|
up
|
||||||
};
|
};
|
||||||
for (i = 0; i < (5 + 4 * COORD_SIZE); i++) helper[i] = command[i];//i<=12 17
|
for (i = 0; i < (5 + 4 * COORD_SIZE); i++)
|
||||||
for (i = 0; i <= len+1; i++) helper[i + 5 + 4 * COORD_SIZE] = text[i];//i<=len 17
|
helper[i] = command[i]; // i<=12 17
|
||||||
|
for (i = 0; i <= len + 1; i++)
|
||||||
|
helper[i + 5 + 4 * COORD_SIZE] = text[i]; // i<=len 17
|
||||||
sendData(helper, sizeof(helper)); // size len+14 17
|
sendData(helper, sizeof(helper)); // size len+14 17
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EDIPTFT::defineTouchSwitch(int x1, int y1, int x2, int y2, char down,
|
||||||
void EDIPTFT::defineTouchSwitch(int x1, int y1, int x2, int y2,
|
char up, const char* text) { // const nicht 17
|
||||||
char down, char up, const char* text) {//const nicht 17
|
|
||||||
byte len = strlen(text);
|
byte len = strlen(text);
|
||||||
byte i;
|
byte i;
|
||||||
char helper[len + 6 + 4 * COORD_SIZE]; // len+13 17
|
char helper[len + 6 + 4 * COORD_SIZE]; // len+13 17
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27, 'A', 'K',
|
27,
|
||||||
|
'A',
|
||||||
|
'K',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1, x2, y2,
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2,
|
||||||
#else
|
#else
|
||||||
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
|
lowByte(x1),
|
||||||
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2),
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2),
|
||||||
#endif
|
#endif
|
||||||
down, up
|
down,
|
||||||
|
up
|
||||||
};
|
};
|
||||||
for (i = 0; i < 5 + 4 * COORD_SIZE; i++) helper[i] = command[i];
|
for (i = 0; i < 5 + 4 * COORD_SIZE; i++)
|
||||||
for (i = 0; i <= len; i++) helper[i + 5 + 4 * COORD_SIZE] = text[i];
|
helper[i] = command[i];
|
||||||
|
for (i = 0; i <= len; i++)
|
||||||
|
helper[i + 5 + 4 * COORD_SIZE] = text[i];
|
||||||
sendData(helper, sizeof(helper)); // size len+14
|
sendData(helper, sizeof(helper)); // size len+14
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::defineTouchSwitch(int x, int y, int img, char downcode,
|
void EDIPTFT::defineTouchSwitch(int x, int y, int img, char downcode,
|
||||||
char upcode, const char* text) {
|
char upcode, const char* text) {
|
||||||
byte len = strlen(text);
|
byte len = strlen(text);
|
||||||
@ -563,135 +607,123 @@ void EDIPTFT::defineTouchSwitch(int x, int y, int img, char downcode,
|
|||||||
byte n = 6 + 2 * COORD_SIZE;
|
byte n = 6 + 2 * COORD_SIZE;
|
||||||
char helper[len + n + 1];
|
char helper[len + n + 1];
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27, 'A', 'J',
|
27,
|
||||||
|
'A',
|
||||||
|
'J',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x, y,
|
x,
|
||||||
|
y,
|
||||||
#else
|
#else
|
||||||
lowByte(x), highByte(x), lowByte(y), highByte(y),
|
lowByte(x),
|
||||||
|
highByte(x),
|
||||||
|
lowByte(y),
|
||||||
|
highByte(y),
|
||||||
#endif
|
#endif
|
||||||
img, downcode, upcode
|
img,
|
||||||
|
downcode,
|
||||||
|
upcode
|
||||||
};
|
};
|
||||||
for (i = 0; i < n; i++) helper[i] = command[i];
|
for (i = 0; i < n; i++)
|
||||||
for (i = 0; i <= len; i++) helper[i + n] = text[i];
|
helper[i] = command[i];
|
||||||
|
for (i = 0; i <= len; i++)
|
||||||
|
helper[i + n] = text[i];
|
||||||
sendData(helper, sizeof(helper));
|
sendData(helper, sizeof(helper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setTouchSwitch(char code, char value) {
|
void EDIPTFT::setTouchSwitch(char code, char value) {
|
||||||
char command [] = {
|
char command[] = {27, 'A', 'P', code, value};
|
||||||
27, 'A', 'P', code, value
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EDIPTFT::setTouchkeyColors(char n1, char n2, char n3, char s1, char s2,
|
||||||
void EDIPTFT::setTouchkeyColors(
|
char s3) {
|
||||||
char n1, char n2, char n3, char s1, char s2, char s3) {
|
char command[] = {27, 'F', 'E', n1, n2, n3, s1, s2, s3};
|
||||||
char command [] = {
|
|
||||||
27, 'F', 'E', n1, n2, n3, s1, s2, s3
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setTouchkeyFont(char font) {
|
void EDIPTFT::setTouchkeyFont(char font) {
|
||||||
char command [] = {
|
char command[] = {27, 'A', 'F', font};
|
||||||
27, 'A', 'F', font
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setTouchkeyLabelColors(char nf, char sf) {
|
void EDIPTFT::setTouchkeyLabelColors(char nf, char sf) {
|
||||||
char command [] = {
|
char command[] = {27, 'F', 'A', nf, sf};
|
||||||
27, 'F', 'A', nf, sf
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setTouchGroup(char group) {
|
void EDIPTFT::setTouchGroup(char group) {
|
||||||
char command [] = {
|
char command[] = {27, 'A', 'R', group};
|
||||||
27, 'A', 'R', group
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::removeTouchArea(char code, char n1) {
|
void EDIPTFT::removeTouchArea(char code, char n1) {
|
||||||
char command [] = {
|
char command[] = {27, 'A', 'L', code, n1};
|
||||||
27, 'A', 'L', code, n1
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::callMacro(uint nr) {
|
void EDIPTFT::callMacro(uint nr) {
|
||||||
char command[] = {
|
char command[] = {27, 'M', 'N', nr};
|
||||||
27, 'M', 'N', nr
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::callTouchMacro(uint nr) {
|
void EDIPTFT::callTouchMacro(uint nr) {
|
||||||
char command[] = {
|
char command[] = {27, 'M', 'T', nr};
|
||||||
27, 'M', 'T', nr
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::callMenuMacro(uint nr) {
|
void EDIPTFT::callMenuMacro(uint nr) {
|
||||||
char command[] = {
|
char command[] = {27, 'M', 'M', nr};
|
||||||
27, 'M', 'M', nr
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EDIPTFT::defineTouchMenu(int x1, int y1, int x2, int y2, char downcode,
|
||||||
void EDIPTFT::defineTouchMenu(int x1, int y1, int x2, int y2,
|
char upcode, char mnucode, const char* text) {
|
||||||
char downcode, char upcode, char mnucode, const char *text) {
|
|
||||||
byte len = strlen(text);
|
byte len = strlen(text);
|
||||||
byte n = 6 + 4 * COORD_SIZE;
|
byte n = 6 + 4 * COORD_SIZE;
|
||||||
char helper[len + n + 1];
|
char helper[len + n + 1];
|
||||||
|
|
||||||
char command[] = {
|
char command[] = {
|
||||||
27, 'A', 'M',
|
27,
|
||||||
|
'A',
|
||||||
|
'M',
|
||||||
#if COORD_SIZE == 1
|
#if COORD_SIZE == 1
|
||||||
x1, y1, x2, y2,
|
x1,
|
||||||
|
y1,
|
||||||
|
x2,
|
||||||
|
y2,
|
||||||
#else
|
#else
|
||||||
lowByte(x1),highByte(x1),lowByte(y1),highByte(y1),
|
lowByte(x1),
|
||||||
lowByte(x2),highByte(x2),lowByte(y2),highByte(y2),
|
highByte(x1),
|
||||||
|
lowByte(y1),
|
||||||
|
highByte(y1),
|
||||||
|
lowByte(x2),
|
||||||
|
highByte(x2),
|
||||||
|
lowByte(y2),
|
||||||
|
highByte(y2),
|
||||||
#endif
|
#endif
|
||||||
downcode, upcode, mnucode
|
downcode,
|
||||||
|
upcode,
|
||||||
|
mnucode
|
||||||
};
|
};
|
||||||
for (int i = 0; i < n; i++) helper[i] = command[i];
|
for (int i = 0; i < n; i++)
|
||||||
for (int i = 0; i <= len; i++) helper[i + n] = text[i];
|
helper[i] = command[i];
|
||||||
|
for (int i = 0; i <= len; i++)
|
||||||
|
helper[i + n] = text[i];
|
||||||
sendData(helper, sizeof(helper));
|
sendData(helper, sizeof(helper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::openTouchMenu() {
|
void EDIPTFT::openTouchMenu() {
|
||||||
char command [] = {
|
char command[] = {27, 'N', 'T', 2};
|
||||||
27, 'N', 'T', 2
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setMenuFont(char font) {
|
void EDIPTFT::setMenuFont(char font) {
|
||||||
char command [] = {
|
char command[] = {27, 'N', 'F', font};
|
||||||
27, 'N', 'F', font
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDIPTFT::setTouchMenuAutomation(bool val) {
|
void EDIPTFT::setTouchMenuAutomation(bool val) {
|
||||||
char n1 = val ? 1 : 0;
|
char n1 = val ? 1 : 0;
|
||||||
char command [] = {
|
char command[] = {27, 'N', 'T', n1};
|
||||||
27, 'N', 'T', n1
|
|
||||||
};
|
|
||||||
sendData(command, sizeof(command));
|
sendData(command, sizeof(command));
|
||||||
}
|
}
|
||||||
@ -37,6 +37,7 @@
|
|||||||
#define COORD_SIZE DEVICE // Byte count for coordinates
|
#define COORD_SIZE DEVICE // Byte count for coordinates
|
||||||
#define SERIAL_DEV Serial3
|
#define SERIAL_DEV Serial3
|
||||||
|
|
||||||
|
#define EA_TRANSPARENT 0
|
||||||
#define EA_BLACK 1
|
#define EA_BLACK 1
|
||||||
#define EA_BLUE 2
|
#define EA_BLUE 2
|
||||||
#define EA_RED 3
|
#define EA_RED 3
|
||||||
@ -207,8 +208,8 @@ class EDIPTFT {
|
|||||||
void deleteBargraph(char no, char n1);
|
void deleteBargraph(char no, char n1);
|
||||||
|
|
||||||
// Instrument
|
// Instrument
|
||||||
void defineInstrument(char no, int x1, int y1, char image,
|
void defineInstrument(char no, int x1, int y1, char image, char angle,
|
||||||
char angle, char sv, char ev);
|
char sv, char ev);
|
||||||
void updateInstrument(char no, char val);
|
void updateInstrument(char no, char val);
|
||||||
void redrawInstrument(char no);
|
void redrawInstrument(char no);
|
||||||
void deleteInstrument(char no, char n1, char n2);
|
void deleteInstrument(char no, char n1, char n2);
|
||||||
@ -252,6 +253,22 @@ class EDIPTFT {
|
|||||||
*/
|
*/
|
||||||
void drawText(uint16_t x1, uint16_t y1, char justification, const char* text);
|
void drawText(uint16_t x1, uint16_t y1, char justification, const char* text);
|
||||||
|
|
||||||
|
/*! \brief Draw text on display in an area
|
||||||
|
*
|
||||||
|
* Draw a *text* on screen. Several lines are separated by the character `|`
|
||||||
|
* ($7C).
|
||||||
|
* * place text between `~`: characters flash on/off
|
||||||
|
* * place text between `@`: characters flash inversely
|
||||||
|
* * use `\\` as to escape special characters
|
||||||
|
*
|
||||||
|
* \param align set alignment in the rectangle. 1 = top left, 2 = top
|
||||||
|
* center, 3 = top right, 4 = center left, 5 = center, 6 = center right, 7 =
|
||||||
|
* bottom left, 8 = bottom center, 9 = bottom right.
|
||||||
|
* \param text text to draw on display
|
||||||
|
*/
|
||||||
|
void drawTextInRect(int x1, int y1, int x2, int y2, uint8_t align,
|
||||||
|
const char* text);
|
||||||
|
|
||||||
// Rectangle and Line
|
// Rectangle and Line
|
||||||
void setLineColor(char fg, char bg);
|
void setLineColor(char fg, char bg);
|
||||||
|
|
||||||
@ -276,6 +293,9 @@ class EDIPTFT {
|
|||||||
|
|
||||||
void drawRectf(int x1, int y1, int x2, int y2, char color);
|
void drawRectf(int x1, int y1, int x2, int y2, char color);
|
||||||
|
|
||||||
|
/*! \brief Clear rectangular area */
|
||||||
|
void clearRect(int x1, int y1, int x2, int y2);
|
||||||
|
|
||||||
// Touch keys
|
// Touch keys
|
||||||
|
|
||||||
/*! \brief Define touch key
|
/*! \brief Define touch key
|
||||||
@ -290,8 +310,8 @@ class EDIPTFT {
|
|||||||
* \param up return/touchmacro (1-255) if released
|
* \param up return/touchmacro (1-255) if released
|
||||||
* \param text label of the touch key
|
* \param text label of the touch key
|
||||||
*/
|
*/
|
||||||
void defineTouchKey(int x1, int y1, int x2, int y2,
|
void defineTouchKey(int x1, int y1, int x2, int y2, char down, char up,
|
||||||
char down, char up, const char* text);
|
const char* text);
|
||||||
|
|
||||||
/*! \brief Define touch switch
|
/*! \brief Define touch switch
|
||||||
*
|
*
|
||||||
@ -305,8 +325,8 @@ class EDIPTFT {
|
|||||||
* \param up return/touchmacro (1-255) if released
|
* \param up return/touchmacro (1-255) if released
|
||||||
* \param text label of the touch key
|
* \param text label of the touch key
|
||||||
*/
|
*/
|
||||||
void defineTouchSwitch(int x1, int y1, int x2, int y2,
|
void defineTouchSwitch(int x1, int y1, int x2, int y2, char down, char up,
|
||||||
char down, char up, const char* text);
|
const char* text);
|
||||||
|
|
||||||
/*! \brief Define touch switch with image
|
/*! \brief Define touch switch with image
|
||||||
*
|
*
|
||||||
@ -320,8 +340,8 @@ class EDIPTFT {
|
|||||||
* \param up return/touchmacro (1-255) if released
|
* \param up return/touchmacro (1-255) if released
|
||||||
* \param text label of the touch switch
|
* \param text label of the touch switch
|
||||||
*/
|
*/
|
||||||
void defineTouchSwitch(int x, int y, int img, char downcode,
|
void defineTouchSwitch(int x, int y, int img, char downcode, char upcode,
|
||||||
char upcode, const char* text);
|
const char* text);
|
||||||
|
|
||||||
/*! \brief Set touch switch
|
/*! \brief Set touch switch
|
||||||
*
|
*
|
||||||
@ -333,8 +353,7 @@ class EDIPTFT {
|
|||||||
*/
|
*/
|
||||||
void setTouchSwitch(char code, char value);
|
void setTouchSwitch(char code, char value);
|
||||||
|
|
||||||
void setTouchkeyColors(char n1, char n2, char n3,
|
void setTouchkeyColors(char n1, char n2, char n3, char s1, char s2, char s3);
|
||||||
char s1, char s2, char s3);
|
|
||||||
|
|
||||||
/*! \brief Label font
|
/*! \brief Label font
|
||||||
*
|
*
|
||||||
@ -387,21 +406,23 @@ class EDIPTFT {
|
|||||||
/*! \brief Define touch key with menu function
|
/*! \brief Define touch key with menu function
|
||||||
*
|
*
|
||||||
* Define the area from *x1*, *y1* to *x2*, *y2* as a menu key.
|
* Define the area from *x1*, *y1* to *x2*, *y2* as a menu key.
|
||||||
* The first character determines the direction in which the menu opens (R=right,L=left,O=up,U=down)
|
* The first character determines the direction in which the menu opens
|
||||||
* The second character determines the alignment of the touch text (C=center,L=left-,R=right justified)
|
* (R=right,L=left,O=up,U=down) The second character determines the alignment
|
||||||
* The menu items are separated by the character '|' ($7C,dec:124) (e.g. "UCkey|item1|item2|item3".
|
* of the touch text (C=center,L=left-,R=right justified) The menu items are
|
||||||
* The key text is written with the current touch font and the menu items are written with the current menu font. The background of the menu is saved automatically.
|
* separated by the character '|' ($7C,dec:124) (e.g.
|
||||||
* \param downcode `1-255` return/touchmacro if pressed
|
* "UCkey|item1|item2|item3". The key text is written with the current touch
|
||||||
* \param upcode `1-255` return/touchmacro if released
|
* font and the menu items are written with the current menu font. The
|
||||||
* \param mnucode return/menumacro+(item nr - 1) after selection of a
|
* background of the menu is saved automatically. \param downcode `1-255`
|
||||||
|
* return/touchmacro if pressed \param upcode `1-255` return/touchmacro if
|
||||||
|
* released \param mnucode return/menumacro+(item nr - 1) after selection of a
|
||||||
* menu item
|
* menu item
|
||||||
* \param text string with the key text and menu items
|
* \param text string with the key text and menu items
|
||||||
*/
|
*/
|
||||||
void defineTouchMenu(int x1, int y1, int x2, int y2,
|
void defineTouchMenu(int x1, int y1, int x2, int y2, char downcode,
|
||||||
char downcode, char upcode, char mnucode,
|
char upcode, char mnucode, const char* text);
|
||||||
const char *text);
|
|
||||||
|
|
||||||
/*! \brief Send *open* signal after a Menu open request has been sent from TFT.
|
/*! \brief Send *open* signal after a Menu open request has been sent from
|
||||||
|
* TFT.
|
||||||
*
|
*
|
||||||
* If a touch menu is not set to open automatically the TFT sends a
|
* If a touch menu is not set to open automatically the TFT sends a
|
||||||
* request 'ESC T 0'. This function sends 'ESC N T 2' to open the menu.
|
* request 'ESC T 0'. This function sends 'ESC N T 2' to open the menu.
|
||||||
|
|||||||
Reference in New Issue
Block a user