Commit 5ee63302 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent 78a42efa
......@@ -7,7 +7,7 @@
* @date 2015/8/13
*
* @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
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
......
/**
* @file NexDualStateButton.cpp
*
* The implementation of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexDualStateButton.h"
NexDSButton::NexDSButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
bool NexDSButton::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexDSButton::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* @file NexDualStateButton.h
*
* The definition of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
*
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXDSBUTTON_H__
#define __NEXDSBUTTON_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexDSButton component.
*
* Commonly, you want to do something after push and pop it. It is recommanded that only
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/
class NexDSButton: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexDSButton(uint8_t pid, uint8_t cid, const char *name);
/**
* Get number attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
bool getValue(uint32_t *number);
/**
* Set number attribute of component.
*
* @param buffer - number buffer.
* @return true if success, false for failure.
*/
bool setValue(uint32_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXDSBUTTON_H__ */
......@@ -25,7 +25,7 @@
*/
/**
* 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
#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_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) {
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#if ENABLED(LCD_USE_I2C_BUZZER)
#if ENABLED(LCD_USE_I2C_BUZZER)
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);
#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
unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000;
......@@ -19,15 +19,17 @@ void buzz(long duration, uint16_t freq) {
WRITE(BEEPER_PIN, LOW);
delayMicroseconds(delay);
}
#else // buzzer has its own resonator - needs a DC
#else // buzzer has its own resonator - needs a DC
WRITE(BEEPER_PIN, HIGH);
delay(duration);
WRITE(BEEPER_PIN, LOW);
#endif
#else
#endif
#else
delay(duration);
#endif
} else
#endif
}
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
#if SDPOWER > -1
OUT_WRITE(SDPOWER, HIGH);
#endif //SDPOWER
#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,14 +91,19 @@ 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++;
......@@ -102,7 +117,8 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma
createFilename(filename, p);
if (match != NULL) {
if (strcasecmp(match, filename) == 0) return;
} else if (cnt == nrFiles) return;
}
else if (cnt == nrFiles) return;
cnt++;
break;
}
......@@ -118,27 +134,38 @@ 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) {
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 : "???");
......@@ -152,35 +179,43 @@ void CardReader::printLongPath(char* path) {
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)
#if ENABLED(SDEXTRASLOW)
#define SPI_SPEED SPI_QUARTER_SPEED
#elif ENABLED(SDSLOW)
#elif ENABLED(SDSLOW)
#define SPI_SPEED SPI_HALF_SPEED
#else
#else
#define SPI_SPEED SPI_FULL_SPEED
#endif
#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.
......@@ -26,7 +26,7 @@
// 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
......@@ -66,8 +66,8 @@ 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
......@@ -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];
......@@ -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;
......@@ -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;
}
else {
step_rate = acc_step_rate - step_rate; // Decelerate from acceleration end point.
if (step_rate <= acc_step_rate) { // Still decelerating?
step_rate = acc_step_rate - step_rate;
NOLESS(step_rate, current_block->final_rate);
}
// 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();
......@@ -109,33 +112,35 @@
#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,10 +19,9 @@
#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");
......@@ -43,16 +42,13 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val)
#define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();}
#define ST7920_WRITE_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);
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
......@@ -61,12 +57,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
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
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
for (i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments
ST7920_WRITE_BYTE(0);
ST7920_SET_CMD();
}
......@@ -74,33 +69,27 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
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);
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 ++ )
{
for (i = 0; i < PAGE_HEIGHT; i ++) {
ST7920_SET_CMD();
if ( y < 32 )
{
if (y < 32) {
ST7920_WRITE_BYTE(0x80 | y); //y
ST7920_WRITE_BYTE(0x80); //x=0
}
else
{
ST7920_WRITE_BYTE(0x80 | (y-32)); //y
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
ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
y++;
}
ST7920_NCS();
......@@ -116,12 +105,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
#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
{
class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
public:
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
};
......
......@@ -55,7 +55,6 @@
#elif ENABLED(DISPLAY_CHARSET_HD44780_WESTERN)
#if ENABLED(MAPPER_C2C3)
:
const PROGMEM uint8_t utf_recode[] =
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is relative complete.
0x20,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0x22,0xa9,0xaa,0xab,0x3f,0x3f,0xae,0x3f, // c2a ¡¢£¤¥¦§¨©ª«¬­®¯
......@@ -122,14 +121,17 @@
#endif // SIMULATE_ROMFONT
#if ENABLED(MAPPER_NON)
char charset_mapper(char c){
char charset_mapper(char c) {
HARDWARE_CHAR_OUT( c );
return 1;
}
#elif ENABLED(MAPPER_C2C3)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_c2 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_c2 = false;
uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling
if ( (d >= 0xc0) && (!seen_c2) ) {
......@@ -137,12 +139,12 @@
seen_c2 = true;
return 0;
}
else if (seen_c2){
else if (seen_c2) {
d &= 0x3f;
#if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else
HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d) ) ;
HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
#endif
}
else {
......@@ -155,96 +157,116 @@
seen_c2 = false;
return 1;
}
#elif ENABLED(MAPPER_D0D1_MOD)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
// it is a Russian alphabet translation
// except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_d5 = false;
uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling
if ((d >= 0xd0) && (!seen_d5)) {
if (d >= 0x80) { // UTF-8 handling
if (d >= 0xd0 && !seen_d5) {
utf_hi_char = d - 0xd0;
seen_d5 = true;
return 0;
} else if (seen_d5) {
}
else if (seen_d5) {
d &= 0x3f;
if ( !utf_hi_char && ( d == 1 )) {
HARDWARE_CHAR_OUT((char) 0xa2 ); // Ё
} else if ((utf_hi_char == 1) && (d == 0x11)) {
HARDWARE_CHAR_OUT((char) 0xb5 ); // ё
} else {
HARDWARE_CHAR_OUT((char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x10 ) );
if (!utf_hi_char && d == 1) {
HARDWARE_CHAR_OUT((char) 0xa2); // Ё
}
else if (utf_hi_char == 1 && d == 0x11) {
HARDWARE_CHAR_OUT((char)0xb5); // ё
}
else {
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x10));
}
}
else {
HARDWARE_CHAR_OUT('?');
}
} else {
}
else {
HARDWARE_CHAR_OUT((char) c );
}
seen_d5 = false;
return 1;
}
#elif ENABLED(MAPPER_D0D1)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_d5 = false;
uint8_t d = c;
if ( d >= 0x80u ) { // UTF-8 handling
if ((d >= 0xd0u) && (!seen_d5)) {
if (d >= 0x80u) { // UTF-8 handling
if (d >= 0xd0u && !seen_d5) {
utf_hi_char = d - 0xd0u;
seen_d5 = true;
return 0;
} else if (seen_d5) {
}
else if (seen_d5) {
d &= 0x3fu;
#if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else
HARDWARE_CHAR_OUT( (char) (0xa0u + ( utf_hi_char << 6 ) + d ) ) ;
HARDWARE_CHAR_OUT((char)(0xa0u + (utf_hi_char << 6) + d)) ;
#endif
} else {
}
else {
HARDWARE_CHAR_OUT('?');
}
} else {
}
else {
HARDWARE_CHAR_OUT((char) c );
}
seen_d5 = false;
return 1;
}
#elif ENABLED(MAPPER_E382E383)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_e3 = false;
bool seen_82_83 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_e3 = false;
static bool seen_82_83 = false;
uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling
if ( (d == 0xe3) && (seen_e3 == false)) {
if (d >= 0x80) { // UTF-8 handling
if (d == 0xe3 && !seen_e3) {
seen_e3 = true;
return 0; // eat 0xe3
} else if ( (d >= 0x82) && (seen_e3 == true) && (seen_82_83 == false)) {
}
else if (d >= 0x82 && seen_e3 && !seen_82_83) {
utf_hi_char = d - 0x82;
seen_82_83 = true;
return 0;
} else if ((seen_e3 == true) && (seen_82_83 == true)){
}
else if (seen_e3 && seen_82_83) {
d &= 0x3f;
#if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else
HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d ) ) ;
HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
#endif
} else {
}
else {
HARDWARE_CHAR_OUT((char) '?' );
}
} else {
}
else {
HARDWARE_CHAR_OUT((char) c );
}
seen_e3 = false;
seen_82_83 = false;
return 1;
}
#else
#error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file" // should not occur because (en) will set.
#endif // code mappers
#endif // UTF_MAPPER_H
......@@ -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;
......@@ -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");
......@@ -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,10 +19,10 @@
#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();
......@@ -41,8 +41,7 @@ struct vector_3
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