Browse Source

Libs updates

pull/1/head
Scott Lahteine 7 years ago
parent
commit
d7ee81202f
  1. 79
      Marlin/src/libs/hex_print_routines.cpp
  2. 14
      Marlin/src/libs/hex_print_routines.h
  3. 7
      Marlin/src/libs/least_squares_fit.cpp
  4. 13
      Marlin/src/libs/least_squares_fit.h
  5. 24
      Marlin/src/libs/nozzle.cpp
  6. 4
      Marlin/src/libs/nozzle.h
  7. 5
      Marlin/src/libs/point_t.h
  8. 2
      Marlin/src/libs/private_spi.h
  9. 2
      Marlin/src/libs/softspi.h
  10. 2
      Marlin/src/libs/stopwatch.cpp
  11. 4
      Marlin/src/libs/stopwatch.h
  12. 7
      Marlin/src/libs/vector_3.cpp
  13. 4
      Marlin/src/libs/vector_3.h

79
Marlin/src/libs/hex_print_routines.cpp

@ -19,37 +19,58 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "Marlin.h"
#include "gcode.h" #include "../inc/MarlinConfig.h"
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER) #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER)
#include "hex_print_routines.h" #include "hex_print_routines.h"
static char _hex[7] = "0x0000"; #ifdef CPU_32_BIT
constexpr int byte_start = 0;
char* hex_byte(const uint8_t b) { static char _hex[] = "0x0000";
_hex[4] = hex_nybble(b >> 4); #else
_hex[5] = hex_nybble(b); constexpr int byte_start = 4;
return &_hex[4]; static char _hex[] = "0x00000000";
} #endif
char* hex_word(const uint16_t w) { char* hex_byte(const uint8_t b) {
_hex[2] = hex_nybble(w >> 12); _hex[byte_start + 4] = hex_nybble(b >> 4);
_hex[3] = hex_nybble(w >> 8); _hex[byte_start + 5] = hex_nybble(b);
_hex[4] = hex_nybble(w >> 4); return &_hex[byte_start];
_hex[5] = hex_nybble(w); }
return &_hex[2];
} char* hex_word(const uint16_t w) {
_hex[byte_start + 2] = hex_nybble(w >> 12);
char* hex_address(const void * const w) { _hex[byte_start + 3] = hex_nybble(w >> 8);
(void)hex_word((int)w); _hex[byte_start + 4] = hex_nybble(w >> 4);
return _hex; _hex[byte_start + 5] = hex_nybble(w);
} return &_hex[byte_start - 2];
}
void print_hex_nybble(const uint8_t n) { SERIAL_CHAR(hex_nybble(n)); }
void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); } #ifdef CPU_32_BIT
void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); } char* hex_long(const uint32_t w) {
void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); } _hex[byte_start - 2] = hex_nybble(w >> 28);
_hex[byte_start - 1] = hex_nybble(w >> 24);
_hex[byte_start + 0] = hex_nybble(w >> 20);
_hex[byte_start + 1] = hex_nybble(w >> 16);
(void)hex_word((uint16_t)(w & 0xFFFF));
return &_hex[byte_start - 6];
}
#endif
char* hex_address(const void * const w) {
#ifdef CPU_32_BIT
(void)hex_long((ptr_int_t)w);
#else
(void)hex_word((ptr_int_t)w);
#endif
return _hex;
}
void print_hex_nybble(const uint8_t n) { SERIAL_CHAR(hex_nybble(n)); }
void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); }
void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); }
void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
#endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER #endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER

14
Marlin/src/libs/hex_print_routines.h

@ -23,16 +23,13 @@
#ifndef HEX_PRINT_ROUTINES_H #ifndef HEX_PRINT_ROUTINES_H
#define HEX_PRINT_ROUTINES_H #define HEX_PRINT_ROUTINES_H
#include "MarlinConfig.h" #include <stdint.h>
#include "gcode.h"
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER)
// //
// Utility functions to create and print hex strings as nybble, byte, and word. // Utility functions to create and print hex strings as nybble, byte, and word.
// //
inline char hex_nybble(const uint8_t n) { FORCE_INLINE char hex_nybble(const uint8_t n) {
return (n & 0xF) + ((n & 0xF) < 10 ? '0' : 'A' - 10); return (n & 0xF) + ((n & 0xF) < 10 ? '0' : 'A' - 10);
} }
char* hex_byte(const uint8_t b); char* hex_byte(const uint8_t b);
@ -44,5 +41,10 @@ void print_hex_byte(const uint8_t b);
void print_hex_word(const uint16_t w); void print_hex_word(const uint16_t w);
void print_hex_address(const void * const w); void print_hex_address(const void * const w);
#endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER #ifdef CPU_32_BIT
typedef uint32_t ptr_int_t;
#else
typedef uint16_t ptr_int_t;
#endif
#endif // HEX_PRINT_ROUTINES_H #endif // HEX_PRINT_ROUTINES_H

7
Marlin/src/libs/least_squares_fit.cpp

