#include "stdint.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
-
-// flags for backlight control
-#define LCD_BACKLIGHT 0x08
-#define LCD_NOBACKLIGHT 0x00
-
-// specific LED assignments
-#define LED_FAN_ON 1
-#define LED_HOTEND_ON 2
-#define LED_BED_ON 3
-
// Standard directional button bits
#define BUTTON_SELECT 0x01
#define BUTTON_RIGHT 0x02
#define BUTTON_AUX1 0x40
#define BUTTON_AUX2 0x80
+// specific LED assignments
+#define LED_FAN_ON 1
+#define LED_HOTEND_ON 2
+#define LED_BED_ON 3
+
class Panel;
class LcdBase {
-/*
+/*
This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
Smoothie 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.
Smoothie 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 Smoothie. If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Smoothiepanel.h"
#include "smoothiepanel/LCDBang.h"
#include "smoothiepanel/Colors.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
+
+// flags for backlight control
+#define LCD_BACKLIGHT 0x08
+#define LCD_NOBACKLIGHT 0x00
+
+
#define LCD_WRITE 0x00
#define LCD_READ 0x01
#define LCD_ACK 0x01
}
}
-// cycle the buzzer pin at a certain frequency (hz) for a certain duration (ms)
+// cycle the buzzer pin at a certain frequency (hz) for a certain duration (ms)
void Smoothiepanel::buzz(long duration, uint16_t freq) {
const int expander = PCA9505_ADDRESS | this->i2c_address;
char cmd[2];
static uint8_t old_AB = 0;
int8_t state;
old_AB <<= 2; //remember previous state
- old_AB |= ( this->encoder_a_pin.get() + ( this->encoder_b_pin.get() * 2 ) ); //add current state
+ old_AB |= ( this->encoder_a_pin.get() + ( this->encoder_b_pin.get() * 2 ) ); //add current state
state = enc_states[(old_AB&0x0f)];
if(state != 0){
this->encoder_hue += state;
void Smoothiepanel::send(uint8_t value, uint8_t mode) {
#ifdef USE_FASTMODE
// polls for ready. not sure on I2C this is any faster
-
+
// set Data pins as input
char data[2];
data[0]= MCP23017_IODIRB;
data[1]= 0x1E;
i2c->write(this->i2c_address, data, 2);
uint8_t b= _backlightBits >> 8;
- burstBits8b((M17_BIT_RW>>8)|b); // RW hi,RS lo
+ burstBits8b((M17_BIT_RW>>8)|b); // RW hi,RS lo
char busy;
data[0] = MCP23017_GPIOB;
do {
data[0]= MCP23017_IODIRB;
data[1]= 0x00;
i2c->write(this->i2c_address, data, 2);
- burstBits8b(b); // RW lo
+ burstBits8b(b); // RW lo
#else
// wait_us(320);
#endif
-
+
// BURST SPEED, OH MY GOD
// the (now High Speed!) I/O expander pinout
- // B7 B6 B5 B4 B3 B2 B1 B0 A7 A6 A5 A4 A3 A2 A1 A0 - MCP23017
- // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- // RS RW EN D4 D5 D6 D7 B G R B4 B3 B2 B1 B0
+ // B7 B6 B5 B4 B3 B2 B1 B0 A7 A6 A5 A4 A3 A2 A1 A0 - MCP23017
+ // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ // RS RW EN D4 D5 D6 D7 B G R B4 B3 B2 B1 B0
// n.b. RW bit stays LOW to write
uint8_t buf = _backlightBits >> 8;
if (value & 0x20) buf |= M17_BIT_D5 >> 8;
if (value & 0x40) buf |= M17_BIT_D6 >> 8;
if (value & 0x80) buf |= M17_BIT_D7 >> 8;
-
+
if (mode) buf |= (M17_BIT_RS|M17_BIT_EN) >> 8; // RS+EN
else buf |= M17_BIT_EN >> 8; // EN
if (value & 0x02) buf |= M17_BIT_D5 >> 8;
if (value & 0x04) buf |= M17_BIT_D6 >> 8;
if (value & 0x08) buf |= M17_BIT_D7 >> 8;
-
+
if (mode) buf |= (M17_BIT_RS|M17_BIT_EN) >> 8; // RS+EN
else buf |= M17_BIT_EN >> 8; // EN
#define M17_BIT_B1 0x0002
#define M17_BIT_B0 0x0001
+// 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
+
+// flags for backlight control
+#define LCD_BACKLIGHT 0x08
+#define LCD_NOBACKLIGHT 0x00
+
VikiLCD::VikiLCD() {
// I2C com
int i2c_pins = THEKERNEL->config->value(panel_checksum, i2c_pins_checksum)->by_default(3)->as_number();