本帖最后由 sky929 于 2014-3-31 14:43 编辑
savagego 发表于 2014-3-28 13:06 
你买的是什么型号的?国产的12864可能改过了,特别是带汉字字库的。
也许可以试试这个
http://www.geek-w ...
我試用了这个库,ST7920串口显示,但只出数字
#include "LCD12864RSPI.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )
LCD12864RSPI LCDA(A0,A1,A2);
///LCD12864RSPI(int _latchPin,int _dataPin,int _clockPin):
//RS->A0,R/W->A1,E->A2
//LCD Smartie matrix.dll 4x16 ;
void setup() {
Serial.begin(9600);
}
byte serial_getch(){
int incoming;
while (Serial.available()==0){}
incoming = Serial.read();
return (byte) (incoming &0xff);
}
void loop(){
byte rxbyte;
byte temp;
int row = 0;
rxbyte = serial_getch();
if (rxbyte == 254) //Matrix Orbital uses 254 prefix for commands
{
switch (serial_getch())
{
case 66: //backlight on (at previously set brightness)
// not implemented
break;
case 70: //backlight off
// not implemented
break;
case 71: //set cursor position
row = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
case 1:
row = 0;//row1
break;
case 2:
row = 1;//row2
break;
case 3:
row = 2;//row3
break;
case 4:
row = 3;//row4
break;
default:
break;
}
LCDA.setCursor(row,0);
break;
case 72: //cursor home (reset display position)
break;
case 74: //show underline cursor
break;
case 75: //underline cursor off
case 84: //block cursor off
break;
case 76: //move cursor left
break;
case 77: //move cursor right
break;
case 78: //define custom char
break;
case 83: //show blinking block cursor
break;
case 86: //GPO OFF
//implement later
break;
case 87: //GPO ON
break;
case 88: //clear display, cursor home
LCDA.clear();
break;
case 152: //set and remember (doesn't save value, though)
case 153: //set backlight brightness
//not implemented
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
break;
}
return;
}
LCDA.print(rxbyte); //otherwise a plain char so we print it to lcd
return;
}
在LCD 中出现的是全DEC 数字例如串口输出”A” LCD 是65 请问如何解决
谢谢 |