参考普中示例程序时发现:他使用了app_demo函数进行集成可以使用同样的思想。
这样方便切换。
我肚子饿,要去学校食堂吃饭,下午参考示例代码进行修改再发
现在进行修改
创建总函数.c,.h文件
将代码复制过来
void app_demo(void)
{
u8g2_t u8g2; // a structure which will contain all the data for one display °üº¬Ò»´ÎÏÔʾµÄËùÓÐÊý¾ÝµÄ½á¹¹
u8g2_Setup_ssd1306_i2c_128x64_noname_f(&u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_stm32_gpio_and_delay); // init u8g2 structure u8g2½á¹¹
u8g2_InitDisplay(&u8g2); // send init sequence to the display, display is in sleep mode after this,·¢ËÍinitÐòÁе½ÏÔʾÆ÷£¬ÏÔʾÆ÷ÔÚ´ËÖ®ºó´¦ÓÚ˯Ãßģʽ£¬
u8g2_SetPowerSave(&u8g2, 0); // wake up display ÐÑÀ´µÄʱºòÏÔʾ
while(1)
{
delay_ms(100);
u8g2_ClearBuffer(&u8g2);
jdt(&u8g2);
u8g2_SendBuffer(&u8g2);
}
}
这样以后加程序不需要重新修改主函数。
原来的主函数