OLED demo程式(基於AB1601)

2021-08-11 19:28:05 字數 3004 閱讀 4756

oled:ssd1306

#define oled_spi_rspio1//command/data

#define oled_spi_rst

pio2//reset

#define size 16

#define xlevell

0x02

#define xlevelh

0x10

#define max_column

128#define max_row

64#define

brightness

0xff

#define x_width

128#define y_width

64#define oled_cmd  

0//寫命令

#define oled_data 1//寫資料

const unsigned char f6x8[6] =

;const unsigned char f8x16=

930x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94

};const unsigned char hzk[32]=

,,/*"中",0*/

,,/*"景",1*/

,,/*"園",2*/

,,/*"電",3*/

,,/*"子",4*/

,,/*"科",5*/

,,/*"技",6*/

};unsigned char bmp1 =

;unsigned char bmp2 =

;void oledspigpiorsinit(void)

void oledcommandmode(void)

void oleddatamode(void)

void oledspigpiorstinit(void)

void oledrstlow(void)

void oledrsthigh(void)

void oled_rst_set(void)

void oled_rst_clr(void)

void oledspigpioinit(void)

void oled_drv_spi_no_wait_writeread (volatile uint8_t* txbuf, volatile uint16_t txsize, volatile uint8_t* rxbuf, volatile uint16_t rxsize)

static volatile u8 spirxbuf[16];

void oledspiwriteonebyte(volatile u8 regdata)

void oled_wr_byte(u8 dat, u8 mode)

else

oledspiwriteonebyte(dat);

}void oledspiwritedatamulbyte(u8 *pdata, u8 datalen)

oled_drv_spi_no_wait_writeread(spi_tx_buf, datalen, spirxbuf, 0);

}void oled_set_pos(unsigned char x, unsigned char y)

void oled_display_on(void)

void oled_display_off(void)

void oled_clear(void)

for(i=0; i<8; i++)

}static void delay_ms(unsigned int ms)

void oled_showchar(u8 x,u8 y,u8 chr)

if(size == 16)

else

}//m^n函式

u32 oled_pow(u8 m, u8 n)

return result;

}void oled_shownum(u8 x,u8 y,u32 num,u8 len,u8 size2)

else

}//延時函式初始化

//nvic_configuration();//設定nvic中斷分組2:2位搶占優先順序,2位響應優先順序 led_init();    //led埠初始化

oled_init(); //初始化oled

oled_clear();

/*oled_showstring(30,0,"oled test");

oled_showstring(8,2,"zhongjingyuan");

oled_showstring(20,4,"2014/05/01");

oled_showstring(0,6,"ascii:");

oled_showstring(63,6,"code:");

t=' ';

oled_showchinese(0,0,0);//中

oled_showchinese(18,0,1);//景

oled_showchinese(36,0,2);//園

oled_showchinese(54,0,3);//電

oled_showchinese(72,0,4);//子

oled_showchinese(90,0,5);//科

oled_showchinese(108,0,6);//技

*/t=' ';

while(1)

oled_shownum(103,6,t,3,16);//顯示ascii字元的碼值

delay_ms(500);

oled_clear();

delay_ms(500);

oled_drawbmp(0,0,128,8,bmp1);  //顯示(顯示慎用,生成的字表較大,會占用較多空間,flash空間8k以下慎用)

delay_ms(500);

oled_drawbmp(0,0,128,8,bmp2);

delay_ms(500);

printf("hello world.....\n");}}

時間程式(基於UDP)

server 需求 寫乙個時間同步的伺服器 服務端接收請求 按照client端傳送的時間格式,將伺服器時間轉換成對應格式 傳送給客戶端 import time import socket sk socket.socket type socket.sock dgram sk.bind 127.0.0....

基於SOCKET簡單通訊程式

主要功能 利用c s模式,可以多台客服機於主機通訊。標頭檔案 ifndef head h define head h include include include include include include include include include include include inc...

基於UDP簡單聊天程式

server.c include include include include include include include include include include define server port 8888 define max msg size 1024 void udps re...