Skip to content

Commit

Permalink
volume and autoscroll part1
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasToka committed Aug 2, 2023
1 parent e5af607 commit fca55cf
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 5 deletions.
130 changes: 128 additions & 2 deletions Marlin/src/lcd/rts/e3s1pro/lcd_rts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@
#endif

#if ENABLED(E3S1PRO_RTS)

#if ENABLED(DGUS_SOFTWARE_AUTOSCROLL)
#ifndef DGUS_AUTOSCROLL_START_CYCLES
// Additional refresh cycles where strings beginnings are shown
#define DGUS_AUTOSCROLL_START_CYCLES 1
#endif
#ifndef DGUS_AUTOSCROLL_END_CYCLES
// Additional refresh cycles where strings endings are shown
#define DGUS_AUTOSCROLL_END_CYCLES 1
#endif
#endif

RTSSHOW rtscheck;
bool hasSelected = false;
short previousSelectionIndex;
Expand Down Expand Up @@ -106,7 +118,7 @@ bool power_off_type_yes = false;
int old_leveling = 0;
int bltouch_tramming = 0;
int leveling_running = 0;

unsigned long VolumeSet = 0x80;
int touchscreen_requested_mesh = 0;

const float manual_feedrate_mm_m[] = {50 * 60, 50 * 60, 4 * 60, 60};
Expand Down Expand Up @@ -198,6 +210,30 @@ bool sd_printing_autopause;
bool home_flag = false;
bool rts_start_print = false;

ssize_t currentScrollIndex = 0;
size_t pageMaxStringLen = 0;
size_t pageMaxControlLen = 0;
bool full_update = false;
bool booted = true;

#define VP_HELPER_FILENAME(ADDR, filenameIndex) \
VP_HELPER(ADDR, DGUS_FILENAME_LEN, VPFLAG_TXSTRING_AUTOSCROLL, \
VP_EXTRA_TO_STR(card.selectFileByIndexSorted(i)), \
nullptr, extraToString)

void triggerFullUpdate() {
full_update = true;
}

ssize_t getScrollIndex() {
return currentScrollIndex;
}

void addCurrentPageStringLength(size_t stringLength, size_t textControlLength) {
NOLESS(pageMaxStringLen, stringLength);
NOLESS(pageMaxControlLen, textControlLength);
}

const int manual_level_5position[9][2] = MANUALL_BED_LEVEING_5POSITION;

