Anycubic followup

This commit is contained in:
Scott Lahteine 2020-07-21 14:43:43 -05:00
parent 2119e19bff
commit 1e5d73579c
2 changed files with 23 additions and 25 deletions

View File

@ -29,10 +29,10 @@
#if ENABLED(ANYCUBIC_TFT_MODEL)
#include "Arduino.h"
#include <Arduino.h>
// this next line disables the entire HardwareSerial.cpp,
// so I can support AtTiny series and other chips without a UART
// This next line disables the entire anycubic_serial.cpp,
// to support AtTiny series and other chips without a UART
#ifdef UBRR3H
#include "anycubic_serial.h"
@ -59,10 +59,8 @@ struct ring_buffer {
volatile unsigned int tail;
};
#ifdef UBRR3H
ring_buffer rx_buffer_ajg = { { 0 }, 0, 0 };
ring_buffer tx_buffer_ajg = { { 0 }, 0, 0 };
#endif
ring_buffer rx_buffer_ajg = { { 0 }, 0, 0 };
ring_buffer tx_buffer_ajg = { { 0 }, 0, 0 };
inline void store_char(unsigned char c, ring_buffer *buffer) {
int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;
@ -286,9 +284,7 @@ AnycubicSerialClass::operator bool() {
// Preinstantiate Objects //////////////////////////////////////////////////////
#ifdef UBRR3H
AnycubicSerialClass AnycubicSerial(&rx_buffer_ajg, &tx_buffer_ajg, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3);
#endif
AnycubicSerialClass AnycubicSerial(&rx_buffer_ajg, &tx_buffer_ajg, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3);
#endif // UBRR3H
#endif // ANYCUBIC_TFT_MODEL

View File

@ -103,15 +103,15 @@ class AnycubicSerialClass : public Stream {
extern void serialEventRun(void) __attribute__((weak));
#define ANYCUBIC_SERIAL_PROTOCOL(x) (AnycubicSerial.print(x))
#define ANYCUBIC_SERIAL_PROTOCOL_F(x,y) (AnycubicSerial.print(x,y))
#define ANYCUBIC_SERIAL_PROTOCOL_F(x,y) (AnycubicSerial.print(x, y))
#define ANYCUBIC_SERIAL_PROTOCOLPGM(x) (AnycubicSerialprintPGM(PSTR(x)))
#define ANYCUBIC_SERIAL_(x) (AnycubicSerial.print(x),AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_PROTOCOLLN(x) (AnycubicSerial.print(x),AnycubicSerial.write('\r'),AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_PROTOCOLLNPGM(x) (AnycubicSerialprintPGM(PSTR(x)),AnycubicSerial.write('\r'),AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_(x) (AnycubicSerial.print(x), AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_PROTOCOLLN(x) (AnycubicSerial.print(x), AnycubicSerial.write('\r'), AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_PROTOCOLLNPGM(x) (AnycubicSerialprintPGM(PSTR(x)), AnycubicSerial.write('\r'), AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_START() (AnycubicSerial.write('\r'),AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_CMD_SEND(x) (AnycubicSerialprintPGM(PSTR(x)),AnycubicSerial.write('\r'),AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_ENTER() (AnycubicSerial.write('\r'),AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_START() (AnycubicSerial.write('\r'), AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_CMD_SEND(x) (AnycubicSerialprintPGM(PSTR(x)), AnycubicSerial.write('\r'), AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_ENTER() (AnycubicSerial.write('\r'), AnycubicSerial.write('\n'))
#define ANYCUBIC_SERIAL_SPACE() (AnycubicSerial.write(' '))
const char newErr[] PROGMEM = "ERR ";
@ -130,14 +130,16 @@ const char newSucc[] PROGMEM = "OK";
#define ANYCUBIC_SERIAL_ECHOPGM(x) ANYCUBIC_SERIAL_PROTOCOLPGM(x)
#define ANYCUBIC_SERIAL_ECHO(x) ANYCUBIC_SERIAL_PROTOCOL(x)
FORCE_INLINE void AnycubicSerialprintPGM(const char *str) {
char ch = pgm_read_byte(str);
while (ch) {
AnycubicSerialClass::write(ch);
ch = pgm_read_byte(++str);
}
}
#ifdef UBRR3H
extern AnycubicSerialClass AnycubicSerial;
FORCE_INLINE void AnycubicSerialprintPGM(const char *str) {
char ch = pgm_read_byte(str);
while (ch) {
AnycubicSerial.write(ch);
ch = pgm_read_byte(++str);
}
}
#endif