Merge pull request #826 from XPila/MK3-new_lang

Mk3 new lang
This commit is contained in:
XPila 2018-06-10 16:40:43 +02:00 committed by GitHub
commit e559404448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 431 additions and 572 deletions

View File

@ -404,9 +404,9 @@ your extruder heater takes 2 minutes to hit the target on heating.
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_INVERTING 1 // set to 1 to invert the logic of the endstop.
//#define DISABLE_MAX_ENDSTOPS
//#define DISABLE_MIN_ENDSTOPS
@ -422,11 +422,11 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define E_ENABLE_ON 0 // For all extruders
// Disables axis when it's not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z false
#define DISABLE_E false // For all extruders
#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled
#define DISABLE_X 0
#define DISABLE_Y 0
#define DISABLE_Z 0
#define DISABLE_E 0// For all extruders
#define DISABLE_INACTIVE_EXTRUDER 1 //disable only inactive extruders and keep active extruder enabled
// ENDSTOP SETTINGS:
@ -436,11 +436,11 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define Z_HOME_DIR -1
#ifdef DEBUG_DISABLE_SWLIMITS
#define min_software_endstops false
#define max_software_endstops false
#define min_software_endstops 0
#define max_software_endstops 0
#else
#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below.
#define min_software_endstops 1 // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops 1 // If true, axis won't move to coordinates greater than the defined lengths below.
#endif //DEBUG_DISABLE_SWLIMITS

View File

@ -143,7 +143,7 @@
//#define Y_DUAL_STEPPER_DRIVERS
// Define if the two Y drives need to rotate in opposite directions
#define INVERT_Y2_VS_Y_DIR true
#define INVERT_Y2_VS_Y_DIR 1
#ifdef Y_DUAL_STEPPER_DRIVERS
#undef EXTRUDERS
@ -160,13 +160,13 @@
#define Z_HOME_RETRACT_MM 2
//#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
#define AXIS_RELATIVE_MODES {false, false, false, false}
#define AXIS_RELATIVE_MODES {0, 0, 0, 0}
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step). Toshiba steppers are 4x slower, but Prusa3D does not use those.
//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
#define INVERT_X_STEP_PIN false
#define INVERT_Y_STEP_PIN false
#define INVERT_Z_STEP_PIN false
#define INVERT_E_STEP_PIN false
#define INVERT_X_STEP_PIN 0
#define INVERT_Y_STEP_PIN 0
#define INVERT_Z_STEP_PIN 0
#define INVERT_E_STEP_PIN 0
//default stepper release if idle
#define DEFAULT_STEPPER_DEACTIVE_TIME 60
@ -206,7 +206,7 @@
//#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
#define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
#define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers?
#define SD_FINISHED_STEPPERRELEASE 1 //if sd support and the file is finished: disable steppers?
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
#define SDCARD_RATHERRECENTFIRST //reverse file order of sd card menu display. Its sorted practically after the file system block order.
@ -241,7 +241,7 @@
// SD Card Sorting options
// In current firmware Prusa Firmware version,
// SDSORT_CACHE_NAMES and SDSORT_DYNAMIC_RAM is not supported and must be set to false.
// SDSORT_CACHE_NAMES and SDSORT_DYNAMIC_RAM is not supported and must be set to 0.
#ifdef SDCARD_SORT_ALPHA
#define SD_SORT_TIME 0
#define SD_SORT_ALPHA 1
@ -249,11 +249,11 @@
#define SDSORT_LIMIT 100 // Maximum number of sorted items (10-256).
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
#define SDSORT_GCODE 0 // Allow turning sorting on/off with LCD and M34 g-code.
#define SDSORT_USES_RAM 0 // Pre-allocate a static array for faster pre-sorting.
#define SDSORT_USES_STACK 0 // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
#define SDSORT_CACHE_NAMES 0 // Keep sorted items in RAM longer for speedy performance. Most expensive option.
#define SDSORT_DYNAMIC_RAM 0 // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
#endif
#if defined(SDCARD_SORT_ALPHA)
@ -283,7 +283,7 @@
#define BABYSTEPPING
#ifdef BABYSTEPPING
#define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions
#define BABYSTEP_INVERT_Z false //true for inverse movements in Z
#define BABYSTEP_INVERT_Z 0 //1 for inverse movements in Z
#define BABYSTEP_Z_MULTIPLICATOR 2 //faster z movements
#ifdef COREXY

View File

@ -50,7 +50,7 @@
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#include "WString.h"
//#include "WString.h"
#ifdef AT90USB
#ifdef BTENABLED

View File

@ -216,7 +216,7 @@ class MarlinSerial //: public Stream
static void print(unsigned long, int = DEC);
static void print(double, int = 2);
static void println(const String &s);
// static void println(const String &s);
static void println(const char[]);
static void println(char, int = BYTE);
static void println(unsigned char, int = BYTE);

View File

