Commit 5ee63302 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent 78a42efa
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* @date 2015/8/13 * @date 2015/8/13
* *
* @copyright * @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n * Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
......
/**
* @file NexDualStateButton.cpp
*
* The implementation of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* 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 "NexDualStateButton.h"
NexDSButton::NexDSButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
bool NexDSButton::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexDSButton::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 NexDualStateButton.h
*
* The definition of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
*
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* 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 __NEXDSBUTTON_H__
#define __NEXDSBUTTON_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexDSButton component.
*
* Commonly, you want to do something after push and pop it. It is recommanded that only
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/
class NexDSButton: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexDSButton(uint8_t pid, uint8_t cid, const char *name);
/**
* Get number attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
bool getValue(uint32_t *number);
/**
* Set number attribute of component.
*
* @param buffer - number buffer.
* @return true if success, false for failure.
*/
bool setValue(uint32_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXDSBUTTON_H__ */
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
*/ */
/** /**
* NexTNumber component. * NexNumber component.
*/ */
class NexNumber: public NexTouch class NexNumber: public NexTouch
{ {
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "NexTimer.h" #include "NexTimer.h"
#include "NexNumber.h" #include "NexNumber.h"
#include "NexVar.h" #include "NexVar.h"
#include "NexDualStateButton.h"
#endif /* #ifndef __NEXTION_H__ */ #endif /* #ifndef __NEXTION_H__ */
...@@ -286,6 +286,9 @@ ...@@ -286,6 +286,9 @@
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when travelling from between next probing points #define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when travelling from between next probing points
#define Z_RAISE_AFTER_PROBING 5 //How much the extruder will be raised after the last probing point. #define Z_RAISE_AFTER_PROBING 5 //How much the extruder will be raised after the last probing point.
//#define Z_PROBE_END_SCRIPT "G1 Z10 F8000\nG1 X10 Y10\nG1 Z0.5" // These commands will be executed in the end of G29 routine.
// Useful to retract a deployable Z probe.
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pick up the sled. 0 should be fine but you can push it further if you'd like. //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pick up the sled. 0 should be fine but you can push it further if you'd like.
/*****************************************************************************************/ /*****************************************************************************************/
......
...@@ -308,6 +308,9 @@ ...@@ -308,6 +308,9 @@
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when travelling from between next probing points #define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when travelling from between next probing points
#define Z_RAISE_AFTER_PROBING 5 //How much the extruder will be raised after the last probing point. #define Z_RAISE_AFTER_PROBING 5 //How much the extruder will be raised after the last probing point.
//#define Z_PROBE_END_SCRIPT "G1 Z10 F8000\nG1 X10 Y10\nG1 Z0.5" // These commands will be executed in the end of G29 routine.
// Useful to retract a deployable Z probe.
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pick up the sled. 0 should be fine but you can push it further if you'd like. //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pick up the sled. 0 should be fine but you can push it further if you'd like.
/*****************************************************************************************/ /*****************************************************************************************/
......
...@@ -406,7 +406,7 @@ ...@@ -406,7 +406,7 @@
* * * *
***********************************************************************/ ***********************************************************************/
//#define NPR2 //#define NPR2
#define COLOR_STEP {120,25,-65,-155} // CARTER ANGLE #define COLOR_STEP {0, 10, 20, 30} // CARTER ANGLE
#define COLOR_SLOWRATE 170 // MICROSECOND delay for carter motor routine (Carter Motor Feedrate: upper value-slow feedrate) #define COLOR_SLOWRATE 170 // MICROSECOND delay for carter motor routine (Carter Motor Feedrate: upper value-slow feedrate)
#define COLOR_HOMERATE 4 // FEEDRATE for carter home #define COLOR_HOMERATE 4 // FEEDRATE for carter home
#define MOTOR_ANGLE 1.8 // Nema angle for single step #define MOTOR_ANGLE 1.8 // Nema angle for single step
...@@ -674,10 +674,10 @@ ...@@ -674,10 +674,10 @@
* * * *
**************************************************************************/ **************************************************************************/
//#define BABYSTEPPING //#define BABYSTEPPING
//#define BABYSTEP_XY // not only z, but also XY in the menu. more clutter, more functions #define BABYSTEP_XY // not only z, but also XY in the menu. more clutter, more functions
// not implemented for CoreXY and deltabots! // not implemented for CoreXY and deltabots!
#define BABYSTEP_INVERT_Z false // true for inverse movements in Z #define BABYSTEP_INVERT_Z false // true for inverse movements in Z
#define BABYSTEP_Z_MULTIPLICATOR 2 // faster z movements #define BABYSTEP_MULTIPLICATOR 2 // faster z movements
/**************************************************************************/ /**************************************************************************/
...@@ -1074,13 +1074,13 @@ ...@@ -1074,13 +1074,13 @@
// The Panucatt Devices Viki 2.0 and mini Viki with Graphic LCD // The Panucatt Devices Viki 2.0 and mini Viki with Graphic LCD
// http://panucatt.com // http://panucatt.com
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib // ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define VIKI2 //#define VIKI2
//#define miniVIKI //#define miniVIKI
// This is a new controller currently under development. https://github.com/eboston/Adafruit-ST7565-Full-Graphic-Controller/ // This is a new controller currently under development. https://github.com/eboston/Adafruit-ST7565-Full-Graphic-Controller/
// //
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib // ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define ELB_FULL_GRAPHIC_CONTROLLER //#define ELB_FULL_GRAPHIC_CONTROLLER
//#define SD_DETECT_INVERTED //#define SD_DETECT_INVERTED
...@@ -1095,7 +1095,7 @@ ...@@ -1095,7 +1095,7 @@
// The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB) // The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB)
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller // http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
// //
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib // ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER //#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
// The RepRapWorld REPRAPWORLD_KEYPAD v1.1 // The RepRapWorld REPRAPWORLD_KEYPAD v1.1
...@@ -1113,7 +1113,7 @@ ...@@ -1113,7 +1113,7 @@
// #define MINIPANEL // #define MINIPANEL
// Nextion HMI panel // Nextion HMI panel
// REMEMBER TO INSTALL Nextion library in your ARDUINO library folder. You can find it in Arduino\libraries\ // ==> REMEMBER TO INSTALL Nextion library in your ARDUINO library folder. You can find it in Arduino\libraries\
//#define NEXTION //#define NEXTION
// I2C Panels // I2C Panels
...@@ -1132,7 +1132,7 @@ ...@@ -1132,7 +1132,7 @@
//#define LCD_I2C_VIKI //#define LCD_I2C_VIKI
// SSD1306 OLED generic display support // SSD1306 OLED generic display support
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib // ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define U8GLIB_SSD1306 //#define U8GLIB_SSD1306
// Shift register panels // Shift register panels
......
This diff is collapsed.
#include "base.h" #include "base.h"
#if HAS(BUZZER) #if HAS(BUZZER)
#include "buzzer.h" #include "buzzer.h"
#include "ultralcd.h" #include "ultralcd.h"
void buzz(long duration, uint16_t freq) { void buzz(long duration, uint16_t freq) {
if (freq > 0) { if (freq > 0) {
#if ENABLED(LCD_USE_I2C_BUZZER) #if ENABLED(LCD_USE_I2C_BUZZER)
lcd_buzz(duration, freq); lcd_buzz(duration, freq);
#elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition #elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition
SET_OUTPUT(BEEPER_PIN); SET_OUTPUT(BEEPER_PIN);
#if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC #if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC
//tone(BEEPER_PIN, freq, duration); // needs a PWMable pin //tone(BEEPER_PIN, freq, duration); // needs a PWMable pin
unsigned int delay = 1000000 / freq / 2; unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000; int i = duration * freq / 1000;
...@@ -19,15 +19,17 @@ void buzz(long duration, uint16_t freq) { ...@@ -19,15 +19,17 @@ void buzz(long duration, uint16_t freq) {
WRITE(BEEPER_PIN, LOW); WRITE(BEEPER_PIN, LOW);
delayMicroseconds(delay); delayMicroseconds(delay);
} }
#else // buzzer has its own resonator - needs a DC #else // buzzer has its own resonator - needs a DC
WRITE(BEEPER_PIN, HIGH); WRITE(BEEPER_PIN, HIGH);
delay(duration); delay(duration);
WRITE(BEEPER_PIN, LOW); WRITE(BEEPER_PIN, LOW);
#endif #endif
#else #else
delay(duration); delay(duration);
#endif #endif
} else }
else {
delay(duration); delay(duration);
} }
}
#endif #endif
#ifndef BUZZER_H #ifndef BUZZER_H
#define BUZZER_H #define BUZZER_H
void buzz(long duration, uint16_t freq); #if HAS(BUZZER)
void buzz(long duration, uint16_t freq);
#endif
#endif #endif // BUZZER_H
...@@ -24,12 +24,15 @@ CardReader::CardReader() { ...@@ -24,12 +24,15 @@ CardReader::CardReader() {
workDirDepth = 0; workDirDepth = 0;
file_subcall_ctr = 0; file_subcall_ctr = 0;
memset(workDirParents, 0, sizeof(workDirParents)); memset(workDirParents, 0, sizeof(workDirParents));
autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software. autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
autostart_index = 0; autostart_index = 0;
//power to SD reader //power to SD reader
#if SDPOWER > -1 #if SDPOWER > -1
OUT_WRITE(SDPOWER, HIGH); OUT_WRITE(SDPOWER, HIGH);
#endif //SDPOWER #endif // SDPOWER
next_autostart_ms = millis() + SPLASH_SCREEN_DURATION; next_autostart_ms = millis() + SPLASH_SCREEN_DURATION;
} }
...@@ -53,24 +56,31 @@ char* createFilename(char* buffer, const dir_t& p) { //buffer > 12characters ...@@ -53,24 +56,31 @@ char* createFilename(char* buffer, const dir_t& p) { //buffer > 12characters
void CardReader::lsDive(const char* prepend, SdFile parent, const char* const match/*=NULL*/) { void CardReader::lsDive(const char* prepend, SdFile parent, const char* const match/*=NULL*/) {
dir_t p; dir_t p;
uint8_t cnt = 0; uint8_t cnt = 0;
// Read the next entry from a directory // Read the next entry from a directory
while (parent.readDir(p, longFilename) > 0) { while (parent.readDir(p, longFilename) > 0) {
// If the entry is a directory and the action is LS_SerialPrint // If the entry is a directory and the action is LS_SerialPrint
if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) { if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
// Get the short name for the item, which we know is a folder // Get the short name for the item, which we know is a folder
char lfilename[FILENAME_LENGTH]; char lfilename[FILENAME_LENGTH];
createFilename(lfilename, p); createFilename(lfilename, p);
// Allocate enough stack space for the full path to a folder, trailing slash, and nul // Allocate enough stack space for the full path to a folder, trailing slash, and nul
boolean prepend_is_empty = (prepend[0] == '\0'); boolean prepend_is_empty = (prepend[0] == '\0');
int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(lfilename) + 1 + 1; int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(lfilename) + 1 + 1;
char path[len]; char path[len];
// Append the FOLDERNAME12/ to the passed string. // Append the FOLDERNAME12/ to the passed string.
// It contains the full path to the "parent" argument. // It contains the full path to the "parent" argument.
// We now have the full path to the item in this folder. // We now have the full path to the item in this folder.
strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty
strcat(path, lfilename); // FILENAME_LENGTH-1 characters maximum strcat(path, lfilename); // FILENAME_LENGTH-1 characters maximum
strcat(path, "/"); // 1 character strcat(path, "/"); // 1 character
// Serial.print(path); // Serial.print(path);
// Get a new directory object using the full path // Get a new directory object using the full path
// and dive recursively into it. // and dive recursively into it.
SdFile dir; SdFile dir;
...@@ -81,14 +91,19 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma ...@@ -81,14 +91,19 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma
} }
lsDive(path, dir); lsDive(path, dir);
// close() is done automatically by destructor of SdFile // close() is done automatically by destructor of SdFile
} else { }
else {
char pn0 = p.name[0]; char pn0 = p.name[0];
if (pn0 == DIR_NAME_FREE) break; if (pn0 == DIR_NAME_FREE) break;
if (pn0 == DIR_NAME_DELETED || pn0 == '.') continue; if (pn0 == DIR_NAME_DELETED || pn0 == '.') continue;
if (longFilename[0] == '.') continue; if (longFilename[0] == '.') continue;
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
filenameIsDir = DIR_IS_SUBDIR(&p); filenameIsDir = DIR_IS_SUBDIR(&p);
if (!filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue; if (!filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue;
switch (lsAction) { switch (lsAction) {
case LS_Count: case LS_Count:
nrFiles++; nrFiles++;
...@@ -102,7 +117,8 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma ...@@ -102,7 +117,8 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma
createFilename(filename, p); createFilename(filename, p);
if (match != NULL) { if (match != NULL) {
if (strcasecmp(match, filename) == 0) return; if (strcasecmp(match, filename) == 0) return;
} else if (cnt == nrFiles) return; }
else if (cnt == nrFiles) return;
cnt++; cnt++;
break; break;
} }
...@@ -118,27 +134,38 @@ void CardReader::ls() { ...@@ -118,27 +134,38 @@ void CardReader::ls() {
#if ENABLED(LONG_FILENAME_HOST_SUPPORT) #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
/** /**
* Get a long pretty path based on a DOS 8.3 path * Get a long pretty path based on a DOS 8.3 path
*/ */
void CardReader::printLongPath(char* path) { void CardReader::printLongPath(char* path) {
lsAction = LS_GetFilename; lsAction = LS_GetFilename;
int i, pathLen = strlen(path); int i, pathLen = strlen(path);
// ECHO_M("Full Path: "); ECHO_EV(path); // ECHO_M("Full Path: "); ECHO_EV(path);
// Zero out slashes to make segments // Zero out slashes to make segments
for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0'; for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
SdFile diveDir = root; // start from the root for segment 1 SdFile diveDir = root; // start from the root for segment 1
for (i = 0; i < pathLen;) { for (i = 0; i < pathLen;) {
if (path[i] == '\0') i++; // move past a single nul if (path[i] == '\0') i++; // move past a single nul
char* segment = &path[i]; // The segment after most slashes char* segment = &path[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit // If a segment is empty (extra-slash) then exit
if (!*segment) break; if (!*segment) break;
// Go to the next segment // Go to the next segment
while (path[++i]) { } while (path[++i]) { }
// ECHO_M("Looking for segment: "); ECHO_EV(segment); // ECHO_M("Looking for segment: "); ECHO_EV(segment);
// Find the item, setting the long filename // Find the item, setting the long filename
diveDir.rewind(); diveDir.rewind();
lsDive("", diveDir, segment); lsDive("", diveDir, segment);
// Print /LongNamePart to serial output // Print /LongNamePart to serial output
ECHO_C('/'); ECHO_C('/');
ECHO_V(longFilename[0] ? longFilename : "???"); ECHO_V(longFilename[0] ? longFilename : "???");
...@@ -152,35 +179,43 @@ void CardReader::printLongPath(char* path) { ...@@ -152,35 +179,43 @@ void CardReader::printLongPath(char* path) {
ECHO_SMV(DB, MSG_SD_CANT_OPEN_SUBDIR, segment); ECHO_SMV(DB, MSG_SD_CANT_OPEN_SUBDIR, segment);
break; break;
} }
diveDir.close(); diveDir.close();
diveDir = dir; diveDir = dir;
} // while i<pathLen } // while i<pathLen
ECHO_E; ECHO_E;
} }
#endif // LONG_FILENAME_HOST_SUPPORT #endif // LONG_FILENAME_HOST_SUPPORT
void CardReader::initsd() { void CardReader::initsd() {
cardOK = false; cardOK = false;
if (root.isOpen()) root.close(); if (root.isOpen()) root.close();
#if ENABLED(SDEXTRASLOW)
#if ENABLED(SDEXTRASLOW)
#define SPI_SPEED SPI_QUARTER_SPEED #define SPI_SPEED SPI_QUARTER_SPEED
#elif ENABLED(SDSLOW) #elif ENABLED(SDSLOW)
#define SPI_SPEED SPI_HALF_SPEED #define SPI_SPEED SPI_HALF_SPEED
#else #else
#define SPI_SPEED SPI_FULL_SPEED #define SPI_SPEED SPI_FULL_SPEED
#endif #endif
if (!card.init(SPI_SPEED, SDSS) if (!card.init(SPI_SPEED, SDSS)
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS) #if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
&& !card.init(SPI_SPEED, LCD_SDSS) && !card.init(SPI_SPEED, LCD_SDSS)
#endif #endif
) { ) {
ECHO_LM(DB, MSG_SD_INIT_FAIL); ECHO_LM(DB, MSG_SD_INIT_FAIL);
} else if (!volume.init(&card)) { }
else if (!volume.init(&card)) {
ECHO_LM(ER, MSG_SD_VOL_INIT_FAIL); ECHO_LM(ER, MSG_SD_VOL_INIT_FAIL);
} else if (!root.openRoot(&volume)) { }
else if (!root.openRoot(&volume)) {
ECHO_LM(ER, MSG_SD_OPENROOT_FAIL); ECHO_LM(ER, MSG_SD_OPENROOT_FAIL);
} else { }
else {
cardOK = true; cardOK = true;
ECHO_LM(DB, MSG_SD_CARD_OK); ECHO_LM(DB, MSG_SD_CARD_OK);
} }
......
...@@ -29,9 +29,11 @@ void digipot_i2c_set_current(int channel, float current) { ...@@ -29,9 +29,11 @@ void digipot_i2c_set_current(int channel, float current) {
addr = 0x2E; // channel 4-7 addr = 0x2E; // channel 4-7
channel -= 4; channel -= 4;
} }
// Initial setup // Initial setup
i2c_send(addr, 0x40, 0xff); i2c_send(addr, 0x40, 0xff);
i2c_send(addr, 0xA0, 0xff); i2c_send(addr, 0xA0, 0xff);
// Set actual wiper value // Set actual wiper value
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 }; byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
i2c_send(addr, addresses[channel], current_to_wiper(current)); i2c_send(addr, addresses[channel], current_to_wiper(current));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -32,7 +32,7 @@ void FirmwareTest() { ...@@ -32,7 +32,7 @@ void FirmwareTest() {
ECHO_EM(" "); ECHO_EM(" ");
ECHO_EM("***** ENDSTOP X *****"); ECHO_EM("***** ENDSTOP X *****");
#if PIN_EXISTS(X_MIN_PIN) && (X_HOME_DIR == -1) #if PIN_EXISTS(X_MIN) && (X_HOME_DIR == -1)
if (!READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) { if (!READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) {
ECHO_M("MIN ENDSTOP X: "); ECHO_M("MIN ENDSTOP X: ");
ECHO_EV(MSG_ENDSTOP_OPEN); ECHO_EV(MSG_ENDSTOP_OPEN);
...@@ -72,7 +72,7 @@ void FirmwareTest() { ...@@ -72,7 +72,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
return; return;
} }
#elif PIN_EXISTS(X_MAX_PIN) && X_HOME_DIR == 1 #elif PIN_EXISTS(X_MAX) && X_HOME_DIR == 1
if (!READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) { if (!READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) {
ECHO_M("MAX ENDSTOP X: "); ECHO_M("MAX ENDSTOP X: ");
ECHO_EV(MSG_ENDSTOP_OPEN); ECHO_EV(MSG_ENDSTOP_OPEN);
...@@ -126,7 +126,7 @@ void FirmwareTest() { ...@@ -126,7 +126,7 @@ void FirmwareTest() {
ECHO_EM(" "); ECHO_EM(" ");
ECHO_EM("***** ENDSTOP Y *****"); ECHO_EM("***** ENDSTOP Y *****");
#if PIN_EXISTS(Y_MIN_PIN) && Y_HOME_DIR == -1 #if PIN_EXISTS(Y_MIN) && Y_HOME_DIR == -1
if (!READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) { if (!READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) {
ECHO_M("MIN ENDSTOP Y: "); ECHO_M("MIN ENDSTOP Y: ");
ECHO_EV(MSG_ENDSTOP_OPEN); ECHO_EV(MSG_ENDSTOP_OPEN);
...@@ -166,7 +166,7 @@ void FirmwareTest() { ...@@ -166,7 +166,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
return; return;
} }
#elif PIN_EXISTS(Y_MAX_PIN) && Y_HOME_DIR == 1 #elif PIN_EXISTS(Y_MAX) && Y_HOME_DIR == 1
if (!READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) { if (!READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) {
ECHO_M("MAX ENDSTOP Y: "); ECHO_M("MAX ENDSTOP Y: ");
ECHO_EV(MSG_ENDSTOP_OPEN); ECHO_EV(MSG_ENDSTOP_OPEN);
...@@ -220,7 +220,7 @@ void FirmwareTest() { ...@@ -220,7 +220,7 @@ void FirmwareTest() {
ECHO_EM(" "); ECHO_EM(" ");
ECHO_EM("***** ENDSTOP Z *****"); ECHO_EM("***** ENDSTOP Z *****");
#if PIN_EXISTS(Z_MIN_PIN) && Z_HOME_DIR == -1 #if PIN_EXISTS(Z_MIN) && Z_HOME_DIR == -1
if (!READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) { if (!READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) {
ECHO_M("MIN ENDSTOP Z: "); ECHO_M("MIN ENDSTOP Z: ");
ECHO_EV(MSG_ENDSTOP_OPEN); ECHO_EV(MSG_ENDSTOP_OPEN);
...@@ -260,7 +260,7 @@ void FirmwareTest() { ...@@ -260,7 +260,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
return; return;
} }
#elif PIN_EXISTS(Z_MAX_PIN) && Z_HOME_DIR == 1 #elif PIN_EXISTS(Z_MAX) && Z_HOME_DIR == 1
if (!READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) { if (!READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) {
ECHO_M("MAX ENDSTOP Z: "); ECHO_M("MAX ENDSTOP Z: ");
ECHO_EV(MSG_ENDSTOP_OPEN); ECHO_EV(MSG_ENDSTOP_OPEN);
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
#define MSG_TEMPERATURE "Temperatura" #define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimento" #define MSG_MOTION "Movimento"
#define MSG_FILAMENT "Filamento" #define MSG_FILAMENT "Filamento"
#define MSG_VOLUMETRIC_ENABLED "E in mm3" #define MSG_VOLUMETRIC_ENABLED "E in mm³"
#define MSG_FILAMENT_SIZE_EXTRUDER "Diam. filo" #define MSG_FILAMENT_SIZE_EXTRUDER "Diam. filo"
#define MSG_CONTRAST "Contrasto LCD" #define MSG_CONTRAST "Contrasto LCD"
#define MSG_STORE_EPROM "Salva in EEPROM" #define MSG_STORE_EPROM "Salva in EEPROM"
......
This diff is collapsed.
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
// the source g-code and may never actually be reached if acceleration management is active. // the source g-code and may never actually be reached if acceleration management is active.
struct beffering{ typedef struct {
// Fields used by the bresenham algorithm for tracing the line // Fields used by the bresenham algorithm for tracing the line
long steps[NUM_AXIS]; // Step count along each axis long steps[NUM_AXIS]; // Step count along each axis
unsigned long step_event_count; // The number of step events required to complete this block unsigned long step_event_count; // The number of step events required to complete this block
...@@ -66,8 +66,8 @@ struct beffering{ ...@@ -66,8 +66,8 @@ struct beffering{
unsigned long laser_ttlmodulation; unsigned long laser_ttlmodulation;
#endif #endif
volatile char busy; volatile char busy;
}; } block_t;
typedef struct beffering block_t;
#define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1)) #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
// Initialize the motion plan subsystem // Initialize the motion plan subsystem
...@@ -96,37 +96,39 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block ...@@ -96,37 +96,39 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block
* Add a new linear movement to the buffer. x, y, z are the signed, absolute target position in * Add a new linear movement to the buffer. x, y, z are the signed, absolute target position in
* millimeters. Feed rate specifies the (target) speed of the motion. * millimeters. Feed rate specifies the (target) speed of the motion.
*/ */
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver); void plan_buffer_line(float x, float y, float z, const float& e, float feed_rate, const uint8_t extruder, const uint8_t driver);
/** /**
* Set the planner positions. Used for G92 instructions. * Set the planner positions. Used for G92 instructions.
* Multiplies by axis_steps_per_unit[] to set stepper positions. * Multiplies by axis_steps_per_unit[] to set stepper positions.
* Clears previous speed values. * Clears previous speed values.
*/ */
void plan_set_position(float x, float y, float z, const float &e); void plan_set_position(float x, float y, float z, const float& e);
#else #else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver);
void plan_set_position(const float &x, const float &y, const float &z, const float &e); void plan_buffer_line(const float& x, const float& y, const float& z, const float& e, float feed_rate, const uint8_t extruder, const uint8_t driver);
void plan_set_position(const float& x, const float& y, const float& z, const float& e);
#endif // AUTO_BED_LEVELING_FEATURE #endif // AUTO_BED_LEVELING_FEATURE
void plan_set_e_position(const float &e); void plan_set_e_position(const float& e);
//=========================================================================== //===========================================================================
//============================= public variables ============================ //============================= public variables ============================
//=========================================================================== //===========================================================================
extern millis_t minsegmenttime; extern millis_t minsegmenttime;
extern float max_feedrate[3 + EXTRUDERS]; // set the max speeds extern float max_feedrate[3 + EXTRUDERS]; // Max speeds in mm per minute
extern float axis_steps_per_unit[3 + EXTRUDERS]; extern float axis_steps_per_unit[3 + EXTRUDERS];
extern unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use M201 to override by software extern unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use M201 to override by software
extern float minimumfeedrate; extern float minimumfeedrate;
extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX extern float acceleration; // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all moves. M204 SXXXX
extern float retract_acceleration[EXTRUDERS]; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX extern float retract_acceleration[EXTRUDERS]; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axis M204 TXXXX
extern float travel_acceleration; // Travel acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX extern float travel_acceleration; // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly. extern float max_xy_jerk; // The largest speed change requiring no acceleration
extern float max_z_jerk; extern float max_z_jerk;
extern float max_e_jerk[EXTRUDERS]; // mm/s - initial speed for extruder retract moves extern float max_e_jerk[EXTRUDERS];
extern float mintravelfeedrate; extern float mintravelfeedrate;
extern unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS]; extern unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
...@@ -152,9 +154,9 @@ FORCE_INLINE void plan_discard_current_block() { ...@@ -152,9 +154,9 @@ FORCE_INLINE void plan_discard_current_block() {
} }
// Gets the current block. Returns NULL if buffer empty // Gets the current block. Returns NULL if buffer empty
FORCE_INLINE block_t *plan_get_current_block() { FORCE_INLINE block_t* plan_get_current_block() {
if (blocks_queued()) { if (blocks_queued()) {
block_t *block = &block_buffer[block_buffer_tail]; block_t* block = &block_buffer[block_buffer_tail];
block->busy = true; block->busy = true;
return block; return block;
} }
......
...@@ -80,20 +80,20 @@ volatile static unsigned long step_events_completed; // The number of step event ...@@ -80,20 +80,20 @@ volatile static unsigned long step_events_completed; // The number of step event
static long acceleration_time, deceleration_time; static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate; //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
static unsigned short acc_step_rate; // needed for deceleration start point static unsigned short acc_step_rate; // needed for deceleration start point
static char step_loops; static uint8_t step_loops;
static uint8_t step_loops_nominal;
static unsigned short OCR1A_nominal; static unsigned short OCR1A_nominal;
static unsigned short step_loops_nominal;
volatile long endstops_trigsteps[3] = { 0 }; volatile long endstops_trigsteps[3] = { 0 };
volatile long endstops_stepsTotal, endstops_stepsDone; volatile long endstops_stepsTotal, endstops_stepsDone;
static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
#if DISABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS) || ENABLED(NPR2)
static byte
#else
static uint16_t static uint16_t
#else
static byte
#endif #endif
old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX, E_MIN
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
bool abort_on_endstop_hit = false; bool abort_on_endstop_hit = false;
...@@ -315,7 +315,7 @@ void enable_endstops(bool check) { ...@@ -315,7 +315,7 @@ void enable_endstops(bool check) {
// Check endstops // Check endstops
inline void update_endstops() { inline void update_endstops() {
#if ENABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS) || ENABLED(NPR2)
uint16_t uint16_t
#else #else
byte byte
...@@ -478,6 +478,9 @@ inline void update_endstops() { ...@@ -478,6 +478,9 @@ inline void update_endstops() {
#if MECH(COREXZ) #if MECH(COREXZ)
} }
#endif #endif
#if ENABLED(NPR2)
UPDATE_ENDSTOP(E, MIN);
#endif
old_endstop_bits = current_endstop_bits; old_endstop_bits = current_endstop_bits;
} }
...@@ -504,7 +507,8 @@ void st_wake_up() { ...@@ -504,7 +507,8 @@ void st_wake_up() {
FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) { FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
unsigned short timer; unsigned short timer;
if (step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
NOMORE(step_rate, MAX_STEP_FREQUENCY);
if(step_rate > (2 * DOUBLE_STEP_FREQUENCY)) { // If steprate > 2*DOUBLE_STEP_FREQUENCY >> step 4 times if(step_rate > (2 * DOUBLE_STEP_FREQUENCY)) { // If steprate > 2*DOUBLE_STEP_FREQUENCY >> step 4 times
step_rate = (step_rate >> 2) & 0x3fff; step_rate = (step_rate >> 2) & 0x3fff;
...@@ -518,8 +522,8 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) { ...@@ -518,8 +522,8 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
step_loops = 1; step_loops = 1;
} }
if (step_rate < (F_CPU / 500000)) step_rate = (F_CPU / 500000); NOLESS(step_rate, F_CPU / 500000);
step_rate -= (F_CPU / 500000); // Correct for minimal speed step_rate -= F_CPU / 500000; // Correct for minimal speed
if (step_rate >= (8 * 256)) { // higher step rate if (step_rate >= (8 * 256)) { // higher step rate
unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate >> 8)][0]; unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate >> 8)][0];
unsigned char tmp_step_rate = (step_rate & 0x00ff); unsigned char tmp_step_rate = (step_rate & 0x00ff);
...@@ -738,8 +742,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -738,8 +742,7 @@ ISR(TIMER1_COMPA_vect) {
acc_step_rate += current_block->initial_rate; acc_step_rate += current_block->initial_rate;
// upper limit // upper limit
if (acc_step_rate > current_block->nominal_rate) NOMORE(acc_step_rate, current_block->nominal_rate);
acc_step_rate = current_block->nominal_rate;
// step_rate to timer interval // step_rate to timer interval
timer = calc_timer(acc_step_rate); timer = calc_timer(acc_step_rate);
...@@ -748,10 +751,9 @@ ISR(TIMER1_COMPA_vect) { ...@@ -748,10 +751,9 @@ ISR(TIMER1_COMPA_vect) {
#if ENABLED(ADVANCE) #if ENABLED(ADVANCE)
for (int8_t i = 0; i < step_loops; i++) { advance += advance_rate * step_loops;
advance += advance_rate; //NOLESS(advance, current_block->advance);
}
// if (advance > current_block->advance) advance = current_block->advance;
// Do E steps + advance steps // Do E steps + advance steps
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance); e_steps[current_block->active_driver] += ((advance >> 8) - old_advance);
old_advance = advance >> 8; old_advance = advance >> 8;
...@@ -761,29 +763,26 @@ ISR(TIMER1_COMPA_vect) { ...@@ -761,29 +763,26 @@ ISR(TIMER1_COMPA_vect) {
else if (step_events_completed > (unsigned long)current_block->decelerate_after) { else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate); MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
if (step_rate > acc_step_rate) { // Check step_rate stays positive if (step_rate <= acc_step_rate) { // Still decelerating?
step_rate = current_block->final_rate; step_rate = acc_step_rate - step_rate;
} NOLESS(step_rate, current_block->final_rate);
else {
step_rate = acc_step_rate - step_rate; // Decelerate from acceleration end point.
} }
else
// lower limit
if (step_rate < current_block->final_rate)
step_rate = current_block->final_rate; step_rate = current_block->final_rate;
// step_rate to timer interval // step_rate to timer interval
timer = calc_timer(step_rate); timer = calc_timer(step_rate);
OCR1A = timer; OCR1A = timer;
deceleration_time += timer; deceleration_time += timer;
#if ENABLED(ADVANCE) #if ENABLED(ADVANCE)
for (int8_t i = 0; i < step_loops; i++) { advance -= advance_rate * step_loops;
advance -= advance_rate; NOLESS(advance, final_advance);
}
if (advance < final_advance) advance = final_advance;
// Do E steps + advance steps // Do E steps + advance steps
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance); uint32_t advance_whole = advance >> 8;
old_advance = advance >> 8; e_steps[current_block->active_driver] += advance_whole - old_advance;
old_advance = advance_whole;
#endif //ADVANCE #endif //ADVANCE
} }
else { else {
...@@ -996,28 +995,28 @@ void st_init() { ...@@ -996,28 +995,28 @@ void st_init() {
#if HAS(X_MIN) #if HAS(X_MIN)
SET_INPUT(X_MIN_PIN); SET_INPUT(X_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_XMIN) #if ENABLED(ENDSTOPPULLUP_XMIN)
WRITE(X_MIN_PIN,HIGH); WRITE(X_MIN_PIN, HIGH);
#endif #endif
#endif #endif
#if HAS(Y_MIN) #if HAS(Y_MIN)
SET_INPUT(Y_MIN_PIN); SET_INPUT(Y_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_YMIN) #if ENABLED(ENDSTOPPULLUP_YMIN)
WRITE(Y_MIN_PIN,HIGH); WRITE(Y_MIN_PIN, HIGH);
#endif #endif
#endif #endif
#if HAS(Z_MIN) #if HAS(Z_MIN)
SET_INPUT(Z_MIN_PIN); SET_INPUT(Z_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMIN) #if ENABLED(ENDSTOPPULLUP_ZMIN)
WRITE(Z_MIN_PIN,HIGH); WRITE(Z_MIN_PIN, HIGH);
#endif #endif
#endif #endif
#if HAS(Z2_MIN) #if HAS(Z2_MIN)
SET_INPUT(Z2_MIN_PIN); SET_INPUT(Z2_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MIN) #if ENABLED(ENDSTOPPULLUP_Z2MIN)
WRITE(Z2_MIN_PIN,HIGH); WRITE(Z2_MIN_PIN, HIGH);
#endif #endif
#endif #endif
...@@ -1031,35 +1030,35 @@ void st_init() { ...@@ -1031,35 +1030,35 @@ void st_init() {
#if HAS(X_MAX) #if HAS(X_MAX)
SET_INPUT(X_MAX_PIN); SET_INPUT(X_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_XMAX) #if ENABLED(ENDSTOPPULLUP_XMAX)
WRITE(X_MAX_PIN,HIGH); WRITE(X_MAX_PIN, HIGH);
#endif #endif
#endif #endif
#if HAS(Y_MAX) #if HAS(Y_MAX)
SET_INPUT(Y_MAX_PIN); SET_INPUT(Y_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_YMAX) #if ENABLED(ENDSTOPPULLUP_YMAX)
WRITE(Y_MAX_PIN,HIGH); WRITE(Y_MAX_PIN, HIGH);
#endif #endif
#endif #endif
#if HAS(Z_MAX) #if HAS(Z_MAX)
SET_INPUT(Z_MAX_PIN); SET_INPUT(Z_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMAX) #if ENABLED(ENDSTOPPULLUP_ZMAX)
WRITE(Z_MAX_PIN,HIGH); WRITE(Z_MAX_PIN, HIGH);
#endif #endif
#endif #endif
#if HAS(Z2_MAX) #if HAS(Z2_MAX)
SET_INPUT(Z2_MAX_PIN); SET_INPUT(Z2_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MAX) #if ENABLED(ENDSTOPPULLUP_Z2MAX)
WRITE(Z2_MAX_PIN,HIGH); WRITE(Z2_MAX_PIN, HIGH);
#endif #endif
#endif #endif
#if HAS(Z_PROBE) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used. #if HAS(Z_PROBE) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
SET_INPUT(Z_PROBE_PIN); SET_INPUT(Z_PROBE_PIN);
#if ENABLED(ENDSTOPPULLUP_ZPROBE) #if ENABLED(ENDSTOPPULLUP_ZPROBE)
WRITE(Z_PROBE_PIN,HIGH); WRITE(Z_PROBE_PIN, HIGH);
#endif #endif
#endif #endif
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
*/ */
enum AxisEnum {X_AXIS=0, A_AXIS=0, Y_AXIS=1, B_AXIS=1, Z_AXIS=2, C_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5, Z_HEAD=5}; enum AxisEnum {X_AXIS=0, A_AXIS=0, Y_AXIS=1, B_AXIS=1, Z_AXIS=2, C_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5, Z_HEAD=5};
enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=6, Z2_MIN=7, Z2_MAX=8}; enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=6, Z2_MIN=7, Z2_MAX=8, E_MIN=9};
#if DRIVER_EXTRUDERS > 3 #if DRIVER_EXTRUDERS > 3
#define E_STEP_WRITE(v) { if(current_block->active_driver == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_driver == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}} #define E_STEP_WRITE(v) { if(current_block->active_driver == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_driver == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
...@@ -116,11 +116,11 @@ void microstep_readings(); ...@@ -116,11 +116,11 @@ void microstep_readings();
#endif #endif
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention void babystep(const uint8_t axis, const bool direction); // perform a short step with a single stepper motor, outside of any convention
#endif #endif
#if ENABLED(NPR2) // Multiextruder #if ENABLED(NPR2) // Multiextruder
void colorstep(long csteps,const bool direction); void colorstep(long csteps, const bool direction);
#endif #endif
#endif // STEPPER_H #endif // STEPPER_H
This diff is collapsed.
This diff is collapsed.
#ifndef ULTRALCD_H #ifndef ULTRALCD_H
#define ULTRALCD_H #define ULTRALCD_H
#include "Marlin_main.h"
#if ENABLED(ULTRA_LCD) #if ENABLED(ULTRA_LCD)
int lcd_strlen(char *s); #include "buzzer.h"
int lcd_strlen_P(const char *s);
int lcd_strlen(char* s);
int lcd_strlen_P(const char* s);
void lcd_update(); void lcd_update();
void lcd_init(); void lcd_init();
bool lcd_hasstatus(); bool lcd_hasstatus();
...@@ -109,33 +112,35 @@ ...@@ -109,33 +112,35 @@
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST)) #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#endif//NEWPANEL #endif//NEWPANEL
char *itostr2(const uint8_t &x); char* itostr2(const uint8_t& x);
char *itostr31(const int &xx); char* itostr31(const int& xx);
char *itostr3(const int &xx); char* itostr3(const int& xx);
char *itostr3left(const int &xx); char* itostr3left(const int& xx);
char *itostr4(const int &xx); char* itostr4(const int& xx);
char* itostr4sign(const int& x);
char *ltostr7(const long &xx);
char* ltostr7(const long& xx);
char *ftostr3(const float &x);
char *ftostr30(const float &x); char* ftostr3(const float& x);
char *ftostr31ns(const float &x); // float to string without sign character char* ftostr4sign(const float& x);
char *ftostr31(const float &x); char* ftostr30(const float& x);
char *ftostr32(const float &x); char* ftostr31ns(const float& x); // float to string without sign character
char *ftostr43(const float &x); char* ftostr31(const float& x);
char *ftostr12ns(const float &x); char* ftostr32(const float& x);
char *ftostr32sp(const float &x); // remove zero-padding from ftostr32 char* ftostr43(const float& x);
char *ftostr5(const float &x); char* ftostr12ns(const float& x);
char *ftostr51(const float &x); char* ftostr32sp(const float& x); // remove zero-padding from ftostr32
char *ftostr52(const float &x); char* ftostr5(const float& x);
char* ftostr51(const float& x);
char* ftostr52(const float& x);
#elif DISABLED(NEXTION) #elif DISABLED(NEXTION)
FORCE_INLINE void lcd_update() {} FORCE_INLINE void lcd_update() {}
FORCE_INLINE void lcd_init() {} FORCE_INLINE void lcd_init() {}
FORCE_INLINE bool lcd_hasstatus() { return false; } FORCE_INLINE bool lcd_hasstatus() { return false; }
FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {} FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {UNUSED(message); UNUSED(persist);}
FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {} FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {UNUSED(message); UNUSED(level);}
FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_buttons_update() {}
FORCE_INLINE void lcd_reset_alert_level() {} FORCE_INLINE void lcd_reset_alert_level() {}
FORCE_INLINE bool lcd_detected(void) { return true; } FORCE_INLINE bool lcd_detected(void) { return true; }
......
...@@ -19,10 +19,9 @@ ...@@ -19,10 +19,9 @@
#include <U8glib.h> #include <U8glib.h>
static void ST7920_SWSPI_SND_8BIT(uint8_t val) static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
{
uint8_t i; uint8_t i;
for( i = 0; i < 8; i++ ) { for (i = 0; i < 8; i++) {
WRITE(ST7920_CLK_PIN,0); WRITE(ST7920_CLK_PIN,0);
#if F_CPU == 20000000 #if F_CPU == 20000000
__asm__("nop\n\t"); __asm__("nop\n\t");
...@@ -43,16 +42,13 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) ...@@ -43,16 +42,13 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val)
#define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();} #define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();}
#define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();} #define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();}
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
{ uint8_t i, y;
uint8_t i,y; switch (msg) {
switch(msg) case U8G_DEV_MSG_INIT: {
{ OUT_WRITE(ST7920_CS_PIN, LOW);
case U8G_DEV_MSG_INIT: OUT_WRITE(ST7920_DAT_PIN, LOW);
{ OUT_WRITE(ST7920_CLK_PIN, HIGH);
OUT_WRITE(ST7920_CS_PIN,LOW);
OUT_WRITE(ST7920_DAT_PIN,LOW);
OUT_WRITE(ST7920_CLK_PIN,HIGH);
ST7920_CS(); ST7920_CS();
u8g_Delay(120); //initial delay for boot up u8g_Delay(120); //initial delay for boot up
...@@ -61,12 +57,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo ...@@ -61,12 +57,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
for(y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) //clear GDRAM for (y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) { //clear GDRAM
{ ST7920_WRITE_BYTE(0x80 | y); //set y
ST7920_WRITE_BYTE(0x80|y); //set y
ST7920_WRITE_BYTE(0x80); //set x = 0 ST7920_WRITE_BYTE(0x80); //set x = 0
ST7920_SET_DAT(); ST7920_SET_DAT();
for(i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments for (i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments
ST7920_WRITE_BYTE(0); ST7920_WRITE_BYTE(0);
ST7920_SET_CMD(); ST7920_SET_CMD();
} }
...@@ -74,33 +69,27 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo ...@@ -74,33 +69,27 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_NCS(); ST7920_NCS();
} }
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{ uint8_t* ptr;
uint8_t *ptr; u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem);
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
y = pb->p.page_y0; y = pb->p.page_y0;
ptr = (uint8_t*)pb->buf; ptr = (uint8_t*)pb->buf;
ST7920_CS(); ST7920_CS();
for( i = 0; i < PAGE_HEIGHT; i ++ ) for (i = 0; i < PAGE_HEIGHT; i ++) {
{
ST7920_SET_CMD(); ST7920_SET_CMD();
if ( y < 32 ) if (y < 32) {
{
ST7920_WRITE_BYTE(0x80 | y); //y ST7920_WRITE_BYTE(0x80 | y); //y
ST7920_WRITE_BYTE(0x80); //x=0 ST7920_WRITE_BYTE(0x80); //x=0
} }
else else {
{ ST7920_WRITE_BYTE(0x80 | (y - 32)); //y
ST7920_WRITE_BYTE(0x80 | (y-32)); //y
ST7920_WRITE_BYTE(0x80 | 8); //x=64 ST7920_WRITE_BYTE(0x80 | 8); //x=64
} }
ST7920_SET_DAT(); ST7920_SET_DAT();
ST7920_WRITE_BYTES(ptr,LCD_PIXEL_WIDTH/8); //ptr is incremented inside of macro ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
y++; y++;
} }
ST7920_NCS(); ST7920_NCS();
...@@ -116,12 +105,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo ...@@ -116,12 +105,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
#endif #endif
} }
uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH*(PAGE_HEIGHT/8)] U8G_NOCOMMON; uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH * (PAGE_HEIGHT / 8)] U8G_NOCOMMON;
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT,LCD_PIXEL_HEIGHT,0,0,0},LCD_PIXEL_WIDTH,u8g_dev_st7920_128x64_rrd_buf}; u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn,&u8g_dev_st7920_128x64_rrd_pb,&u8g_com_null_fn}; u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};
class U8GLIB_ST7920_128X64_RRD : public U8GLIB class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
{
public: public:
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {} U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
}; };
......
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
#elif ENABLED(DISPLAY_CHARSET_HD44780_WESTERN) #elif ENABLED(DISPLAY_CHARSET_HD44780_WESTERN)
#if ENABLED(MAPPER_C2C3) #if ENABLED(MAPPER_C2C3)
:
const PROGMEM uint8_t utf_recode[] = const PROGMEM uint8_t utf_recode[] =
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is relative complete. { // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is relative complete.
0x20,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0x22,0xa9,0xaa,0xab,0x3f,0x3f,0xae,0x3f, // c2a ¡¢£¤¥¦§¨©ª«¬­®¯ 0x20,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0x22,0xa9,0xaa,0xab,0x3f,0x3f,0xae,0x3f, // c2a ¡¢£¤¥¦§¨©ª«¬­®¯
...@@ -122,14 +121,17 @@ ...@@ -122,14 +121,17 @@
#endif // SIMULATE_ROMFONT #endif // SIMULATE_ROMFONT
#if ENABLED(MAPPER_NON) #if ENABLED(MAPPER_NON)
char charset_mapper(char c){
char charset_mapper(char c) {
HARDWARE_CHAR_OUT( c ); HARDWARE_CHAR_OUT( c );
return 1; return 1;
} }
#elif ENABLED(MAPPER_C2C3) #elif ENABLED(MAPPER_C2C3)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_c2 = false; char charset_mapper(char c) {
char charset_mapper(char c){ static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_c2 = false;
uint8_t d = c; uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling if ( d >= 0x80 ) { // UTF-8 handling
if ( (d >= 0xc0) && (!seen_c2) ) { if ( (d >= 0xc0) && (!seen_c2) ) {
...@@ -137,12 +139,12 @@ ...@@ -137,12 +139,12 @@
seen_c2 = true; seen_c2 = true;
return 0; return 0;
} }
else if (seen_c2){ else if (seen_c2) {
d &= 0x3f; d &= 0x3f;
#if DISABLED(MAPPER_ONE_TO_ONE) #if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) ); HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else #else
HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d) ) ; HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
#endif #endif
} }
else { else {
...@@ -155,96 +157,116 @@ ...@@ -155,96 +157,116 @@
seen_c2 = false; seen_c2 = false;
return 1; return 1;
} }
#elif ENABLED(MAPPER_D0D1_MOD) #elif ENABLED(MAPPER_D0D1_MOD)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false; char charset_mapper(char c) {
char charset_mapper(char c){
// it is a Russian alphabet translation // it is a Russian alphabet translation
// except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё // except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_d5 = false;
uint8_t d = c; uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling if (d >= 0x80) { // UTF-8 handling
if ((d >= 0xd0) && (!seen_d5)) { if (d >= 0xd0 && !seen_d5) {
utf_hi_char = d - 0xd0; utf_hi_char = d - 0xd0;
seen_d5 = true; seen_d5 = true;
return 0; return 0;
} else if (seen_d5) { }
else if (seen_d5) {
d &= 0x3f; d &= 0x3f;
if ( !utf_hi_char && ( d == 1 )) { if (!utf_hi_char && d == 1) {
HARDWARE_CHAR_OUT((char) 0xa2 ); // Ё HARDWARE_CHAR_OUT((char) 0xa2); // Ё
} else if ((utf_hi_char == 1) && (d == 0x11)) { }
HARDWARE_CHAR_OUT((char) 0xb5 ); // ё else if (utf_hi_char == 1 && d == 0x11) {
} else { HARDWARE_CHAR_OUT((char)0xb5); // ё
HARDWARE_CHAR_OUT((char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x10 ) ); }
else {
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x10));
} }
} }
else { else {
HARDWARE_CHAR_OUT('?'); HARDWARE_CHAR_OUT('?');
} }
} else { }
else {
HARDWARE_CHAR_OUT((char) c ); HARDWARE_CHAR_OUT((char) c );
} }
seen_d5 = false; seen_d5 = false;
return 1; return 1;
} }
#elif ENABLED(MAPPER_D0D1) #elif ENABLED(MAPPER_D0D1)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false; char charset_mapper(char c) {
char charset_mapper(char c){ static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_d5 = false;
uint8_t d = c; uint8_t d = c;
if ( d >= 0x80u ) { // UTF-8 handling if (d >= 0x80u) { // UTF-8 handling
if ((d >= 0xd0u) && (!seen_d5)) { if (d >= 0xd0u && !seen_d5) {
utf_hi_char = d - 0xd0u; utf_hi_char = d - 0xd0u;
seen_d5 = true; seen_d5 = true;
return 0; return 0;
} else if (seen_d5) { }
else if (seen_d5) {
d &= 0x3fu; d &= 0x3fu;
#if DISABLED(MAPPER_ONE_TO_ONE) #if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) ); HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else #else
HARDWARE_CHAR_OUT( (char) (0xa0u + ( utf_hi_char << 6 ) + d ) ) ; HARDWARE_CHAR_OUT((char)(0xa0u + (utf_hi_char << 6) + d)) ;
#endif #endif
} else { }
else {
HARDWARE_CHAR_OUT('?'); HARDWARE_CHAR_OUT('?');
} }
} else { }
else {
HARDWARE_CHAR_OUT((char) c ); HARDWARE_CHAR_OUT((char) c );
} }
seen_d5 = false; seen_d5 = false;
return 1; return 1;
} }
#elif ENABLED(MAPPER_E382E383) #elif ENABLED(MAPPER_E382E383)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_e3 = false; char charset_mapper(char c) {
bool seen_82_83 = false; static uint8_t utf_hi_char; // UTF-8 high part
char charset_mapper(char c){ static bool seen_e3 = false;
static bool seen_82_83 = false;
uint8_t d = c; uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling if (d >= 0x80) { // UTF-8 handling
if ( (d == 0xe3) && (seen_e3 == false)) { if (d == 0xe3 && !seen_e3) {
seen_e3 = true; seen_e3 = true;
return 0; // eat 0xe3 return 0; // eat 0xe3
} else if ( (d >= 0x82) && (seen_e3 == true) && (seen_82_83 == false)) { }
else if (d >= 0x82 && seen_e3 && !seen_82_83) {
utf_hi_char = d - 0x82; utf_hi_char = d - 0x82;
seen_82_83 = true; seen_82_83 = true;
return 0; return 0;
} else if ((seen_e3 == true) && (seen_82_83 == true)){ }
else if (seen_e3 && seen_82_83) {
d &= 0x3f; d &= 0x3f;
#if DISABLED(MAPPER_ONE_TO_ONE) #if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) ); HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else #else
HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d ) ) ; HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
#endif #endif
} else { }
else {
HARDWARE_CHAR_OUT((char) '?' ); HARDWARE_CHAR_OUT((char) '?' );
} }
} else { }
else {
HARDWARE_CHAR_OUT((char) c ); HARDWARE_CHAR_OUT((char) c );
} }
seen_e3 = false; seen_e3 = false;
seen_82_83 = false; seen_82_83 = false;
return 1; return 1;
} }
#else #else
#error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file" // should not occur because (en) will set. #error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file" // should not occur because (en) will set.
#endif // code mappers #endif // code mappers
#endif // UTF_MAPPER_H #endif // UTF_MAPPER_H
...@@ -51,9 +51,9 @@ void vector_3::normalize() { ...@@ -51,9 +51,9 @@ void vector_3::normalize() {
} }
void vector_3::apply_rotation(matrix_3x3 matrix) { void vector_3::apply_rotation(matrix_3x3 matrix) {
float resultX = x * matrix.matrix[3*0+0] + y * matrix.matrix[3*1+0] + z * matrix.matrix[3*2+0]; float resultX = x * matrix.matrix[3 * 0 + 0] + y * matrix.matrix[3 * 1 + 0] + z * matrix.matrix[3 * 2 + 0];
float resultY = x * matrix.matrix[3*0+1] + y * matrix.matrix[3*1+1] + z * matrix.matrix[3*2+1]; float resultY = x * matrix.matrix[3 * 0 + 1] + y * matrix.matrix[3 * 1 + 1] + z * matrix.matrix[3 * 2 + 1];
float resultZ = x * matrix.matrix[3*0+2] + y * matrix.matrix[3*1+2] + z * matrix.matrix[3*2+2]; float resultZ = x * matrix.matrix[3 * 0 + 2] + y * matrix.matrix[3 * 1 + 2] + z * matrix.matrix[3 * 2 + 2];
x = resultX; x = resultX;
y = resultY; y = resultY;
z = resultZ; z = resultZ;
...@@ -66,7 +66,7 @@ void vector_3::debug(const char title[]) { ...@@ -66,7 +66,7 @@ void vector_3::debug(const char title[]) {
ECHO_EMV(" z: ", z, 6); ECHO_EMV(" z: ", z, 6);
} }
void apply_rotation_xyz(matrix_3x3 matrix, float &x, float& y, float& z) { void apply_rotation_xyz(matrix_3x3 matrix, float& x, float& y, float& z) {
vector_3 vector = vector_3(x, y, z); vector_3 vector = vector_3(x, y, z);
vector.apply_rotation(matrix); vector.apply_rotation(matrix);
x = vector.x; x = vector.x;
...@@ -94,7 +94,7 @@ void matrix_3x3::set_to_identity() { ...@@ -94,7 +94,7 @@ void matrix_3x3::set_to_identity() {
matrix_3x3 matrix_3x3::create_look_at(vector_3 target) { matrix_3x3 matrix_3x3::create_look_at(vector_3 target) {
vector_3 z_row = target.get_normal(); vector_3 z_row = target.get_normal();
vector_3 x_row = vector_3(1, 0, -target.x/target.z).get_normal(); vector_3 x_row = vector_3(1, 0, -target.x / target.z).get_normal();
vector_3 y_row = vector_3::cross(z_row, x_row).get_normal(); vector_3 y_row = vector_3::cross(z_row, x_row).get_normal();
// x_row.debug("x_row"); // x_row.debug("x_row");
...@@ -119,9 +119,9 @@ matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { ...@@ -119,9 +119,9 @@ matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) {
void matrix_3x3::debug(const char title[]) { void matrix_3x3::debug(const char title[]) {
ECHO_LV(DB, title); ECHO_LV(DB, title);
int count = 0; int count = 0;
for(int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
ECHO_S(DB); ECHO_S(DB);
for(int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
if (matrix[count] >= 0.0) ECHO_C('+'); if (matrix[count] >= 0.0) ECHO_C('+');
ECHO_V(matrix[count], 6); ECHO_V(matrix[count], 6);
ECHO_C(' '); ECHO_C(' ');
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#ifndef VECTOR_3_H #ifndef VECTOR_3_H
#define VECTOR_3_H #define VECTOR_3_H
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
class matrix_3x3; class matrix_3x3;
struct vector_3 struct vector_3 {
{
float x, y, z; float x, y, z;
vector_3(); vector_3();
...@@ -41,8 +41,7 @@ struct vector_3 ...@@ -41,8 +41,7 @@ struct vector_3
void apply_rotation(matrix_3x3 matrix); void apply_rotation(matrix_3x3 matrix);
}; };
struct matrix_3x3 struct matrix_3x3 {
{
float matrix[9]; float matrix[9];
static matrix_3x3 create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2); static matrix_3x3 create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2);
...@@ -55,6 +54,7 @@ struct matrix_3x3 ...@@ -55,6 +54,7 @@ struct matrix_3x3
}; };
void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float& y, float& z); void apply_rotation_xyz(matrix_3x3 rotationMatrix, float& x, float& y, float& z);
#endif // AUTO_BED_LEVELING_FEATURE
#endif // VECTOR_3_H #endif // VECTOR_3_H
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