4、基于抽象解释的静态分析器中的跟踪分区与ASTRÉE分析器解析

基于抽象解释的静态分析器中的跟踪分区与ASTRÉE分析器解析

1. 跟踪分区示例

在基于抽象解释的静态分析器中,以计算两个值的重心为例,能很好地说明跟踪分区的作用。考虑如下代码:

l0 :
int r = 0; float x = 0.0;
l1 :
while(true){
l2 :
r = random(0, 50);
l3 :
x = (x * r + random(-100, 100))/(r + 1);
l4 :
}

在很多实时嵌入式系统中,这样的计算通常处于无限循环内。若使用非关系域,难以证明变量 x 不会溢出。但通过对值进行分区,就能轻松证明 x 始终处于 [-100, 100] 范围内。假设 x ∈ [-100, 100] r ∈ [0, 50] ,不分区时 (x * r + random(-100, 100))/(r + 1) 的范围是 [-5100, 5100] ;而对 r [0, 50] 内取任意特定值进行计算,该表达式的范围是 [-100, 100]

2. 循环展开

分析循环的前 n 次迭代,能显著提高最终结果的精度,具体体现在以下方面:
- 嵌入式程序初始化

深度学习作为人工智能的关键分支,依托多层神经网络架构对高维数据进行模式识别函数逼近,广泛应用于连续变量预测任务。在Python编程环境中,得益于TensorFlow、PyTorch等框架的成熟生态,研究者能够高效构建面向回归分析的神经网络模型。本资源库聚焦于通过循环神经网络及其优化变体解决时序预测问题,特别针对传统RNN在长程依赖建模中的梯度异常现象,引入具有门控机制的长短期记忆网络(LSTM)以增强序列建模能力。 实践案例涵盖从数据预处理到模型评估的全流程:首先对原始时序数据进行标准化处理滑动窗口分割,随后构建包含嵌入层、双向LSTM层及全连接层的网络结构。在模型训练阶段,采用自适应矩估计优化器配合早停策略,通过损失函数曲线监测过拟合现象。性能评估不仅关注均方根误差等量化指标,还通过预测值真实值的轨迹可视化进行定性分析。 资源包内部分为三个核心模块:其一是经过清洗的金融时序数据集,包含标准化后的股价波动记录;其二是模块化编程实现的模型构建、训练验证流程;其三是基于Matplotlib实现的动态结果展示系统。所有代码均遵循面向对象设计原则,提供完整的类型注解异常处理机制。 该实践项目揭示了深度神经网络在非线性回归任务中的优势:通过多层非线性变换,模型能够捕获数据中的高阶相互作用,而Dropout层正则化技术的运用则保障了泛化能力。值得注意的是,当处理高频时序数据时,需特别注意序列平稳性检验季节性分解等预处理步骤,这对预测精度具有决定性影响。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
#include <math.h> #include <string.h> #include "oled.h" #include "memory.h" /* GPIOS ºê¶¨Òå */ #define CS_PORT GPIOA #define CS_PIN GPIO_Pin_8 #define DC_PORT GPIOB #define DC_PIN GPIO_Pin_15 #define SDA_PORT GPIOB #define SDA_PIN GPIO_Pin_13 #define SCL_PORT GPIOB #define SCL_PIN GPIO_Pin_12 #define RES_PORT GPIOB #define RES_PIN GPIO_Pin_14 /* дÈ뷽ʽ */ typedef enum { OLED_CMD = 0,//OLEDµÄÖ¸Áî²Ù×÷ OLED_DAT = 1,//OLEDµÄÊý&frac34;ݲÙ×÷ }OLED_WriteType; static OLED _oled; static unsigned char _init_status = 0; /* º¯ÊýÉùÃ÷ */ static void _oledCls(void); static void _oledReset(void); static void _oledGpioInit(void); static void _oledUpDisBuffToDevice(void); static void _oledRegisterConfiguration(void); static void _oledSetPoint(unsigned char x,unsigned char y); static void _oledWriteByte(OLED_WriteType type,unsigned char data); static void _oledWriteBmpToDispalyMemory(unsigned int x,unsigned int y,BMP *bmp); static void _oledWriteCharacterToDispalyMemory(unsigned int x,unsigned int y,char ch,WordStock wordStock); static void _oledWriteStringToDispalyMemoryEx(unsigned int line,char *str,WordStock wordStock,ALIGN align); static void _oledWriteStringToDispalyMemory(unsigned int x,unsigned int y,char *str,WordStock wordStock,FunctionalState wordWrap); //ÆÁÄ»³ß´çÐÅÏ¢ #if OLED_SIZE == OLED_128_64 static unsigned int _screen_hight=64; static unsigned int _screen_width=128; static unsigned char _oled_dis_buff[128][8]; #endif /** *³õÊ&frac14;»¯MCUÓëOLEDÆÁĻͨѶµÄÒý½Å *@param void *@return void */ static void _oledGpioInit(void) { GPIO_InitTypeDef oledInitStruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB,ENABLE);//¿ªÆôGPIOʱÖÓ oledInitStruct.GPIO_Mode = GPIO_Mode_Out_PP;//Ñ¡ÔñÍÆÍìÊä³öģʽ oledInitStruct.GPIO_Speed = GPIO_Speed_50MHz;//Ñ¡ÔñÊä³öËÙÂÊ //CS oledInitStruct.GPIO_Pin = CS_PIN; GPIO_Init(CS_PORT,&oledInitStruct); //DC oledInitStruct.GPIO_Pin = DC_PIN; GPIO_Init(DC_PORT,&oledInitStruct); //SDA oledInitStruct.GPIO_Pin = SDA_PIN; GPIO_Init(SDA_PORT,&oledInitStruct); //SCL oledInitStruct.GPIO_Pin = SCL_PIN; GPIO_Init(SCL_PORT,&oledInitStruct); //RES oledInitStruct.GPIO_Pin = RES_PIN; GPIO_Init(RES_PORT,&oledInitStruct); } /** *ÏòOLEDдÈëÒ»¸ö×Ö½Ú£¬ÃüÁî»òÕßÊý&frac34;Ý *@param OLED_WriteType type дÈ뷽ʽö&frac34;Ù * unsigned char data Êý&frac34;ÝÖµ *@return void */ static void _oledWriteByte(OLED_WriteType type,unsigned char data) { if(type == OLED_CMD)//дÈ뷽ʽ GPIO_ResetBits(DC_PORT,DC_PIN); else GPIO_SetBits(DC_PORT,DC_PIN); GPIO_ResetBits(CS_PORT,CS_PIN);//ʹÄÜÉ豸 for(int index=0;index<8;index++)//Ñ­»··¢ËÍÊý&frac34;Ý ¸ßλÏÈÐÐ { GPIO_ResetBits(SCL_PORT,SCL_PIN);//À­µÍʱÖÓÏß if((data&0x80) == 0x80)//·¢ËÍ×î¸ßλ GPIO_SetBits(SDA_PORT,SDA_PIN); else GPIO_ResetBits(SDA_PORT,SDA_PIN); GPIO_SetBits(SCL_PORT,SCL_PIN);//À­¸ßʱÖÓÏß Íê³ÉһλµÄ·¢ËÍ data <<= 1;//Êý&frac34;Ý×óÒÆÒ»Î» }GPIO_SetBits(CS_PORT,CS_PIN);//ÊÍ·ÅÉ豸 } /** *OLEDÆÁÄ»µÄÓ²&frac14;þ¸´Î» *@param void *@return void */ static void _oledReset(void) { //ÉϵçÖØÖÃ(µÍµçƽÂö³å) GPIO_WriteBit(RES_PORT,RES_PIN,Bit_SET); GPIO_WriteBit(RES_PORT,RES_PIN,Bit_RESET); GPIO_WriteBit(RES_PORT,RES_PIN,Bit_SET); } /** *OLEDĬÈÏ&frac14;Ä´æÆ÷ÅäÖà *@param void *@return ĬÈÏΨһµÄ¿ØÖƽṹÌå */ static void _oledRegisterConfiguration(void) { //»ù±&frac34;ÃüÁî _oledWriteByte(OLED_CMD,0xAE);//¹ØÏÔÊ&frac34; _oledWriteByte(OLED_CMD,0x81);//ÉèÖöԱȶȣ¨Ë«×Ö½Ú£ºÅäºÏÏÂÒ»×Ö½Ú£© _oledWriteByte(OLED_CMD,0xFF);//ÅäÖöԱȶÈΪ0x7F _oledWriteByte(OLED_CMD,0xA4);//»Ö¸´RAMÄÚÈݵÄÏÔÊ&frac34; _oledWriteByte(OLED_CMD,0xA6);//Õý³£ÏÔÊ&frac34;£¨0¹Ø 1¿ª£© //¹öÆÁÃüÁî _oledWriteByte(OLED_CMD,0x2E);//¹Ø±Õ¹öÆÁ¹¦ÄÜ //µØÖ·É趨ÃüÁî _oledWriteByte(OLED_CMD,0x00);//ÉèÖõÍËÄλҳµØÖ· _oledWriteByte(OLED_CMD,0x10);//ÉèÖøßËÄλҳµØÖ· _oledWriteByte(OLED_CMD,0x20);//ÉèÖÃÄÚ´æµØÖ·Ä£Ê½£¨Ë«×Ö½Ú£ºÅäºÏÏÂÒ»×Ö½Ú£© _oledWriteByte(OLED_CMD,0x00);//00£ºË®Æ½Ñ°Ö· 01£º´¹Ö±Ñ°Ö· _oledWriteByte(OLED_CMD,0x21);//ÉèÖÃÁеØÖ· ÉèÖÃÁеĿªÊ&frac14;ºÍ½áÊøµØÖ·£¨Èý×Ö½Ú£ºÅäºÏÏÂÁ½×Ö½Ú£© _oledWriteByte(OLED_CMD,0x00);//ÉèÖÿªÊ&frac14;µØÖ· 0x00 _oledWriteByte(OLED_CMD,0x7f);//ÉèÖýáÊøµØÖ· 0x7f _oledWriteByte(OLED_CMD,0x22);//ÉèÖÃÒ³µØÖ· ÉèÖÃÒ³µÄ¿ªÊ&frac14;ºÍ½áÊøµØÖ· (Èý×Ö½Ú£ºÅäºÏÏÂÁ½×Ö½Ú£© _oledWriteByte(OLED_CMD,0x00);//ÉèÖÿªÊ&frac14;µØÖ· 0x00 _oledWriteByte(OLED_CMD,0x07);//ÉèÖýáÊøµØÖ· 0x07 _oledWriteByte(OLED_CMD,0xB0);//ÉèÖÃÒ³¿ªÊ&frac14;µØÖ· //Ó²&frac14;þÅäÖÃÃüÁî _oledWriteByte(OLED_CMD,0x40);//ÉèÖÃÏÔÊ&frac34;RAMÏÔÊ&frac34;ÆðÊ&frac14;ÐÐ&frac14;Ä´æÆ÷ RAM0 -> COM0 _oledWriteByte(OLED_CMD,0xA1);//ÉèÖöÎÔÙÏÖ ÓÃÓÚ×óÓÒ·´Ïò£¨0£º1£© ˮƽ·­×ª _oledWriteByte(OLED_CMD,0xA8);//ÉèÖöàÓø´ÓÃÂÊ£¨Ë«×Ö½Ú£ºÅäºÏÏÂÒ»×Ö½Ú£© _oledWriteByte(OLED_CMD,0x3f);//--1/64 duty _oledWriteByte(OLED_CMD,0xC8);//ÉèÖÃCOMɨÃèÊä³ö·½Ïò ´ÓCOM0 µ½ COM[N¨C1] ´¹Ö±·­×ª _oledWriteByte(OLED_CMD,0xD3);//ÉèÖÃÏÔÊ&frac34;µÖÏû(Ë«×Ö½Ú£ºÅäºÏÏÂÒ»×Ö½Ú£© _oledWriteByte(OLED_CMD,0x00);//Æ«ÒÆ0 _oledWriteByte(OLED_CMD,0xDA);//ÉèÖÃCOMÒý½Å£¨Ë«×Ö½Ú£ºÅäºÏÏÂÒ»×Ö½Ú£© _oledWriteByte(OLED_CMD,0x12); //ÉèÖÃʱ&frac14;äºÍÇý¶¯·½°¸ÃüÁî _oledWriteByte(OLED_CMD,0xD5);//--set display clock divide ratio/oscillator frequency _oledWriteByte(OLED_CMD,0x80);//--set divide ratio, Set Clock as 100 Frames/Sec _oledWriteByte(OLED_CMD,0xD9);//--set pre-charge period _oledWriteByte(OLED_CMD,0xF1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock _oledWriteByte(OLED_CMD,0xDB);//--set vcomh _oledWriteByte(OLED_CMD,0x40);// _oledWriteByte(OLED_CMD,0x8D);//ÉèÖóäµç±ÃÆôÓÃ/½ûÓà _oledSetPoint(0,7); for(int row=0;row<_screen_hight/8;row++) for(int col=0;col<_screen_width;col++) _oledWriteByte(OLED_DAT,0x00); _oledWriteByte(OLED_CMD,0xAF);//¿ªÏÔÊ&frac34; } /** *ÉèÖÃÏÔÊ&frac34;λÖà *@param unsigned char x unsigned char y *@return void */ static void _oledSetPoint(unsigned char x,unsigned char y) { if((x>=_screen_width) || y>=(_screen_hight/8))return;//·Ç·¨µØÖ· _oledWriteByte(OLED_CMD,0xB0+y%8);//ÉèÖÃÒ³(&frac14;´YÖá×ø±ê) _oledWriteByte(OLED_CMD,0x00+(x&0x0f));//ÉèÖÃÁеÍ4bit _oledWriteByte(OLED_CMD,0x10+(x>>4));//ÉèÖÃÁиß4bit } /** *ͬ²½ÏÔ´æµ½ÆÁÄ» *@param void *@return void */ static void _oledUpDisBuffToDevice(void) { unsigned int colMax=_screen_width; unsigned int rowMax=_screen_hight/8; _oledSetPoint(0x00,0x00);//Ö¸Õë¹éλ //½«ÏÔ´æÊý&frac34;Ýͬ²½µ½ÆÁÄ» for(int row=0;row<rowMax;row++) for(int col=0;col<colMax;col++) _oledWriteByte(OLED_DAT,_oled_dis_buff[col][row]); } /** *OLEDÇåÆÁ²Ù×÷ *@param void *@return void */ static void _oledCls(void) { memInit(_oled_dis_buff,_screen_hight*_screen_width/8,0x00); } /** *OLEDÇå³ý²Ù×÷ *@param unsigned int line ÐÐ0->127 * unsigned int column ÁÐ0->7 *@return void */ static void _oledClear(unsigned int line,unsigned int column) { //µØÖ·ÅÐ¶Ï if((line>=(_screen_hight/8)) || (column>=_screen_width))return; if((line==All_LINE) && (column==All_COLUMN)) _oledCls(); else if(line == All_LINE){ for(int i=0;i<line;i++) _oled_dis_buff[column][i] = 0x00; }else if(column == All_COLUMN){ for(int i=0;i<column;i++) _oled_dis_buff[i][line] = 0x00; }else _oled_dis_buff[column][line] = 0x00; } /** *ÔÚÏÔ´æÖÐдÈë×Ö·ûÊý&frac34;Ý *@param unsigned int x ºá×ø±êÖµ0->(_screen_width-1) * unsigned int y ×Ý×ø±êÖµ0->(_screen_hight/8-1) * char ch ×Ö·ûÂë * WordStock wordStock ×Ö¿âÀàÐÍ *@return void */ static void _oledWriteCharacterToDispalyMemory(unsigned int x,unsigned int y,char ch,WordStock wordStock) { if((x>=_screen_width) || (y>=_screen_hight))return;//·Ç·¨µØÖ· FONT *font = getFontOnWordStock(wordStock,ch);///»ñµÃ×ÖÌå if(font == NULL)return;//ÅжÏ×ÖÌåÊÇ·ñÓÐЧ //Èç¹ûдÈëλÖÃyÊÇXµÄÕûÊýʱ£¬²ÉÓÃÖ±½ÓдÈëЧÂʸü¸ß£¬ÓÃBMP»æÖƵÄÐÎʽ¸ü&frac14;ÓͨÓà if((y%0x08) == 0x00) { _oled.showBmp(x,y,(BMP*)font); }else _oled.showBmp(x,y,(BMP*)font); } /** *ÔÚÏÔ´æÖÐдÈë×Ö·û´®Êý&frac34;Ý *@param unsigned int x ºá×ø±êÖµ0->(_screen_width-1) * unsigned int y ×Ý×ø±êÖµ0->(_screen_hight/8-1) * char str ×Ö·û´® * WordStock wordStock ×Ö¿âÀàÐÍ * FunctionalState wordWrap ×Ô¶¯»Ø³µÊ¹ÄÜ *@return void */ static void _oledWriteStringToDispalyMemory(unsigned int x,unsigned int y,char *str,WordStock wordStock,FunctionalState wordWrap) { if(str == NULL)return;//Ö¸Õë´æÔÚÒì³£ if((x>=_screen_width) || (y>=_screen_hight))return;//·Ç·¨µØÖ· FONT *font = getFontOnWordStock(wordStock,str[0]);//»ñÈ¡×ÖÌå if(font == NULL)return;//ÅжÏ×ÖÌåÊÇ·ñÓÐЧ while(*str != '\0')//Ñ­»··¢ËÍ×Ö·û´®Êý&frac34;Ý { _oledWriteCharacterToDispalyMemory(x,y,*str++,wordStock);//»æÖÆ×Ö·û x += font->width;//×Ö·ûx×ø±êµÝÔö if((x + font->width) >= _screen_width)//Èç¹ûÊ£Óà¿í¶È²»×ãÒÔÏÔÊ&frac34;Ò»¸ö×Ö·ûÔò»Ø³µ»òÕßÍ˳ö { if(wordWrap == ENABLE){ if(y > 7)return;//ÒÑ&frac34;­µ½µ× x = 0;y++; _oledSetPoint(x,y);//ÖØÐÂÉèÖÃÏÔÊ&frac34;µØÖ· }else return; } } } /** *ÔÚÏÔ´æÖÐдÈë×Ö·û´®Êý&frac34;Ý *@param unsigned int line ÐÐÊý * char str ×Ö·û´® * WordStock wordStock ×Ö¿âÀàÐÍ * ALIGN allign ¶ÔÆë·½Ê½£¬¿ÉÒÔʹÓøÃö&frac34;Ù±äÁ¿ *@return void */ static void _oledWriteStringToDispalyMemoryEx(unsigned int line,char *str,WordStock wordStock,ALIGN align) { unsigned int x=0; int strLength = strlen((char*)str);//»ñµÃ×Ö·û´®³¤¶È FONT *font = getFontOnWordStock(wordStock,str[0]);//»ñµÃ×ÖÌ广¸ñ switch(align) { case Align_Left:break;//×ó¶ÔÆë case Align_Center:x = (_screen_width-(strLength*font->width))/2;break;//&frac34;ÓÖÐ¶ÔÆë case Align_Right:x = _screen_width-(strLength*font->width+1);break;//ÓÒ¶ÔÆë default:return; }_oledWriteStringToDispalyMemory(x,line,str,wordStock,DISABLE);//ÏÔÊ&frac34;×Ö·û´® } /** *ÔÚÏÔ´æÖÐдÈëλÍ&frac14;£¬×¢ÒâȡģӦ²ÉÓà ÖðÁС¢ÄæÏòÒõÂëµÄÐÎʽ *@param unsigned int x ºá×ø±êÖµ0->_screen_width-1 * unsigned int y ×Ý×ø±êÖµ0->_screen_hight-1 * BMP *bmp λÍ&frac14;½á¹¹Ìå *@return void */ static void _oledWriteBmpToDispalyMemory(unsigned int x,unsigned int y,BMP *bmp) { long long cache = 0x00; unsigned int bytes = bmp->heiht/0x08; //²ÉÓÃÖðÁÐɨÃèдÈëµÄ·½Ê½ for(int i=0;i<bmp->width;i++) { unsigned int add = (unsigned int)bmp->bmp+i*bytes;//»ñÈ¡Êý&frac34;ݵØÖ· if(bytes > 0x04){ unsigned int add_2 = (unsigned int)bmp->bmp+i*bytes+4;//»ñÈ¡Êý&frac34;ݵØÖ·2 cache = (((long long)(*(unsigned int*)add_2))<<32)|(*(unsigned int*)add);//×°ÔØÊý&frac34;Ý }else cache = *(unsigned int*)add;//×°ÔØÊý&frac34;Ý cache &= ((long long)1<<bmp->heiht)-1;//ÑÚÂë²Ù×÷ cache <<= y; //ÒÆÎ»²Ù×÷ *(long long*)(&_oled_dis_buff[x+i][0]) |= cache;//дÈëÏÔ´æ } } /** *ÔÚÏÔ´æÖÐдÈëµã *@param unsigned int x ºá×ø±êÖµ0->_screen_width-1 * unsigned int y ×Ý×ø±êÖµ0->_screen_hight-1 *@return void */ static void _oledWriteDotToDispalyMemory(unsigned int x,unsigned int y) { if((x > _screen_width) || (y > _screen_hight))return;//ÎÞЧλÖà _oled_dis_buff[x][y/8] |= 0x01<<(y%8); } /** *ÔÚÏÔ´æÖÐдÈëÏß *@param unsigned int s_x ¿ªÊ&frac14;ºá×ø±êÖµ0->_screen_width-1 * unsigned int s_y ¿ªÊ&frac14;×Ý×ø±êÖµ0->_screen_hight-1 * unsigned int e_x ½áÊøºá×ø±êÖµ0->_screen_width-1 * unsigned int e_y ½áÊø×Ý×ø±êÖµ0->_screen_hight-1 *@return void */ static void _oledWriteLineToDispalyMemory(unsigned int s_x,unsigned int s_y,unsigned int e_x,unsigned int e_y) { float stepValue; //ÅжÏÁ½ÖáÖ®²îµÄ´óС£¬&frac34;ö¶¨Ë­×÷ΪÖ÷Öá»æÖÆ if(fabs((int)s_x-(int)e_x) > fabs((int)s_y-(int)e_y)) { //Èç¹û½áÊøx×ø±êСÓÚÆðÊ&frac14;x×ø±êÔòµ÷»» if(e_x < s_x) { unsigned int temp = e_x; e_x = s_x;s_x = temp; temp = e_y; e_y = s_y;s_y = e_y; } //´Ós_x¿ªÊ&frac14;±éÀú stepValue = (int)(e_y - s_y)/(float)((int)(e_x - s_x));//²½½øÖµ for(int i=s_x;i<e_x;i++) _oledWriteDotToDispalyMemory(i,s_y + (i-s_x)*stepValue); }else{ //Èç¹û½áÊøy×ø±êСÓÚÆðÊ&frac14;y×ø±êÔòµ÷»» if(e_y < s_y) { unsigned int temp = e_y; e_y = s_y;s_y = temp; temp = e_x; e_x = s_x;s_x = e_x; } //´Ós_x¿ªÊ&frac14;±éÀú stepValue = (int)(e_x - s_x)/(float)((int)(e_y - s_y));//²½½øÖµ for(int i=s_y;i<e_y;i++) _oledWriteDotToDispalyMemory(s_x + (i-s_y)*stepValue,i); } } /** *ÔÚÏÔ´æÖÐдÈë&frac34;ØÐÎ *@param unsigned int x ¿ªÊ&frac14;ºá×ø±êÖµ0->_screen_width-1 * unsigned int y ¿ªÊ&frac14;×Ý×ø±êÖµ0->_screen_hight-1 * unsigned int length ³¤¶È0->_screen_width-1 * unsigned int width ¿í¶È0->_screen_hight-1 *@return void */ static void _oledWriteRectangleToDispalyMemory(unsigned int x,unsigned int y,unsigned int length,unsigned int width) { //&frac34;ØÐβ»¹ýËÄÌõÏß _oledWriteLineToDispalyMemory(x,y,x,y+width); _oledWriteLineToDispalyMemory(x,y,x+length,y); _oledWriteLineToDispalyMemory(x,y+width,x+length,y+width); _oledWriteLineToDispalyMemory(x+length,y+width,x+length,y); } /** *ÔÚÏÔ´æÖÐдÈëÔ² *@param unsigned int x Ô²Ðĺá×ø±êÖµ0->_screen_width-1 * unsigned int y Ô²ÐÄ×Ý×ø±êÖµ0->_screen_hight-1 * unsigned int radii °ë&frac34;¶0->_screen_width-1 *@return void */ static void _oledWriteCircleToDispalyMemory(unsigned int x,unsigned int y,unsigned int radii) { //±éÀúx×ø±ê»­µã for(int i=(0-radii);i<(int)radii;i++) { //ÀûÓù´¹É¶¨ÀíÇóµÚÈý±é float temp = sqrt((radii*radii)-(i*i)); _oledWriteDotToDispalyMemory(x+i,y-temp); _oledWriteDotToDispalyMemory(x+i,y+temp); } //±éÀúy×ø±ê»­µã for(int i=(0-radii);i<(int)radii;i++) { //ÀûÓù´¹É¶¨ÀíÇóµÚÈý±é float temp = sqrt((radii*radii)-(i*i)); _oledWriteDotToDispalyMemory(x-temp,y+i); _oledWriteDotToDispalyMemory(x+temp,y+i); } } /** *»æÖƲ¨Ðε½ÏÔ´æµ±ÖÐ *@param unsigned char *data Êý&frac34;ÝÖ¸Õë * unsigned int length »º´æÇø³¤¶È *@return ÎÞ */ static void _oledWriteWaveformToDispalyMemory(unsigned char *data,unsigned int length) { for(int i=0;i<length;i++) _oledWriteLineToDispalyMemory(i,63-data[i],i+1,63-data[i+1]); } /** *»ñȡĬÈÏ¿ØÖƽṹÌå,ÕâÊDZ&frac34;ÎÄ&frac14;þΨһµÄ¶ÔÍâ½Ó¿Ú,»ñÈ¡½á¹¹ÌåÖ¸Õëºó£¬ *½ø¶ø¿ÉÒÔ²Ù×÷Õû¸öOLEDÆÁÄ»¡£ *@param void *@return ĬÈÏΨһµÄ¿ØÖƽṹÌå */ OLED* getOledHandle(void) { //Èç¹û¸ÃÖ¸ÕëÒÑ&frac34;­±»»ñÈ¡¹ýÁËÔòÍ˳ö if(_init_status != 0x00) { return &_oled; }else _init_status = 0x01; //Ö´ÐÐÆ÷&frac14;þ³õÊ&frac14;»¯ _oledGpioInit(); _oledReset(); _oledRegisterConfiguration(); //Ϊº¯ÊýÖ¸Õ븳ֵ _oled.cls =_oledCls; _oled.clear = _oledClear; _oled.memorySynchronous = _oledUpDisBuffToDevice; _oled.showString = _oledWriteStringToDispalyMemory; _oled.showStringEx = _oledWriteStringToDispalyMemoryEx; _oled.showCharacter = _oledWriteCharacterToDispalyMemory; _oled.showBmp = _oledWriteBmpToDispalyMemory; _oled.showDot = _oledWriteDotToDispalyMemory; _oled.showLine = _oledWriteLineToDispalyMemory; _oled.showCircle = _oledWriteCircleToDispalyMemory; _oled.showRectangle = _oledWriteRectangleToDispalyMemory; _oled.showWaveform = _oledWriteWaveformToDispalyMemory; return &_oled; } 这个代码属于标准还是模拟(虽然可能是SPI)
07-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值