我对任何形式的C语言编程都很陌生。
我有一个可编程控制器(Teso PC1620) (使用兔子处理器)和液晶显示屏(矩阵轨道LK204-7T-1U-USBWB)。我试着在LCD的水平条形/图形功能中使用构建。
下面的代码可以工作,但我希望能够更改条形图的长度( " bar“数组中的第6个值)。我尝试使用注释掉的代码,而不是"bar“的静态常量,这似乎不起作用,并在LCD上给出了随机条形图。
是什么导致了这一点,是否有一种更简单/更好的方法来分配"bar“数组。
#use "oempc16xxdrivers.elib" //Include the OEM pro-teso PC16XO driver library
#define DINBUFSIZE 31 //Defining the serial IN buffer size
#define DOUTBUFSIZE 31 //Defining the serial OUT buffer size
void main()
{
static const char clear[] = {254,88}; //Clear LCD command
static const char load[] = {254,104}; //Initialize horizontal bar
static const char bar[] = {254,124,1,1,0,54}; //Place horizontal bar(245,124) column,Row,Direction,Length
auto int percentage;
auto int rxKey;
//auto char bar[6];
IOInit(); //Initialises the PC1600 (PLC).
serDopen(19200L); //Setting the baudrate of the serial port
serDrdFlush(); //Flushes the serial port D input buffer
serDwrFlush(); //Flushes the serial port D transmit buffer
serDwrite(clear,sizeof(clear)); //Clear LCD
serDwrite(load,sizeof(load)); //Initialize horizontal bar
// bar[0] = 254;
// bar[1] = 124;
// bar[2] = 1;
// bar[3] = 1;
// bar[4] = 0;
// bar[5] = 54;
for(;;)
{
rxKey = serDgetc();
percentage = 10;
//bar[5] = percentage;
if (0x42 == rxKey)
{
serDwrite(bar,sizeof(bar));
}
}
serDclose ();
}动态c版9.62
链接:
液晶显示器:result.php?keywords=LK204-7T-1U+usb&search.x=0&search.y=0
可编程控制器:http://www.teso.com.au/pro-teso/PC1-Controllers/PC1600-Controller.aspx
发布于 2015-04-14 06:54:00
你的代码似乎是正确的。
你的堆栈空间可能很短吗?这很可能是罪魁祸首,因为您添加了一个自动变量。
如果将bar定义为全局/静态,则尝试它是否有效。
https://stackoverflow.com/questions/29612756
复制相似问题