Contact me: hankecnc@gmail.com

阿杜诺图书馆 #1231

推推 grbl 3年前 (2023-01-23) 440次浏览

关闭
algo1980 开了这个issue 2017 年 5 月 18 日 · 12条评论
 Closed

Arduino Library#1231

algo1980 opened this issue on May 18, 2017 · 12 comments

注释

阿杜诺图书馆 #1231

您好,我正在尝试添加一个简单的代码,但在编辑后无法编译代码。有人可以建议发生了什么事。

阿杜诺图书馆 #1231
成员

@algo1980:Grbl 不使用任何 Arduino 代码,如果您尝试使用,它会中断。它仅使用 IDE 作为编译和刷新它的工具。您将只需要编辑和编写 Grbl 源代码。避免任何 Arduino 函数调用。

阿杜诺图书馆 #1231
作者

感谢您的快速回复。

阿杜诺图书馆 #1231
作者

什么是 IO 异常错误?

阿杜诺图书馆 #1231
拉洛维 评论了 2017 年 5 月 18 日 通过电子邮件
阿杜诺图书馆 #1231
作者

我尝试添加 .h 和 .cpp。编译时说无法上传..

怎么了?

阿杜诺图书馆 #1231
作者

无论我在做什么,它都会返回一个错误

阿杜诺图书馆 #1231

@algo1980 no one can assist you if you don’t provide more information on what you’re actually doing. You will need to explain what version of grbl you are using, what version of Arduino, what platform you’re compiling on and the hardware you are targeting. You also need to show some code and provide error messages. Just saying “it could not upload” or “it returns with an error” doesn’t get us anywhere!

阿杜诺图书馆 #1231
Author

using grbl0.9e on atmega 2560. i am trying to add the lcd.cpp and lcd.h to the whole set of grbl files, but it fails to compile it. here is the code im adding

/////////////////lcd.cpp
#ifndef LiquidCrystal_h
#define LiquidCrystal_h

#include <inttypes.h>
#include “Print.h”

// commands
#define LCD_CLEARDISPLAY 0x01
#define LCD_RETURNHOME 0x02
#define LCD_ENTRYMODESET 0x04
#define LCD_DISPLAYCONTROL 0x08
#define LCD_CURSORSHIFT 0x10
#define LCD_FUNCTIONSET 0x20
#define LCD_SETCGRAMADDR 0x40
#define LCD_SETDDRAMADDR 0x80

// flags for display entry mode
#define LCD_ENTRYRIGHT 0x00
#define LCD_ENTRYLEFT 0x02
#define LCD_ENTRYSHIFTINCREMENT 0x01
#define LCD_ENTRYSHIFTDECREMENT 0x00

// flags for display on/off control
#define LCD_DISPLAYON 0x04
#define LCD_DISPLAYOFF 0x00
#define LCD_CURSORON 0x02
#define LCD_CURSOROFF 0x00
#define LCD_BLINKON 0x01
#define LCD_BLINKOFF 0x00

// flags for display/cursor shift
#define LCD_DISPLAYMOVE 0x08
#define LCD_CURSORMOVE 0x00
#define LCD_MOVERIGHT 0x04
#define LCD_MOVELEFT 0x00

// flags for function set
#define LCD_8BITMODE 0x10
#define LCD_4BITMODE 0x00
#define LCD_2LINE 0x08
#define LCD_1LINE 0x00
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00

class LiquidCrystal : public Print {
public:
LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);

void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);

void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);

void clear();
void home();

void noDisplay();
void display();
void noBlink();
void blink();
void noCursor();
void cursor();
void scrollDisplayLeft();
void scrollDisplayRight();
void leftToRight();
void rightToLeft();
void autoscroll();
void noAutoscroll();

void setRowOffsets(int row1, int row2, int row3, int row4);
void createChar(uint8_t, uint8_t[]);
void setCursor(uint8_t, uint8_t);
virtual size_t write(uint8_t);
void command(uint8_t);

using Print::write;
private:
void send(uint8_t, uint8_t);
void write4bits(uint8_t);
void write8bits(uint8_t);
void pulseEnable();

uint8_t _rs_pin; // LOW: command. HIGH: character.
uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD.
uint8_t _enable_pin; // activated by a HIGH pulse.
uint8_t _data_pins[8];