@ -32,15 +32,14 @@
* *
*/ */
#include "MarlinConfig.h" #include "../inc/MarlinConfig.h"
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_LINEAR) #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_LINEAR)
#include "macros.h"
#include <math.h>
#include "least_squares_fit.h" #include "least_squares_fit.h"
#include <math.h>
int finish_incremental_LSF(struct linear_fit_data *lsf) { int finish_incremental_LSF(struct linear_fit_data *lsf) {
const float N = lsf->N; const float N = lsf->N;

13
Marlin/src/libs/least_squares_fit.h

@ -32,12 +32,10 @@
* *
*/ */
#include "MarlinConfig.h" #ifndef _LEAST_SQUARES_FIT_H_
#define _LEAST_SQUARES_FIT_H_
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_LINEAR) #include "../inc/MarlinConfig.h"
#include "Marlin.h"
#include "macros.h"
#include <math.h> #include <math.h>
struct linear_fit_data { struct linear_fit_data {
@ -54,7 +52,7 @@ void inline incremental_LSF_reset(struct linear_fit_data *lsf) {
void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) { void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
// weight each accumulator by factor w, including the "number" of samples // weight each accumulator by factor w, including the "number" of samples
// (analagous to calling inc_LSF twice with same values to weight it by 2X) // (analogous to calling inc_LSF twice with same values to weight it by 2X)
lsf->xbar += w * x; lsf->xbar += w * x;
lsf->ybar += w * y; lsf->ybar += w * y;
lsf->zbar += w * z; lsf->zbar += w * z;
@ -86,5 +84,4 @@ void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const f
int finish_incremental_LSF(struct linear_fit_data *); int finish_incremental_LSF(struct linear_fit_data *);
#endif #endif // _LEAST_SQUARES_FIT_H_

24
Marlin/src/libs/nozzle.cpp

@ -1,6 +1,28 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "nozzle.h" #include "nozzle.h"
#include "Marlin.h" #include "../Marlin.h"
#include "point_t.h" #include "point_t.h"
/** /**

4
Marlin/src/libs/nozzle.h

@ -23,7 +23,7 @@
#ifndef __NOZZLE_H__ #ifndef __NOZZLE_H__
#define __NOZZLE_H__ #define __NOZZLE_H__
#include "Marlin.h" #include "../inc/MarlinConfig.h"
#include "point_t.h" #include "point_t.h"
#if ENABLED(NOZZLE_CLEAN_FEATURE) #if ENABLED(NOZZLE_CLEAN_FEATURE)
@ -106,4 +106,4 @@ class Nozzle {
) _Os; ) _Os;
}; };
#endif #endif // __NOZZLE_H__

5
Marlin/src/libs/point_t.h

@ -34,10 +34,7 @@
* @param e The e-coordinate of the point. * @param e The e-coordinate of the point.
*/ */
struct point_t { struct point_t {
float x; float x, y, z, e;
float y;
float z;
float e;
/** /**
* @brief Two dimensional point constructor * @brief Two dimensional point constructor

2
Marlin/src/libs/private_spi.h

@ -23,8 +23,8 @@
#ifndef __PRIVATE_SPI_H__ #ifndef __PRIVATE_SPI_H__
#define __PRIVATE_SPI_H__ #define __PRIVATE_SPI_H__
#include <stdint.h>
#include "softspi.h" #include "softspi.h"
#include <stdint.h>
template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin> template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin>
class SPI { class SPI {

2
Marlin/src/libs/softspi.h

@ -766,5 +766,3 @@ class SoftSPI {
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
}; };

2
Marlin/src/libs/stopwatch.cpp

@ -20,7 +20,7 @@
* *
*/ */
#include "Marlin.h" #include "../Marlin.h"
#include "stopwatch.h" #include "stopwatch.h"
Stopwatch::Stopwatch() { Stopwatch::Stopwatch() {

4
Marlin/src/libs/stopwatch.h

@ -23,7 +23,7 @@
#ifndef STOPWATCH_H #ifndef STOPWATCH_H
#define STOPWATCH_H #define STOPWATCH_H
#include "macros.h" #include "../core/types.h"
// Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM) // Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM)
//#define DEBUG_STOPWATCH //#define DEBUG_STOPWATCH
@ -103,7 +103,7 @@ class Stopwatch {
*/ */
millis_t duration(); millis_t duration();
#if ENABLED(DEBUG_STOPWATCH) #ifdef DEBUG_STOPWATCH
/** /**
* @brief Prints a debug message * @brief Prints a debug message

7
Marlin/src/libs/vector_3.cpp

@ -38,12 +38,15 @@
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <math.h>
#include "Marlin.h" #include "../inc/MarlinConfig.h"
#if HAS_ABL #if HAS_ABL
#include "vector_3.h" #include "vector_3.h"
#include <math.h>
vector_3::vector_3() : x(0), y(0), z(0) { } vector_3::vector_3() : x(0), y(0), z(0) { }
vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { } vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }

4
Marlin/src/libs/vector_3.h

@ -38,11 +38,10 @@
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef VECTOR_3_H #ifndef VECTOR_3_H
#define VECTOR_3_H #define VECTOR_3_H
#if HAS_ABL
class matrix_3x3; class matrix_3x3;
struct vector_3 { struct vector_3 {
@ -79,5 +78,4 @@ 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 // HAS_ABL
#endif // VECTOR_3_H #endif // VECTOR_3_H

Loading…
Cancel
Save