@ -82,9 +82,7 @@
#include "swspi.h"
#endif //SWSPI
#ifdef NEW_SPI
#include "spi.h"
#endif //NEW_SPI
#ifdef SWI2C
#include "swi2c.h"
@ -333,7 +331,6 @@ static LongTimer crashDetTimer;
bool mesh_bed_leveling_flag = false;
bool mesh_bed_run_from_menu = false;
//unsigned char lang_selected = 0;
int8_t FarmMode = 0;
bool prusa_sd_card_upload = false;
@ -624,7 +621,6 @@ void servo_init()
#endif
}
static void lcd_language_menu();
void stop_and_save_print_to_ram(float z_move, float e_move);
void restore_print_from_ram_and_continue(float e_move);
@ -796,8 +792,7 @@ void factory_reset(char level, bool quiet)
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
lcd_force_language_selection();
lang_reset();
break;
//Level 1: Reset statistics
@ -828,12 +823,11 @@ void factory_reset(char level, bool quiet)
//lcd_print_at_PGM(1,2,PSTR("Shipping prep"));
// Force language selection at the next boot up.
lcd_force_language_selection();
lang_reset();
// Force the "Follow calibration flow" message at the next boot up.
calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION);
eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard
farm_no = 0;
//*** MaR::180501_01
farm_mode = false;
eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode);
EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no);
@ -1002,7 +996,7 @@ void show_fw_version_warnings() {
lcd_print_at_PGM(0, 3, PSTR(FW_REPOSITORY));
lcd_wait_for_click();
break;
default: lcd_show_fullscreen_message_and_wait_P(_i("WARNING: This is an unofficial, unsupported build. Use at your own risk!")); break;////MSG_FW_VERSION_UNKNOWN c=20 r=8
// default: lcd_show_fullscreen_message_and_wait_P(_i("WARNING: This is an unofficial, unsupported build. Use at your own risk!")); break;////MSG_FW_VERSION_UNKNOWN c=20 r=8
}
lcd_update_enable(true);
}
@ -1029,37 +1023,56 @@ void erase_eeprom_section(uint16_t offset, uint16_t bytes)
for (int i = offset; i < (offset+bytes); i++) eeprom_write_byte((uint8_t*)i, 0xFF);
}
#include "bootapp.h"
void __test()
{
cli();
boot_app_magic = 0x55aa55aa;
boot_app_flags = BOOT_APP_FLG_USER0;
boot_reserved = 0x00;
wdt_enable(WDTO_15MS);
while(1);
}
#if (LANG_MODE != 0) //secondary language support
#ifdef W25X20CL
void upgrade_sec_lang_from_external_flash()
#include "bootapp.h" //bootloader support
// language update from external flash
#define LANGBOOT_BLOCKSIZE 0x1000
#define LANGBOOT_RAMBUFFER 0x0800
void update_sec_lang_from_external_flash()
{
if ((boot_app_magic == 0x55aa55aa) && (boot_app_flags & BOOT_APP_FLG_USER0))
if ((boot_app_magic == BOOT_APP_MAGIC) && (boot_app_flags & BOOT_APP_FLG_USER0))
{
fprintf_P(lcdout, PSTR(ESC_2J ESC_H(1,1) "TEST %d"), boot_reserved);
boot_reserved++;
if (boot_reserved < 4)
uint8_t lang = boot_reserved >> 4;
uint8_t state = boot_reserved & 0xf;
lang_table_header_t header;
uint32_t src_addr;
if (lang_get_header(lang, &header, &src_addr))
{
_delay_ms(1000);
cli();
wdt_enable(WDTO_15MS);
while(1);
fputs_P(PSTR(ESC_H(1,3) "Language update."), lcdout);
for (uint8_t i = 0; i < state; i++) fputc('.', lcdout);
delay(100);
boot_reserved = (state + 1) | (lang << 4);
if ((state * LANGBOOT_BLOCKSIZE) < header.size)
{
cli();
uint16_t size = header.size - state * LANGBOOT_BLOCKSIZE;
if (size > LANGBOOT_BLOCKSIZE) size = LANGBOOT_BLOCKSIZE;
w25x20cl_rd_data(src_addr + state * LANGBOOT_BLOCKSIZE, (uint8_t*)LANGBOOT_RAMBUFFER, size);
if (state == 0)
{
//TODO - check header integrity
}
bootapp_ram2flash(LANGBOOT_RAMBUFFER, _SEC_LANG_TABLE + state * LANGBOOT_BLOCKSIZE, size);
}
else
{
//TODO - check sec lang data integrity
eeprom_update_byte((unsigned char *)EEPROM_LANG, LANG_ID_SEC);
}
}
}
boot_app_flags &= ~BOOT_APP_FLG_USER0;
}
#ifdef DEBUG_W25X20CL
uint8_t lang_xflash_enum_codes(uint16_t* codes)
{
lang_table_header_t header;
@ -1079,7 +1092,7 @@ uint8_t lang_xflash_enum_codes(uint16_t* codes)
printf_P(_n(" _lt_size = 0x%04x (%d)\n"), header.size, header.size);
printf_P(_n(" _lt_count = 0x%04x (%d)\n"), header.count, header.count);
printf_P(_n(" _lt_chsum = 0x%04x\n"), header.checksum);
printf_P(_n(" _lt_code = 0x%04x\n"), header.code);
printf_P(_n(" _lt_code = 0x%04x (%c%c)\n"), header.code, header.code >> 8, header.code & 0xff);
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), header.reserved1);
addr += header.size;
@ -1096,28 +1109,37 @@ void list_sec_lang_from_external_flash()
printf_P(_n("XFlash lang count = %hhd\n"), count);
}
#endif //DEBUG_W25X20CL
#endif //W25X20CL
#endif //(LANG_MODE != 0)
// "Setup" function is called by the Arduino framework on startup.
// Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code
// are initialized by the main() routine provided by the Arduino framework.
void setup()
{
#ifdef NEW_SPI
spi_init();
#endif //NEW_SPI
lcd_init();
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
upgrade_sec_lang_from_external_flash();
spi_init();
lcd_splash();
#if (LANG_MODE != 0) //secondary language support
#ifdef W25X20CL
if (w25x20cl_init())
update_sec_lang_from_external_flash();
else
kill(_i("External SPI flash W25X20CL not responding."));
#endif //W25X20CL
#endif //(LANG_MODE != 0)
setup_killpin();
setup_powerhold();
//*** MaR::180501_02b
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no);
if ((farm_mode == 0xFF && farm_no == 0) || ((uint16_t)farm_no == 0xFFFF))
@ -1140,6 +1162,97 @@ void setup()
SERIAL_ECHO_START;
printf_P(PSTR(" " FW_VERSION_FULL "\n"));
#ifdef DEBUG_SEC_LANG
lang_table_header_t header;
uint32_t src_addr = 0x00000;
if (lang_get_header(3, &header, &src_addr))
{
//this is comparsion of some printing-methods regarding to flash space usage and code size/readability
#define LT_PRINT_TEST 2
// flash usage
// total p.test
//0 252718 t+c text code
//1 253142 424 170 254
//2 253040 322 164 158
//3 253248 530 135 395
#if (LT_PRINT_TEST==1) //not optimized printf
printf_P(_n(" _src_addr = 0x%08lx\n"), src_addr);
printf_P(_n(" _lt_magic = 0x%08lx %S\n"), header.magic, (header.magic==LANG_MAGIC)?_n("OK"):_n("NA"));
printf_P(_n(" _lt_size = 0x%04x (%d)\n"), header.size, header.size);
printf_P(_n(" _lt_count = 0x%04x (%d)\n"), header.count, header.count);
printf_P(_n(" _lt_chsum = 0x%04x\n"), header.checksum);
printf_P(_n(" _lt_code = 0x%04x (%c%c)\n"), header.code, header.code >> 8, header.code & 0xff);
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), header.reserved1);
#elif (LT_PRINT_TEST==2) //optimized printf
printf_P(
_n(
" _src_addr = 0x%08lx\n"
" _lt_magic = 0x%08lx %S\n"
" _lt_size = 0x%04x (%d)\n"
" _lt_count = 0x%04x (%d)\n"
" _lt_chsum = 0x%04x\n"
" _lt_code = 0x%04x (%c%c)\n"
" _lt_resv1 = 0x%08lx\n"
),
src_addr,
header.magic, (header.magic==LANG_MAGIC)?_n("OK"):_n("NA"),
header.size, header.size,
header.count, header.count,
header.checksum,
header.code, header.code >> 8, header.code & 0xff,
header.reserved1
);
#elif (LT_PRINT_TEST==3) //arduino print/println (leading zeros not solved)
MYSERIAL.print(" _src_addr = 0x");
MYSERIAL.println(src_addr, 16);
MYSERIAL.print(" _lt_magic = 0x");
MYSERIAL.print(header.magic, 16);
MYSERIAL.println((header.magic==LANG_MAGIC)?" OK":" NA");
MYSERIAL.print(" _lt_size = 0x");
MYSERIAL.print(header.size, 16);
MYSERIAL.print(" (");
MYSERIAL.print(header.size, 10);
MYSERIAL.println(")");
MYSERIAL.print(" _lt_count = 0x");
MYSERIAL.print(header.count, 16);
MYSERIAL.print(" (");
MYSERIAL.print(header.count, 10);
MYSERIAL.println(")");
MYSERIAL.print(" _lt_chsum = 0x");
MYSERIAL.println(header.checksum, 16);
MYSERIAL.print(" _lt_code = 0x");
MYSERIAL.print(header.code, 16);
MYSERIAL.print(" (");
MYSERIAL.print((char)(header.code >> 8), 0);
MYSERIAL.print((char)(header.code & 0xff), 0);
MYSERIAL.println(")");
MYSERIAL.print(" _lt_resv1 = 0x");
MYSERIAL.println(header.reserved1, 16);
#endif //(LT_PRINT_TEST==)
#undef LT_PRINT_TEST
#if 0
w25x20cl_rd_data(0x25ba, (uint8_t*)&block_buffer, 1024);
for (uint16_t i = 0; i < 1024; i++)
{
if ((i % 16) == 0) printf_P(_n("%04x:"), 0x25ba+i);
printf_P(_n(" %02x"), ((uint8_t*)&block_buffer)[i]);
if ((i % 16) == 15) putchar('\n');
}
#endif
#if 1
for (uint16_t i = 0; i < 1024*10; i++)
{
if ((i % 16) == 0) printf_P(_n("%04x:"), _SEC_LANG_TABLE+i);
printf_P(_n(" %02x"), pgm_read_byte((uint8_t*)(_SEC_LANG_TABLE+i)));
if ((i % 16) == 15) putchar('\n');
}
#endif
}
else
printf_P(_n("lang_get_header failed!\n"));
#if 0
SERIAL_ECHOLN("Reading eeprom from 0 to 100: start");
for (int i = 0; i < 4096; ++i) {
@ -1154,6 +1267,8 @@ void setup()
SERIAL_ECHOLN("Reading eeprom from 0 to 100: done");
#endif
#endif //DEBUG_SEC_LANG
// Check startup - does nothing if bootloader sets MCUSR to 0
byte mcu = MCUSR;
/* if (mcu & 1) SERIAL_ECHOLNRPGM(_T(MSG_POWERUP));
@ -1310,7 +1425,6 @@ void setup()
#if defined(Z_AXIS_ALWAYS_ON)
enable_z();
#endif
//*** MaR::180501_02
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no);
if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode
@ -1404,37 +1518,35 @@ void setup()
// If they differ, an update procedure may need to be performed. At the end of this block, the current firmware version
// is being written into the EEPROM, so the update procedure will be triggered only once.
spi_setup(TMC2130_SPCR, TMC2130_SPSR);
puts_P(_n("w25x20cl init: "));
if (w25x20cl_ini())
{
uint8_t uid[8]; // 64bit unique id
w25x20cl_rd_uid(uid);
puts_P(_n("OK, UID="));
for (uint8_t i = 0; i < 8; i ++)
printf_P(PSTR("%02hhx"), uid[i]);
putchar('\n');
list_sec_lang_from_external_flash();
}
else
puts_P(_n("NG!\n"));
#if (LANG_MODE != 0) //secondary language support
lang_selected = eeprom_read_byte((uint8_t*)EEPROM_LANG);
if (lang_selected >= LANG_NUM)
{
// lcd_mylang();
lang_selected = 0;
}
lang_select(lang_selected);
#ifdef DEBUG_W25X20CL
W25X20CL_SPI_ENTER();
uint8_t uid[8]; // 64bit unique id
w25x20cl_rd_uid(uid);
puts_P(_n("W25X20CL UID="));
for (uint8_t i = 0; i < 8; i ++)
printf_P(PSTR("%02hhx"), uid[i]);
putchar('\n');
list_sec_lang_from_external_flash();
#endif //DEBUG_W25X20CL
uint16_t sec_lang_code = lang_get_code(1);
printf_P(_n("SEC_LANG_CODE=0x%04x (%c%c)\n"), sec_lang_code, sec_lang_code >> 8, sec_lang_code & 0xff);
// lang_reset();
if (!lang_select(eeprom_read_byte((uint8_t*)EEPROM_LANG)))
lcd_language();
#ifdef DEBUG_SEC_LANG
lang_print_sec_lang(uartout);
uint16_t sec_lang_code = lang_get_code(1);
uint16_t ui = _SEC_LANG_TABLE; //table pointer
printf_P(_n("lang_selected=%d\nlang_table=0x%04x\nSEC_LANG_CODE=0x%04x (%c%c)\n"), lang_selected, ui, sec_lang_code, sec_lang_code >> 8, sec_lang_code & 0xff);
// lang_print_sec_lang(uartout);
#endif //DEBUG_SEC_LANG
#endif //(LANG_MODE != 0)
if (eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE) == 255) {
eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0);
temp_cal_active = false;
@ -2259,7 +2371,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep)
#ifdef TMC2130
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
FORCE_HIGH_POWER_END;
kill(MSG_BED_LEVELING_FAILED_POINT_LOW);
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
return;
}
#endif //TMC2130
@ -2275,7 +2387,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep)
#ifdef TMC2130
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
FORCE_HIGH_POWER_END;
kill(MSG_BED_LEVELING_FAILED_POINT_LOW);
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
return;
}
#endif //TMC2130
@ -3145,8 +3257,10 @@ void process_commands()
trace();
prusa_sd_card_upload = true;
card.openFile(strchr_pointer+4,false);
} else if (code_seen("SN")) {
gcode_PRUSA_SN();
} else if(code_seen("Fir")){
SERIAL_PROTOCOLLN(FW_VERSION);
@ -3156,19 +3270,12 @@ void process_commands()
SERIAL_PROTOCOLLN(FILAMENT_SIZE "-" ELECTRONICS "-" NOZZLE_TYPE );
} else if(code_seen("Lang")) {
lcd_force_language_selection();
} else if(code_seen("Lz")) {
lang_reset();
} else if(code_seen("Lz")) {
EEPROM_save_B(EEPROM_BABYSTEP_Z,0);
} else if (code_seen("SERIAL LOW")) {
MYSERIAL.println("SERIAL LOW");
MYSERIAL.begin(BAUDRATE);
return;
} else if (code_seen("SERIAL HIGH")) {
MYSERIAL.println("SERIAL HIGH");
MYSERIAL.begin(1152000);
return;
} else if(code_seen("Beat")) {
} else if(code_seen("Beat")) {
// Kick farm link timer
kicktime = millis();
@ -5055,7 +5162,7 @@ Sigma_Exit:
setWatch();
break;
case 112: // M112 -Emergency Stop
kill("", 3);
kill(_n(""), 3);
break;
case 140: // M140 set bed temp
if (code_seen('S')) setTargetBed(code_value());
@ -5304,15 +5411,7 @@ Sigma_Exit:
#endif
#ifdef ULTIPANEL
powersupply = false;
LCD_MESSAGERPGM(CAT4(CUSTOM_MENDEL_NAME,PSTR(" "),MSG_OFF,PSTR("."))); //!!
/*
MACHNAME = "Prusa i3"
MSGOFF = "Vypnuto"
"Prusai3"" ""vypnuto""."
"Prusa i3"" "_T(MSG_ALL)[lang_selected][50]"."
*/
LCD_MESSAGERPGM(CAT4(CUSTOM_MENDEL_NAME,PSTR(" "),MSG_OFF,PSTR(".")));
lcd_update();
#endif
break;
@ -5977,7 +6076,7 @@ Sigma_Exit:
break;
case 509: //M509 Force language selection
{
lcd_force_language_selection();
lang_reset();
SERIAL_ECHO_START;
SERIAL_PROTOCOLPGM(("LANG SEL FORCED"));
}
@ -7439,7 +7538,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
if( (millis() - previous_millis_cmd) > max_inactive_time )
if(max_inactive_time)
kill("", 4);
kill(_n(""), 4);
if(stepper_inactive_time) {
if( (millis() - previous_millis_cmd) > stepper_inactive_time )
{

View File

@ -20,20 +20,31 @@ void bootapp_print_vars()
void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
{
cli();
boot_app_magic = 0x55aa55aa;
boot_app_magic = BOOT_APP_MAGIC;
boot_app_flags |= BOOT_APP_FLG_COPY;
uint16_t ui; for (ui = 0; ui < size; ui++)
boot_app_flags |= BOOT_APP_FLG_ERASE;
/* uint16_t ui; for (ui = 0; ui < size; ui++)
{
uint8_t uc = ram_array[ui+rptr];
if (pgm_readbyte(ui+fptr) & uc != uc)
if (pgm_read_byte(ui+fptr) & uc != uc)
{
boot_app_flags |= BOOT_APP_FLG_ERASE;
break;
}
}
}*/
boot_copy_size = (uint16_t)size;
boot_src_addr = (uint32_t)rptr;
boot_dst_addr = (uint32_t)fptr;
wdt_enable(WDTO_15MS);
while(1);
}
void bootapp_reboot_user0(uint8_t reserved)
{
cli();
boot_app_magic = BOOT_APP_MAGIC;
boot_app_flags = BOOT_APP_FLG_USER0;
boot_reserved = reserved;
wdt_enable(WDTO_15MS);
while(1);
}

View File

@ -20,6 +20,8 @@
#define BOOT_APP_FLG_USER0 0x80
#define BOOT_APP_MAGIC 0x55aa55aa
#if defined(__cplusplus)
extern "C" {
@ -28,6 +30,7 @@ extern "C" {
extern void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size);
extern void bootapp_reboot_user0(uint8_t reserved);
#if defined(__cplusplus)
}

View File

@ -19,11 +19,16 @@
#define TMC2130_SPSR SPI_SPSR(TMC2130_SPI_RATE)
//W25X20CL configuration
//pinout:
#define W25X20CL_PIN_CS 32
//spi:
#define W25X20CL_SPI_RATE 0 // fosc/4 = 4MHz
#define W25X20CL_SPCR SPI_SPCR(W25X20CL_SPI_RATE, 1, 1, 1, 0)
#define W25X20CL_SPSR SPI_SPSR(W25X20CL_SPI_RATE)
//LANG - Multi-language support
//#define LANG_MODE 0 // primary language only
#define LANG_MODE 1 // sec. language support
#define LANG_MODE 0 // sec. language support
#define LANG_SIZE_RESERVED 0x2700 // reserved space for secondary language (~10kb)
//#define LANG_SIZE_RESERVED 0x1ef8 // reserved space for secondary language (~10kb)

View File

@ -1,8 +1,10 @@
//language.c
#include "language.h"
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "bootapp.h"
#include "Configuration.h"
#ifdef W25X20CL
#include "w25x20cl.h"
@ -18,6 +20,8 @@ uint8_t lang_select(uint8_t lang) { return 0; }
uint8_t lang_get_count() { return 1; }
uint16_t lang_get_code(uint8_t lang) { return LANG_CODE_EN; }
const char* lang_get_name_by_code(uint16_t code) { return _n("English"); }
void lang_reset(void) { }
uint8_t lang_is_selected(void) { return 1; }
#else //(LANG_MODE == 0) //secondary languages in progmem or xflash
@ -39,49 +43,37 @@ const char* lang_get_translation(const char* s)
return (const char*)((char*)lang_table + ui); //return calculated pointer
}
const char* lang_get_sec_lang_str(const char* s)
{
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
lang_table_t* _lang_table = ui; //table pointer
ui = pgm_read_word(((uint16_t*)s)); //read string id
if (ui == 0xffff) return s + 2; //translation not found
ui = pgm_read_word(((uint16_t*)(((char*)_lang_table + 16 + ui*2)))); //read relative offset
return (const char*)((char*)_lang_table + ui); //return calculated pointer
}
uint8_t lang_select(uint8_t lang)
{
if (lang == LANG_ID_PRI) //primary language
{
lang_table = 0;
lang_selected = 0;
return 1;
lang_selected = lang;
}
#ifdef W25X20CL
if (lang_get_code(lang) == lang_get_code(LANG_ID_SEC)) lang = LANG_ID_SEC;
if (lang == LANG_ID_SEC) //current secondary language
{
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
if (pgm_read_dword(((uint32_t*)(ui + 0))) != LANG_MAGIC) return 0; //magic not valid
lang_table = ui; // set table pointer
lang_selected = 1; // set language id
return 1;
if (pgm_read_dword(((uint32_t*)_SEC_LANG_TABLE)) == LANG_MAGIC) //magic valid
{
lang_table = _SEC_LANG_TABLE; // set table pointer
lang_selected = lang; // set language id
}
}
#else //W25X20CL
#endif //W25X20CL
/*
uint16_t ui = (uint16_t)&_SEC_LANG; //pointer to _SEC_LANG reserved space
ui += 0x00ff; //add 1 page
ui &= 0xff00; //align to page
lang_table = ui; //set table pointer
ui = pgm_read_word(((uint16_t*)(((char*)lang_table + 16)))); //read relative offset of first string (language name)
return (const char*)((char*)lang_table + ui); //return calculated pointer
*/
if (lang_selected == lang)
{
eeprom_update_byte((unsigned char*)EEPROM_LANG, lang_selected);
return 1;
}
return 0;
}
uint8_t lang_get_count()
{
#ifdef W25X20CL
W25X20CL_SPI_ENTER();
uint8_t count = 2; //count = 1+n (primary + secondary + all in xflash)
uint32_t addr = 0x00000; //start of xflash
lang_table_header_t header; //table header structure
@ -97,16 +89,44 @@ uint8_t lang_get_count()
#endif //W25X20CL
}
uint16_t lang_get_code(uint8_t lang)
uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset)
{
if (lang == LANG_ID_PRI) return 0; //primary lang not supported for this function
#ifdef W25X20CL
if (lang == LANG_ID_PRI) return LANG_CODE_EN; //primary lang = EN
if (lang == LANG_ID_SEC)
{
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
uint16_t ui = _SEC_LANG_TABLE; //table pointer
memcpy_P(header, ui, sizeof(lang_table_header_t)); //read table header from progmem
if (offset) *offset = ui;
return (header == LANG_MAGIC)?1:0; //return 1 if magic valid
}
W25X20CL_SPI_ENTER();
uint32_t addr = 0x00000; //start of xflash
lang--;
while (1)
{
w25x20cl_rd_data(addr, header, sizeof(lang_table_header_t)); //read table header from xflash
if (header->magic != LANG_MAGIC) break; //break if not valid
if (offset) *offset = addr;
if (--lang == 0) return 1;
addr += header->size; //calc address of next table
}
return 0;
#else //W25X20CL
#endif //W25X20CL
}
uint16_t lang_get_code(uint8_t lang)
{
if (lang == LANG_ID_PRI) return LANG_CODE_EN; //primary lang = EN
#ifdef W25X20CL
if (lang == LANG_ID_SEC)
{
uint16_t ui = _SEC_LANG_TABLE; //table pointer
if (pgm_read_dword(((uint32_t*)(ui + 0))) != LANG_MAGIC) return LANG_CODE_XX; //magic not valid
return pgm_read_word(((uint32_t*)(ui + 10))); //return lang code from progmem
}
W25X20CL_SPI_ENTER();
uint32_t addr = 0x00000; //start of xflash
lang_table_header_t header; //table header structure
lang--;
@ -122,7 +142,7 @@ uint16_t lang_get_code(uint8_t lang)
// if (lang == LANG_ID_SEC)
// {
// uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
// uint16_t ui = _SEC_LANG_TABLE; //table pointer
// if (pgm_read_dword(((uint32_t*)(ui + 0))) == LANG_MAGIC) //magic num is OK
// return pgm_read_word(((uint16_t*)(ui + 10))); //read language code
// }
@ -141,22 +161,24 @@ const char* lang_get_name_by_code(uint16_t code)
case LANG_CODE_PL: return _n("Polski");
}
return _n("??");
}
// if (lang == LANG_ID_UNDEFINED) lang = lang_selected;
// if (lang == LANG_ID_PRI) return _T(MSG_LANGUAGE_NAME + 2);
// if (lang == LANG_ID_SEC)
// {
// uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
// if (pgm_read_dword(((uint32_t*)(ui + 0))) == LANG_MAGIC) //magic num is OK
// return lang_get_sec_lang_str(MSG_LANGUAGE_NAME);
// }
// return 0;
void lang_reset(void)
{
lang_selected = 0;
eeprom_update_byte((unsigned char*)EEPROM_LANG, LANG_ID_FORCE_SELECTION);
}
uint8_t lang_is_selected(void)
{
uint8_t lang_eeprom = eeprom_read_byte((unsigned char*)EEPROM_LANG);
return (lang_eeprom != LANG_ID_FORCE_SELECTION) && (lang_eeprom == lang_selected);
}
#ifdef DEBUG_SEC_LANG
const char* lang_get_sec_lang_str_by_id(uint16_t id)
{
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
uint16_t ui = _SEC_LANG_TABLE; //table pointer
return ui + pgm_read_word(((uint16_t*)(ui + 16 + id * 2))); //read relative offset and return calculated pointer
}
@ -180,7 +202,7 @@ uint16_t lang_print_sec_lang(FILE* out)
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), _lt_resv1);
if (_lt_magic != LANG_MAGIC) return 0;
puts_P(_n(" strings:\n"));
uint16_t ui = ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00); //table pointer
uint16_t ui = _SEC_LANG_TABLE; //table pointer
for (ui = 0; ui < _lt_count; ui++)
fprintf_P(out, _n(" %3d %S\n"), ui, lang_get_sec_lang_str_by_id(ui));
return _lt_count;
@ -189,5 +211,10 @@ uint16_t lang_print_sec_lang(FILE* out)
#endif //(LANG_MODE == 0)
//const char MSG_LANGUAGE_NAME[] PROGMEM_I1 = ISTR("English"); ////c=0 r=0
void lang_boot_update_start(uint8_t lang)
{
uint8_t cnt = lang_get_count();
if ((lang < 2) || (lang > cnt)) return; //only languages from xflash can be selected
bootapp_reboot_user0(lang << 4);
}

