Libs updates

This commit is contained in:
Scott Lahteine 2017-09-06 06:28:32 -05:00
parent 34101224c4
commit d7ee81202f
13 changed files with 97 additions and 60 deletions

View File

@ -19,37 +19,58 @@
* 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)
#include "hex_print_routines.h"
#include "hex_print_routines.h"
static char _hex[7] = "0x0000";
#ifdef CPU_32_BIT
constexpr int byte_start = 0;
static char _hex[] = "0x0000";
#else
constexpr int byte_start = 4;
static char _hex[] = "0x00000000";
#endif
char* hex_byte(const uint8_t b) {
_hex[4] = hex_nybble(b >> 4);
_hex[5] = hex_nybble(b);
return &_hex[4];
}
char* hex_byte(const uint8_t b) {
_hex[byte_start + 4] = hex_nybble(b >> 4);
_hex[byte_start + 5] = hex_nybble(b);
return &_hex[byte_start];
}
char* hex_word(const uint16_t w) {
_hex[2] = hex_nybble(w >> 12);
_hex[3] = hex_nybble(w >> 8);
_hex[4] = hex_nybble(w >> 4);
_hex[5] = hex_nybble(w);
return &_hex[2];
}
char* hex_word(const uint16_t w) {
_hex[byte_start + 2] = hex_nybble(w >> 12);
_hex[byte_start + 3] = hex_nybble(w >> 8);
_hex[byte_start + 4] = hex_nybble(w >> 4);
_hex[byte_start + 5] = hex_nybble(w);
return &_hex[byte_start - 2];
}
char* hex_address(const void * const w) {
(void)hex_word((int)w);
return _hex;
}
#ifdef CPU_32_BIT
char* hex_long(const uint32_t 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
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)); }
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

View File

@ -23,16 +23,13 @@
#ifndef HEX_PRINT_ROUTINES_H
#define HEX_PRINT_ROUTINES_H
#include "MarlinConfig.h"
#include "gcode.h"
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER)
#include <stdint.h>
//
// 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);
}
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_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

View File

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

View File

@ -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 "Marlin.h"
#include "macros.h"
#include "../inc/MarlinConfig.h"
#include <math.h>
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) {
// 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->ybar += w * y;
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 *);
#endif
#endif // _LEAST_SQUARES_FIT_H_

View File

@ -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 "Marlin.h"
#include "../Marlin.h"
#include "point_t.h"
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,12 +38,15 @@
License along with this library; if not, write to the Free Software
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
#include "vector_3.h"
#include <math.h>
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_) { }

View File

@ -38,11 +38,10 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef VECTOR_3_H
#define VECTOR_3_H
#if HAS_ABL
class matrix_3x3;
struct vector_3 {
@ -79,5 +78,4 @@ struct matrix_3x3 {
void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float &y, float &z);
#endif // HAS_ABL
#endif // VECTOR_3_H