Revision 4:0c943e6ba349, committed 2012-02-22
- Comitter:
- chag
- Date:
- Wed Feb 22 08:12:46 2012 +0000
- Parent:
- 3:889836485429
- Commit message:
- revised to use new firmware
Changed in this revision
diff -r 889836485429 -r 0c943e6ba349 MODSERIAL.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib Wed Feb 22 08:12:46 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/MODSERIAL/#af2af4c61c2f
diff -r 889836485429 -r 0c943e6ba349 SparkFunSerialGraphicLCD.cpp
--- a/SparkFunSerialGraphicLCD.cpp Mon Feb 20 03:14:16 2012 +0000
+++ b/SparkFunSerialGraphicLCD.cpp Wed Feb 22 08:12:46 2012 +0000
@@ -4,9 +4,12 @@
SparkFunSerialGraphicLCD::SparkFunSerialGraphicLCD(PinName tx, PinName rx = NC) : MySerial(tx, rx) {
- MySerial.baud(115200);
- wait_ms(1500);
+ MySerial.baud(9600);
clear();
+ setBacklight(100);
+ setFont(0);
+ setAutoCRLF(false);
+ setReverse(false);
}
void SparkFunSerialGraphicLCD::clear() {
@@ -35,9 +38,10 @@
MySerial.putc(set);
}
-void SparkFunSerialGraphicLCD::toggleCRLF() {
+void SparkFunSerialGraphicLCD::setAutoCRLF(bool enable) {
MySerial.putc(0x7C);
MySerial.putc(0x04);
+ MySerial.putc(enable);
}
void SparkFunSerialGraphicLCD::eraseBlock(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1) {
@@ -54,14 +58,39 @@
MySerial.putc(0x06);
}
-void SparkFunSerialGraphicLCD::setBaud() {
+void SparkFunSerialGraphicLCD::setBaud(unsigned char baud) {
+ if(baud < 1) baud = 1;
+ else if(baud > 6) baud = 6;
+
MySerial.putc(0x7C);
MySerial.putc(0x07);
+ MySerial.putc(baud);
+ switch(baud) {
+ case 1:
+ MySerial.baud(4800);
+ break;
+ case 2:
+ MySerial.baud(9600);
+ break;
+ case 3:
+ MySerial.baud(19200);
+ break;
+ case 4:
+ MySerial.baud(38400);
+ break;
+ case 5:
+ MySerial.baud(57600);
+ break;
+ case 6:
+ MySerial.baud(115200);
+ break;
+ }
}
-void SparkFunSerialGraphicLCD::toggleFont() {
+void SparkFunSerialGraphicLCD::setFont(unsigned char font) {
MySerial.putc(0x7C);
MySerial.putc(0x08);
+ MySerial.putc(font);
}
void SparkFunSerialGraphicLCD::setFontMode(unsigned char mode) {
@@ -126,15 +155,17 @@
}
-void SparkFunSerialGraphicLCD::toggleReverse() {
+void SparkFunSerialGraphicLCD::setReverse(bool enable) {
MySerial.putc(0x7C);
MySerial.putc(0x14);
+ MySerial.putc(enable);
}
-void SparkFunSerialGraphicLCD::toggleSplash() {
+/*void SparkFunSerialGraphicLCD::setSplash(bool enable) {
MySerial.putc(0x7C);
MySerial.putc(0x15);
-}
+ MySerial.putc(enable);
+}*/
void SparkFunSerialGraphicLCD::bitblt(unsigned char x, unsigned char y, unsigned char mode, unsigned char w, unsigned char h, unsigned char* data) {
error("method not implemented");
diff -r 889836485429 -r 0c943e6ba349 SparkFunSerialGraphicLCD.h
--- a/SparkFunSerialGraphicLCD.h Mon Feb 20 03:14:16 2012 +0000
+++ b/SparkFunSerialGraphicLCD.h Wed Feb 22 08:12:46 2012 +0000
@@ -12,24 +12,24 @@
/* 0x01 */ void setDebug(unsigned char level);
/* 0x02 */ void setBacklight(unsigned char intensity);
/* 0x03 */ void drawCircle(unsigned char x, unsigned char y, unsigned char radius, bool set);
- /* 0x04 */ void toggleCRLF();
+ /* 0x04 */ void setAutoCRLF(bool enable);
/* 0x05 */ void eraseBlock(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1);
/* 0x06 */ void reset();
- /* 0x07 */ void setBaud();
- /* 0x08 */ void toggleFont();
+ /* 0x07 */ void setBaud(unsigned char baud);
+ /* 0x08 */ void setFont(unsigned char font);
/* 0x0A */ void setFontMode(unsigned char mode);
/* 0x0B */ void drawSprite(unsigned char x, unsigned char y, unsigned char sprite, unsigned char mode);
/* 0x0C */ void drawLine(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, bool set);
- /* 0x0D */ void uploadSprite(unsigned char sprite, unsigned char width, unsigned char height, unsigned char* data);
- /* 0x0F */ void drawBox(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, bool set);
- /* 0x10 */ void setPixel(unsigned char x, unsigned char y, bool set);
- /* 0x12 */ void drawFilledBox(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char fill);
- /* 0x14 */ void toggleReverse();
- /* 0x15 */ void toggleSplash();
- /* 0x16 */ void bitblt(unsigned char x, unsigned char y, unsigned char mode, unsigned char w, unsigned char h, unsigned char* data);
+ /* 0x0D */ void uploadSprite(unsigned char sprite, unsigned char width, unsigned char height, unsigned char* data);
+ /* 0x0F */ void drawBox(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, bool set);
+ /* 0x10 */ void setPixel(unsigned char x, unsigned char y, bool set);
+ /* 0x12 */ void drawFilledBox(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char fill);
+ /* 0x14 */ void setReverse(bool enable);
+ /* 0x15 */ /*void setSplash();*/
+ /* 0x16 */ void bitblt(unsigned char x, unsigned char y, unsigned char mode, unsigned char w, unsigned char h, unsigned char* data);
/* 0x18 */ void setCursorX(unsigned char x);
/* 0x19 */ void setCursorY(unsigned char y);
-
+
void printf(const char *msg, ...);
protected: