这是我的效果,借用的gpio的代码,我的可以正常显示,看图片和你的应该也是类似的OLED屏,同样的,在while里面增加前两行代码也会闪烁。当然要注意上拉电阻的问题,因为demo板只是引出了pin脚,但并没有上拉,所以我外部接了两个上拉电阻。不知道是不是差在这里。
int main(void)
{
static uint8_t s_key6Up = 1; /* key6 push/pop status 1:pop 0:push */
static uint8_t s_key7Up = 1; /* key7 push/pop status 1:pop 0:push */
InitDelay();
InitDebug();
OLED_Init();
OLED_Clear();
KEY_Init(); /* init key gpio */
LED_Init(); /* init led gpio */
//noInitData++;
printf("\r\nAC7811: GPIO_Demo\r\n");
OLED_ShowString(0, 0, "GPIO Demo", 16);
while(1)
{
//OLED_Clear();
//OLED_ShowString(0, 0, "GPIO Demo", 16);
mdelay(100);
if (s_key6Up && KEY6 == 0)
{
mdelay(10);
if (s_key6Up && KEY6 == 0)
{
// (*testpdata)++;
LED2 = !LED2; /* toggle LED2 output */
if (s_key6Up == 1)
{
s_key6Up = 0;
OLED_ShowString(0, 4, " KEY6 Push! ", 16);
}
}
}
else
{
if (s_key6Up == 0 && KEY6 == 1)
{
s_key6Up = 1;
OLED_ShowString(0, 4, " KEY6 Pop! ", 16);
//NVIC_SystemReset();
}
}
if (s_key7Up && KEY7 == 0)
{
mdelay(10);
if (s_key7Up && KEY7 == 0)
{
LED3 = !LED3; /* toggle LED3 output */
if (s_key7Up == 1)
{
s_key7Up = 0;
OLED_ShowString(0, 4, " KEY7 Push! ", 16);
}
}
}
else
{
if (s_key7Up == 0 && KEY7 == 1)
{
s_key7Up = 1;
OLED_ShowString(0, 4, " KEY7 Pop! ", 16);
}
}
}
}
|