极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10580|回复: 1

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

[复制链接]
发表于 2014-4-4 11:40:22 | 显示全部楼层 |阅读模式
我最近使用UNO做一个倒计时的计分器,使用12864显示。可是我发现如果我不使用清屏程序,本来要显示数字9的时候就会变成90(所有个位数都是这样)。如果使用了清屏程序之后,问题得到解决,可是屏幕闪烁得非常严重。请各位大神指教
#include "LCD12864RSPI.h"
#include "MsTimer2.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )
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;
   
}

}
回复

使用道具 举报

发表于 2014-4-5 22:55:15 | 显示全部楼层
请考虑一下09 90 9分别占位多少
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-10 05:03 , Processed in 0.038349 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表