View File

@ -75,9 +75,6 @@ typedef struct
// Default language ID, if no language is selected.
#define LANG_ID_DEFAULT LANG_ID_PRI
// Number of languages available in the language table.
#define LANG_NUM 2
// Magic number at begin of lang table.
#define LANG_MAGIC 0x4bb45aa5
@ -100,22 +97,31 @@ extern uint8_t lang_selected;
#if (LANG_MODE != 0)
extern const char _SEC_LANG[LANG_SIZE_RESERVED];
extern const char* lang_get_translation(const char* s);
extern const char* lang_get_sec_lang_str(const char* s);
#define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00)
#endif //(LANG_MODE != 0)
//selects
//selects language, eeprom is updated in case of success
extern uint8_t lang_select(uint8_t lang);
//get total number of languages (primary + all in xflash)
extern uint8_t lang_get_count();
//returns total number of languages (primary + all in xflash)
extern uint8_t lang_get_count(void);
//reads lang table header and offset in xflash or progmem
extern uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset);
//reads lang code from xflash or progmem
extern uint16_t lang_get_code(uint8_t lang);
//returns localized language name (text for menu item)
extern const char* lang_get_name_by_code(uint16_t code);
//reset language to "LANG_ID_FORCE_SELECTION", epprom is updated
extern void lang_reset(void);
//returns 1 if language is selected
extern uint8_t lang_is_selected(void);
#ifdef DEBUG_SEC_LANG
extern const char* lang_get_sec_lang_str_by_id(uint16_t id);
extern uint16_t lang_print_sec_lang(FILE* out);
#endif //DEBUG_SEC_LANG
extern void lang_boot_update_start(uint8_t lang);
#if defined(__cplusplus)
}
#endif //defined(__cplusplus)
@ -123,9 +129,6 @@ extern uint16_t lang_print_sec_lang(FILE* out);
#define CAT2(_s1, _s2) _s1
#define CAT4(_s1, _s2, _s3, _s4) _s1
//Localized language name
//extern const char MSG_LANGUAGE_NAME[];
#include "messages.h"

