Commit 5ee63302 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent 78a42efa
/**
* @file NexButton.h
*
* The definition of class NexButton.
* The definition of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* @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
......@@ -20,17 +20,17 @@
#include "NexTouch.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
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/
class NexButton: public NexTouch
{
......@@ -44,19 +44,19 @@ public: /* methods */
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t getText(char *buffer, uint16_t len);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
* @param buffer - text buffer terminated with '\0'.
* @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 @@
*/
/**
* NexTNumber component.
* NexNumber component.
*/
class NexNumber: public NexTouch
{
......
......@@ -35,6 +35,7 @@
#include "NexTimer.h"
#include "NexNumber.h"
#include "NexVar.h"
#include "NexDualStateButton.h"
#endif /* #ifndef __NEXTION_H__ */
......@@ -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_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 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 @@
#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_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 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 @@
* *
***********************************************************************/
//#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_HOMERATE 4 // FEEDRATE for carter home
#define MOTOR_ANGLE 1.8 // Nema angle for single step
......@@ -674,10 +674,10 @@
* *
**************************************************************************/
//#define BABYSTEPPING
//#define BABYSTEP_XY // not only z, but also XY in the menu. more clutter, more functions
// not implemented for CoreXY and deltabots!
#define BABYSTEP_INVERT_Z false // true for inverse movements in Z
#define BABYSTEP_Z_MULTIPLICATOR 2 // faster z movements
#define BABYSTEP_XY // not only z, but also XY in the menu. more clutter, more functions
// not implemented for CoreXY and deltabots!
#define BABYSTEP_INVERT_Z false // true for inverse movements in Z
#define BABYSTEP_MULTIPLICATOR 2 // faster z movements
/**************************************************************************/
......@@ -1074,13 +1074,13 @@
// The Panucatt Devices Viki 2.0 and mini Viki with Graphic LCD
// 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 miniVIKI
// 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 SD_DETECT_INVERTED
......@@ -1095,7 +1095,7 @@
// The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB)
// 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
// The RepRapWorld REPRAPWORLD_KEYPAD v1.1
......@@ -1113,7 +1113,7 @@
// #define MINIPANEL
// 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
// I2C Panels
......@@ -1132,7 +1132,7 @@
//#define LCD_I2C_VIKI
// 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
// Shift register panels
......
This diff is collapsed.
#include "base.h"
#if HAS(BUZZER)
#include "buzzer.h"
#include "ultralcd.h"
#include "buzzer.h"
#include "ultralcd.h"
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#if ENABLED(LCD_USE_I2C_BUZZER)
lcd_buzz(duration, freq);
#elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition
SET_OUTPUT(BEEPER_PIN);
#if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC
//tone(BEEPER_PIN, freq, duration); // needs a PWMable pin
unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000;
while (i--) {
WRITE(BEEPER_PIN, HIGH);
delayMicroseconds(delay);
WRITE(BEEPER_PIN, LOW);
delayMicroseconds(delay);
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#if ENABLED(LCD_USE_I2C_BUZZER)
lcd_buzz(duration, freq);
#elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition
SET_OUTPUT(BEEPER_PIN);
#if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC
//tone(BEEPER_PIN, freq, duration); // needs a PWMable pin
unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000;
while (i--) {
WRITE(BEEPER_PIN, HIGH);
delayMicroseconds(delay);
WRITE(BEEPER_PIN, LOW);
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
WRITE(BEEPER_PIN, HIGH);
delay(duration);
WRITE(BEEPER_PIN, LOW);
#endif
#else
delay(duration);
#endif
} else
delay(duration);
}
else {
delay(duration);
}
}
#endif
#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() {
workDirDepth = 0;
file_subcall_ctr = 0;
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_index = 0;
//power to SD reader
#if SDPOWER > -1
OUT_WRITE(SDPOWER, HIGH);
#endif //SDPOWER
#if SDPOWER > -1
OUT_WRITE(SDPOWER, HIGH);
#endif // SDPOWER
next_autostart_ms = millis() + SPLASH_SCREEN_DURATION;
}
......@@ -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*/) {
dir_t p;
uint8_t cnt = 0;
// Read the next entry from a directory
while (parent.readDir(p, longFilename) > 0) {
// If the entry is a directory and the action is LS_SerialPrint
if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
// Get the short name for the item, which we know is a folder
char lfilename[FILENAME_LENGTH];
createFilename(lfilename, p);
// Allocate enough stack space for the full path to a folder, trailing slash, and nul
boolean prepend_is_empty = (prepend[0] == '\0');
int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(lfilename) + 1 + 1;
char path[len];
// Append the FOLDERNAME12/ to the passed string.
// It contains the full path to the "parent" argument.
// We now have the full path to the item in this folder.
strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty
strcat(path, lfilename); // FILENAME_LENGTH-1 characters maximum
strcat(path, "/"); // 1 character
// Serial.print(path);
// Get a new directory object using the full path
// and dive recursively into it.
SdFile dir;
......@@ -81,30 +91,36 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma
}
lsDive(path, dir);
// close() is done automatically by destructor of SdFile
} else {
}
else {
char pn0 = p.name[0];
if (pn0 == DIR_NAME_FREE) break;
if (pn0 == DIR_NAME_DELETED || pn0 == '.') continue;
if (longFilename[0] == '.') continue;
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
filenameIsDir = DIR_IS_SUBDIR(&p);
if (!filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue;
switch (lsAction) {
case LS_Count:
nrFiles++;
break;
case LS_SerialPrint:
createFilename(filename, p);
ECHO_V(prepend);
ECHO_EV(filename);
break;
case LS_GetFilename:
createFilename(filename, p);
if (match != NULL) {
if (strcasecmp(match, filename) == 0) return;
} else if (cnt == nrFiles) return;
cnt++;
break;
case LS_Count:
nrFiles++;
break;
case LS_SerialPrint:
createFilename(filename, p);
ECHO_V(prepend);
ECHO_EV(filename);
break;
case LS_GetFilename:
createFilename(filename, p);
if (match != NULL) {
if (strcasecmp(match, filename) == 0) return;
}
else if (cnt == nrFiles) return;
cnt++;
break;
}
}
} // while readDir
......@@ -118,69 +134,88 @@ void CardReader::ls() {
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
/**
* Get a long pretty path based on a DOS 8.3 path
*/
void CardReader::printLongPath(char* path) {
lsAction = LS_GetFilename;
int i, pathLen = strlen(path);
// ECHO_M("Full Path: "); ECHO_EV(path);
// Zero out slashes to make segments
for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
SdFile diveDir = root; // start from the root for segment 1
for (i = 0; i < pathLen;) {
if (path[i] == '\0') i++; // move past a single nul
char* segment = &path[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit
if (!*segment) break;
// Go to the next segment
while (path[++i]) { }
// ECHO_M("Looking for segment: "); ECHO_EV(segment);
// Find the item, setting the long filename
diveDir.rewind();
lsDive("", diveDir, segment);
// Print /LongNamePart to serial output
ECHO_C('/');
ECHO_V(longFilename[0] ? longFilename : "???");
// If the filename was printed then that's it
if (!filenameIsDir) break;
// 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;
}
/**
* Get a long pretty path based on a DOS 8.3 path
*/
void CardReader::printLongPath(char* path) {
lsAction = LS_GetFilename;
int i, pathLen = strlen(path);
// ECHO_M("Full Path: "); ECHO_EV(path);
// Zero out slashes to make segments
for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
SdFile diveDir = root; // start from the root for segment 1
for (i = 0; i < pathLen;) {
if (path[i] == '\0') i++; // move past a single nul
char* segment = &path[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit
if (!*segment) break;
// Go to the next segment
while (path[++i]) { }
// ECHO_M("Looking for segment: "); ECHO_EV(segment);
// Find the item, setting the long filename
diveDir.rewind();
lsDive("", diveDir, segment);
// Print /LongNamePart to serial output
ECHO_C('/');
ECHO_V(longFilename[0] ? longFilename : "???");
// If the filename was printed then that's it
if (!filenameIsDir) break;
// 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
void CardReader::initsd() {
cardOK = false;
if (root.isOpen()) root.close();
#if ENABLED(SDEXTRASLOW)
#define SPI_SPEED SPI_QUARTER_SPEED
#elif ENABLED(SDSLOW)
#define SPI_SPEED SPI_HALF_SPEED
#else
#define SPI_SPEED SPI_FULL_SPEED
#endif
#if ENABLED(SDEXTRASLOW)
#define SPI_SPEED SPI_QUARTER_SPEED
#elif ENABLED(SDSLOW)
#define SPI_SPEED SPI_HALF_SPEED
#else
#define SPI_SPEED SPI_FULL_SPEED
#endif
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)
#endif
#endif
) {
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);
} else if (!root.openRoot(&volume)) {
}
else if (!root.openRoot(&volume)) {
ECHO_LM(ER, MSG_SD_OPENROOT_FAIL);
} else {
}
else {
cardOK = true;
ECHO_LM(DB, MSG_SD_CARD_OK);
}
......
......@@ -29,9 +29,11 @@ void digipot_i2c_set_current(int channel, float current) {
addr = 0x2E; // channel 4-7
channel -= 4;
}
// Initial setup
i2c_send(addr, 0x40, 0xff);
i2c_send(addr, 0xA0, 0xff);
// Set actual wiper value
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
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() {
ECHO_EM(" ");
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) {
ECHO_M("MIN ENDSTOP X: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -72,7 +72,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
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) {
ECHO_M("MAX ENDSTOP X: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -126,7 +126,7 @@ void FirmwareTest() {
ECHO_EM(" ");
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) {
ECHO_M("MIN ENDSTOP Y: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -166,7 +166,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
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) {
ECHO_M("MAX ENDSTOP Y: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -220,7 +220,7 @@ void FirmwareTest() {
ECHO_EM(" ");
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) {
ECHO_M("MIN ENDSTOP Z: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -260,7 +260,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
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) {
ECHO_M("MAX ENDSTOP Z: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......
......@@ -104,7 +104,7 @@
#define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimento"
#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_CONTRAST "Contrasto LCD"
#define MSG_STORE_EPROM "Salva in EEPROM"
......
This diff is collapsed.
......@@ -18,15 +18,15 @@
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.
#ifndef 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.
struct beffering{
typedef struct {
// Fields used by the bresenham algorithm for tracing the line
long steps[NUM_AXIS]; // Step count along each axis
unsigned long step_event_count; // The number of step events required to complete this block
......@@ -44,7 +44,7 @@ struct beffering{
// 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 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 max_entry_speed; // Maximum allowable junction entry speed in mm/sec
float millimeters; // The total travel of this block in mm
......@@ -53,8 +53,8 @@ struct beffering{
unsigned char nominal_length_flag; // Planner flag for nominal speed always reached
// Settings for the trapezoid generator
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 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 final_rate; // The minimal rate at exit
unsigned long acceleration_st; // acceleration steps/sec^2
unsigned long fan_speed;
......@@ -66,11 +66,11 @@ struct beffering{
unsigned long laser_ttlmodulation;
#endif
volatile char busy;
};
typedef struct beffering block_t;
} block_t;
#define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
// Initialize the motion plan subsystem
// Initialize the motion plan subsystem
void plan_init();
void check_axes_activity();
......@@ -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
* 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.
* Multiplies by axis_steps_per_unit[] to set stepper positions.
* 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
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
void plan_set_e_position(const float &e);
void plan_set_e_position(const float& e);
//===========================================================================
//============================= public variables ============================
//===========================================================================
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 unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use M201 to override by software
extern float minimumfeedrate;
extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE 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 travel_acceleration; // Travel acceleration mm/s^2 THIS IS THE 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 acceleration; // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all moves. M204 SXXXX
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 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
extern float max_xy_jerk; // The largest speed change requiring no acceleration
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 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 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
FORCE_INLINE bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
......@@ -152,9 +154,9 @@ FORCE_INLINE void plan_discard_current_block() {
}
// 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()) {
block_t *block = &block_buffer[block_buffer_tail];
block_t* block = &block_buffer[block_buffer_tail];
block->busy = true;
return block;
}
......
......@@ -80,20 +80,20 @@ volatile static unsigned long step_events_completed; // The number of step event
static long acceleration_time, deceleration_time;
//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 char step_loops;
static uint8_t step_loops;
static uint8_t step_loops_nominal;
static unsigned short OCR1A_nominal;
static unsigned short step_loops_nominal;
volatile long endstops_trigsteps[3] = { 0 };
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
#if DISABLED(Z_DUAL_ENDSTOPS)
static byte
#else
#if ENABLED(Z_DUAL_ENDSTOPS) || ENABLED(NPR2)
static uint16_t
#else
static byte
#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)
bool abort_on_endstop_hit = false;
......@@ -277,16 +277,16 @@ void checkHitEndstops() {
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZS);
}
#if ENABLED(Z_PROBE_ENDSTOP)
if (endstop_hit_bits & BIT(Z_PROBE)) {
ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
}
if (endstop_hit_bits & BIT(Z_PROBE)) {
ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
}
#endif
#if ENABLED(NPR2)
if (endstop_hit_bits & BIT(E_MIN)) {
ECHO_MV(MSG_ENDSTOP_E, (float)endstops_trigsteps[E_AXIS] / axis_steps_per_unit[E_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ES);
}
if (endstop_hit_bits & BIT(E_MIN)) {
ECHO_MV(MSG_ENDSTOP_E, (float)endstops_trigsteps[E_AXIS] / axis_steps_per_unit[E_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ES);
}
#endif
ECHO_E;
......@@ -315,7 +315,7 @@ void enable_endstops(bool check) {
// Check endstops
inline void update_endstops() {
#if ENABLED(Z_DUAL_ENDSTOPS)
#if ENABLED(Z_DUAL_ENDSTOPS) || ENABLED(NPR2)
uint16_t
#else
byte
......@@ -478,6 +478,9 @@ inline void update_endstops() {
#if MECH(COREXZ)
}
#endif
#if ENABLED(NPR2)
UPDATE_ENDSTOP(E, MIN);
#endif
old_endstop_bits = current_endstop_bits;
}
......@@ -504,7 +507,8 @@ void st_wake_up() {
FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
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
step_rate = (step_rate >> 2) & 0x3fff;
......@@ -518,8 +522,8 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
step_loops = 1;
}
if (step_rate < (F_CPU / 500000)) step_rate = (F_CPU / 500000);
step_rate -= (F_CPU / 500000); // Correct for minimal speed
NOLESS(step_rate, F_CPU / 500000);
step_rate -= F_CPU / 500000; // Correct for minimal speed
if (step_rate >= (8 * 256)) { // higher step rate
unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate >> 8)][0];
unsigned char tmp_step_rate = (step_rate & 0x00ff);
......@@ -738,8 +742,7 @@ ISR(TIMER1_COMPA_vect) {
acc_step_rate += current_block->initial_rate;
// upper limit
if (acc_step_rate > current_block->nominal_rate)
acc_step_rate = current_block->nominal_rate;
NOMORE(acc_step_rate, current_block->nominal_rate);
// step_rate to timer interval
timer = calc_timer(acc_step_rate);
......@@ -748,10 +751,9 @@ ISR(TIMER1_COMPA_vect) {
#if ENABLED(ADVANCE)
for (int8_t i = 0; i < step_loops; i++) {
advance += advance_rate;
}
// if (advance > current_block->advance) advance = current_block->advance;
advance += advance_rate * step_loops;
//NOLESS(advance, current_block->advance);
// Do E steps + advance steps
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance);
old_advance = advance >> 8;
......@@ -761,29 +763,26 @@ ISR(TIMER1_COMPA_vect) {
else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
if (step_rate > acc_step_rate) { // Check step_rate stays positive
step_rate = current_block->final_rate;
if (step_rate <= acc_step_rate) { // Still decelerating?
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.
}
// lower limit
if (step_rate < current_block->final_rate)
else
step_rate = current_block->final_rate;
// step_rate to timer interval
timer = calc_timer(step_rate);
OCR1A = timer;
deceleration_time += timer;
#if ENABLED(ADVANCE)
for (int8_t i = 0; i < step_loops; i++) {
advance -= advance_rate;
}
if (advance < final_advance) advance = final_advance;
advance -= advance_rate * step_loops;
NOLESS(advance, final_advance);
// Do E steps + advance steps
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance);
old_advance = advance >> 8;
uint32_t advance_whole = advance >> 8;
e_steps[current_block->active_driver] += advance_whole - old_advance;
old_advance = advance_whole;
#endif //ADVANCE
}
else {
......@@ -996,28 +995,28 @@ void st_init() {
#if HAS(X_MIN)
SET_INPUT(X_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_XMIN)
WRITE(X_MIN_PIN,HIGH);
WRITE(X_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Y_MIN)
SET_INPUT(Y_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_YMIN)
WRITE(Y_MIN_PIN,HIGH);
WRITE(Y_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Z_MIN)
SET_INPUT(Z_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMIN)
WRITE(Z_MIN_PIN,HIGH);
WRITE(Z_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Z2_MIN)
SET_INPUT(Z2_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MIN)
WRITE(Z2_MIN_PIN,HIGH);
WRITE(Z2_MIN_PIN, HIGH);
#endif
#endif
......@@ -1031,35 +1030,35 @@ void st_init() {
#if HAS(X_MAX)
SET_INPUT(X_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_XMAX)
WRITE(X_MAX_PIN,HIGH);
WRITE(X_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Y_MAX)
SET_INPUT(Y_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_YMAX)
WRITE(Y_MAX_PIN,HIGH);
WRITE(Y_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Z_MAX)
SET_INPUT(Z_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMAX)
WRITE(Z_MAX_PIN,HIGH);
WRITE(Z_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Z2_MAX)
SET_INPUT(Z2_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MAX)
WRITE(Z2_MAX_PIN,HIGH);
WRITE(Z2_MAX_PIN, HIGH);
#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.
SET_INPUT(Z_PROBE_PIN);
#if ENABLED(ENDSTOPPULLUP_ZPROBE)
WRITE(Z_PROBE_PIN,HIGH);
WRITE(Z_PROBE_PIN, HIGH);
#endif
#endif
......
......@@ -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 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
#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();
#endif
#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
#if ENABLED(NPR2) // Multiextruder
void colorstep(long csteps,const bool direction);
void colorstep(long csteps, const bool direction);
#endif
#endif // STEPPER_H
This diff is collapsed.
This diff is collapsed.
#ifndef ULTRALCD_H
#define ULTRALCD_H
#include "Marlin_main.h"
#if ENABLED(ULTRA_LCD)
int lcd_strlen(char *s);
int lcd_strlen_P(const char *s);
#include "buzzer.h"
int lcd_strlen(char* s);
int lcd_strlen_P(const char* s);
void lcd_update();
void lcd_init();
bool lcd_hasstatus();
......@@ -105,37 +108,39 @@
#define B_ST BIT(BL_ST)
#define EN_B BIT(BLEN_B)
#define EN_A BIT(BLEN_A)
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#endif//NEWPANEL
char *itostr2(const uint8_t &x);
char *itostr31(const int &xx);
char *itostr3(const int &xx);
char *itostr3left(const int &xx);
char *itostr4(const int &xx);
char *ltostr7(const long &xx);
char *ftostr3(const float &x);
char *ftostr30(const float &x);
char *ftostr31ns(const float &x); // float to string without sign character
char *ftostr31(const float &x);
char *ftostr32(const float &x);
char *ftostr43(const float &x);
char *ftostr12ns(const float &x);
char *ftostr32sp(const float &x); // remove zero-padding from ftostr32
char *ftostr5(const float &x);
char *ftostr51(const float &x);
char *ftostr52(const float &x);
char* itostr2(const uint8_t& x);
char* itostr31(const int& xx);
char* itostr3(const int& xx);
char* itostr3left(const int& xx);
char* itostr4(const int& xx);
char* itostr4sign(const int& x);
char* ltostr7(const long& xx);
char* ftostr3(const float& x);
char* ftostr4sign(const float& x);
char* ftostr30(const float& x);
char* ftostr31ns(const float& x); // float to string without sign character
char* ftostr31(const float& x);
char* ftostr32(const float& x);
char* ftostr43(const float& x);
char* ftostr12ns(const float& x);
char* ftostr32sp(const float& x); // remove zero-padding from ftostr32
char* ftostr5(const float& x);
char* ftostr51(const float& x);
char* ftostr52(const float& x);
#elif DISABLED(NEXTION)
FORCE_INLINE void lcd_update() {}
FORCE_INLINE void lcd_init() {}
FORCE_INLINE bool lcd_hasstatus() { return false; }
FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {}
FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {}
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) {UNUSED(message); UNUSED(level);}
FORCE_INLINE void lcd_buttons_update() {}
FORCE_INLINE void lcd_reset_alert_level() {}
FORCE_INLINE bool lcd_detected(void) { return true; }
......
......@@ -19,19 +19,18 @@
#include <U8glib.h>
static void ST7920_SWSPI_SND_8BIT(uint8_t val)
{
static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
uint8_t i;
for( i = 0; i < 8; i++ ) {
for (i = 0; i < 8; i++) {
WRITE(ST7920_CLK_PIN,0);
#if F_CPU == 20000000
__asm__("nop\n\t");
__asm__("nop\n\t");
#endif
WRITE(ST7920_DAT_PIN,val&0x80);
WRITE(ST7920_DAT_PIN,val&0x80);
val<<=1;
WRITE(ST7920_CLK_PIN,1);
#if F_CPU == 20000000
__asm__("nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t");
#endif
}
}
......@@ -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_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 i,y;
switch(msg)
{
case U8G_DEV_MSG_INIT:
{
OUT_WRITE(ST7920_CS_PIN,LOW);
OUT_WRITE(ST7920_DAT_PIN,LOW);
OUT_WRITE(ST7920_CLK_PIN,HIGH);
ST7920_CS();
u8g_Delay(120); //initial delay for boot up
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
uint8_t i, y;
switch (msg) {
case U8G_DEV_MSG_INIT: {
OUT_WRITE(ST7920_CS_PIN, LOW);
OUT_WRITE(ST7920_DAT_PIN, LOW);
OUT_WRITE(ST7920_CLK_PIN, HIGH);
ST7920_CS();
u8g_Delay(120); //initial delay for boot up
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(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:
break;
case U8G_DEV_MSG_PAGE_NEXT:
{
uint8_t *ptr;
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
y = pb->p.page_y0;
ptr = (uint8_t*)pb->buf;
ST7920_CS();
for( i = 0; i < PAGE_HEIGHT; i ++ )
{
ST7920_SET_CMD();
if ( y < 32 )
{
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++;
case U8G_DEV_MSG_PAGE_NEXT: {
uint8_t* ptr;
u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem);
y = pb->p.page_y0;
ptr = (uint8_t*)pb->buf;
ST7920_CS();
for (i = 0; i < PAGE_HEIGHT; i ++) {
ST7920_SET_CMD();
if (y < 32) {
ST7920_WRITE_BYTE(0x80 | y); //y
ST7920_WRITE_BYTE(0x80); //x=0
}
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
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
#endif
}
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_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};
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_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
{
public:
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
public:
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_) { }
vector_3 vector_3::cross(vector_3 left, vector_3 right) {
return vector_3(left.y * right.z - left.z * right.y,
left.z * right.x - left.x * right.z,
left.x * right.y - left.y * right.x);
left.z * right.x - left.x * right.z,
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)); }
......@@ -51,9 +51,9 @@ void vector_3::normalize() {
}
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 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 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 resultZ = x * matrix.matrix[3 * 0 + 2] + y * matrix.matrix[3 * 1 + 2] + z * matrix.matrix[3 * 2 + 2];
x = resultX;
y = resultY;
z = resultZ;
......@@ -66,7 +66,7 @@ void vector_3::debug(const char title[]) {
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.apply_rotation(matrix);
x = vector.x;
......@@ -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_2.debug("row_2");
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[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[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[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z;
//new_matrix.debug("new_matrix");
return new_matrix;
}
......@@ -94,7 +94,7 @@ void matrix_3x3::set_to_identity() {
matrix_3x3 matrix_3x3::create_look_at(vector_3 target) {
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();
// x_row.debug("x_row");
......@@ -110,8 +110,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) {
matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) {
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[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7];
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[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8];
return new_matrix;
}
......@@ -119,9 +119,9 @@ matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) {
void matrix_3x3::debug(const char title[]) {
ECHO_LV(DB, title);
int count = 0;
for(int i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
ECHO_S(DB);
for(int j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) {
if (matrix[count] >= 0.0) ECHO_C('+');
ECHO_V(matrix[count], 6);
ECHO_C(' ');
......
......@@ -19,13 +19,13 @@
#ifndef VECTOR_3_H
#define VECTOR_3_H
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
class matrix_3x3;
struct vector_3
{
struct vector_3 {
float x, y, z;
vector_3();
vector_3();
vector_3(float x, float y, float z);
static vector_3 cross(vector_3 a, vector_3 b);
......@@ -37,12 +37,11 @@ struct vector_3
vector_3 get_normal();
void debug(const char title[]);
void apply_rotation(matrix_3x3 matrix);
};
struct matrix_3x3
{
struct matrix_3x3 {
float matrix[9];
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
};
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
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