Commit 2e813978 authored by MagoKimbra's avatar MagoKimbra

Update 4.2.5

BIG UPDATE
Add HAL for 8 bit version
Rewrite communication and use HAL for it.
Rewrite servo
and more
parent cbdc92ce
......@@ -24,13 +24,15 @@
// Serial port 0 is still used by the Arduino bootloader regardless of this setting.
#define SERIAL_PORT 0
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
// This determines the communication speed of the printer
// 2400,9600,19200,38400,57600,115200,250000
#define BAUDRATE 115200
// Enable the Bluetooth serial interface
//#define BLUETOOTH
#define BLUETOOTH_SERIAL 1
#define BLUETOOTH_BAUD 115200
// User-specified version info of this build to display in [Pronterface, etc] terminal window during
// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
// build by the user have been successfully uploaded into firmware.
......
......@@ -277,7 +277,6 @@
#define WATCH_TEMP_PERIOD 16 // Seconds
#define WATCH_TEMP_INCREASE 4 // Degrees Celsius
//#define THERMAL_PROTECTION_BED
#define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds
......@@ -1492,7 +1491,7 @@
************************************** Buffer stuff ************************************
****************************************************************************************/
// The number of linear motions that can be in the plan at any give time.
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ring-buffering.
// THE BLOCK BUFFER SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ring-buffering.
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
//The ASCII buffer for receiving from the serial:
......
This diff is collapsed.
#ifndef CONFIGURATION_STORE_H
#define CONFIGURATION_STORE_H
#include "base.h"
void Config_ResetDefault();
void ConfigSD_ResetDefault();
......
#ifndef CONFIGURATION_VERSION_H
#define CONFIGURATION_VERSION_H
#define BUILD_VERSION "MarlinKimbra 4.2.4 dev"
#define SHORT_BUILD_VERSION "4.2.4_dev"
#define BUILD_VERSION "MarlinKimbra 4.2.5 dev"
#define SHORT_BUILD_VERSION "4.2.5_dev"
#define STRING_DISTRIBUTION_DATE __DATE__ " " __TIME__ // build date and time
// It might also be appropriate to define a location where additional information can be found
#define FIRMWARE_URL "https://github.com/MagoKimbra/MarlinKimbra"
......
This diff is collapsed.
......@@ -4,26 +4,16 @@
#include "Arduino.h"
#include "pins_arduino.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#ifdef __SAM3X8E__
#include "module/HAL.h"
#else
// Arduino < 1.0.0 does not define this, so we need to do it ourselves
#ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) ((p) + 0xA0)
#endif
#include <util/delay.h>
#include <avr/eeprom.h>
#include "module/fastio.h"
#endif
#include "module/HAL.h"
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include "module/macros.h"
#include "Boards.h"
#include "module/mechanics.h"
......@@ -47,13 +37,58 @@
#include "Configuration_Feature.h"
#endif
#include "Configuration_Store.h"
#include "language/language.h"
#include "module/language/language.h"
#include "module/conditionals.h"
#include "module/sanitycheck.h"
#include "module/thermistortables.h"
#include "module/comunication.h"
#include "module/communication/communication.h"
#include "module/MK_Main.h"
#include "module/motion/stepper.h"
#include "module/motion/stepper_indirection.h"
#include "module/motion/planner.h"
#include "module/temperature/temperature.h"
#include "module/temperature/thermistortables.h"
#include "module/lcd/ultralcd.h"
#include "module/nextion/nextion_lcd.h"
#if ENABLED(SDSUPPORT)
#include "module/sd/cardreader.h"
#endif
typedef unsigned long millis_t;
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "module/motion/vector_3.h"
#if ENABLED(AUTO_BED_LEVELING_GRID)
#include "module/motion/qr_solve.h"
#endif
#endif // AUTO_BED_LEVELING_FEATURE
#if MB(ALLIGATOR)
#include "module/alligator/external_dac.h"
#endif
#if ENABLED(USE_WATCHDOG)
#include "module/watchdog/watchdog.h"
#endif
#if HAS(BUZZER)
#include "module/lcd/buzzer.h"
#endif
#if ENABLED(BLINKM)
#include "module/blinkm/blinkm.h"
#endif
#if HAS(SERVOS)
#include "module/servo/servo.h"
#endif
#if HAS(DIGIPOTSS)
#include <SPI.h>
#endif
#if ENABLED(FIRMWARE_TEST)
#include "module/fwtest/firmware_test.h"
#endif
#endif
This diff is collapsed.
/**
* This is the main Hardware Abstraction Layer (HAL).
* To make the firmware work with different processors and toolchains,
* all hardware related code should be packed into the hal files.
*
* 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/>.
*
*
* Description: *** HAL for Arduino Due ***
*
* ARDUINO_ARCH_SAM
*/
#ifndef HAL_H
#define HAL_H
#include <avr/pgmspace.h>
//#include <avr/io.h>
// Arduino < 1.0.0 does not define this, so we need to do it ourselves
#ifndef analogInputToDigitalPin
#define analogInputToDigitalPin(p) ((p) + 0xA0)
#endif
/**
* Defines & Macros
*/
// Compiler warning on unused varable.
#define UNUSED(x) (void) (x)
// Macros for bit
#define BIT(b) (1<<(b))
#define TEST(n, b) (((n)&BIT(b))!=0)
#define SET_BIT(n, b, value) (n) ^= ((-value)^(n)) & (BIT(b))
#define bit_clear(x, y) x&= ~(1<<y)
#define bit_set(x, y) x|= (1<<y)
// Macros for maths shortcuts
#ifndef M_PI
#define M_PI 3.1415926536
#endif
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
#define SIN_60 0.8660254037844386
#define COS_60 0.5
// Macros to support option testing
#define ENABLED defined
#define DISABLED !defined
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
#define HAS(FE) (HAS_##FE)
#define HASNT(FE) (!(HAS_##FE))
// Macros to contrain values
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
#define COUNT(a) (sizeof(a)/sizeof(*a))
#define FORCE_INLINE __attribute__((always_inline)) inline
#ifndef CRITICAL_SECTION_START
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
#define CRITICAL_SECTION_END SREG = _sreg;
#endif
#if CPU_ARCH == ARCH_AVR
#include <avr/io.h>
#else
#define PROGMEM
#define PGM_P const char *
#define PSTR(s) s
#define pgm_read_byte_near(x) (*(uint8_t*)x)
#define pgm_read_byte(x) (*(uint8_t*)x)
#endif
#define PACK
#define FSTRINGVALUE(var,value) const char var[] PROGMEM = value;
#define FSTRINGVAR(var) static const char var[] PROGMEM;
#define FSTRINGPARAM(var) PGM_P var
#include <avr/eeprom.h>
#include <avr/wdt.h>
//#define EXTERNALSERIAL // Force using arduino serial
#ifndef EXTERNALSERIAL
#define HardwareSerial_h // Don't use standard serial console
#endif
#include <inttypes.h>
#include "Print.h"
#ifdef EXTERNALSERIAL
#define SERIAL_RX_BUFFER_SIZE 128
#endif
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#define COMPAT_PRE1
#endif
/**
* Types
*/
typedef uint32_t millis_t;
#if CPU_ARCH == ARCH_AVR
#include "fastio.h"
#else
#define READ(IO) digitalRead(IO)
#define WRITE(IO, v) digitalWrite(IO, v)
#define SET_INPUT(IO) pinMode(IO, INPUT)
#define SET_OUTPUT(IO) pinMode(IO, OUTPUT)
#endif
class InterruptProtectedBlock {
uint8_t sreg;
public:
inline void protect() {
cli();
}
inline void unprotect() {
SREG = sreg;
}
inline InterruptProtectedBlock(bool later = false) {
sreg = SREG;
if (!later) cli();
}
inline ~InterruptProtectedBlock() {
SREG = sreg;
}
};
#ifndef EXTERNALSERIAL
// Implement serial communication for one stream only!
/*
* HardwareSerial.h - Hardware serial library for Wiring
* Copyright (c) 2006 Nicholas Zambetti. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Modified 28 September 2010 by Mark Sproul
*
* Modified to use only 1 queue with fixed length by Repetier
*/
#define SERIAL_BUFFER_SIZE 128
#define SERIAL_BUFFER_MASK 127
#undef SERIAL_TX_BUFFER_SIZE
#undef SERIAL_TX_BUFFER_MASK
#ifdef BIG_OUTPUT_BUFFER
#define SERIAL_TX_BUFFER_SIZE 128
#define SERIAL_TX_BUFFER_MASK 127
#else
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_TX_BUFFER_MASK 63
#endif
struct ring_buffer {
uint8_t buffer[SERIAL_BUFFER_SIZE];
volatile uint8_t head;
volatile uint8_t tail;
};
struct ring_buffer_tx {
uint8_t buffer[SERIAL_TX_BUFFER_SIZE];
volatile uint8_t head;
volatile uint8_t tail;
};
class MKHardwareSerial : public Print {
public:
ring_buffer *_rx_buffer;
ring_buffer_tx *_tx_buffer;
volatile uint8_t *_ubrrh;
volatile uint8_t *_ubrrl;
volatile uint8_t *_ucsra;
volatile uint8_t *_ucsrb;
volatile uint8_t *_udr;
uint8_t _rxen;
uint8_t _txen;
uint8_t _rxcie;
uint8_t _udrie;
uint8_t _u2x;
public:
MKHardwareSerial(ring_buffer *rx_buffer, ring_buffer_tx *tx_buffer,
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *udr,
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x);
void begin(unsigned long);
void end();
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
#ifdef COMPAT_PRE1
virtual void write(uint8_t);
#else
virtual size_t write(uint8_t);
#endif
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
int outputUnused(void); // Used for output in interrupts
};
extern MKHardwareSerial MKSerial;
#define MKSERIAL MKSerial
//extern ring_buffer x_buffer;
#define WAIT_OUT_EMPTY while(tx_buffer.head != tx_buffer.tail) {}
#else
#define MKSERIAL Serial
#endif
class HAL {
public:
HAL();
virtual ~HAL();
static inline char readFlashByte(PGM_P ptr) { return pgm_read_byte(ptr); }
static inline void serialSetBaudrate(long baud) { MKSERIAL.begin(baud); }
static inline bool serialByteAvailable() { return MKSERIAL.available() > 0; }
static inline uint8_t serialReadByte() { return MKSERIAL.read(); }
static inline void serialWriteByte(char b) { MKSERIAL.write(b); }
static inline void serialFlush() { MKSERIAL.flush(); }
static void showStartReason();
static int getFreeRam();
static void resetHardware();
protected:
private:
};
#endif // HAL_H
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
// License: GPL
#ifndef MARLIN_H
#define MARLIN_H
#ifndef MK_H
#define MK_H
#include <math.h>
#include <stdint.h>
void get_command();
void idle(bool ignore_stepper_queue = false);
void manage_inactivity(bool ignore_stepper_queue=false);
void manage_inactivity(bool ignore_stepper_queue = false);
void FlushSerialRequestResend();
void ok_to_send();
......@@ -251,4 +254,4 @@ extern void calculate_volumetric_multipliers();
#endif
#endif //MARLIN_H
#endif // MK_H
/*
HardwareSerial.cpp - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 23 November 2006 by David A. Mellis
Modified 28 September 2010 by Mark Sproul
*/
#include "../base.h"
#include "MarlinSerial.h"
#ifndef USBCON
// this next line disables the entire HardwareSerial.cpp,
// this is so I can support Attiny series and any other chip without a UART
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
#if UART_PRESENT(SERIAL_PORT)
ring_buffer rx_buffer = { { 0 }, 0, 0 };
#endif
FORCE_INLINE void store_char(unsigned char c) {
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != rx_buffer.tail) {
rx_buffer.buffer[rx_buffer.head] = c;
rx_buffer.head = i;
}
}
//#elif defined(SIG_USART_RECV)
#if defined(M_USARTx_RX_vect)
// fixed by Mark Sproul this is on the 644/644p
//SIGNAL(SIG_USART_RECV)
SIGNAL(M_USARTx_RX_vect) {
unsigned char c = M_UDRx;
store_char(c);
}
#endif
// Constructors ////////////////////////////////////////////////////////////////
MarlinSerial::MarlinSerial() { }
// Public Methods //////////////////////////////////////////////////////////////
void MarlinSerial::begin(long baud) {
uint16_t baud_setting;
bool useU2X = true;
#if F_CPU == 16000000UL && SERIAL_PORT == 0
// hard-coded exception for compatibility with the bootloader shipped
// with the Duemilanove and previous boards and the firmware on the 8U2
// on the Uno and Mega 2560.
if (baud == 57600) {
useU2X = false;
}
#endif
if (useU2X) {
M_UCSRxA = BIT(M_U2Xx);
baud_setting = (F_CPU / 4 / baud - 1) / 2;
} else {
M_UCSRxA = 0;
baud_setting = (F_CPU / 8 / baud - 1) / 2;
}
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
M_UBRRxH = baud_setting >> 8;
M_UBRRxL = baud_setting;
sbi(M_UCSRxB, M_RXENx);
sbi(M_UCSRxB, M_TXENx);
sbi(M_UCSRxB, M_RXCIEx);
}
void MarlinSerial::end() {
cbi(M_UCSRxB, M_RXENx);
cbi(M_UCSRxB, M_TXENx);
cbi(M_UCSRxB, M_RXCIEx);
}
int MarlinSerial::peek(void) {
if (rx_buffer.head == rx_buffer.tail) {
return -1;
} else {
return rx_buffer.buffer[rx_buffer.tail];
}
}
int MarlinSerial::read(void) {
// if the head isn't ahead of the tail, we don't have any characters
if (rx_buffer.head == rx_buffer.tail) {
return -1;
}
else {
unsigned char c = rx_buffer.buffer[rx_buffer.tail];
rx_buffer.tail = (unsigned int)(rx_buffer.tail + 1) % RX_BUFFER_SIZE;
return c;
}
}
void MarlinSerial::flush() {
// don't reverse this or there may be problems if the RX interrupt
// occurs after reading the value of rx_buffer_head but before writing
// the value to rx_buffer_tail; the previous value of rx_buffer_head
// may be written to rx_buffer_tail, making it appear as if the buffer
// don't reverse this or there may be problems if the RX interrupt
// occurs after reading the value of rx_buffer_head but before writing
// the value to rx_buffer_tail; the previous value of rx_buffer_head
// may be written to rx_buffer_tail, making it appear as if the buffer
// were full, not empty.
rx_buffer.head = rx_buffer.tail;
}
/// imports from print.h
void MarlinSerial::print(char c, int base) {
print((long) c, base);
}
void MarlinSerial::print(unsigned char b, int base) {
print((unsigned long) b, base);
}
void MarlinSerial::print(int n, int base) {
print((long) n, base);
}
void MarlinSerial::print(unsigned int n, int base) {
print((unsigned long) n, base);
}
void MarlinSerial::print(long n, int base) {
if (base == 0) {
write(n);
}
else if (base == 10) {
if (n < 0) {
print('-');
n = -n;
}
printNumber(n, 10);
} else {
printNumber(n, base);
}
}
void MarlinSerial::print(unsigned long n, int base) {
if (base == 0) write(n);
else printNumber(n, base);
}
void MarlinSerial::print(double n, int digits) {
printFloat(n, digits);
}
void MarlinSerial::println(void) {
print('\r');
print('\n');
}
void MarlinSerial::println(const String &s) {
print(s);
println();
}
void MarlinSerial::println(const char c[]) {
print(c);
println();
}
void MarlinSerial::println(char c, int base) {
print(c, base);
println();
}
void MarlinSerial::println(unsigned char b, int base) {
print(b, base);
println();
}
void MarlinSerial::println(int n, int base) {
print(n, base);
println();
}
void MarlinSerial::println(unsigned int n, int base) {
print(n, base);
println();
}
void MarlinSerial::println(long n, int base) {
print(n, base);
println();
}
void MarlinSerial::println(unsigned long n, int base) {
print(n, base);
println();
}
void MarlinSerial::println(double n, int digits) {
print(n, digits);
println();
}
// Private Methods /////////////////////////////////////////////////////////////
void MarlinSerial::printNumber(unsigned long n, uint8_t base) {
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
unsigned long i = 0;
if (n == 0) {
print('0');
return;
}
while (n > 0) {
buf[i++] = n % base;
n /= base;
}
for (; i > 0; i--)
print((char) (buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10));
}
void MarlinSerial::printFloat(double number, uint8_t digits) {
// Handle negative numbers
if (number < 0.0) {
print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i = 0; i < digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) print('.');
// Extract digits from the remainder one at a time
while (digits-- > 0) {
remainder *= 10.0;
int toPrint = int(remainder);
print(toPrint);
remainder -= toPrint;
}
}
// Preinstantiate Objects //////////////////////////////////////////////////////
MarlinSerial customizedSerial;
#endif // whole file
#endif // !USBCON
// For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;
#endif
/*
HardwareSerial.h - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 28 September 2010 by Mark Sproul
*/
#ifndef MARLINSERIAL_H
#define MARLINSERIAL_H
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
// The presence of the UBRRH register is used to detect a UART.
#define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \
(port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \
(port == 3 && defined(UBRR3H)))
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
#else
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
#endif
// Registers used by MarlinSerial class (these are expanded
// depending on selected serial port
#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B)
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)
#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)
#define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
#define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)
#define M_USARTx_RX_vect SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)
#define M_U2Xx SERIAL_REGNAME(U2X,SERIAL_PORT,)
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#define BYTE 0
#ifndef USBCON
// Define constants and variables for buffering incoming serial data. We're
// using a ring buffer (I think), in which rx_buffer_head is the index of the
// location to which to write the next incoming character and rx_buffer_tail
// is the index of the location from which to read.
#define RX_BUFFER_SIZE 128
struct ring_buffer {
unsigned char buffer[RX_BUFFER_SIZE];
int head;
int tail;
};
#if UART_PRESENT(SERIAL_PORT)
extern ring_buffer rx_buffer;
#endif
class MarlinSerial { //: public Stream
public:
MarlinSerial();
void begin(long);
void end();
int peek(void);
int read(void);
void flush(void);
FORCE_INLINE int available(void) {
return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
}
FORCE_INLINE void write(uint8_t c) {
while (!TEST(M_UCSRxA, M_UDREx))
;
M_UDRx = c;
}
FORCE_INLINE void checkRx(void) {
if (TEST(M_UCSRxA, M_RXCx)) {
unsigned char c = M_UDRx;
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != rx_buffer.tail) {
rx_buffer.buffer[rx_buffer.head] = c;
rx_buffer.head = i;
}
}
}
private:
void printNumber(unsigned long, uint8_t);
void printFloat(double, uint8_t);
public:
FORCE_INLINE void write(const char *str) { while (*str) write(*str++); }
FORCE_INLINE void write(const uint8_t *buffer, size_t size) { while (size--) write(*buffer++); }
FORCE_INLINE void print(const String &s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
FORCE_INLINE void print(const char *str) { write(str); }
void print(char, int = BYTE);
void print(unsigned char, int = BYTE);
void print(int, int = DEC);
void print(unsigned int, int = DEC);
void print(long, int = DEC);
void print(unsigned long, int = DEC);
void print(double, int = 2);
void println(const String &s);
void println(const char[]);
void println(char, int = BYTE);
void println(unsigned char, int = BYTE);
void println(int, int = DEC);
void println(unsigned int, int = DEC);
void println(long, int = DEC);
void println(unsigned long, int = DEC);
void println(double, int = 2);
void println(void);
};
extern MarlinSerial customizedSerial;
#endif // !USBCON
// Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;
#endif
#endif
/* Arduino SdFat Library
* Copyright (C) 2009 by William Greiman
*
* This file is part of the Arduino SdFat Library
*
* This Library 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 Library 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 the Arduino SdFat Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
/**
* \file
* \brief configuration definitions
*/
#ifndef SdFatConfig_h
#define SdFatConfig_h
#include <stdint.h>
//------------------------------------------------------------------------------
/**
* To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.
*
* Using multiple cards costs 400 - 500 bytes of flash.
*
* Each card requires about 550 bytes of SRAM so use of a Mega is recommended.
*/
#define USE_MULTIPLE_CARDS 0
//------------------------------------------------------------------------------
/**
* Call flush for endl if ENDL_CALLS_FLUSH is nonzero
*
* The standard for iostreams is to call flush. This is very costly for
* SdFat. Each call to flush causes 2048 bytes of I/O to the SD.
*
* SdFat has a single 512 byte buffer for SD I/O so it must write the current
* data block to the SD, read the directory block from the SD, update the
* directory entry, write the directory block to the SD and read the data
* block back into the buffer.
*
* The SD flash memory controller is not designed for this many rewrites
* so performance may be reduced by more than a factor of 100.
*
* If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force
* all data to be written to the SD.
*/
#define ENDL_CALLS_FLUSH 0
//------------------------------------------------------------------------------
/**
* Allow use of deprecated functions if ALLOW_DEPRECATED_FUNCTIONS is nonzero
*/
#define ALLOW_DEPRECATED_FUNCTIONS 1
//------------------------------------------------------------------------------
/**
* Allow FAT12 volumes if FAT12_SUPPORT is nonzero.
* FAT12 has not been well tested.
*/
#define FAT12_SUPPORT 0
//------------------------------------------------------------------------------
/**
* SPI init rate for SD initialization commands. Must be 5 (F_CPU/64)
* or 6 (F_CPU/128).
*/
#define SPI_SD_INIT_RATE 5
//------------------------------------------------------------------------------
/**
* Set the SS pin high for hardware SPI. If SS is chip select for another SPI
* device this will disable that device during the SD init phase.
*/
#define SET_SPI_SS_HIGH 1
//------------------------------------------------------------------------------
/**
* Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos.
* Pins used are SS 10, MOSI 11, MISO 12, and SCK 13.
*
* MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used
* on Mega Arduinos. Software SPI works well with GPS Shield V1.1
* but many SD cards will fail with GPS Shield V1.0.
*/
#define MEGA_SOFT_SPI 0
//------------------------------------------------------------------------------
/**
* Set USE_SOFTWARE_SPI nonzero to always use software SPI.
*/
#define USE_SOFTWARE_SPI 0
// define software SPI pins so Mega can use unmodified 168/328 shields
/** Software SPI chip select pin for the SD */
uint8_t const SOFT_SPI_CS_PIN = 10;
/** Software SPI Master Out Slave In pin */
uint8_t const SOFT_SPI_MOSI_PIN = 11;
/** Software SPI Master In Slave Out pin */
uint8_t const SOFT_SPI_MISO_PIN = 12;
/** Software SPI Clock pin */
uint8_t const SOFT_SPI_SCK_PIN = 13;
//------------------------------------------------------------------------------
/**
* The __cxa_pure_virtual function is an error handler that is invoked when
* a pure virtual function is called.
*/
#define USE_CXA_PURE_VIRTUAL 1
/** Number of UTF-16 characters per entry */
#define FILENAME_LENGTH 13
/**
* Defines for long (vfat) filenames
*/
/** Number of VFAT entries used. Every entry has 13 UTF-16 characters */
#define MAX_VFAT_ENTRIES (2)
/** Total size of the buffer used to store the long filenames */
#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
#endif // SdFatConfig_h
/* Arduino SdFat Library
* Copyright (C) 2008 by William Greiman
*
* This file is part of the Arduino SdFat Library
*
* This Library 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 Library 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 the Arduino SdFat Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "SdFatUtil.h"
//------------------------------------------------------------------------------
/** Amount of free RAM
* \return The number of free bytes.
*/
#ifdef __arm__
extern "C" char* sbrk(int incr);
int SdFatUtil::FreeRam() {
char top;
return &top - reinterpret_cast<char*>(sbrk(0));
}
#else // __arm__
extern char *__brkval;
extern char __bss_end;
/** Amount of free RAM
* \return The number of free bytes.
*/
int SdFatUtil::FreeRam() {
char top;
return __brkval ? &top - __brkval : &top - &__bss_end;
}
#endif // __arm
//------------------------------------------------------------------------------
/** %Print a string in flash memory.
*
* \param[in] pr Print object for output.
* \param[in] str Pointer to string stored in flash memory.
*/
void SdFatUtil::print_P( PGM_P str) {
for (uint8_t c; (c = pgm_read_byte(str)); str++) MYSERIAL.write(c);
}
//------------------------------------------------------------------------------
/** %Print a string in flash memory followed by a CR/LF.
*
* \param[in] pr Print object for output.
* \param[in] str Pointer to string stored in flash memory.
*/
void SdFatUtil::println_P( PGM_P str) {
print_P( str);
MYSERIAL.println();
}
//------------------------------------------------------------------------------
/** %Print a string in flash memory to Serial.
*
* \param[in] str Pointer to string stored in flash memory.
*/
void SdFatUtil::SerialPrint_P(PGM_P str) {
print_P(str);
}
//------------------------------------------------------------------------------
/** %Print a string in flash memory to Serial followed by a CR/LF.
*
* \param[in] str Pointer to string stored in flash memory.
*/
void SdFatUtil::SerialPrintln_P(PGM_P str) {
println_P( str);
}
\ No newline at end of file
/* Arduino SdFat Library
* Copyright (C) 2008 by William Greiman
*
* This file is part of the Arduino SdFat Library
*
* This Library 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 Library 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 the Arduino SdFat Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "../base.h"
#ifndef SdFatUtil_h
#define SdFatUtil_h
/**
* \file
* \brief Useful utility functions.
*/
#include "MarlinSerial.h"
/** Store and print a string in flash memory.*/
#define PgmPrint(x) SerialPrint_P(PSTR(x))
/** Store and print a string in flash memory followed by a CR/LF.*/
#define PgmPrintln(x) SerialPrintln_P(PSTR(x))
namespace SdFatUtil {
int FreeRam();
void print_P( PGM_P str);
void println_P( PGM_P str);
void SerialPrint_P(PGM_P str);
void SerialPrintln_P(PGM_P str);
}
using namespace SdFatUtil; // NOLINT
#endif // #define SdFatUtil_h
......@@ -2,7 +2,7 @@
blinkm.cpp - Library for controlling a BlinkM over i2c
Created by Tim Koster, August 21 2013.
*/
#include "../base.h"
#include "../../base.h"
#if ENABLED(BLINKM)
......
/**
* This file is part of MarlinKimbra Firmware.
*
* MarlinKimbra Firmware 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.
*
* MarlinKimbra Firmware 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 MarlinKimbra Firmware. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../base.h"
void Com::printF(FSTRINGPARAM(ptr)) {
char c;
while ((c = HAL::readFlashByte(ptr++)) != 0)
HAL::serialWriteByte(c);
}
void Com::printVal(int value) {
print(value);
}
void Com::printVal(int8_t value) {
print(value);
}
void Com::printVal(uint8_t value) {
print(value);
}
void Com::printVal(int32_t value) {
print(value);
}
void Com::printVal(uint32_t value) {
printNumber(value);
}
void Com::printVal(float value, uint8_t digits) {
printFloat(value, digits);
}
void Com::printVal(double value, uint8_t digits) {
printFloat(value, digits);
}
void Com::print(const char* text) {
while(*text) {
HAL::serialWriteByte(*text++);
}
}
void Com::print(char c) {
HAL::serialWriteByte(c);
}
void Com::print(float number) {
printFloat(number, 6);
}
void Com::print(int value) {
print((int32_t)value);
}
void Com::print(long value) {
if(value < 0) {
HAL::serialWriteByte('-');
value = -value;
}
printNumber(value);
}
void Com::print(uint16_t value) {
printNumber(value);
}
void Com::print(uint32_t value) {
printNumber(value);
}
void Com::printNumber(uint32_t n) {
char buf[11]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[10];
*str = '\0';
do {
unsigned long m = n;
n /= 10;
*--str = '0'+(m - 10 * n);
} while(n);
print(str);
}
void Com::printArray(float *arr, uint8_t n, uint8_t digits) {
for (uint8_t i = 0; i < n; i++) {
print(" ");
printFloat(arr[i], digits);
}
}
void Com::printArray(int32_t *arr, uint8_t n) {
for (uint8_t i = 0; i < n; i++) {
print(" ");
printVal(arr[i]);
}
}
void Com::printFloat(float number, uint8_t digits) {
if (isnan(number)) {
print(TNAN);
return;
}
if (isinf(number)) {
print(TINF);
return;
}
// Handle negative numbers
if (number < 0.0) {
print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
float rounding = 0.5;
for (uint8_t i = 0; i < digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
float remainder = number - (float)int_part;
printNumber(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0)
print('.');
// Extract digits from the remainder one at a time
while (digits-- > 0) {
remainder *= 10.0;
int toPrint = int(remainder);
print(toPrint);
remainder -= toPrint;
}
}
#ifndef COMMUNICATION_H
#define COMMUNICATION_H
class Com {
public:
#define START "start" // start for host
#define OK "ok " // ok answer for host
#define ER "Error: " // error for host
#define WT "Wait" // wait for host
#define DB "Echo: " // message for user
#define CFG "Config: " // config for host
#define INFO "Info: " // info for host
#define RESEND "Resend: " // resend for host
#define WARNING "Warning: " // warning for host
#define TNAN "NAN" // NAN for host
#define TINF "INF" // INF for host
#define PAUSE "//action:pause" // command for host that support action
#define RESUME "//action:resume" // command for host that support action
#define DISCONNECT "//action:disconnect" // command for host that support action
static void printFloat(float number, uint8_t digits);
static void printVal(int value);
static void printVal(int8_t value);
static void printVal(uint8_t value);
static void printVal(int32_t value);
static void printVal(uint32_t value);
static void printVal(float value, uint8_t digits = 2);
static void printVal(double value, uint8_t digits = 2);
static void printArray(float *arr, uint8_t n = 4, uint8_t digits = 2);
static void printArray(long *arr, uint8_t n = 4);
static void printNumber(uint32_t n);
static void print(long value);
static void print(uint16_t value);
static void print(uint32_t value);
static void print(int value);
static void print(float number);
static void print(const char *text);
static void print(char c);
static void println() { HAL::serialWriteByte('\r'); HAL::serialWriteByte('\n'); }
static void printF(FSTRINGPARAM(ptr));
protected:
private:
};
#define SERIAL_WRITE(x) HAL::serialWriteByte(x)
#define ECHO_S(srt) Com::printF(PSTR(srt))
#define ECHO_M(msg) Com::printF(PSTR(msg))
#define ECHO_T(txt) Com::print(txt)
#define ECHO_V(val, args...) Com::printVal(val, ##args)
#define ECHO_C(x) Com::print(x)
#define ECHO_E Com::println()
#define ECHO_MV(msg, val, args...) ECHO_M(msg),ECHO_V(val, ##args)
#define ECHO_VM(val, msg, args...) ECHO_V(val, ##args),ECHO_M(msg)
#define ECHO_MT(msg, txt) ECHO_M(msg),ECHO_T(txt)
#define ECHO_TM(txt, msg) ECHO_T(txt),ECHO_M(msg)
#define ECHO_SM(srt, msg) ECHO_S(srt),ECHO_M(msg)
#define ECHO_ST(srt, txt) ECHO_S(srt),ECHO_T(txt)
#define ECHO_SV(srt, val, args...) ECHO_S(srt),ECHO_V(val, ##args)
#define ECHO_SMV(srt, msg, val, args...) ECHO_S(srt),ECHO_MV(msg, val, ##args)
#define ECHO_SMT(srt, msg, txt) ECHO_S(srt),ECHO_MT(msg, txt)
#define ECHO_EM(msg) ECHO_M(msg),ECHO_E
#define ECHO_ET(txt) ECHO_T(txt),ECHO_E
#define ECHO_EV(val, args...) ECHO_V(val, ##args),ECHO_E
#define ECHO_EMV(msg, val, args...) ECHO_MV(msg, val, ##args),ECHO_E
#define ECHO_EVM(val, msg, args...) ECHO_VM(val, msg, ##args),ECHO_E
#define ECHO_EMT(msg, txt) ECHO_MT(msg, txt),ECHO_E
#define ECHO_L(srt) ECHO_S(srt),ECHO_E
#define ECHO_LM(srt, msg) ECHO_S(srt),ECHO_M(msg),ECHO_E
#define ECHO_LT(srt, txt) ECHO_S(srt),ECHO_T(txt),ECHO_E
#define ECHO_LV(srt, val, args...) ECHO_S(srt),ECHO_V(val, ##args),ECHO_E
#define ECHO_LMV(srt, msg, val, args...) ECHO_S(srt),ECHO_MV(msg, val, ##args),ECHO_E
#define ECHO_LVM(srt, val, msg, args...) ECHO_S(srt),ECHO_VM(val, msg, ##args),ECHO_E
#define ECHO_LMT(srt, msg, txt) ECHO_S(srt),ECHO_MT(msg, txt),ECHO_E
#endif
/**
* Comunication.h - serial messages functions
* Part of MarlinKimbra
*
* Author: Simone Primarosa
*/
#ifndef COMUNICATION_H
#define COMUNICATION_H
#ifdef USBCON
#include "HardwareSerial.h"
#endif
#ifndef __SAM3X8E__
#include "MarlinSerial.h"
#endif
#include "WString.h"
#ifdef USBCON
#if ENABLED(BLUETOOTH)
#define MYSERIAL bluetoothSerial
#else
#define MYSERIAL Serial
#endif // BLUETOOTH
#else
#ifdef __SAM3X8E__
#if SERIAL_PORT == -1
#define MYSERIAL SerialUSB
#elif SERIAL_PORT == 0
#define MYSERIAL Serial
#elif SERIAL_PORT == 1
#define MYSERIAL Serial1
#elif SERIAL_PORT == 2
#define MYSERIAL Serial2
#elif SERIAL_PORT == 3
#define MYSERIAL Serial3
#endif
#else
#define MYSERIAL customizedSerial
#endif
#endif
#define START "start" // start for host
#define OK "ok " // ok answer for host
#define ER "error: " // error for host
#define WT "wait" // wait for host
#define DB "echo: " // message for user
#define RS "resend: " // resend for host
#define PAUSE "//action:pause" // command for host that support action
#define RESUME "//action:resume" // command for host that support action
#define DISCONNECT "//action:disconnect" // command for host that support action
#define SERIAL_INIT(baud) MYSERIAL.begin(baud), delay(1)
#define SERIAL_WRITE(x) MYSERIAL.write(x)
#define SERIAL_PRINT(msg, args...) MYSERIAL.print(msg, ##args)
#define SERIAL_ENDL MYSERIAL.println()
FORCE_INLINE void PS_PGM(const char *str) {
char ch;
while ((ch = pgm_read_byte(str))) {
SERIAL_WRITE(ch);
str++;
}
}
#define ECHO_ENDL SERIAL_ENDL
#define ECHO_PGM(message) PS_PGM(PSTR(message))
#define ECHO_MV(msg, val, args...) ECHO_PGM(msg),ECHO_V(val, ##args)
#define ECHO_VM(val, msg, args...) ECHO_V(val, ##args),ECHO_PGM(msg)
#define ECHO_M(msg) ECHO_PGM(msg)
#define ECHO_V SERIAL_PRINT
#define ECHO_C SERIAL_WRITE
#define ECHO_S(srt) ECHO_PGM(srt)
#define ECHO_SM(srt, msg) ECHO_S(srt),ECHO_M(msg)
#define ECHO_SV(srt, val, args...) ECHO_S(srt),ECHO_V(val, ##args)
#define ECHO_SMV(srt, msg, val, args...) ECHO_S(srt),ECHO_MV(msg, val, ##args)
#define ECHO_SVM(srt, val, msg, args...) ECHO_S(srt),ECHO_VM(val, msg, ##args)
#define ECHO_E ECHO_ENDL
#define ECHO_EM(msg) ECHO_M(msg),ECHO_E
#define ECHO_EV(val, args...) ECHO_V(val, ##args),ECHO_E
#define ECHO_EMV(msg, val, args...) ECHO_MV(msg, val, ##args),ECHO_E
#define ECHO_EVM(val, msg, args...) ECHO_VM(val, msg, ##args),ECHO_E
#define ECHO_L(srt) ECHO_S(srt),ECHO_E
#define ECHO_LM(srt, msg) ECHO_S(srt),ECHO_M(msg),ECHO_E
#define ECHO_LV(srt, val) ECHO_S(srt),ECHO_V(val),ECHO_E
#define ECHO_LMV(srt, msg, val, args...) ECHO_S(srt),ECHO_MV(msg, val, ##args),ECHO_E
#define ECHO_LVM(srt, val, msg, args...) ECHO_S(srt),ECHO_VM(val, msg, ##args),ECHO_E
#endif
......@@ -435,6 +435,7 @@
*
*/
#if ENABLED(SD_DISABLED_DETECT)
#undef SD_DETECT_PIN
#define SD_DETECT_PIN -1
#endif
#if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
......@@ -643,6 +644,7 @@
#define HAS_BTN_BACK (PIN_EXISTS(BTN_BACK))
#define HAS_POWER_SWITCH (POWER_SUPPLY > 0 && PIN_EXISTS(PS_ON))
#define HAS_MOTOR_CURRENT_PWM_XY (PIN_EXISTS(MOTOR_CURRENT_PWM_XY))
#define HAS_SDSUPPORT (ENABLED(SDSUPPORT))
#define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS))
......
#include "../base.h"
#include "../../base.h"
#if ENABLED(DIGIPOT_I2C)
......
......@@ -6,7 +6,6 @@
#ifndef _FASTIO_ARDUINO_H
#define _FASTIO_ARDUINO_H
#include <avr/io.h>
/*
utility functions
......
......@@ -3,20 +3,11 @@
* By MagoKimbra
*/
#include "../base.h"
#include "../Marlin_main.h"
#include "../../base.h"
#if ENABLED(FIRMWARE_TEST)
#include "firmware_test.h"
#include "planner.h"
#include "stepper_indirection.h"
#include "stepper.h"
#include "temperature.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#endif
static char serial_answer;
......
......@@ -31,7 +31,7 @@
#define STRINGIFY_(n) #n
#define STRINGIFY(n) STRINGIFY_(n)
#define PROTOCOL_VERSION "1.0"
#define PROTOCOL_VERSION "2.0"
#if MB(ULTIMAKER)|| MB(ULTIMAKER_OLD)|| MB(ULTIMAIN_2)
#define MACHINE_NAME "Ultimaker"
......
......@@ -206,6 +206,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -206,6 +206,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -152,7 +152,7 @@
#define MSG_HEATING_FAILED_LCD "Heating failed"
#define MSG_ERR_REDUNDANT_TEMP "REDUNDANT TEMP ERROR"
#define MSG_THERMAL_RUNAWAY "THERMAL RUNAWAY"
#define MSG_HOTEND_AD595 "HOTEND AD595 Offset & Gain"
#define MSG_AD595 "AD595 Offset & Gain"
#define MSG_ERR_MAXTEMP "MAXTEMP ERROR"
#define MSG_ERR_MINTEMP "MINTEMP ERROR"
#define MSG_ERR_MAXTEMP_BED "MAXTEMP BED ERROR"
......@@ -205,6 +205,21 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_TYPE "Type: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMP_HOTEND "Temperature Hotend: "
#define MSG_RFID_TEMP_BED "Temperature Bed: "
#define MSG_RFID_TEMP_USER_HOTEND "User temperature Hotend: "
#define MSG_RFID_TEMP_USER_BED "User temperatura Bed: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -152,7 +152,7 @@
#define MSG_HEATING_FAILED_LCD "Riscaldamento fallito"
#define MSG_ERR_REDUNDANT_TEMP "REDUNDANT TEMP ERROR"
#define MSG_THERMAL_RUNAWAY "THERMAL RUNAWAY"
#define MSG_HOTEND_AD595 "HOTEND AD595 Offset & Gain"
#define MSG_AD595 "AD595 Offset & Gain"
#define MSG_ERR_MAXTEMP "MAXTEMP ERROR"
#define MSG_ERR_MINTEMP "MINTEMP ERROR"
#define MSG_ERR_MAXTEMP_BED "MAXTEMP BED ERROR"
......@@ -205,6 +205,21 @@
#define MSG_RESTORING_POS "Ripristino posizione"
#define MSG_INVALID_POS_SLOT "Slot invalido, slot totali: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Bobina su E"
#define MSG_RFID_BRAND "Marca: "
#define MSG_RFID_TYPE "Tipo: "
#define MSG_RFID_COLOR "Colore: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMP_HOTEND "Temperatura Hotend: "
#define MSG_RFID_TEMP_BED "Temperatura Bed: "
#define MSG_RFID_TEMP_USER_HOTEND "Temperatura utente Hotend: "
#define MSG_RFID_TEMP_USER_BED "Temperatura utente Bed: "
#define MSG_RFID_DENSITY "Densita': "
#define MSG_RFID_SPOOL_LENGHT "Lunghezza bobina: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Dai il comando Y per andare avanti"
......
......@@ -207,6 +207,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -210,6 +210,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
......@@ -205,6 +205,17 @@
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Rfid module
#if ENABLED(RFID_MODULE)
#define MSG_RFID_SPOOL "Spool on E"
#define MSG_RFID_BRAND "Brand: "
#define MSG_RFID_COLOR "Color: "
#define MSG_RFID_SIZE "Size: "
#define MSG_RFID_TEMPERATURE "Temperature: "
#define MSG_RFID_DENSITY "Density: "
#define MSG_RFID_SPOOL_LENGHT "Spool Lenght: "
#endif
// Firmware Test
#if ENABLED(FIRMWARE_TEST)
#define MSG_FWTEST_YES "Put the Y command to go next"
......
#include "../base.h"
#include "../../base.h"
#if HAS(BUZZER)
#include "buzzer.h"
#include "ultralcd.h"
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
......
#include "../base.h"
#include "../Marlin_main.h"
#include "../Configuration_Store.h"
#include "../../base.h"
#if ENABLED(ULTRA_LCD)
#include "cardreader.h"
#include "temperature.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#endif
#include "planner.h"
#include "stepper_indirection.h"
#include "stepper.h"
#include "ultralcd.h"
#if HAS(BUZZER)
#include "buzzer.h"
#endif
int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
bool encoderRateMultiplierEnabled;
......
#ifndef ULTRALCD_H
#define ULTRALCD_H
#include "../Marlin_main.h"
#if ENABLED(ULTRA_LCD)
#if HAS(BUZZER)
#include "buzzer.h"
......
#ifndef MACROS_H
#define MACROS_H
// Compiler warning on unused varable.
#define UNUSED(x) (void) (x)
// Macros for bit masks
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
// Macros for maths shortcuts
#ifndef M_PI
#define M_PI 3.1415926536
#endif
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
#define SIN_60 0.8660254037844386
#define COS_60 0.5
// Macros to support option testing
#define ENABLED defined
#define DISABLED !defined
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
#define HAS(FE) (HAS_##FE)
#define HASNT(FE) (!(HAS_##FE))
// Macros to contrain values
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
#define COUNT(a) (sizeof(a)/sizeof(*a))
// Function macro
#define FORCE_INLINE __attribute__((always_inline)) inline
#if DISABLED(CRITICAL_SECTION_START)
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
#define CRITICAL_SECTION_END SREG = _sreg;
#endif
#endif //__MACROS_H
......@@ -48,14 +48,8 @@
*
*/
#include "../base.h"
#include "../Marlin_main.h"
#include "../../base.h"
#include "planner.h"
#include "stepper_indirection.h"
#include "stepper.h"
#include "temperature.h"
#include "ultralcd.h"
//===========================================================================
//============================= public variables ============================
......@@ -121,7 +115,7 @@ uint8_t g_uc_extruder_last_move[EXTRUDERS] = { 0 };
#endif
#if ENABLED(FILAMENT_SENSOR)
static char meas_sample; //temporary variable to hold filament measurement sample
static char meas_sample; // temporary variable to hold filament measurement sample
#endif
#if ENABLED(DUAL_X_CARRIAGE)
......
#include "qr_solve.h"
#include "../../base.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && ENABLED(AUTO_BED_LEVELING_GRID)
#include "qr_solve.h"
#include <stdlib.h>
#include <math.h>
......
#include "../base.h"
#if ENABLED(AUTO_BED_LEVELING_GRID)
void daxpy(int n, double da, double dx[], int incx, double dy[], int incy);
......
......@@ -22,26 +22,10 @@
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
and Philipp Tiefenbacher. */
#include "../base.h"
#include "../Marlin_main.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#endif
#include "planner.h"
#include "stepper_indirection.h"
#if MB(ALLIGATOR)
#include "external_dac.h"
#endif
#include "../../base.h"
#include "stepper.h"
#include "temperature.h"
#include "ultralcd.h"
#include "nextion_lcd.h"
#if ENABLED(SDSUPPORT)
#include "cardreader.h"
#endif
#include "speed_lookuptable.h"
#if HAS(DIGIPOTSS)
#include <SPI.h>
#endif
......@@ -553,7 +537,7 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
timer = (unsigned short)pgm_read_word_near(table_address);
timer -= (((unsigned short)pgm_read_word_near(table_address + 2) * (unsigned char)(step_rate & 0x0007)) >> 3);
}
if (timer < 100) { timer = 100; MYSERIAL.print(SERIAL_STEPPER_TOO_HIGH); MYSERIAL.println(step_rate); }//(20kHz this should never happen)
if (timer < 100) { timer = 100; ECHO_M(SERIAL_STEPPER_TOO_HIGH); ECHO_T(step_rate); }//(20kHz this should never happen)
return timer;
}
......@@ -702,7 +686,7 @@ ISR(TIMER1_COMPA_vect) {
// Take multiple steps per interrupt (For high speed moves)
for (int8_t i = 0; i < step_loops; i++) {
#ifndef USBCON
customizedSerial.checkRx(); // Check for serial chars.
HAL::serialByteAvailable(); // Check for serial chars.
#endif
#if ENABLED(ADVANCE)
......
......@@ -19,7 +19,7 @@
along with Marlin. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../base.h"
#include "../../base.h"
#include "stepper_indirection.h"
#if ENABLED(HAVE_TMCDRIVER)
......
......@@ -16,8 +16,9 @@
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 "../../base.h"
#include <math.h>
#include "../base.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
......@@ -60,7 +61,7 @@ void vector_3::apply_rotation(matrix_3x3 matrix) {
}
void vector_3::debug(const char title[]) {
ECHO_SV(DB, title);
ECHO_ST(DB, title);
ECHO_MV(" x: ", x, 6);
ECHO_MV(" y: ", y, 6);
ECHO_EMV(" z: ", z, 6);
......@@ -117,7 +118,7 @@ matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) {
}
void matrix_3x3::debug(const char title[]) {
ECHO_LV(DB, title);
ECHO_LT(DB, title);
int count = 0;
for (int i = 0; i < 3; i++) {
ECHO_S(DB);
......
......@@ -16,6 +16,7 @@
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
......
......@@ -15,11 +15,10 @@
*
*/
#include "../base.h"
#include "../Marlin_main.h"
#include "../../base.h"
#if ENABLED(NEXTION_GFX)
#include "stepper.h"
#include "nextion_gfx.h"
const int INSIDE = 0; // 0000
......
#include "../base.h"
#include "../Marlin_main.h"
#include "../Configuration_Store.h"
#include "../../base.h"
#if ENABLED(NEXTION)
#include "cardreader.h"
#include "temperature.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#endif
#include "planner.h"
#include "stepper_indirection.h"
#include "stepper.h"
#include "nextion_lcd.h"
#include "nextion_gfx.h"
#include <Nextion.h>
......@@ -265,7 +254,7 @@
card.getfilename(i);
printrowsd(row, card.filenameIsDir, card.filename, card.longFilename);
} else {
printrowsd(row, false, "", "");
printrowsd(row, false, "", (char*)"");
}
}
sendCommand("ref 0");
......@@ -476,12 +465,16 @@
#endif
void lcd_init() {
delay(1000);
for (uint8_t i = 0; i < 10; i++) {
NextionON = nexInit();
if (NextionON) break;
delay(1000);
}
if (!NextionON) {
ECHO_LM(DB, "Nextion LCD not connected!");
} else {
}
else {
ECHO_LM(DB, "Nextion LCD connected!");
Pstart.attachPop(ExitPopCallback);
......
......@@ -18,13 +18,12 @@
* <http://www.gnu.org/licenses/>.
*/
#include "../base.h"
#ifndef Sd2Card_h
#define Sd2Card_h
#include "../../base.h"
#if ENABLED(SDSUPPORT)
#ifndef Sd2Card_h
#define Sd2Card_h
/**
* \file
* \brief Sd2Card class for V2 SD/SDHC cards
......@@ -32,7 +31,6 @@
#include "SdFatConfig.h"
#include "Sd2PinMap.h"
#include "SdInfo.h"
//------------------------------------------------------------------------------
// SPI speed is F_CPU/2^(1 + index), 0 <= index <= 6
/** Set SCK to max rate of F_CPU/2. See Sd2Card::setSckRate(). */
......@@ -121,35 +119,35 @@ uint8_t const SD_CARD_TYPE_SDHC = 3;
*/
//------------------------------------------------------------------------------
#if MEGA_SOFT_SPI && (defined(__AVR_ATmega1280__)||defined(__AVR_ATmega2560__))
#define SOFTWARE_SPI
#define SOFTWARE_SPI
#elif USE_SOFTWARE_SPI
#define SOFTWARE_SPI
#define SOFTWARE_SPI
#endif // MEGA_SOFT_SPI
//------------------------------------------------------------------------------
// SPI pin definitions - do not edit here - change in SdFatConfig.h
//
#if DISABLED(SOFTWARE_SPI)
// hardware pin defs
/** The default chip select pin for the SD card is SS. */
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
// The following three pins must not be redefined for hardware SPI.
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
/** SPI Master In Slave Out pin */
uint8_t const SPI_MISO_PIN = MISO_PIN;
/** SPI Clock pin */
uint8_t const SPI_SCK_PIN = SCK_PIN;
// hardware pin defs
/** The default chip select pin for the SD card is SS. */
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
// The following three pins must not be redefined for hardware SPI.
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
/** SPI Master In Slave Out pin */
uint8_t const SPI_MISO_PIN = MISO_PIN;
/** SPI Clock pin */
uint8_t const SPI_SCK_PIN = SCK_PIN;
#else // SOFTWARE_SPI
/** SPI chip select pin */
uint8_t const SD_CHIP_SELECT_PIN = SOFT_SPI_CS_PIN;
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = SOFT_SPI_MOSI_PIN;
/** SPI Master In Slave Out pin */
uint8_t const SPI_MISO_PIN = SOFT_SPI_MISO_PIN;
/** SPI Clock pin */
uint8_t const SPI_SCK_PIN = SOFT_SPI_SCK_PIN;
/** SPI chip select pin */
uint8_t const SD_CHIP_SELECT_PIN = SOFT_SPI_CS_PIN;
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = SOFT_SPI_MOSI_PIN;
/** SPI Master In Slave Out pin */
uint8_t const SPI_MISO_PIN = SOFT_SPI_MISO_PIN;
/** SPI Clock pin */
uint8_t const SPI_SCK_PIN = SOFT_SPI_SCK_PIN;
#endif // SOFTWARE_SPI
//------------------------------------------------------------------------------
/**
......@@ -206,7 +204,7 @@ class Sd2Card {
bool readCSD(csd_t* csd) {
return readRegister(CMD9, csd);
}
bool readData(uint8_t *dst);
bool readData(uint8_t* dst);
bool readStart(uint32_t blockNumber);
bool readStop();
bool setSckRate(uint8_t sckRateID);
......
......@@ -19,6 +19,10 @@
*/
// Warning this file was generated by a program.
#include "../../base.h"
#if ENABLED(SDSUPPORT)
#ifndef Sd2PinMap_h
#define Sd2PinMap_h
#include <avr/io.h>
......@@ -393,7 +397,8 @@ static inline __attribute__((always_inline))
bool getPinMode(uint8_t pin) {
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1;
} else {
}
else {
return badPinNumber();
}
}
......@@ -402,10 +407,12 @@ static inline __attribute__((always_inline))
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
if (mode) {
*digitalPinMap[pin].ddr |= BIT(digitalPinMap[pin].bit);
} else {
}
else {
*digitalPinMap[pin].ddr &= ~BIT(digitalPinMap[pin].bit);
}
} else {
}
else {
badPinNumber();
}
}
......@@ -413,7 +420,8 @@ static inline __attribute__((always_inline))
bool fastDigitalRead(uint8_t pin) {
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1;
} else {
}
else {
return badPinNumber();
}
}
......@@ -422,12 +430,16 @@ static inline __attribute__((always_inline))
if (__builtin_constant_p(pin) && pin < digitalPinCount) {
if (value) {
*digitalPinMap[pin].port |= BIT(digitalPinMap[pin].bit);
} else {
}
else {
*digitalPinMap[pin].port &= ~BIT(digitalPinMap[pin].bit);
}
} else {
}
else {
badPinNumber();
}
}
#endif // Sd2PinMap_h
#endif
......@@ -17,6 +17,11 @@
* along with the Arduino SdFat Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "../../base.h"
#if ENABLED(SDSUPPORT)
#ifndef SdBaseFile_h
#define SdBaseFile_h
/**
......@@ -154,7 +159,7 @@ static inline uint8_t FAT_HOUR(uint16_t fatTime) {
* \return Extracted minute [0,59]
*/
static inline uint8_t FAT_MINUTE(uint16_t fatTime) {
return(fatTime >> 5) & 0X3F;
return (fatTime >> 5) & 0X3F;
}
/** second part of FAT directory time field
* Note second/2 is stored in packed time.
......@@ -164,7 +169,7 @@ static inline uint8_t FAT_MINUTE(uint16_t fatTime) {
* \return Extracted second [0,58]
*/
static inline uint8_t FAT_SECOND(uint16_t fatTime) {
return 2*(fatTime & 0X1F);
return 2 * (fatTime & 0X1F);
}
/** Default date for file timestamps is 1 Jan 2000 */
uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1;
......@@ -180,7 +185,7 @@ class SdBaseFile {
/** Create an instance. */
SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {}
SdBaseFile(const char* path, uint8_t oflag);
~SdBaseFile() {if(isOpen()) close();}
~SdBaseFile() {if (isOpen()) close();}
/**
* writeError is set to true if an error occurs during a write().
* Set writeError to false before calling print() and/or write() and check
......@@ -262,7 +267,7 @@ class SdBaseFile {
bool isRoot() const {
return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32;
}
void ls( uint8_t flags = 0, uint8_t indent = 0);
void ls(uint8_t flags = 0, uint8_t indent = 0);
bool mkdir(SdBaseFile* dir, const char* path, bool pFlag = true);
// alias for backward compactability
bool makeDir(SdBaseFile* dir, const char* path) {
......@@ -275,7 +280,7 @@ class SdBaseFile {
bool openRoot(SdVolume* vol);
int peek();
static void printFatDate(uint16_t fatDate);
static void printFatTime( uint16_t fatTime);
static void printFatTime(uint16_t fatTime);
bool printName();
int16_t read();
int16_t read(void* buf, uint16_t nbyte);
......@@ -316,7 +321,7 @@ class SdBaseFile {
/** \return SdVolume that contains this file. */
SdVolume* volume() const {return vol_;}
int16_t write(const void* buf, uint16_t nbyte);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
private:
// allow SdFat to set cwd_
friend class SdFat;
......@@ -348,7 +353,7 @@ class SdBaseFile {
bool addCluster();
bool addDirCluster();
dir_t* cacheDirEntry(uint8_t action);
int8_t lsPrintNext( uint8_t flags, uint8_t indent);
int8_t lsPrintNext(uint8_t flags, uint8_t indent);
static bool make83Name(const char* str, uint8_t* name, const char** ptr);
bool mkdir(SdBaseFile* parent, const uint8_t dname[11]);
bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
......@@ -356,10 +361,10 @@ class SdBaseFile {
dir_t* readDirCache();
//------------------------------------------------------------------------------
// to be deleted
static void printDirName( const dir_t& dir,
static void printDirName(const dir_t& dir,
uint8_t width, bool printSlash);
//------------------------------------------------------------------------------
// Deprecated functions - suppress cpplint warnings with NOLINT comment
//------------------------------------------------------------------------------
// Deprecated functions - suppress cpplint warnings with NOLINT comment
#if ALLOW_DEPRECATED_FUNCTIONS && DISABLED(DOXYGEN)
public:
/** \deprecated Use:
......@@ -461,8 +466,8 @@ class SdBaseFile {
static bool remove(SdBaseFile& dirFile, const char* path) { // NOLINT
return remove(&dirFile, path);
}
//------------------------------------------------------------------------------
// rest are private
//------------------------------------------------------------------------------
// rest are private
private:
static void (*oldDateTime_)(uint16_t& date, uint16_t& time); // NOLINT
static void oldToNew(uint16_t* date, uint16_t* time) {
......@@ -475,4 +480,5 @@ class SdBaseFile {
#endif // ALLOW_DEPRECATED_FUNCTIONS
};
#endif // SdBaseFile_h
#endif
This diff is collapsed.
......@@ -17,6 +17,11 @@
* along with the Arduino SdFat Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "../../base.h"
#if ENABLED(SDSUPPORT)
#ifndef SdFatStructs_h
#define SdFatStructs_h
......@@ -638,3 +643,6 @@ static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
}
#endif // SdFatStructs_h
#endif
......@@ -18,11 +18,9 @@
* <http://www.gnu.org/licenses/>.
*/
#include "../base.h"
#include "../Marlin_main.h"
#include "../../base.h"
#if ENABLED(SDSUPPORT)
#include "SdFile.h"
/** Create a file object and open it in the current working directory.
*
......@@ -58,15 +56,13 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
* Use writeError to check for errors.
*/
#if ARDUINO >= 100
size_t SdFile::write(uint8_t b)
{
size_t SdFile::write(uint8_t b) {
return SdBaseFile::write(&b, 1);
}
}
#else
void SdFile::write(uint8_t b)
{
void SdFile::write(uint8_t b) {
SdBaseFile::write(&b, 1);
}
}
#endif
//------------------------------------------------------------------------------
/** Write a string to a file. Used by the Arduino Print class.
......@@ -93,4 +89,6 @@ void SdFile::writeln_P(PGM_P str) {
write_P(str);
write_P(PSTR("\r\n"));
}
#endif
......@@ -21,6 +21,10 @@
* \file
* \brief SdFile class
*/
#include "../../base.h"
#if ENABLED(SDSUPPORT)
#include "SdBaseFile.h"
#include <Print.h>
#ifndef SdFile_h
......@@ -46,3 +50,6 @@ class SdFile : public SdBaseFile, public Print {
void writeln_P(PGM_P str);
};
#endif // SdFile_h
#endif
......@@ -6,6 +6,7 @@
#define MAX_DIR_DEPTH 10 // Maximum folder depth
#include "SdFile.h"
enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
class CardReader {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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