Commit 5ee63302 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent 78a42efa
/** /**
* @file NexButton.h * @file NexButton.h
* *
* The definition of class NexButton. * The definition of class NexButton.
* *
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>) * @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @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
...@@ -20,17 +20,17 @@ ...@@ -20,17 +20,17 @@
#include "NexTouch.h" #include "NexTouch.h"
#include "NexHardware.h" #include "NexHardware.h"
/** /**
* @addtogroup Component * @addtogroup Component
* @{ * @{
*/ */
/** /**
* NexButton component. * NexButton component.
* *
* Commonly, you want to do something after push and pop it. It is recommanded that only * Commonly, you want to do something after push and pop it. It is recommanded that only
* call @ref NexTouch::attachPop to satisfy your purpose. * call @ref NexTouch::attachPop to satisfy your purpose.
* *
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can. * @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/ */
class NexButton: public NexTouch class NexButton: public NexTouch
{ {
...@@ -44,19 +44,19 @@ public: /* methods */ ...@@ -44,19 +44,19 @@ public: /* methods */
/** /**
* Get text attribute of component. * Get text attribute of component.
* *
* @param buffer - buffer storing text returned. * @param buffer - buffer storing text returned.
* @param len - length of buffer. * @param len - length of buffer.
* @return The real length of text returned. * @return The real length of text returned.
*/ */
uint16_t getText(char *buffer, uint16_t len); uint16_t getText(char *buffer, uint16_t len);
/** /**
* Set text attribute of component. * Set text attribute of component.
* *
* @param buffer - text buffer terminated with '\0'. * @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure. * @return true if success, false for failure.
*/ */
bool setText(const char *buffer); bool setText(const char *buffer);
}; };
/** /**
* @} * @}
......
/**
* @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;
while (i--) { while (i--) {
WRITE(BEEPER_PIN, HIGH); WRITE(BEEPER_PIN, HIGH);
delayMicroseconds(delay); delayMicroseconds(delay);
WRITE(BEEPER_PIN, LOW); WRITE(BEEPER_PIN, LOW);
delayMicroseconds(delay); delayMicroseconds(delay);
}
#else // buzzer has its own resonator - needs a DC
WRITE(BEEPER_PIN, HIGH);
delay(duration);
WRITE(BEEPER_PIN, LOW);
#endif
#else
delay(duration);
#endif
} }
#else // buzzer has its own resonator - needs a DC else {
WRITE(BEEPER_PIN, HIGH); delay(duration);
delay(duration); }
WRITE(BEEPER_PIN, LOW); }
#endif
#else
delay(duration);
#endif
} else
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,30 +91,36 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma ...@@ -81,30 +91,36 @@ 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++;
break; break;
case LS_SerialPrint: case LS_SerialPrint:
createFilename(filename, p); createFilename(filename, p);
ECHO_V(prepend); ECHO_V(prepend);
ECHO_EV(filename); ECHO_EV(filename);
break; break;
case LS_GetFilename: case LS_GetFilename:
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; }
cnt++; else if (cnt == nrFiles) return;
break; cnt++;
break;
} }
} }
} // while readDir } // while readDir
...@@ -118,69 +134,88 @@ void CardReader::ls() { ...@@ -118,69 +134,88 @@ 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);
// ECHO_M("Full Path: "); ECHO_EV(path); int i, pathLen = strlen(path);
// Zero out slashes to make segments
for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0'; // ECHO_M("Full Path: "); ECHO_EV(path);
SdFile diveDir = root; // start from the root for segment 1
for (i = 0; i < pathLen;) { // Zero out slashes to make segments
if (path[i] == '\0') i++; // move past a single nul for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
char* segment = &path[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit SdFile diveDir = root; // start from the root for segment 1
if (!*segment) break; for (i = 0; i < pathLen;) {
// Go to the next segment
while (path[++i]) { } if (path[i] == '\0') i++; // move past a single nul
// ECHO_M("Looking for segment: "); ECHO_EV(segment);
// Find the item, setting the long filename char* segment = &path[i]; // The segment after most slashes
diveDir.rewind();
lsDive("", diveDir, segment); // If a segment is empty (extra-slash) then exit
// Print /LongNamePart to serial output if (!*segment) break;
ECHO_C('/');
ECHO_V(longFilename[0] ? longFilename : "???"); // Go to the next segment
// If the filename was printed then that's it while (path[++i]) { }
if (!filenameIsDir) break;
// ECHO_M("Opening dir: "); ECHO_EV(segment); // ECHO_M("Looking for segment: "); ECHO_EV(segment);
// Open the sub-item as the new dive parent
SdFile dir; // Find the item, setting the long filename
if (!dir.open(diveDir, segment, O_READ)) { diveDir.rewind();
ECHO_E; lsDive("", diveDir, segment);
ECHO_SMV(DB, MSG_SD_CANT_OPEN_SUBDIR, segment);
break; // Print /LongNamePart to serial output
} ECHO_C('/');
diveDir.close(); ECHO_V(longFilename[0] ? longFilename : "???");
diveDir = dir; // If the filename was printed then that's it
} // while i<pathLen if (!filenameIsDir) break;
ECHO_E; // ECHO_M("Opening dir: "); ECHO_EV(segment);
} // Open the sub-item as the new dive parent
SdFile dir;
if (!dir.open(diveDir, segment, O_READ)) {
ECHO_E;
ECHO_SMV(DB, MSG_SD_CANT_OPEN_SUBDIR, segment);
break;
}
diveDir.close();
diveDir = dir;
} // while i<pathLen
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)
#define SPI_SPEED SPI_QUARTER_SPEED #if ENABLED(SDEXTRASLOW)
#elif ENABLED(SDSLOW) #define SPI_SPEED SPI_QUARTER_SPEED
#define SPI_SPEED SPI_HALF_SPEED #elif ENABLED(SDSLOW)
#else #define SPI_SPEED SPI_HALF_SPEED
#define SPI_SPEED SPI_FULL_SPEED #else
#endif #define SPI_SPEED SPI_FULL_SPEED
#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.
...@@ -18,15 +18,15 @@ ...@@ -18,15 +18,15 @@
along with Grbl. If not, see <http://www.gnu.org/licenses/>. along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/ */
// This module is to be considered a sub-module of stepper.c. Please don't include // This module is to be considered a sub-module of stepper.c. Please don't include
// this file from any other module. // this file from any other module.
#ifndef PLANNER_H #ifndef PLANNER_H
#define PLANNER_H #define PLANNER_H
// 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
...@@ -44,7 +44,7 @@ struct beffering{ ...@@ -44,7 +44,7 @@ struct beffering{
// Fields used by the motion planner to manage acceleration // Fields used by the motion planner to manage acceleration
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis
float nominal_speed; // The nominal speed for this block in mm/sec float nominal_speed; // The nominal speed for this block in mm/sec
float entry_speed; // Entry speed at previous-current junction in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec
float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec
float millimeters; // The total travel of this block in mm float millimeters; // The total travel of this block in mm
...@@ -53,8 +53,8 @@ struct beffering{ ...@@ -53,8 +53,8 @@ struct beffering{
unsigned char nominal_length_flag; // Planner flag for nominal speed always reached unsigned char nominal_length_flag; // Planner flag for nominal speed always reached
// Settings for the trapezoid generator // Settings for the trapezoid generator
unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec
unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long initial_rate; // The jerk-adjusted step rate at start of block
unsigned long final_rate; // The minimal rate at exit unsigned long final_rate; // The minimal rate at exit
unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long acceleration_st; // acceleration steps/sec^2
unsigned long fan_speed; unsigned long fan_speed;
...@@ -66,11 +66,11 @@ struct beffering{ ...@@ -66,11 +66,11 @@ 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
void plan_init(); void plan_init();
void check_axes_activity(); void check_axes_activity();
...@@ -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];
...@@ -139,7 +141,7 @@ extern unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS]; ...@@ -139,7 +141,7 @@ extern unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions
extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed
extern volatile unsigned char block_buffer_tail; extern volatile unsigned char block_buffer_tail;
// Returns true if the buffer has a queued block, false otherwise // Returns true if the buffer has a queued block, false otherwise
FORCE_INLINE bool blocks_queued() { return (block_buffer_head != block_buffer_tail); } FORCE_INLINE bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
...@@ -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;
...@@ -277,16 +277,16 @@ void checkHitEndstops() { ...@@ -277,16 +277,16 @@ void checkHitEndstops() {
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZS); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZS);
} }
#if ENABLED(Z_PROBE_ENDSTOP) #if ENABLED(Z_PROBE_ENDSTOP)
if (endstop_hit_bits & BIT(Z_PROBE)) { if (endstop_hit_bits & BIT(Z_PROBE)) {
ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
} }
#endif #endif
#if ENABLED(NPR2) #if ENABLED(NPR2)
if (endstop_hit_bits & BIT(E_MIN)) { if (endstop_hit_bits & BIT(E_MIN)) {
ECHO_MV(MSG_ENDSTOP_E, (float)endstops_trigsteps[E_AXIS] / axis_steps_per_unit[E_AXIS]); ECHO_MV(MSG_ENDSTOP_E, (float)endstops_trigsteps[E_AXIS] / axis_steps_per_unit[E_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ES); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ES);
} }
#endif #endif
ECHO_E; ECHO_E;
...@@ -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 { else
step_rate = acc_step_rate - step_rate; // Decelerate from acceleration end point.
}
// 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();
...@@ -105,37 +108,39 @@ ...@@ -105,37 +108,39 @@
#define B_ST BIT(BL_ST) #define B_ST BIT(BL_ST)
#define EN_B BIT(BLEN_B) #define EN_B BIT(BLEN_B)
#define EN_A BIT(BLEN_A) #define EN_A BIT(BLEN_A)
#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,19 +19,18 @@ ...@@ -19,19 +19,18 @@
#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");
#endif #endif
WRITE(ST7920_DAT_PIN,val&0x80); WRITE(ST7920_DAT_PIN,val&0x80);
val<<=1; val<<=1;
WRITE(ST7920_CLK_PIN,1); WRITE(ST7920_CLK_PIN,1);
#if F_CPU == 20000000 #if F_CPU == 20000000
__asm__("nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t");
#endif #endif
} }
} }
...@@ -43,69 +42,59 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) ...@@ -43,69 +42,59 @@ 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); ST7920_CS();
OUT_WRITE(ST7920_CLK_PIN,HIGH); u8g_Delay(120); //initial delay for boot up
ST7920_SET_CMD();
ST7920_CS(); ST7920_WRITE_BYTE(0x08); //display off, cursor+blink off
u8g_Delay(120); //initial delay for boot up ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
for (y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) { //clear GDRAM
ST7920_WRITE_BYTE(0x80 | y); //set y
ST7920_WRITE_BYTE(0x80); //set x = 0
ST7920_SET_DAT();
for (i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments
ST7920_WRITE_BYTE(0);
ST7920_SET_CMD(); ST7920_SET_CMD();
ST7920_WRITE_BYTE(0x08); //display off, cursor+blink off
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
for(y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) //clear GDRAM
{
ST7920_WRITE_BYTE(0x80|y); //set y
ST7920_WRITE_BYTE(0x80); //set x = 0
ST7920_SET_DAT();
for(i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments
ST7920_WRITE_BYTE(0);
ST7920_SET_CMD();
}
ST7920_WRITE_BYTE(0x0C); //display on, cursor+blink off
ST7920_NCS();
} }
break; ST7920_WRITE_BYTE(0x0C); //display on, cursor+blink off
ST7920_NCS();
}
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();
{ if (y < 32) {
ST7920_SET_CMD(); ST7920_WRITE_BYTE(0x80 | y); //y
if ( y < 32 ) ST7920_WRITE_BYTE(0x80); //x=0
{
ST7920_WRITE_BYTE(0x80 | y); //y
ST7920_WRITE_BYTE(0x80); //x=0
}
else
{
ST7920_WRITE_BYTE(0x80 | (y-32)); //y
ST7920_WRITE_BYTE(0x80 | 8); //x=64
}
ST7920_SET_DAT();
ST7920_WRITE_BYTES(ptr,LCD_PIXEL_WIDTH/8); //ptr is incremented inside of macro
y++;
} }
ST7920_NCS(); else {
ST7920_WRITE_BYTE(0x80 | (y - 32)); //y
ST7920_WRITE_BYTE(0x80 | 8); //x=64
}
ST7920_SET_DAT();
ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
y++;
} }
break; ST7920_NCS();
}
break;
} }
#if PAGE_HEIGHT == 8 #if PAGE_HEIGHT == 8
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg); return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
...@@ -116,14 +105,13 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo ...@@ -116,14 +105,13 @@ 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) {}
}; };
......
This diff is collapsed.
...@@ -28,8 +28,8 @@ vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { } ...@@ -28,8 +28,8 @@ vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }
vector_3 vector_3::cross(vector_3 left, vector_3 right) { vector_3 vector_3::cross(vector_3 left, vector_3 right) {
return vector_3(left.y * right.z - left.z * right.y, return vector_3(left.y * right.z - left.z * right.y,
left.z * right.x - left.x * right.z, left.z * right.x - left.x * right.z,
left.x * right.y - left.y * right.x); left.x * right.y - left.y * right.x);
} }
vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); }
...@@ -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;
...@@ -79,9 +79,9 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 ...@@ -79,9 +79,9 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3
//row_1.debug("row_1"); //row_1.debug("row_1");
//row_2.debug("row_2"); //row_2.debug("row_2");
matrix_3x3 new_matrix; matrix_3x3 new_matrix;
new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z;
new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z;
new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z;
//new_matrix.debug("new_matrix"); //new_matrix.debug("new_matrix");
return new_matrix; return new_matrix;
} }
...@@ -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");
...@@ -110,8 +110,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) { ...@@ -110,8 +110,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) {
matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) {
matrix_3x3 new_matrix; matrix_3x3 new_matrix;
new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6];
new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7];
new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8];
return new_matrix; return new_matrix;
} }
...@@ -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,13 +19,13 @@ ...@@ -19,13 +19,13 @@
#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();
vector_3(float x, float y, float z); vector_3(float x, float y, float z);
static vector_3 cross(vector_3 a, vector_3 b); static vector_3 cross(vector_3 a, vector_3 b);
...@@ -37,12 +37,11 @@ struct vector_3 ...@@ -37,12 +37,11 @@ struct vector_3
vector_3 get_normal(); vector_3 get_normal();
void debug(const char title[]); void debug(const char title[]);
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