View File

@ -8,7 +8,6 @@
#include "Configuration_prusa.h"
//internationalized messages
const char MSG_ALL[] PROGMEM_I1 = ISTR("All"); ////c=19 r=1
const char MSG_AUTO_HOME[] PROGMEM_I1 = ISTR("Auto home"); ////c=0 r=0
const char MSG_AUTO_MODE_ON[] PROGMEM_I1 = ISTR("Mode [auto power]"); ////c=0 r=0
const char MSG_BABYSTEP_Z[] PROGMEM_I1 = ISTR("Live adjust Z"); ////c=0 r=0
@ -119,3 +118,4 @@ const char MSG_Z_MAX[] PROGMEM_N1 = "z_max: "; ////c=0 r=0
const char MSG_Z_MIN[] PROGMEM_N1 = "z_min: "; ////c=0 r=0
const char MSG_ZPROBE_OUT[] PROGMEM_N1 = "Z probe out. bed"; ////c=0 r=0
const char MSG_ZPROBE_ZOFFSET[] PROGMEM_N1 = "Z Offset"; ////c=0 r=0
const char MSG_TMC_OVERTEMP[] PROGMEM_N1 = "TMC DRIVER OVERTEMP"; ////c=0 r=0

View File

@ -5,7 +5,6 @@
// LCD Menu Messages
//internationalized messages
extern const char MSG_ALL[];
extern const char MSG_AUTO_HOME[];
extern const char MSG_AUTO_MODE_ON[];
extern const char MSG_BABYSTEP_Z[];
@ -116,3 +115,4 @@ extern const char MSG_Z_MAX[];
extern const char MSG_Z_MIN[];
extern const char MSG_ZPROBE_OUT[];
extern const char MSG_ZPROBE_ZOFFSET[];
extern const char MSG_TMC_OVERTEMP[];