uint8_t _displayfunction;
uint8_t _displaycontrol;
uint8_t _displaymode;

uint8_t _initialized;

uint8_t _numlines;
uint8_t _row_offsets[4];
};

#endif

and here is the header which i am using lcd.h
#ifndef LiquidCrystal_h
#define LiquidCrystal_h

#include <inttypes.h>
#include “Print.h”

// commands
#define LCD_CLEARDISPLAY 0x01
#define LCD_RETURNHOME 0x02
#define LCD_ENTRYMODESET 0x04
#define LCD_DISPLAYCONTROL 0x08
#define LCD_CURSORSHIFT 0x10
#define LCD_FUNCTIONSET 0x20
#define LCD_SETCGRAMADDR 0x40
#define LCD_SETDDRAMADDR 0x80

// flags for display entry mode
#define LCD_ENTRYRIGHT 0x00
#define LCD_ENTRYLEFT 0x02
#define LCD_ENTRYSHIFTINCREMENT 0x01
#define LCD_ENTRYSHIFTDECREMENT 0x00

// flags for display on/off control
#define LCD_DISPLAYON 0x04
#define LCD_DISPLAYOFF 0x00
#define LCD_CURSORON 0x02
#define LCD_CURSOROFF 0x00
#define LCD_BLINKON 0x01
#define LCD_BLINKOFF 0x00

// flags for display/cursor shift
#define LCD_DISPLAYMOVE 0x08
#define LCD_CURSORMOVE 0x00
#define LCD_MOVERIGHT 0x04
#define LCD_MOVELEFT 0x00

// flags for function set
#define LCD_8BITMODE 0x10
#define LCD_4BITMODE 0x00
#define LCD_2LINE 0x08
#define LCD_1LINE 0x00
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00

class LiquidCrystal : public Print {
public:
LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);

void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);

void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);

void clear();
void home();

void noDisplay();
void display();
void noBlink();
void blink();
void noCursor();
void cursor();
void scrollDisplayLeft();
void scrollDisplayRight();
void leftToRight();
void rightToLeft();
void autoscroll();
void noAutoscroll();

void setRowOffsets(int row1, int row2, int row3, int row4);
void createChar(uint8_t, uint8_t[]);
void setCursor(uint8_t, uint8_t);
virtual size_t write(uint8_t);
void command(uint8_t);

using Print::write;
private:
void send(uint8_t, uint8_t);
void write4bits(uint8_t);
void write8bits(uint8_t);
void pulseEnable();

uint8_t _rs_pin; // LOW: command. HIGH: character.
uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD.
uint8_t _enable_pin; // activated by a HIGH pulse.
uint8_t _data_pins[8];

uint8_t _displayfunction;
uint8_t _displaycontrol;
uint8_t _displaymode;

uint8_t _initialized;

uint8_t _numlines;
uint8_t _row_offsets[4];
};

#endif

阿杜诺图书馆 #1231

Should we assume that you are asking us to compile this and figure it out? ;-)
No error message either as asked for.

You need to learn how to write a problem report/defect/issue that provides enough information to help you, otherwise we are left playing ’20 questions’ which some us (me in particular) have no patience for after 40+ years in sw development.

阿杜诺图书馆 #1231
Member

@algo1980 : Grbl does not use the Arduino IDE libraries and is all custom written for CNC control to optimize performance and efficiency. It will break if you try to use them with Grbl’s source code. It only uses the IDE as a vehicle to easily compile and flash Grbl to an Arduino. If you want to add something, you’ll have to figure out how to use Arduino libraries with Grbl (not easy), find libraries that have no dependencies, or write them yourself. With Grbl’s new HAL that is soon to be released, I’m hoping that I can make it easier to use existing libraries with Grbl, but it’s not guaranteed.

阿杜诺图书馆 #1231
Author

感谢 chamnit,这对像我这样的许多初学者来说将是一个很大的帮助。我对新的 HAL 感到很兴奋。并希望快速启动。顺便说一句,它是一个非常智能的代码。我必须补充作者。

阿杜诺图书馆 #1231
作者

cham 是否有可能我仅将 arduino lib 用作参考并声明我自己的函数?

阿杜诺图书馆 #1231 X3msnake 提到了这个问题 2017 年 5 月 30 日
喜欢 (0)