0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-01-19 08:08:25 +00:00

🧑‍💻 IA RTS refactor

This commit is contained in:
Scott Lahteine 2023-05-02 18:26:06 -05:00
parent 18e63ad880
commit 5201869a55
4 changed files with 2195 additions and 2203 deletions

View file

@ -95,23 +95,23 @@ void FileNavigator::getFiles(uint16_t index) {
// Clear currently drawn screen
for (int i = 0; i < DISPLAY_FILES; i++) {
for (int j = 0; j < 20; j++)
rtscheck.RTS_SndData(0, SDFILE_ADDR + (i * 20) + j);
rts.sendData(0, SDFILE_ADDR + (i * 20) + j);
}
for (int j = 0; j < 10; j++) {
rtscheck.RTS_SndData(0, Printfilename + j); // clear screen.
rtscheck.RTS_SndData(0, Choosefilename + j); // clear filename
rts.sendData(0, Printfilename + j); // clear screen.
rts.sendData(0, Choosefilename + j); // clear filename
}
for (int j = 0; j < 8; j++)
rtscheck.RTS_SndData(0, FilenameCount + j);
rts.sendData(0, FilenameCount + j);
for (int j = 1; j <= DISPLAY_FILES; j++) {
rtscheck.RTS_SndData(10, FilenameIcon + j);
rtscheck.RTS_SndData(10, FilenameIcon1 + j);
rts.sendData(10, FilenameIcon + j);
rts.sendData(10, FilenameIcon1 + j);
}
if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder
files--;
rtscheck.RTS_SndData("Up Directory", SDFILE_ADDR);
rts.sendData("Up Directory", SDFILE_ADDR);
fcnt++;
}
else if (currentindex == DISPLAY_FILES && folderdepth > 0)
@ -123,18 +123,18 @@ void FileNavigator::getFiles(uint16_t index) {
if (filelen > 20) {
char *buf = (char *)filelist.filename();
buf[18] = '\0'; // cutoff at screen edge
rtscheck.RTS_SndData(buf, (SDFILE_ADDR + (fcnt * 20)));
rts.sendData(buf, (SDFILE_ADDR + (fcnt * 20)));
}
else
rtscheck.RTS_SndData(filelist.filename(), (SDFILE_ADDR + (fcnt * 20)));
rts.sendData(filelist.filename(), (SDFILE_ADDR + (fcnt * 20)));
if (filelist.isDir()) {
rtscheck.RTS_SndData((uint8_t)4, FilenameIcon + (fcnt+1));
rtscheck.RTS_SndData((unsigned long)0x041F, (FilenameNature + ((1+fcnt) * 16))); // Change BG of selected line to Blue
rts.sendData((uint8_t)4, FilenameIcon + (fcnt+1));
rts.sendData((unsigned long)0x041F, (FilenameNature + ((1+fcnt) * 16))); // Change BG of selected line to Blue
}
else {
rtscheck.RTS_SndData((uint8_t)0, FilenameIcon + (fcnt+1));
rtscheck.RTS_SndData((unsigned long)0xFFFF, (FilenameNature + ((1+fcnt) * 16))); // white
rts.sendData((uint8_t)0, FilenameIcon + (fcnt+1));
rts.sendData((unsigned long)0xFFFF, (FilenameNature + ((1+fcnt) * 16))); // white
}
SERIAL_ECHOLNPGM("-", seek, " '", filelist.filename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n");
fcnt++;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,7 @@
#define FileNum MaxFileNumber
#define FileNameLen TEXTBYTELEN
#define SizeofDatabuf 46
#define DATA_BUF_SIZE 46
//#define FONT_EEPROM 90
//#define AutoLeve_EEPROM 100
@ -177,122 +177,114 @@
#define StatusMessageString 0x2064
// TODO: Use LCD_SERIAL 1 or 3 (?) by configuration, not overriding here
#ifdef TARGET_STM32F4
#define DWIN_SERIAL Serial1
#else
#define DWIN_SERIAL LCD_SERIAL
#endif
namespace ExtUI {
/************struct**************/
/************struct**************/
typedef enum : uint8_t {
DGUS_IDLE, //< waiting for DGUS_HEADER1.
DGUS_HEADER1_SEEN, //< DGUS_HEADER1 received
DGUS_HEADER2_SEEN, //< DGUS_HEADER2 received
DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes.
} rx_datagram_state_t;
typedef enum : uint8_t {
DGUS_IDLE, //< waiting for DGUS_HEADER1.
DGUS_HEADER1_SEEN, //< DGUS_HEADER1 received
DGUS_HEADER2_SEEN, //< DGUS_HEADER2 received
DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes.
} rx_datagram_state_t;
typedef struct DataBuf {
uint8_t len;
uint8_t head[2];
uint8_t command;
uint32_t addr;
uint32_t bytelen;
uint16_t data[32];
uint8_t reserv[4];
} DB;
typedef struct DataBuf {
uint8_t len;
uint8_t head[2];
uint8_t command;
uint32_t addr;
uint32_t bytelen;
uint16_t data[32];
uint8_t reserv[4];
} DB;
struct creality_dwin_settings_t {
size_t settings_size;
uint8_t settings_version;
struct creality_dwin_settings_t {
size_t settings_size;
uint8_t settings_version;
bool display_standby;
bool display_sound;
int8_t screen_rotation;
int16_t display_volume;
uint8_t standby_screen_brightness;
uint8_t screen_brightness;
int16_t standby_time_seconds;
};
bool display_standby;
bool display_sound;
int8_t screen_rotation;
int16_t display_volume;
uint8_t standby_screen_brightness;
uint8_t screen_brightness;
int16_t standby_time_seconds;
};
class RTS {
public:
RTS();
static void onStartup();
static void onIdle();
static int16_t receiveData();
static void sendData();
static void sendData(const String&, const uint32_t, const uint8_t=VarAddr_W);
static void sendData(const char[], const uint32_t, const uint8_t=VarAddr_W);
static void sendData(char, const uint32_t, const uint8_t=VarAddr_W);
static void sendData(int, const uint32_t, const uint8_t=VarAddr_W);
static void sendData(unsigned long, const uint32_t, const uint8_t=VarAddr_W);
static void sendData(const_float_t, const uint32_t, const uint8_t=VarAddr_W);
void SetTouchScreenConfiguration();
static void sendData(uint8_t * const str, const uint32_t addr, const uint8_t cmd=VarAddr_W) { sendData((char *)str, addr, cmd); }
static void sendData(const unsigned int n, uint32_t addr, const uint8_t cmd=VarAddr_W) { sendData(int(n), addr, cmd); }
static void sendData(const long n, const uint32_t addr, const uint8_t cmd=VarAddr_W) { sendData((unsigned long)n, addr, cmd); }
class RTSSHOW {
public:
RTSSHOW();
int16_t RTS_RecData();
void RTS_SDCardInit();
void RTS_SDCardUpate(bool, bool);
int16_t RTS_CheckFilament(int16_t);
void RTS_SndData();
void RTS_SndData(const String&, const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(const char[], const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(char, const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(int, const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(unsigned long, const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(const_float_t, const uint32_t, const uint8_t=VarAddr_W);
static void handleData();
void RTS_SndData(uint8_t * const str, const uint32_t addr, const uint8_t cmd=VarAddr_W) { RTS_SndData((char *)str, addr, cmd); }
void RTS_SndData(const unsigned int n, uint32_t addr, const uint8_t cmd=VarAddr_W) { RTS_SndData(int(n), addr, cmd); }
void RTS_SndData(const long n, const uint32_t addr, const uint8_t cmd=VarAddr_W) { RTS_SndData((unsigned long)n, addr, cmd); }
static void writeVariable(const uint16_t adr, const void * const values, uint8_t valueslen, const bool isstr=false, const char fillChar=' ');
static void setTouchScreenConfiguration();
void RTS_SDcard_Stop();
void RTS_HandleData();
void RTS_Init();
static DB recdat, snddat;
static uint8_t databuf[DATA_BUF_SIZE];
DB recdat;
DB snddat;
uint8_t databuf[SizeofDatabuf];
static rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len;
};
static rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len;
static bool Initialized;
};
extern RTS rts;
static RTSSHOW rtscheck;
#define Addvalue 3
#define PrintChoice_Value (0 + Addvalue)
#define Zoffset_Value (3 + Addvalue)
#define Setting_Value (8 + Addvalue)
#define XYZEaxis_Value (12 + Addvalue)
#define Filament_Value (15 + Addvalue)
#define Language_Value (18 + Addvalue)
#define Filename_Value (22 + Addvalue)
#define Addvalue 3
#define PrintChoice_Value (0 + Addvalue)
#define Zoffset_Value (3 + Addvalue)
#define Setting_Value (8 + Addvalue)
#define XYZEaxis_Value (12 + Addvalue)
#define Filament_Value (15 + Addvalue)
#define Language_Value (18 + Addvalue)
#define Filename_Value (22 + Addvalue)
enum PROC_COM {
Printfile = 0,
Adjust,
Feedrate,
PrintChoice = PrintChoice_Value,
Zoffset = Zoffset_Value,
TempControl,
ManualSetTemp,
Setting = Setting_Value,
ReturnBack,
Bedlevel,
Autohome,
XYZEaxis = XYZEaxis_Value,
Filament = Filament_Value,
LanguageChoice = Language_Value,
No_Filament,
PwrOffNoF,
Volume,
Filename = Filename_Value
};
enum PROC_COM {
Printfile = 0,
Adjust,
Feedrate,
PrintChoice = PrintChoice_Value,
Zoffset = Zoffset_Value,
TempControl,
ManualSetTemp,
Setting = Setting_Value,
ReturnBack,
Bedlevel,
Autohome,
XYZEaxis = XYZEaxis_Value,
Filament = Filament_Value,
LanguageChoice = Language_Value,
No_Filament,
PwrOffNoF,
Volume,
Filename = Filename_Value
};
const uint16_t Addrbuf[] = {
0x1002, 0x1004, 0x1006, 0x1008, 0x100A, 0x100C, 0x1026, 0x1030, 0x1032, 0x1034, 0x103A,
0x103E, 0x1040, 0x1044, 0x1046, 0x1048, 0x104A, 0x104C, 0x1054, 0x1056, 0x1058,
0x105C, 0x105E, 0x105F, 0x1088, 0
};
const uint16_t Addrbuf[] = {
0x1002, 0x1004, 0x1006, 0x1008, 0x100A, 0x100C, 0x1026, 0x1030, 0x1032, 0x1034, 0x103A,
0x103E, 0x1040, 0x1044, 0x1046, 0x1048, 0x104A, 0x104C, 0x1054, 0x1056, 0x1058,
0x105C, 0x105E, 0x105F, 0x1088, 0
};
void RTSUpdate();
void RTSInit();
} // ExtUI
void RTS_Update();
#ifndef MAIN_MENU_ITEM_1_GCODE
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)