普中精灵项目u8g2单色图形库设计实践:3进度条改进

参考普中示例程序时发现:他使用了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); 
	}
}

这样以后加程序不需要重新修改主函数。

原来的主函数


int main()
{

u8g2_t u8g2;
	
	SysTick_Init(72);
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);  //ÖжÏÓÅÏȼ¶·Ö×é·Ö2×é
	USART1_Init(115200);
	LED_Init();
	OLED_Init();
	RTC_Init();
	IIC_Init();
	
	u8g2_Setup_ssd1306_i2c_128x64_noname_f(&u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_stm32_gpio_and_delay);
	u8g2_InitDisplay(&u8g2);
	u8g2_SetPowerSave(&u8g2, 0);
	while(1)
	{	
	delay_ms(100);
	u8g2_ClearBuffer(&u8g2);
		jdt(&u8g2);
		
	u8g2_SendBuffer(&u8g2); 
	}
}

现在的主函数

#include "system.h"
#include "SysTick.h"
#include "led.h"
#include "usart.h"
#include "oled.h"
#include "iic.h"
#include "rtc.h"
#include "u8g2.h"
#include "hdhs.h"
#include "jdt.h"
#include "zhs.h"
uint8_t u8x8_stm32_gpio_and_delay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);


int main()
{


	
	SysTick_Init(72);
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);  //ÖжÏÓÅÏȼ¶·Ö×é·Ö2×é
	USART1_Init(115200);
	LED_Init();
	OLED_Init();
	RTC_Init();
	IIC_Init();
	app_demo();

	while(1)
	{	

	}
}

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值