steering-wheel/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.h

95 lines
2.4 KiB
C
Raw Normal View History

#include "Arduino.h"
#include "EDIPTFT.h"
#include "FT_2018_STW_CAN.h"
#include "FT18_STW_INIT.h"
#ifndef FT18_STW_DISPLAY_h
#define FT18_STW_DISPLAY_h
#define MOSI 75
#define MISO 74
#define CLK 76
#define disp_cs 42
#define reset 43
#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
enum DisplayPage {PAGE_DRIVER, PAGE_TESTING};
#define DISPLAY_PAGES 2
enum Value {
VAL_GEAR, VAL_RPM, VAL_UBATT, VAL_TMOT, VAL_TAIR, VAL_TOIL, VAL_ERR_TYPE,
VAL_PWAT, VAL_POIL, VAL_PBF, VAL_PBR, VAL_SPEED_FL, VAL_SPEED_FR, VAL_SPEED
};
#define VALUES 14
String get_value(Value val);
String get_label(Value val);
#define DISP_CLEAR_INTERVAL 5000 // ms
void init_display(void);
void update_display(void);
void display_trc(void);
void display_mode(void);
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_page_driver();
void update_page_driver();
void redraw_page_testing();
void update_page_testing();
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);
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;
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 50
#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