summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrucewattendorf <brucewattendorf>2009-01-12 19:36:28 +0000
committerbrucewattendorf <brucewattendorf@cb376a5e-1013-0410-a455-b6b1f9ac8223>2009-01-12 19:36:28 +0000
commit3ace7d0129f6c1686b375861457bc22607b5d052 (patch)
treea87f179bc747890e686d688f35b44679eeb7d4de
parent1b30850cc84a89fb7b8b9df359efd474592a32b3 (diff)
downloadreprap-3ace7d0129f6c1686b375861457bc22607b5d052.tar.gz
reprap-3ace7d0129f6c1686b375861457bc22607b5d052.zip
added buttonPress command and renamed files
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@2373 cb376a5e-1013-0410-a455-b6b1f9ac8223
-rw-r--r--trunk/users/bruce/Lcd test/GCode_Interpreter.pde2
-rw-r--r--trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.h (renamed from trunk/users/bruce/Lcd test/LCD test files/i2clcd.h)0
-rw-r--r--trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.pde34
-rw-r--r--trunk/users/bruce/Lcd test/LCD test files/lcd_test.pde2
-rw-r--r--trunk/users/bruce/Lcd test/LCD test files/readme.txt5
-rw-r--r--trunk/users/bruce/Lcd test/i2c_lcd.h (renamed from trunk/users/bruce/Lcd test/i2clcd.h)0
-rw-r--r--trunk/users/bruce/Lcd test/i2c_lcd.pde34
-rw-r--r--trunk/users/bruce/Lcd test/lcd files/I2C_LCD_Demo.pde2
-rw-r--r--trunk/users/bruce/Lcd test/lcd files/i2c_lcd.h (renamed from trunk/users/bruce/Lcd test/lcd files/i2clcd.h)0
-rw-r--r--trunk/users/bruce/Lcd test/lcd files/i2c_lcd.pde216
10 files changed, 286 insertions, 9 deletions
diff --git a/trunk/users/bruce/Lcd test/GCode_Interpreter.pde b/trunk/users/bruce/Lcd test/GCode_Interpreter.pde
index e9f3b4a1..04adb394 100644
--- a/trunk/users/bruce/Lcd test/GCode_Interpreter.pde
+++ b/trunk/users/bruce/Lcd test/GCode_Interpreter.pde
@@ -12,7 +12,7 @@
#include "parameters.h"
#include "pins.h"
#include "extruder.h"
-#include "i2clcd.h"
+#include "i2c_lcd.h"
#include <Wire.h>
byte extruder_in_use = 0;
diff --git a/trunk/users/bruce/Lcd test/LCD test files/i2clcd.h b/trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.h
index ab4f2bf9..ab4f2bf9 100644
--- a/trunk/users/bruce/Lcd test/LCD test files/i2clcd.h
+++ b/trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.h
diff --git a/trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.pde b/trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.pde
index b42dd772..b28cc09b 100644
--- a/trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.pde
+++ b/trunk/users/bruce/Lcd test/LCD test files/i2c_lcd.pde
@@ -1,6 +1,7 @@
+// Reprap I2C LCD code this is to be used with the Reprap I2C interface board
+// 1.0 Writen By Bruce Wattendorf
-
-#include "i2clcd.h"
+#include "i2c_lcd.h"
#include <Wire.h> // REQUIRED Used for the I2C Communications
#include <string.h> //needed for strlen()
@@ -182,5 +183,34 @@ void LCDprintIn(char msg[])
LCDprint(msg[i]);
}
}
+
+// this is to display a number
+void LCDdispnumb(int numbvar)
+{
+ //int THUS= abs(numbvar/1000);
+ int HUNDS= abs(numbvar/100);
+ int TENS = abs((numbvar - (HUNDS*100))/10);
+ int ONES = abs(numbvar-(HUNDS*100)-(TENS*10));
+
+ NUMB[0] = HUNDS+48; // +48 for ASCII conversion
+ NUMB[1] = TENS+48;
+ NUMB[2] = ONES+48;
+
+ for(i=0;i<3;i++)
+ {
+ LCDprint(NUMB[i]); // Print-Out 3 digit number at cursor
+ }
+
+
+// this command is to check for a button press
+
+void LCDcheckbutton() // Use serial monitor at 9600bps to see buttons that are pressed
+{
+ I2C_RX(MCP23017,GPIOB);
+ buttonPress = int(button);
+ switch (buttonPress)
+ {
+
+// note to be added BUTTON interface commands for the 5 buttons \ No newline at end of file
diff --git a/trunk/users/bruce/Lcd test/LCD test files/lcd_test.pde b/trunk/users/bruce/Lcd test/LCD test files/lcd_test.pde
index 067142d6..f8579c75 100644
--- a/trunk/users/bruce/Lcd test/LCD test files/lcd_test.pde
+++ b/trunk/users/bruce/Lcd test/LCD test files/lcd_test.pde
@@ -1,5 +1,5 @@
#include <Wire.h>
-#include "i2clcd.h"
+#include "i2c_lcd.h"
void setup()
diff --git a/trunk/users/bruce/Lcd test/LCD test files/readme.txt b/trunk/users/bruce/Lcd test/LCD test files/readme.txt
index ef71dadb..81d83c1c 100644
--- a/trunk/users/bruce/Lcd test/LCD test files/readme.txt
+++ b/trunk/users/bruce/Lcd test/LCD test files/readme.txt
@@ -15,7 +15,8 @@ i2clcd.h //this is the hex file that contains the settings for the I2c files
i2c_lcd.pde // this is the file that contains the commands that are available
to control the LCD
lcd_test.pde // this is a simple test program to test the function of your LCD
-and board
+and board it uses the serial port and will show what is typed into the keyboard onto
+the LCD screen it uses 19200 baud
Commands
@@ -40,7 +41,7 @@ LCDleftscroll this command will scroll the display to the left
LCDcursorTo this command will position the cursor to the position that is called out
-
+LCDcheckbutton this command is used to scan for a button press it is displayed with a command buttonPress
Using
diff --git a/trunk/users/bruce/Lcd test/i2clcd.h b/trunk/users/bruce/Lcd test/i2c_lcd.h
index ab4f2bf9..ab4f2bf9 100644
--- a/trunk/users/bruce/Lcd test/i2clcd.h
+++ b/trunk/users/bruce/Lcd test/i2c_lcd.h
diff --git a/trunk/users/bruce/Lcd test/i2c_lcd.pde b/trunk/users/bruce/Lcd test/i2c_lcd.pde
index b42dd772..b28cc09b 100644
--- a/trunk/users/bruce/Lcd test/i2c_lcd.pde
+++ b/trunk/users/bruce/Lcd test/i2c_lcd.pde
@@ -1,6 +1,7 @@
+// Reprap I2C LCD code this is to be used with the Reprap I2C interface board
+// 1.0 Writen By Bruce Wattendorf
-
-#include "i2clcd.h"
+#include "i2c_lcd.h"
#include <Wire.h> // REQUIRED Used for the I2C Communications
#include <string.h> //needed for strlen()
@@ -182,5 +183,34 @@ void LCDprintIn(char msg[])
LCDprint(msg[i]);
}
}
+
+// this is to display a number
+void LCDdispnumb(int numbvar)
+{
+ //int THUS= abs(numbvar/1000);
+ int HUNDS= abs(numbvar/100);
+ int TENS = abs((numbvar - (HUNDS*100))/10);
+ int ONES = abs(numbvar-(HUNDS*100)-(TENS*10));
+
+ NUMB[0] = HUNDS+48; // +48 for ASCII conversion
+ NUMB[1] = TENS+48;
+ NUMB[2] = ONES+48;
+
+ for(i=0;i<3;i++)
+ {
+ LCDprint(NUMB[i]); // Print-Out 3 digit number at cursor
+ }
+
+
+// this command is to check for a button press
+
+void LCDcheckbutton() // Use serial monitor at 9600bps to see buttons that are pressed
+{
+ I2C_RX(MCP23017,GPIOB);
+ buttonPress = int(button);
+ switch (buttonPress)
+ {
+
+// note to be added BUTTON interface commands for the 5 buttons \ No newline at end of file
diff --git a/trunk/users/bruce/Lcd test/lcd files/I2C_LCD_Demo.pde b/trunk/users/bruce/Lcd test/lcd files/I2C_LCD_Demo.pde
index a4322a11..3a7df062 100644
--- a/trunk/users/bruce/Lcd test/lcd files/I2C_LCD_Demo.pde
+++ b/trunk/users/bruce/Lcd test/lcd files/I2C_LCD_Demo.pde
@@ -1,6 +1,6 @@
-#include "i2clcd.h"
+#include "i2c_lcd.h"
#include <Wire.h> // REQUIRED Used for the I2C Communications
diff --git a/trunk/users/bruce/Lcd test/lcd files/i2clcd.h b/trunk/users/bruce/Lcd test/lcd files/i2c_lcd.h
index 88e55b9f..88e55b9f 100644
--- a/trunk/users/bruce/Lcd test/lcd files/i2clcd.h
+++ b/trunk/users/bruce/Lcd test/lcd files/i2c_lcd.h
diff --git a/trunk/users/bruce/Lcd test/lcd files/i2c_lcd.pde b/trunk/users/bruce/Lcd test/lcd files/i2c_lcd.pde
new file mode 100644
index 00000000..b28cc09b
--- /dev/null
+++ b/trunk/users/bruce/Lcd test/lcd files/i2c_lcd.pde
@@ -0,0 +1,216 @@
+// Reprap I2C LCD code this is to be used with the Reprap I2C interface board
+// 1.0 Writen By Bruce Wattendorf
+
+#include "i2c_lcd.h"
+#include <Wire.h> // REQUIRED Used for the I2C Communications
+#include <string.h> //needed for strlen()
+
+
+//*******************************************************************************************************************
+// VARIABLE INITS
+//*******************************************************************************************************************
+
+byte LCDCONT = 0; // REQUIRED
+byte button = 0; // REQUIRED
+int i =0; // REQUIRED
+int g_num_lines = screen_lines; // this is the number of lines your screen has
+int buttonPress =0;
+int count = 0;
+
+
+//*******************************************************************************************************************
+// Functions and Subroutines
+//*******************************************************************************************************************
+
+
+//*******************************************************************************************************************
+// REQUIRED I2C TX RX
+//*******************************************************************************************************************
+void I2C_TX(byte device, byte regadd, byte tx_data) // Transmit I2C Data
+{
+ Wire.beginTransmission(device);
+ Wire.send(regadd);
+ Wire.send(tx_data);
+ Wire.endTransmission();
+}
+
+void I2C_RX(byte devicerx, byte regaddrx) // Receive I2C Data
+{
+ Wire.beginTransmission(devicerx);
+ Wire.send(regaddrx);
+ Wire.endTransmission();
+ Wire.requestFrom(int(devicerx), 1);
+
+ byte c = 0;
+ if(Wire.available())
+ {
+ byte c = Wire.receive();
+ button = c >>3;
+ }
+}
+
+//*******************************************************************************************************************
+// REQUIRED LCD INIT
+//*******************************************************************************************************************
+
+void LCDinit()
+{
+ // Only used with port expander
+ LCDCONT = RS_pin | E_pin;
+ I2C_TX(MCP23017,GPIOB,LCDCONT);
+
+ delay(50);
+ LCDcommandWrite(B00110000); // Standard Hitachi initialization for 8-bit mode form sepc sheets
+ delay(60);
+ LCDcommandWrite(B00110000);
+ delay(60);
+ LCDcommandWrite(B00110000);
+ delay(60);
+ LCDcommandWrite(B00111000);
+ delay(60);
+ LCDcommandWrite(B00001000);
+ delay(60);
+ LCDcommandWrite(CMD_CLR);
+ delay(60);
+ LCDcommandWrite(B00000110);
+ delay(60);
+ LCDcommandWrite(B0001100);
+ delay(60);
+}
+
+//*******************************************************************************************************************
+// REQUIRED PORTEXPANDER INIT
+//*******************************************************************************************************************
+void portexpanderinit()
+{
+ // --- Set I/O Direction
+ I2C_TX(MCP23017,IODIRB,B11111000);
+ I2C_TX(MCP23017,IODIRA,B00000000);
+ // --- Set I/O Polarity
+ I2C_TX(MCP23017,IPOLA,B00000000);
+ I2C_TX(MCP23017,IPOLB,B11111000);
+ // --- Set ALL Bits of GPIOA
+ I2C_TX(MCP23017,GPIOA,B00000000);
+ // --- Set Weak Pull-Up on Bits 7 of GPIOB
+ I2C_TX(MCP23017,GPPUB,B11111000);
+ // --- Set Default on Bits 7 of GPIOB
+ I2C_TX(MCP23017,DEFVALB,B00000000);
+ // --- Set Use Default on Bits 7 of GPIOB
+ I2C_TX(MCP23017,INTCONB,B10000000);
+ // --- Set IOC on Bits 7 of GPIOB
+ I2C_TX(MCP23017,GPINTENB,B10011000);
+ // --- Set active low of int pin
+ I2C_TX(MCP23017,IOCON,B00110000);
+}
+
+//*******************************************************************************************************************
+// REQUIRED LCD WRITE / COMMAND
+//*******************************************************************************************************************
+
+// this is the LCD command used to send a command to the lcd screen
+void LCDcommandWrite(byte cmdlcd)
+{
+ LCDCONT =0; // was bcf RS_pin
+ I2C_TX(MCP23017,GPIOB,LCDCONT);
+ LCDprint(cmdlcd);
+ delay(20);
+}
+
+// this is the LCD print command used to print to the screen this will print where the cursor is at
+
+void LCDprint(byte lcdChar)
+{
+ I2C_TX(MCP23017,GPIOA,lcdChar);
+ LCDCONT = LCDCONT | E_pin; // If RS is set then it stays set
+ delay(2);
+ I2C_TX(MCP23017,GPIOB,LCDCONT);
+ LCDCONT = RS_pin;
+ I2C_TX(MCP23017,GPIOB,LCDCONT);
+}
+
+//this is the LCD clear command
+
+void LCDclear()
+{
+ LCDcommandWrite(CMD_CLR);
+ delay(1);
+}
+
+
+//this is to set the cursor to the home position
+void LCDhome()
+{
+ LCDcommandWrite(CMD_HOME);
+}
+
+//scroll whole display to left
+void LCDleftscroll(int num_chars, int delay_time)
+{
+ for (int i=0; i<num_chars; i++) {
+ LCDcommandWrite(CMD_LEFT);
+ delay(delay_time);
+ }
+}
+// this is to move the cursor to a specific location before printing to LCD
+void LCDcursorTO(int line_num, int x)
+{
+ //first put cursor home
+ LCDcommandWrite(CMD_HOME);
+ //if we are on a 1-line display, set line_num to 1st line, regardless of given
+ if (g_num_lines==1)
+ {line_num=1;
+ }
+
+ //offset 40 Char in if secound line requested
+ if (line_num == 2)
+ {
+ x +=40;
+ }
+
+ //advance the cursor to the right according to position. (second line starts at position 40).
+ for (int i=0; i<x; i++)
+ {
+ LCDcommandWrite(0x14);
+ }
+}
+
+//this is the printIn command this will print a line and you do not need to add how long the line is
+
+void LCDprintIn(char msg[])
+{
+ for (i=0;i < strlen(msg);i++)
+ {
+ LCDprint(msg[i]);
+ }
+}
+
+// this is to display a number
+
+void LCDdispnumb(int numbvar)
+{
+ //int THUS= abs(numbvar/1000);
+ int HUNDS= abs(numbvar/100);
+ int TENS = abs((numbvar - (HUNDS*100))/10);
+ int ONES = abs(numbvar-(HUNDS*100)-(TENS*10));
+
+ NUMB[0] = HUNDS+48; // +48 for ASCII conversion
+ NUMB[1] = TENS+48;
+ NUMB[2] = ONES+48;
+
+ for(i=0;i<3;i++)
+ {
+ LCDprint(NUMB[i]); // Print-Out 3 digit number at cursor
+ }
+
+
+// this command is to check for a button press
+
+void LCDcheckbutton() // Use serial monitor at 9600bps to see buttons that are pressed
+{
+ I2C_RX(MCP23017,GPIOB);
+ buttonPress = int(button);
+ switch (buttonPress)
+ {
+
+
+// note to be added BUTTON interface commands for the 5 buttons \ No newline at end of file