View File

@ -1457,7 +1457,6 @@ void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl e
#endif
}
//*** MaR::180416_03
void EEPROM_read_st(int pos, uint8_t* value, uint8_t size)
{
do

View File

@ -832,7 +832,7 @@ static float analog2temp(int raw, uint8_t e) {
SERIAL_ERROR_START;
SERIAL_ERROR((int)e);
SERIAL_ERRORLNPGM(" - Invalid extruder number !");
kill("", 6);
kill(PSTR(""), 6);
return 0.0;
}
#ifdef HEATER_0_USES_MAX6675

View File

@ -1,7 +1,8 @@
#ifndef THERMISTORTABLES_H_
#define THERMISTORTABLES_H_
#include "Marlin.h"
#include "Configuration_adv.h"
#include <avr/pgmspace.h>
#define OVERSAMPLENR 16

View File

@ -5,11 +5,8 @@
#include "tmc2130.h"
#include "LiquidCrystal_Prusa.h"
#include "ultralcd.h"
#ifndef NEW_SPI
#include <SPI.h>
#else //NEW_SPI
#include "language.h"
#include "spi.h"
#endif //NEW_SPI
extern LiquidCrystal_Prusa lcd;
@ -161,9 +158,6 @@ void tmc2130_init()
SET_INPUT(Y_TMC2130_DIAG);
SET_INPUT(Z_TMC2130_DIAG);
SET_INPUT(E0_TMC2130_DIAG);
#ifndef NEW_SPI
SPI.begin();
#endif //NEW_SPI
for (int axis = 0; axis < 2; axis++) // X Y axes
{
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
@ -386,7 +380,6 @@ bool tmc2130_wait_standstill_xy(int timeout)
void tmc2130_check_overtemp()
{
const static char TMC_OVERTEMP_MSG[] PROGMEM = "TMC DRIVER OVERTEMP ";
static uint32_t checktime = 0;
if (millis() - checktime > 1000 )
{
@ -397,11 +390,11 @@ void tmc2130_check_overtemp()
tmc2130_rd(i, TMC2130_REG_DRV_STATUS, &drv_status);
if (drv_status & ((uint32_t)1 << 26))
{ // BIT 26 - over temp prewarning ~120C (+-20C)
SERIAL_ERRORRPGM(TMC_OVERTEMP_MSG);
SERIAL_ERRORRPGM(MSG_TMC_OVERTEMP);
SERIAL_ECHOLN(i);
for (int j = 0; j < 4; j++)
tmc2130_wr(j, TMC2130_REG_CHOPCONF, 0x00010000);
kill(TMC_OVERTEMP_MSG);
kill(MSG_TMC_OVERTEMP);
}
}
@ -628,59 +621,6 @@ inline void tmc2130_cs_high(uint8_t axis)
}
}
#ifndef NEW_SPI
uint8_t tmc2130_tx(uint8_t axis, uint8_t addr, uint32_t wval)
{
//datagram1 - request
printf_P(PSTR("tmc2130_tx %d 0x%02hhx, 0x%08lx\n"), axis, addr, wval);
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
printf_P(PSTR(" SPCR = 0x%02hhx\n"), SPCR);
printf_P(PSTR(" SPSR = 0x%02hhx\n"), SPSR);
tmc2130_cs_low(axis);
SPI.transfer(addr); // address
SPI.transfer((wval >> 24) & 0xff); // MSB
SPI.transfer((wval >> 16) & 0xff);
SPI.transfer((wval >> 8) & 0xff);
SPI.transfer(wval & 0xff); // LSB
tmc2130_cs_high(axis);
SPI.endTransaction();
}
uint8_t tmc2130_rx(uint8_t axis, uint8_t addr, uint32_t* rval)
{
//datagram1 - request
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
tmc2130_cs_low(axis);
SPI.transfer(addr); // address
SPI.transfer(0); // MSB
SPI.transfer(0);
SPI.transfer(0);
SPI.transfer(0); // LSB
tmc2130_cs_high(axis);
SPI.endTransaction();
//datagram2 - response
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
tmc2130_cs_low(axis);
uint8_t stat = SPI.transfer(0); // status
uint32_t val32 = 0;
val32 = SPI.transfer(0); // MSB
val32 = (val32 << 8) | SPI.transfer(0);
val32 = (val32 << 8) | SPI.transfer(0);
val32 = (val32 << 8) | SPI.transfer(0); // LSB
tmc2130_cs_high(axis);
SPI.endTransaction();
if (rval != 0) *rval = val32;
return stat;
}
#else //NEW_SPI
//Arduino SPI
//#define TMC2130_SPI_ENTER() SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3))
//#define TMC2130_SPI_TXRX SPI.transfer
//#define TMC2130_SPI_LEAVE SPI.endTransaction
//spi
#define TMC2130_SPI_ENTER() spi_setup(TMC2130_SPCR, TMC2130_SPSR)
#define TMC2130_SPI_TXRX spi_txrx
@ -727,8 +667,6 @@ uint8_t tmc2130_rx(uint8_t axis, uint8_t addr, uint32_t* rval)
return stat;
}
#endif //NEW_SPI
void tmc2130_eeprom_load_config()
{

View File

@ -214,7 +214,6 @@ static void lcd_prepare_menu();
//static void lcd_move_menu();
static void lcd_settings_menu();
static void lcd_calibration_menu();
static void lcd_language_menu();
static void lcd_control_temperature_menu();
static void lcd_control_temperature_preheat_pla_settings_menu();
static void lcd_control_temperature_preheat_abs_settings_menu();
@ -412,38 +411,12 @@ static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder = 0, const boo
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
// Language selection dialog not active.
#define LANGSEL_OFF 0
// Language selection dialog modal, entered from the info screen. This is the case on firmware boot up,
// if the language index stored in the EEPROM is not valid.
#define LANGSEL_MODAL 1
// Language selection dialog entered from the Setup menu.
#define LANGSEL_ACTIVE 2
// Language selection dialog status
unsigned char langsel = LANGSEL_OFF;
void set_language_from_EEPROM() {
unsigned char eep = eeprom_read_byte((unsigned char*)EEPROM_LANG);
if (eep < LANG_NUM)
{
lang_selected = eep;
// Language is valid, no need to enter the language selection screen.
langsel = LANGSEL_OFF;
}
else
{
lang_selected = LANG_ID_DEFAULT;
// Invalid language, enter the language selection screen in a modal mode.
langsel = LANGSEL_MODAL;
}
}
static void lcd_status_screen()
{
if (firstrun == 1)
{
firstrun = 0;
set_language_from_EEPROM();
if(lcd_status_message_level == 0){
strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH);
@ -455,11 +428,6 @@ static void lcd_status_screen()
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
}
if (langsel) {
//strncpy_P(lcd_status_message, PSTR(">>>>>>>>> PRESS v"), LCD_WIDTH);
// Entering the language selection screen in a modal mode.
}
}
@ -552,9 +520,6 @@ static void lcd_status_screen()
}
}
//if (--langsel ==0) {langsel=1;current_click=true;}
if (current_click && (lcd_commands_type != LCD_COMMAND_STOP_PRINT)) //click is aborted unless stop print finishes
{
menuStack.reset(); //redundant, as already done in lcd_return_to_status(), just to be sure
@ -3714,27 +3679,6 @@ static void lcd_crash_mode_set()
#endif //TMC2130
static void lcd_set_lang(unsigned char lang)
{
if (lang > LANG_ID_SEC)
if (!lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Copy selected language from XFLASH?"), false, true))
{
lcd_return_to_status();
lcd_update_enable(true);
return;
}
lang_select(lang);
/*
lang_selected = lang;
firstrun = 1;
eeprom_update_byte((unsigned char *)EEPROM_LANG, lang);
// langsel=0;
if (langsel == LANGSEL_MODAL)
// From modal mode to an active mode? This forces the menu to return to the setup menu.
langsel = LANGSEL_ACTIVE;
*/
}
#ifdef PAT9125
static void lcd_fsensor_state_set()
{
@ -3762,21 +3706,14 @@ void lcd_set_progress() {
}
#endif
void lcd_force_language_selection() {
eeprom_update_byte((unsigned char *)EEPROM_LANG, LANG_ID_FORCE_SELECTION);
}
#if (LANG_MODE != 0)
static void lcd_language_menu()
{
START_MENU();
if (langsel == LANGSEL_OFF)
MENU_ITEM(back, _T(MSG_SETTINGS), 0);
else if (langsel == LANGSEL_ACTIVE)
MENU_ITEM(back, _T(MSG_WATCH), 0);
if (lang_is_selected()) MENU_ITEM(back, _T(MSG_SETTINGS), 0);
MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(0)), 0);
// MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(1)), 1);
for (int i = 2; i < lang_get_count(); i++) //skip seconday language - solved in menu_action_setlang
for (int i = 2; i < lang_get_count(); i++) //skip seconday language - solved in lang_select
MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(i)), i);
END_MENU();
}
@ -3972,6 +3909,26 @@ void lcd_wizard() {
}
}
void lcd_language()
{
lcd_update_enable(true);
lcd_implementation_clear();
lcd_goto_menu(lcd_language_menu);
lcd_timeoutToStatus = -1; //infinite timeout
lcdDrawUpdate = 2;
while ((currentMenu != lcd_status_screen) && (!lang_is_selected()))
{
delay(50);
lcd_update();
manage_heater();
manage_inactivity(true);
}
if (lang_is_selected())
lcd_return_to_status();
else
lang_select(LANG_ID_PRI);
}
void lcd_wizard(int state) {
bool end = false;
@ -4210,7 +4167,6 @@ static void lcd_settings_menu()
#ifdef TMC2130
if(!farm_mode)
{
//*** MaR::180416_01a
if (SilentModeMenu == SILENT_MODE_NORMAL) MENU_ITEM(function, _T(MSG_STEALTH_MODE_OFF), lcd_silent_mode_set);
else MENU_ITEM(function, _T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);
if (SilentModeMenu == SILENT_MODE_NORMAL)
@ -4566,190 +4522,7 @@ static void lcd_calibration_menu()
END_MENU();
}
/*
void lcd_mylang_top(int hlaska) {
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd_printPGM(_T(MSG_ALL)[hlaska-1][LANGUAGE_SELECT]);
}
void lcd_mylang_drawmenu(int cursor) {
int first = 0;
if (cursor>2) first = cursor-2;
if (cursor==LANG_NUM) first = LANG_NUM-3;
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(1, 1);
lcd_printPGM(_T(MSG_ALL)[first][LANGUAGE_NAME]);
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(1, 2);
lcd_printPGM(_T(MSG_ALL)[first+1][LANGUAGE_NAME]);
lcd.setCursor(0, 3);
lcd.print(" ");
lcd.setCursor(1, 3);
lcd_printPGM(_T(MSG_ALL)[first+2][LANGUAGE_NAME]);
if (cursor==1) lcd.setCursor(0, 1);
if (cursor>1 && cursor<LANG_NUM) lcd.setCursor(0, 2);
if (cursor==LANG_NUM) lcd.setCursor(0, 3);
lcd.print(">");
if (cursor<LANG_NUM-1) {
lcd.setCursor(19,3);
lcd.print("\x01");
}
if (cursor>2) {
lcd.setCursor(19,1);
lcd.print("^");
}
}
*/
/*
void lcd_mylang_drawmenu(int cursor)
{
unsigned char lang_cnt = lang_get_count();
int first = 0;
if (cursor>3) first = cursor-3;
if (cursor==lang_cnt && lang_cnt>4) first = lang_cnt-4;
if (cursor==lang_cnt && lang_cnt==4) first = lang_cnt-4;
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(1, 0);
lcd_printPGM(lang_get_name(first+0));
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(1, 1);
lcd_printPGM(lang_get_name(first+1));
lcd.setCursor(0, 2);
lcd.print(" ");
if (lang_cnt > 2){
lcd.setCursor(1, 2);
lcd_printPGM(lang_get_name(first+2));
}
lcd.setCursor(0, 3);
lcd.print(" ");
if (lang_cnt>3) {
lcd.setCursor(1, 3);
lcd_printPGM(lang_get_name(first+3));
}
if (cursor==1) lcd.setCursor(0, 0);
if (cursor==2) lcd.setCursor(0, 1);
if (cursor>2) lcd.setCursor(0, 2);
if (cursor==lang_cnt && lang_cnt>3) lcd.setCursor(0, 3);
lcd.print(">");
if (cursor<lang_cnt-1 && lang_cnt>4) {
lcd.setCursor(19,3);
lcd.print("\x01");
}
if (cursor>3 && lang_cnt>4) {
lcd.setCursor(19,0);
lcd.print("^");
}
}
*/
/*
void lcd_mylang_drawcursor(int cursor) {
unsigned char lang_cnt = lang_get_count();
if (cursor==1) lcd.setCursor(0, 1);
if (cursor>1 && cursor<lang_cnt) lcd.setCursor(0, 2);
if (cursor==lang_cnt) lcd.setCursor(0, 3);
lcd.print(">");
}
*/
/*
void lcd_mylang()
{
int enc_dif = 0;
int cursor_pos = 1;
lang_selected=255;
int hlaska=1;
int counter=0;
unsigned char lang_cnt = lang_get_count();
lcd_set_custom_characters_arrows();
lcd_implementation_clear();
//lcd_mylang_top(hlaska);
lcd_mylang_drawmenu(cursor_pos);
enc_dif = encoderDiff;
while ( (lang_selected == 255) ) {
manage_heater();
manage_inactivity(true);
if ( abs((enc_dif - encoderDiff)) > 4 ) {
//if ( (abs(enc_dif - encoderDiff)) > 1 ) {
if (enc_dif > encoderDiff ) {
cursor_pos --;
}
if (enc_dif < encoderDiff ) {
cursor_pos ++;
}
if (cursor_pos > lang_cnt) {
cursor_pos = lang_cnt;
}
if (cursor_pos < 1) {
cursor_pos = 1;
}
lcd_mylang_drawmenu(cursor_pos);
enc_dif = encoderDiff;
delay(100);
//}
} else delay(20);
if (lcd_clicked()) {
lcd_set_lang(cursor_pos-1);
delay(500);
}
// if (++counter == 80) {
// hlaska++;
// if(hlaska>LANG_NUM) hlaska=1;
// lcd_mylang_top(hlaska);
// lcd_mylang_drawcursor(cursor_pos);
// counter=0;
// }
};
if(MYSERIAL.available() > 1){
lang_selected = 0;
firstrun = 0;
}
lcd_set_custom_characters_degree();
lcd_implementation_clear();
lcd_return_to_status();
}
*/
void bowden_menu() {
int enc_dif = encoderDiff;
int cursor_pos = 0;
@ -4872,7 +4645,6 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be
lcd_implementation_clear();
lcd_print_at_PGM(0,0,_T(MSG_UNLOAD_FILAMENT)); lcd.print(":");
lcd.setCursor(0, 1); lcd.print(">");
lcd_print_at_PGM(1,1,_T(MSG_ALL));
lcd_print_at_PGM(1,2,_i("Used during print"));////MSG_USED c=19 r=1
lcd_print_at_PGM(1,3,_i("Current"));////MSG_CURRENT c=19 r=1
char cursor_pos = 1;
@ -5657,11 +5429,11 @@ void lcd_confirm_print()
}
extern void __test();
static void lcd_test_menu()
{
__test();
lang_boot_update_start(3);
lcd_update_enable(true);
lcd_return_to_status();
}
static void lcd_main_menu()
@ -5833,7 +5605,7 @@ static void lcd_main_menu()
#endif
MENU_ITEM(submenu, _i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0
// MENU_ITEM(submenu, _i("Test"), lcd_test_menu);////MSG_SUPPORT c=0 r=0
MENU_ITEM(submenu, _i("Test"), lcd_test_menu);////MSG_SUPPORT c=0 r=0
END_MENU();
@ -5952,7 +5724,6 @@ static void lcd_tune_menu()
#ifdef TMC2130
if(!farm_mode)
{
//*** MaR::180416_01b
if (SilentModeMenu == SILENT_MODE_NORMAL) MENU_ITEM(function, _T(MSG_STEALTH_MODE_OFF), lcd_silent_mode_set);
else MENU_ITEM(function, _T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);
@ -6778,7 +6549,6 @@ static bool lcd_selfcheck_pulleys(int axis)
st_current_set(0, 850); //set motor current higher
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 200, active_extruder);
st_synchronize();
//*** MaR::180416_02
if (SilentModeMenu != SILENT_MODE_OFF) st_current_set(0, tmp_motor[0]); //set back to normal operation currents
else st_current_set(0, tmp_motor_loud[0]); //set motor current back
current_position[axis] = current_position[axis] - move;
@ -7345,18 +7115,16 @@ static void menu_action_gcode(const char* pgcode) {
static void menu_action_setlang(unsigned char lang)
{
if (lang <= LANG_ID_SEC)
if (!lang_select(lang))
{
lcd_set_lang(lang);
return;
if (lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Copy selected language from XFLASH?"), false, true))
lang_boot_update_start(lang);
lcd_update_enable(true);
lcd_implementation_clear();
lcd_goto_menu(lcd_language_menu);
lcd_timeoutToStatus = -1; //infinite timeout
lcdDrawUpdate = 2;
}
uint16_t code = lang_get_code(lang);
if (code == lang_get_code(1))
{
lcd_set_lang(1);
return;
}
lcd_set_lang(lang);
}
static void menu_action_function(menuFunc_t data) {

View File

@ -6,6 +6,8 @@
#ifdef ULTRA_LCD
static void lcd_language_menu();
void lcd_update(uint8_t lcdDrawUpdateOverride = 0);
// Call with a false parameter to suppress the LCD update from various places like the planner or the temp control.
void lcd_update_enable(bool enable);
@ -25,7 +27,6 @@
void lcd_loading_filament();
void lcd_change_success();
void lcd_loading_color();
void lcd_force_language_selection();
void lcd_sdcard_stop();
void lcd_sdcard_pause();
void lcd_print_stop();
@ -300,6 +301,8 @@ void display_loading();
void lcd_set_progress();
#endif
void lcd_language();
void lcd_wizard();
void lcd_wizard(int state);

View File

@ -42,17 +42,17 @@ AXIS SETTINGS
// Endstop inverting
#define X_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
// Direction inverting
#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_X_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0
#define INVERT_Z_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_E0_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E1_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E2_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
// Home position
@ -403,7 +403,7 @@ THERMISTORS SETTINGS
#define PINDA_MAX_T 100
#define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring

View File

@ -42,17 +42,17 @@ AXIS SETTINGS
// Endstop inverting
#define X_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
// Direction inverting
#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_X_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0
#define INVERT_Z_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_E0_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E1_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E2_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
// Home position
@ -403,7 +403,7 @@ THERMISTORS SETTINGS
#define PINDA_MAX_T 100
#define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring

View File

@ -38,17 +38,17 @@
#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,133}
// Endstop inverting
#define X_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
// Direction inverting
#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_X_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0
#define INVERT_Z_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_E0_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E1_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E2_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
// Home position
#define MANUAL_X_HOME_POS 0
@ -469,7 +469,7 @@
#define PINDA_MAX_T 100
#define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring

View File

@ -38,17 +38,17 @@
#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,133}
// Endstop inverting
#define X_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
// Direction inverting
#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_X_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0
#define INVERT_Z_DIR 0 // for Mendel set to 0, for Orca set to 1
#define INVERT_E0_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E1_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E2_DIR 1 // for direct drive extruder v9 set to 1, for geared extruder set to 0
// Home position
#define MANUAL_X_HOME_POS 0
@ -469,7 +469,7 @@
#define PINDA_MAX_T 100
#define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring

View File

@ -39,17 +39,17 @@
//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,560}
// Endstop inverting
#define X_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to true to invert the logic of the endstop.
#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
// Direction inverting
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_X_DIR 1 // for Mendel set to 0, for Orca set to 1
#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0
#define INVERT_Z_DIR 1 // for Mendel set to 0, for Orca set to 1
#define INVERT_E0_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E1_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E2_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0
// Home position
#define MANUAL_X_HOME_POS 0
@ -119,9 +119,6 @@
// New XYZ calibration
#define NEW_XYZCAL
// Do not use Arduino SPI
#define NEW_SPI
// Watchdog support
#define WATCHDOG
@ -150,6 +147,7 @@
//#define DEBUG_BUILD
//#define DEBUG_SEC_LANG //secondary language debug output at startup
//#define DEBUG_W25X20CL //debug external spi flash
#ifdef DEBUG_BUILD
//#define _NO_ASM
#define DEBUG_DCODES //D codes
@ -586,7 +584,7 @@
#define PINDA_MAX_T 100
#define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring

View File

@ -36,17 +36,18 @@
//#define _SPI_TX swspi_tx
//#define _SPI_RX swspi_rx
#define _SPI_TX(b) spi_txrx(b)
#define _SPI_RX() spi_txrx(0xff)
#define _SPI_TX(b) spi_txrx(b)
#define _SPI_RX() spi_txrx(0xff)
int w25x20cl_mfrid_devid(void);
int8_t w25x20cl_ini(void)
int8_t w25x20cl_init(void)
{
PIN_OUT(W25X20CL_PIN_CS);
_CS_HIGH();
W25X20CL_SPI_ENTER();
if (!w25x20cl_mfrid_devid()) return 0;
return 1;
}

View File

@ -4,22 +4,25 @@
#include <inttypes.h>
#include "config.h"
#include "spi.h"
#define W25_STATUS_BUSY 0x01
#define W25_STATUS_WEL 0x02
#define W25_STATUS_BP0 0x04
#define W25_STATUS_BP1 0x08
#define W25_STATUS_TB 0x20
#define W25_STATUS_SRP 0x80
#define W25X20CL_STATUS_BUSY 0x01
#define W25X20CL_STATUS_WEL 0x02
#define W25X20CL_STATUS_BP0 0x04
#define W25X20CL_STATUS_BP1 0x08
#define W25X20CL_STATUS_TB 0x20
#define W25X20CL_STATUS_SRP 0x80
#define W25X20CL_SPI_ENTER() spi_setup(W25X20CL_SPCR, W25X20CL_SPSR)
#if defined(__cplusplus)
extern "C" {
#endif //defined(__cplusplus)
extern int8_t w25x20cl_ini(void);
extern int8_t w25x20cl_init(void);
extern void w25x20cl_enable_wr(void);
extern void w25x20cl_disable_wr(void);
extern uint8_t w25x20cl_rd_status_reg(void);