Botasky 发表于 2014-4-4 11:40:22

关于12864清屏后显示闪烁严重的问题

我最近使用UNO做一个倒计时的计分器,使用12864显示。可是我发现如果我不使用清屏程序,本来要显示数字9的时候就会变成90(所有个位数都是这样)。如果使用了清屏程序之后,问题得到解决,可是屏幕闪烁得非常严重。请各位大神指教
#include "LCD12864RSPI.h"
#include "MsTimer2.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a )
int scorebutton1=7;
int gamestart=0;
int score=0;
int score1=0;
int fangui=0;
int fangui1=0;
int minute=12;//初始分钟
int second=59;//初始秒数
unsigned long time;
unsigned long starttime;
int timeMinute; //显示分钟数
int timeSecond; //显示秒数
unsigned char show0[]={0xC8,0xC8,0xBB,0xF0};//REHUO
unsigned char show1[]={0xC2,0xED,0xB4,0xCC};//MACI
unsigned char show2[]={0xB6,0xD3,0xBC,0xCA,0xB7,0xB8,0xB9,0xE6};//DUIJIFANGUI
///LCD12864RSPI(int _latchPin,int _dataPin,int _clockPin):
//RS->A0,R/W->A1,E->A2
LCD12864RSPI LCDA(A0,A1,A2);

void setup()
{
pinMode(scorebutton1,INPUT);
//pinMode(scorebutton2,INPUT);
MsTimer2::set(1000, flash);      // 中断设置函数,每 1000ms 进入一次中断
MsTimer2::start();                //开始计时
}

void loop()
{

    if(digitalRead(scorebutton1)==HIGH)
{
    //delay(100);
    score++;
}
    delay(180);
   
   LCDA.setCursor(0,2);
    LCDA.print(score);
    LCDA.setCursor(0,6);
    LCDA.print(score1);
    LCDA.setCursor(1,0);
    LCDA.print(minute);
    LCDA.setCursor(1,2);
    LCDA.print(second);
    LCDA.setCursor(0,0);
    LCDA.chinese(show0,AR_SIZE(show0));
    LCDA.setCursor(0,4);
    LCDA.chinese(show1,AR_SIZE(show1));
    LCDA.setCursor(3,0);
    LCDA.chinese(show2,AR_SIZE(show2));
}
void flash()                        //中断处理函数
{                        
time=0;
   if(time<719)
{
    delay(1000);
    second--;
if(second==0)
    {
      minute--;
   second=59;
    }
    time=minute*60+second;
   
}

}

maxims 发表于 2014-4-5 22:55:15

请考虑一下09 90 9分别占位多少
页: [1]
查看完整版本: 关于12864清屏后显示闪烁严重的问题