enum{
Expand Down Expand Up @@ -555,7 +591,21 @@ void RTSSHOW::RTS_Init(void)
SERIAL_ECHO_MSG("Value of variable at address 0x17D8: ", textFieldContent.c_str());
*/
delay(50);

VolumeSet = BL24CXX::readOneByte(FONT_EEPROM);
if(VolumeSet < 0 || VolumeSet > 0xFF)
{
VolumeSet = 0x80;
}
if(VolumeSet == 0)
{
RTS_SndData(193, VolumeIcon);
RTS_SndData(191, SoundIcon);
}
else
{
RTS_SndData((VolumeSet+1)/32 - 1 + 193, VolumeIcon);
RTS_SndData(192, SoundIcon);
}
last_zoffset = zprobe_zoffset = probe.offset.z;
touchscreen_requested_mesh = 0;
RTS_SndData(zprobe_zoffset * 100, AUTO_BED_LEVEL_ZOFFSET_VP);
Expand Down Expand Up @@ -3887,6 +3937,25 @@ void RTSSHOW::RTS_HandleData(void)
settings.save();
break;

case Volume:
if(recdat.data[0] < 0) VolumeSet = 0;
else if(recdat.data[0] > 255 ) VolumeSet = 0xFF;
else VolumeSet = recdat.data[0];

if(VolumeSet == 0)
{
RTS_SndData(193, VolumeIcon);
RTS_SndData(191, SoundIcon);
}
else
{
RTS_SndData((VolumeSet+1)/32 - 1 + 193, VolumeIcon);
RTS_SndData(192, SoundIcon);
}
RTS_SndData(VolumeSet<<8, SoundAddr+1);
BL24CXX::writeOneByte(FONT_EEPROM, VolumeSet);
break;

case SelectFileKey:
if (RTS_SD_Detected()) {
if (recdat.data[0] > CardRecbuf.Filesum) break;
Expand Down Expand Up @@ -4276,11 +4345,50 @@ void EachMomentUpdate(void)
millis_t ms = millis();
if(ms > next_rts_update_ms)
{

#if ENABLED(DGUS_SOFTWARE_AUTOSCROLL)
currentScrollIndex = -DGUS_AUTOSCROLL_START_CYCLES;
pageMaxStringLen = 0;
pageMaxControlLen = 0;
#endif
if (ELAPSED(ms, next_rts_update_ms)) {
next_rts_update_ms = ms + (booted ? RTS_UPDATE_INTERVAL: 50);

#if ENABLED(DGUS_SOFTWARE_AUTOSCROLL)
currentScrollIndex += 1;
if (currentScrollIndex > (ssize_t)(pageMaxStringLen - pageMaxControlLen) + DGUS_AUTOSCROLL_END_CYCLES)
currentScrollIndex = -DGUS_AUTOSCROLL_START_CYCLES;
#endif

//if (!sendScreenVPData(current_screen, full_update))
// DEBUG_ECHOLNPGM("SendScreenVPData failed");

return;
}
#if ENABLED(POWER_LOSS_RECOVERY)
// print the file before the power is off.
if(!power_off_type_yes && lcd_sd_status && recovery.recovery_flag)
{
rtscheck.RTS_SndData(ExchangePageBase, ExchangepageAddr);

if(startprogress == 0)
{
rtscheck.RTS_SndData(StartSoundSet, SoundAddr);

if(VolumeSet == 0)
{
rtscheck.RTS_SndData(193, VolumeIcon);
rtscheck.RTS_SndData(191, SoundIcon);
}
else
{
rtscheck.RTS_SndData((VolumeSet+1)/32 - 1 + 193, VolumeIcon);
rtscheck.RTS_SndData(192, SoundIcon);
}
rtscheck.RTS_SndData(VolumeSet, VolumeIcon-2);
rtscheck.RTS_SndData(VolumeSet<<8, SoundAddr+1);
}

if(startprogress < 100)
{
rtscheck.RTS_SndData(startprogress, START_PROCESS_ICON_VP);
Expand All @@ -4307,6 +4415,24 @@ void EachMomentUpdate(void)
else if(!power_off_type_yes && !recovery.recovery_flag)
{
rtscheck.RTS_SndData(ExchangePageBase, ExchangepageAddr);

if(startprogress == 0)
{
rtscheck.RTS_SndData(StartSoundSet, SoundAddr);

if(VolumeSet == 0)
{
rtscheck.RTS_SndData(193, VolumeIcon);
rtscheck.RTS_SndData(191, SoundIcon);
}
else
{
rtscheck.RTS_SndData((VolumeSet+1)/32 - 1 + 193, VolumeIcon);
rtscheck.RTS_SndData(192, SoundIcon);
}
rtscheck.RTS_SndData(VolumeSet, VolumeIcon-2);
rtscheck.RTS_SndData(VolumeSet<<8, SoundAddr+1);
}
if(startprogress < 100)
{
rtscheck.RTS_SndData(startprogress, START_PROCESS_ICON_VP);
Expand Down
11 changes: 8 additions & 3 deletions Marlin/src/lcd/rts/e3s1pro/lcd_rts.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ extern bool power_off_type_yes;
#define DC_SOUND_SET_DDR ((unsigned long)0x0080)
#define WRITE_CURVE_DDR_CMD ((unsigned long)0x030B)


#define VPFLAG_TXSTRING_AUTOSCROLL (1U << 2)
const uint8_t DGUS_READVAR = 0x83;
const uint16_t DGUS_VERSION = 0x000F;

Expand All @@ -69,9 +71,11 @@ const uint16_t DGUS_VERSION = 0x000F;
/*variable addr*/
#define ExchangepageAddr 0x0084
#define SoundAddr 0x00A0

#define PAGE_STATUS_TEXT_CURRENT_VP 0x10CC
#define PAGE_STATUS_TEXT_TOTAL_VP 0x10D0
#define VolumeIcon 0x194A
#define SoundIcon 0x194C
#define FONT_EEPROM 90

#define SELECT_FILE_TEXT_VP 0x219A

Expand Down Expand Up @@ -228,7 +232,6 @@ const uint16_t DGUS_VERSION = 0x000F;
#define FILE19_TEXT_VP 0x2172
#define FILE20_TEXT_VP 0x2186

#define SELECT_FILE_TEXT_VP 0x219A
#define PRINT_FILE_TEXT_VP 0x21C0
#define ABNORMAL_PAGE_TEXT_VP 0x21D4

Expand Down Expand Up @@ -696,7 +699,8 @@ typedef enum PROC_COM : int8_t {
YMinPosEepromEnterKey = 79,
XaxismoveKeyHomeOffset = 80,
YaxismoveKeyHomeOffset = 81,
E0FlowKey = 82
E0FlowKey = 82,
Volume = 83
} proc_command_t;

const unsigned long Addrbuf[] =
Expand Down Expand Up @@ -786,6 +790,7 @@ const unsigned long Addrbuf[] =
0x191A, // y_min_pos_homeoffset
0x192A, // y_min_pos_homeoffset
0x193A, // Flow Key
0x194E, // Volume Key
0
};

Expand Down

0 comments on commit fca55cf

Please sign in to comment.