Commit 248d84a4 authored by MagoKimbra's avatar MagoKimbra

Update Nextion

parent 44830a3f
/**
* @file NexVar.cpp
*
* The implementation of class NexVar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexVar.h"
NexVar::NexVar(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
uint16_t NexVar::getText(char *buffer, uint16_t len)
{
String cmd;
cmd += "get ";
cmd += getObjName();
cmd += ".txt";
sendCommand(cmd.c_str());
return recvRetString(buffer,len);
}
bool NexVar::setText(const char *buffer)
{
String cmd;
cmd += getObjName();
cmd += ".txt=\"";
cmd += buffer;
cmd += "\"";
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
bool NexVar::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexVar::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* @file NexVar.h
*
* The definition of class NexVar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXVAL_H__
#define __NEXVAL_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexVar component.
*/
class NexVar: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexVar(uint8_t pid, uint8_t cid, const char *name);
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t getText(char *buffer, uint16_t len);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
*/
bool setText(const char *buffer);
/**
* Get the value of slider.
*
* @param number - an output parameter to save the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool getValue(uint32_t *number);
/**
* Set the value of slider.
*
* @param number - the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool setValue(uint32_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXTEXT_H__ */
......@@ -33,6 +33,7 @@
#include "NexText.h"
#include "NexWaveform.h"
#include "NexTimer.h"
#include "NexVar.h"
#endif /* #ifndef __NEXTION_H__ */
......@@ -984,10 +984,10 @@
#define DOGLCD_A0 27
#define LCD_PIN_BL 33
#else
//arduino pin which triggers an piezzo beeper
// arduino pin which triggers an piezzo beeper
#define BEEPER_PIN 33 // Beeper on AUX-4
//buttons are directly attached using AUX-2
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64 // encoder
#define BTN_EN2 59 // encoder
......@@ -1030,8 +1030,8 @@
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //NEWPANEL
#endif //ULTRA_LCD
#endif // NEWPANEL
#endif // ULTRA_LCD
// SPI for Max6675 Thermocouple
#if DISABLED(SDSUPPORT)
......@@ -1064,14 +1064,14 @@
#define LARGE_FLASH true
//X axis pins
// X axis pins
#define ORIG_X_STEP_PIN 54
#define ORIG_X_DIR_PIN 55
#define ORIG_X_ENABLE_PIN 38
#define ORIG_X_MIN_PIN 3
#define ORIG_X_MAX_PIN 2
//Y axis pins
// Y axis pins
#define ORIG_Y_STEP_PIN 60
#define ORIG_Y_DIR_PIN 61
#define ORIG_Y_ENABLE_PIN 56
......@@ -1082,7 +1082,7 @@
#define Y2_DIR_PIN 34
#define Y2_ENABLE_PIN 30
//Z axis pins
// Z axis pins
#define ORIG_Z_STEP_PIN 46
#define ORIG_Z_DIR_PIN 48
#define ORIG_Z_ENABLE_PIN 62
......@@ -1093,7 +1093,7 @@
#define Z2_DIR_PIN 34
#define Z2_ENABLE_PIN 30
//E axis pins
// E axis pins
#define ORIG_E0_STEP_PIN 26
#define ORIG_E0_DIR_PIN 28
#define ORIG_E0_ENABLE_PIN 24
......@@ -1152,7 +1152,7 @@
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif // PANEL_ONE
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#define BEEPER_PIN 37
......@@ -1186,10 +1186,10 @@
#define DOGLCD_A0 27
#define LCD_PIN_BL 33
#else
//arduino pin which triggers an piezzo beeper
// arduino pin which triggers an piezzo beeper
#define BEEPER_PIN 33 // Beeper on AUX-4
//buttons are directly attached using AUX-2
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64 // encoder
#define BTN_EN2 59 // encoder
......@@ -1206,7 +1206,7 @@
#define BTN_EN2 35
#define BTN_ENC 31 // the click
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#else
......@@ -1214,7 +1214,7 @@
#endif
#endif
#else // old style panel with shift register
// arduino pin witch triggers an piezo beeper
#define BEEPER_PIN 33 // No Beeper added
......@@ -1225,15 +1225,15 @@
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //NEWPANEL
#endif //ULTRA_LCD
#endif // NEWPANEL
#endif // ULTRA_LCD
// SPI for Max6675 Thermocouple
#if DISABLED(SDSUPPORT)
......@@ -1266,14 +1266,14 @@
#define LARGE_FLASH true
//X axis pins
// X axis pins
#define ORIG_X_STEP_PIN 54
#define ORIG_X_DIR_PIN 55
#define ORIG_X_ENABLE_PIN 38
#define ORIG_X_MIN_PIN 3
#define ORIG_X_MAX_PIN 2
//Y axis pins
// Y axis pins
#define ORIG_Y_STEP_PIN 60
#define ORIG_Y_DIR_PIN 61
#define ORIG_Y_ENABLE_PIN 56
......@@ -1284,7 +1284,7 @@
#define Y2_DIR_PIN 34
#define Y2_ENABLE_PIN 30
//Z axis pins
// Z axis pins
#define ORIG_Z_STEP_PIN 46
#define ORIG_Z_DIR_PIN 48
#define ORIG_Z_ENABLE_PIN 62
......@@ -1295,7 +1295,7 @@
#define Z2_DIR_PIN 34
#define Z2_ENABLE_PIN 30
//E axis pins
// E axis pins
#define ORIG_E0_STEP_PIN 26
#define ORIG_E0_DIR_PIN 28
#define ORIG_E0_ENABLE_PIN 24
......@@ -1388,10 +1388,10 @@
#define DOGLCD_A0 27
#define LCD_PIN_BL 33
#else
//arduino pin which triggers an piezzo beeper
// arduino pin which triggers an piezzo beeper
#define BEEPER_PIN 33 // Beeper on AUX-4
//buttons are directly attached using AUX-2
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64 // encoder
#define BTN_EN2 59 // encoder
......@@ -1408,7 +1408,7 @@
#define BTN_EN2 35
#define BTN_ENC 31 // the click
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#else
......@@ -1416,7 +1416,7 @@
#endif
#endif
#else // old style panel with shift register
// arduino pin witch triggers an piezo beeper
#define BEEPER_PIN 33 // No Beeper added
......@@ -1427,15 +1427,15 @@
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //NEWPANEL
#endif //ULTRA_LCD
#endif // NEWPANEL
#endif // ULTRA_LCD
// SPI for Max6675 Thermocouple
#if DISABLED(SDSUPPORT)
......@@ -1468,14 +1468,14 @@
#define LARGE_FLASH true
//X axis pins
// X axis pins
#define ORIG_X_STEP_PIN 54
#define ORIG_X_DIR_PIN 55
#define ORIG_X_ENABLE_PIN 38
#define ORIG_X_MIN_PIN 3
#define ORIG_X_MAX_PIN 2
//Y axis pins
// Y axis pins
#define ORIG_Y_STEP_PIN 60
#define ORIG_Y_DIR_PIN 61
#define ORIG_Y_ENABLE_PIN 56
......@@ -1486,7 +1486,7 @@
#define Y2_DIR_PIN 34
#define Y2_ENABLE_PIN 30
//Z axis pins
// Z axis pins
#define ORIG_Z_STEP_PIN 46
#define ORIG_Z_DIR_PIN 48
#define ORIG_Z_ENABLE_PIN 62
......@@ -1497,7 +1497,7 @@
#define Z2_DIR_PIN 34
#define Z2_ENABLE_PIN 30
//E axis pins
// E axis pins
#define ORIG_E0_STEP_PIN 26
#define ORIG_E0_DIR_PIN 28
#define ORIG_E0_ENABLE_PIN 24
......@@ -1590,10 +1590,10 @@
#define DOGLCD_A0 27
#define LCD_PIN_BL 33
#else
//arduino pin which triggers an piezzo beeper
// arduino pin which triggers an piezzo beeper
#define BEEPER_PIN 33 // Beeper on AUX-4
//buttons are directly attached using AUX-2
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64 // encoder
#define BTN_EN2 59 // encoder
......@@ -1610,7 +1610,7 @@
#define BTN_EN2 35
#define BTN_ENC 31 // the click
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#else
......@@ -1618,26 +1618,26 @@
#endif
#endif
#else // old style panel with shift register
// arduino pin witch triggers an piezo beeper
#define BEEPER_PIN 33 // No Beeper added
//buttons are attached to a shift register
// buttons are attached to a shift register
// Not wired this yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //NEWPANEL
#endif //ULTRA_LCD
#endif // NEWPANEL
#endif // ULTRA_LCD
// SPI for Max6675 Thermocouple
#if DISABLED(SDSUPPORT)
......@@ -1670,14 +1670,14 @@
#define LARGE_FLASH true
//X axis pins
// X axis pins
#define ORIG_X_STEP_PIN 54
#define ORIG_X_DIR_PIN 55
#define ORIG_X_ENABLE_PIN 38
#define ORIG_X_MIN_PIN 3
#define ORIG_X_MAX_PIN 2
//Y axis pins
// Y axis pins
#define ORIG_Y_STEP_PIN 60
#define ORIG_Y_DIR_PIN 61
#define ORIG_Y_ENABLE_PIN 56
......@@ -1688,7 +1688,7 @@
#define Y2_DIR_PIN 34
#define Y2_ENABLE_PIN 30
//Z axis pins
// Z axis pins
#define ORIG_Z_STEP_PIN 46
#define ORIG_Z_DIR_PIN 48
#define ORIG_Z_ENABLE_PIN 62
......@@ -1699,7 +1699,7 @@
#define Z2_DIR_PIN 34
#define Z2_ENABLE_PIN 30
//E axis pins
// E axis pins
#define ORIG_E0_STEP_PIN 26
#define ORIG_E0_DIR_PIN 28
#define ORIG_E0_ENABLE_PIN 24
......@@ -1758,7 +1758,7 @@
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif // PANEL_ONE
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#define BEEPER_PIN 37
......@@ -1792,10 +1792,10 @@
#define DOGLCD_A0 27
#define LCD_PIN_BL 33
#else
//arduino pin which triggers an piezzo beeper
// arduino pin which triggers an piezzo beeper
#define BEEPER_PIN 33 // Beeper on AUX-4
//buttons are directly attached using AUX-2
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64 // encoder
#define BTN_EN2 59 // encoder
......@@ -1812,7 +1812,7 @@
#define BTN_EN2 35
#define BTN_ENC 31 // the click
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#else
......@@ -1820,12 +1820,12 @@
#endif
#endif
#else // old style panel with shift register
// arduino pin witch triggers an piezo beeper
#define BEEPER_PIN 33 // No Beeper added
//buttons are attached to a shift register
// buttons are attached to a shift register
// Not wired this yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
......@@ -1838,8 +1838,8 @@
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //NEWPANEL
#endif //ULTRA_LCD
#endif // NEWPANEL
#endif // ULTRA_LCD
// SPI for Max6675 Thermocouple
#if DISABLED(SDSUPPORT)
......@@ -2196,20 +2196,20 @@
#define ORIG_X_STEP_PIN 63
#define ORIG_X_DIR_PIN 62
#define ORIG_X_ENABLE_PIN 48
#define ORIG_X_MIN_PIN 22
#define ORIG_X_MAX_PIN 30
#define ORIG_X_MIN_PIN 22
#define ORIG_X_MAX_PIN 30
#define ORIG_Y_STEP_PIN 65
#define ORIG_Y_DIR_PIN 64
#define ORIG_Y_ENABLE_PIN 46
#define ORIG_Y_MIN_PIN 24
#define ORIG_Y_MAX_PIN 38
#define ORIG_Y_MIN_PIN 24
#define ORIG_Y_MAX_PIN 38
#define ORIG_Z_STEP_PIN 67
#define ORIG_Z_DIR_PIN 66
#define ORIG_Z_ENABLE_PIN 44
#define ORIG_Z_MIN_PIN 26
#define ORIG_Z_MAX_PIN 34
#define ORIG_Z_MIN_PIN 26
#define ORIG_Z_MAX_PIN 34
#define ORIG_E0_STEP_PIN 36
#define ORIG_E0_DIR_PIN 28
......@@ -2238,29 +2238,29 @@
#define KILL_PIN -1
#define ORIG_HEATER_BED_PIN 8 // BED
#define ORIG_HEATER_BED_PIN 8 // BED
#define ORIG_HEATER_0_PIN 9
#define ORIG_HEATER_1_PIN 10
#define ORIG_HEATER_2_PIN 11
#define ORIG_HEATER_0_PIN 9
#define ORIG_HEATER_1_PIN 10
#define ORIG_HEATER_2_PIN 11
#define ORIG_TEMP_BED_PIN 7 // ANALOG NUMBERING
#define ORIG_TEMP_BED_PIN 7 // ANALOG NUMBERING
#define ORIG_TEMP_0_PIN 6 // ANALOG NUMBERING
#define ORIG_TEMP_1_PIN 5 // 2 // ANALOG NUMBERING
#define ORIG_TEMP_2_PIN 4 // 3 // ANALOG NUMBERING
#define ORIG_TEMP_0_PIN 6 // ANALOG NUMBERING
#define ORIG_TEMP_1_PIN 5 // 2 // ANALOG NUMBERING
#define ORIG_TEMP_2_PIN 4 // 3 // ANALOG NUMBERING
#define ORIG_TEMP_3_PIN -1 // ANALOG NUMBERING
#define TEMP_4_PIN -1 // ANALOG NUMBERING
#define ORIG_TEMP_3_PIN -1 // ANALOG NUMBERING
#define TEMP_4_PIN -1 // ANALOG NUMBERING
#if NUM_SERVOS > 0
#define SERVO0_PIN 11
#define SERVO0_PIN 11
#if NUM_SERVOS > 1
#define SERVO1_PIN 6
#define SERVO1_PIN 6
#if NUM_SERVOS > 2
#define SERVO2_PIN 5
#define SERVO2_PIN 5
#if NUM_SERVOS > 3
#define SERVO3_PIN 4
#define SERVO3_PIN 4
#endif
#endif
#endif
......@@ -3034,20 +3034,20 @@
#define ORIG_X_STEP_PIN 54
#define ORIG_X_DIR_PIN 55
#define ORIG_X_ENABLE_PIN 38
#define ORIG_X_MIN_PIN 3
#define ORIG_X_MAX_PIN 2
#define ORIG_X_MIN_PIN 3
#define ORIG_X_MAX_PIN 2
#define ORIG_Y_STEP_PIN 60
#define ORIG_Y_DIR_PIN 61
#define ORIG_Y_ENABLE_PIN 56
#define ORIG_Y_MIN_PIN 14
#define ORIG_Y_MAX_PIN 15
#define ORIG_Y_MIN_PIN 14
#define ORIG_Y_MAX_PIN 15
#define ORIG_Z_STEP_PIN 46
#define ORIG_Z_DIR_PIN 48
#define ORIG_Z_ENABLE_PIN 62
#define ORIG_Z_MIN_PIN 18
#define ORIG_Z_MAX_PIN 19
#define ORIG_Z_MIN_PIN 18
#define ORIG_Z_MAX_PIN 19
#define Y2_STEP_PIN 36
#define Y2_DIR_PIN 34
......@@ -5229,6 +5229,7 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#endif
#if ENABLED(DISABLE_YMAX_ENDSTOP)
#undef Y_MAX_PIN
#define Y_MAX_PIN -1
#endif
......
......@@ -2392,11 +2392,11 @@ char *ftostr52(const float &x) {
#include "ultralcd.h"
#include "Nextion.h"
const float MaxWave = 0.2;
bool NextionON = false;
bool PageInfo = false;
char buffer[100] = {0};
int slidermaxval = 20;
const float MaxWave = 0.2;
bool NextionON = false;
bool PageInfo = false;
char buffer[100] = {0};
uint32_t slidermaxval = 20;
char lcd_status_message[30] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
uint8_t lcd_status_message_level = 0;
......@@ -2423,7 +2423,7 @@ NexText sdrow2 = NexText(4, 5, "t2");
NexText sdrow3 = NexText(4, 6, "t3");
NexText sdrow4 = NexText(4, 7, "t4");
NexText sdrow5 = NexText(4, 8, "t5");
NexText sdcmd = NexText(4, 15, "sdcmd");
NexText sdfolder = NexText(4, 23, "sdfolder");
// Picture
NexPicture Menu = NexPicture(1, 10, "p0");
......@@ -2439,6 +2439,8 @@ NexPicture Folder2 = NexPicture(4, 11, "p2");
NexPicture Folder3 = NexPicture(4, 12, "p3");
NexPicture Folder4 = NexPicture(4, 13, "p4");
NexPicture Folder5 = NexPicture(4, 14, "p5");
NexPicture Folderup = NexPicture(4, 15, "p6");
NexPicture Exit = NexPicture(4, 16, "p7");
// Progress Bar
......@@ -2462,6 +2464,16 @@ NexHotspot tdown = NexHotspot(2, 17, "tdown");
NexTimer startimer = NexTimer(0, 1, "tm0");
NexTimer fantimer = NexTimer(1, 23, "tm0");
// Variable
NexVar Hotend = NexVar(1, 20, "he");
NexVar Bed = NexVar(1, 21, "bed");
NexVar filename0 = NexVar(4, 19, "va0");
NexVar filename1 = NexVar(4, 20, "va1");
NexVar filename2 = NexVar(4, 21, "va2");
NexVar filename3 = NexVar(4, 22, "va3");
NexVar filename4 = NexVar(4, 23, "va4");
NexVar filename5 = NexVar(4, 24, "va5");
NexTouch *nex_listen_list[] =
{
&page0,
......@@ -2482,6 +2494,8 @@ NexTouch *nex_listen_list[] =
&sdrow3,
&sdrow4,
&sdrow5,
&Folderup,
&Exit,
NULL
};
......@@ -2491,16 +2505,16 @@ void setpageInfo() {
PageInfo = true;
#if HAS_TEMP_0
sendCommand("he.val=1");
Hotend.setValue(1);
#endif
#if HAS_TEMP_1
sendCommand("he.val=2");
Hotend.setValue(2);
#endif
#if HAS_TEMP_2
sendCommand("he.val=3");
Hotend.setValue(3);
#elif HAS_TEMP_BED
Hotend21.setText("BED");
sendCommand("bed.val=1");
Bed.setValue(1);
#endif
lcd_setstatus(lcd_status_message);
......@@ -2508,82 +2522,102 @@ void setpageInfo() {
#if ENABLED(SDSUPPORT)
void printrowsd(uint8_t row, const bool folder, const char* filename, char* longFilename) {
String cmd;
const char* cmd;
if (longFilename[0])
filename = longFilename;
cmd = longFilename;
else
cmd = filename;
switch (row) {
case 0:
{
if (folder) {
Folder0.setPic(18);
sdrow0.attachPop(sdfolderPopCallback);
}
else {
sdrow0.attachPop(sdfolderPopCallback, &sdrow0);
} else if (cmd == "") {
Folder0.setPic(17);
sdrow0.detachPop();
} else {
Folder0.setPic(17);
sdrow0.attachPop(sdfilePopCallback);
sdrow0.attachPop(sdfilePopCallback, &sdrow0);
}
sdrow0.setText(filename);
sdrow0.setText(cmd);
filename0.setText(filename);
}
case 1:
{
if (folder) {
Folder1.setPic(18);
sdrow1.attachPop(sdfolderPopCallback);
}
else {
sdrow1.attachPop(sdfolderPopCallback, &sdrow1);
} else if (cmd == "") {
Folder1.setPic(17);
sdrow1.detachPop();
} else {
Folder1.setPic(17);
sdrow1.attachPop(sdfilePopCallback);
sdrow1.attachPop(sdfilePopCallback, &sdrow1);
}
sdrow1.setText(filename);
sdrow1.setText(cmd);
filename1.setText(filename);
}
case 2:
{
if (folder) {
Folder2.setPic(18);
sdrow2.attachPop(sdfolderPopCallback);
}
else {
sdrow2.attachPop(sdfolderPopCallback, &sdrow2);
} else if (cmd == "") {
Folder2.setPic(17);
sdrow2.detachPop();
} else {
Folder2.setPic(17);
sdrow2.attachPop(sdfilePopCallback);
sdrow2.attachPop(sdfilePopCallback, &sdrow2);
}
sdrow2.setText(filename);
sdrow2.setText(cmd);
filename2.setText(filename);
}
case 3:
{
if (folder) {
Folder3.setPic(18);
sdrow3.attachPop(sdfolderPopCallback);
}
else {
sdrow3.attachPop(sdfolderPopCallback, &sdrow3);
} else if (cmd == "") {
Folder3.setPic(17);
sdrow3.detachPop();
} else {
Folder3.setPic(17);
sdrow3.attachPop(sdfilePopCallback);
sdrow3.attachPop(sdfilePopCallback, &sdrow3);
}
sdrow3.setText(filename);
sdrow3.setText(cmd);
filename3.setText(filename);
}
case 4:
{
if (folder) {
Folder4.setPic(18);
sdrow4.attachPop(sdfolderPopCallback);
}
else {
sdrow4.attachPop(sdfolderPopCallback, &sdrow4);
} else if (cmd == "") {
Folder4.setPic(17);
sdrow4.detachPop();
} else {
Folder4.setPic(17);
sdrow4.attachPop(sdfilePopCallback);
sdrow4.attachPop(sdfilePopCallback, &sdrow4);
}
sdrow4.setText(filename);
sdrow4.setText(cmd);
filename4.setText(filename);
}
case 5:
{
if (folder) {
Folder5.setPic(18);
sdrow5.attachPop(sdfolderPopCallback);
}
else {
sdrow5.attachPop(sdfolderPopCallback, &sdrow5);
} else if (cmd == "") {
Folder5.setPic(17);
sdrow5.detachPop();
} else {
Folder5.setPic(17);
sdrow5.attachPop(sdfilePopCallback);
sdrow5.attachPop(sdfilePopCallback, &sdrow5);
}
sdrow5.setText(filename);
sdrow5.setText(cmd);
filename5.setText(filename);
}
}
}
......@@ -2593,11 +2627,23 @@ void setpageInfo() {
uint32_t i = 0;
card.getWorkDirName();
if (card.filename[0] != '/') {
Folderup.setPic(20);
Folderup.attachPop(sdfolderUpPopCallback);
sdfolder.setText(card.filename);
} else {
Folderup.detachPop();
Folderup.setPic(19);
sdfolder.setText("");
}
for (uint8_t row = 0; row < 6; row++) {
i = row + number;
if (i <= fileCnt) {
if (i < fileCnt) {
card.getfilename(i);
printrowsd(row, card.filenameIsDir, card.filename, card.longFilename);
} else {
printrowsd(row, false, "", "");
}
}
sendCommand("ref 0");
......@@ -2609,12 +2655,17 @@ void setpageInfo() {
uint16_t fileCnt = card.getnrfilenames();
if (fileCnt <= 6)
slidermaxval = 1;
slidermaxval = 0;
else
slidermaxval = fileCnt - 6;
uint16_t hig = 210 - slidermaxval * 10;
if (hig < 10) hig = 10;
sdlist.setHigValue(hig);
sdlist.setMaxValue(slidermaxval);
sdlist.setValue(slidermaxval);
sendCommand("ref 0");
setrowsdcard();
}
......@@ -2643,15 +2694,50 @@ void setpageInfo() {
void sdfilePopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer));
sdcmd.getText(buffer, sizeof(buffer));
if (ptr == &sdrow0)
filename0.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow1)
filename1.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow2)
filename2.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow3)
filename3.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow4)
filename4.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow5)
filename5.getText(buffer, sizeof(buffer));
menu_action_sdfile(buffer);
}
void sdfolderPopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer));
sdcmd.getText(buffer, sizeof(buffer));
if (ptr == &sdrow0)
filename0.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow1)
filename1.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow2)
filename2.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow3)
filename3.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow4)
filename4.getText(buffer, sizeof(buffer));
else if (ptr == &sdrow5)
filename5.getText(buffer, sizeof(buffer));
menu_action_sddirectory(buffer);
}
void sdfolderUpPopCallback(void *ptr) {
card.updir();
setpagesdcard();
}
void ExitPopCallback(void *ptr) {
setpageInfo();
}
#endif
void page0PopCallback(void *ptr) {
......@@ -2748,7 +2834,9 @@ void lcd_init() {
page0.attachPop(page0PopCallback);
#if ENABLED(SDSUPPORT)
MSD.attachPop(setpagePopCallback, &MSD);
sdlist.attachPop(sdlistPopCallback);
Exit.attachPop(ExitPopCallback);
#endif
#if HAS_TEMP_0
......@@ -2762,7 +2850,6 @@ void lcd_init() {
#endif
Menu.attachPop(setpagePopCallback, &Menu);
MSD.attachPop(setpagePopCallback, &MSD);
MSetup.attachPop(setpagePopCallback, &Menu);
Fanpic.attachPop(setfanPopCallback, &Fanpic);
m11.attachPop(sethotPopCallback, &m11);
......
......@@ -130,6 +130,8 @@
void sdlistPopCallback(void *ptr);
void sdfilePopCallback(void *ptr);
void sdfolderPopCallback(void *ptr);
void sdfolderUpPopCallback(void *ptr);
void ExitUpPopCallback(void *ptr);
#endif
FORCE_INLINE bool lcd_hasstatus() { return false; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment