单片机外设通用化设计
为什么要进行通用化设计
单片机内核多样化,外设功能差异化,给代码移植带来更多工作量,为了避免重复造轮子,使一套代码能够在多种单片机上运行,需要一套通用化的接口。
如何屏蔽平台差异
如何屏蔽编译器差异
单片机外设通用化设计——串口UART
外设功能介绍
API接口通用化
#define STATUS 0x01
#define DISABLE 0x00
#define ENABLE (!DISABLE)
#define ROLE 0x02
#define MASTER 0x01
#define SLAVE 0x02
#define HOST 0x01
#define DEVICE 0x02
#define IT_ENBLE 0x03
#define IT_DISABLE 0x04
#define IT_DMA_ENBLE 0x05
#define IT_DMA_DISABLE 0x06
#define IT_NONE 0x00
#define IT_TXE 0x01
#define IT_TXC 0x02
#define IT_TXH 0x04
#define IT_RXNE 0x08
#define IT_RXC 0x10
#define IT_RXH 0x20
#define IT_IDLE 0x40
#define IT_ERR 0x80
#define PIN_ENBLE 0x07
#define PIN_DISABLE 0x08
#define PIN_REMAP(n) (0xE0|(n))
#define PIN_UNREMAP(n) (0xF0|(n))
// UART
#define PIN_TX 0x01
#define PIN_RX 0x02
#define PIN_CTS 0x04
#define PIN_RTS 0x08
// SPI
#define PIN_CLK 0x01
#define PIN_NSS 0x02
#define PIN_MOSI 0x04
#define PIN_MISO 0x08
#define PIN_SIO0 0x10
#define PIN_SIO1 0x20
#define PIN_SIO2 0x40
#define PIN_SIO3 0x80
// I2C
#define PIN_CLK 0x01
#define PIN_DAT 0x02
#define DMA_ENBLE 0x09
#define DMA_DISABLE 0x0A
#define DMA_TX 0x01
#define DMA_RX 0x02
#define PRIORITY 0x0B
#define PRIORITY_MAIN 0x0B
#define PRIORITY_SUB 0x0C
#define FIFO_SIZE_TX 0x0D
#define FIFO_SIZE_RX 0x0E
#define FIFO_DMA_SIZE_TX 0x0F
#define FIFO_DMA_SIZE_RX 0x10
#define SET_BASE 0x11
#define UART_BPS (SET_BASE+0x00)
#define UART_PARITY (SET_BASE+0x01)
#define PARITY_NONE 0x00
#define PARITY_ODD 0x01
#define PARITY_EVEN 0x02
#define UART_DATA_BITS (SET_BASE+0x02)
#define UART_STOP_BITS (SET_BASE+0x03)
#define STOP_BITS_0_5 0x01
#define STOP_BITS_1 0x02
#define STOP_BITS_1_5 0x03
#define STOP_BITS_2 0x04
#define SPI_SPEED (SET_BASE+0x00)
#define SPI_PHASE (SET_BASE+0x01)
#define SPI_POLARITY (SET_BASE+0x02)
#define SPI_DATA_BITS (SET_BASE+0x03)
#define SPI_FIRST_BIT (SET_BASE+0x04)
#define FIRST_BIT_MSB 0x06
#define FIRST_BIT_LSB 0x06
#define I2C_SPEED (SET_BASE+0x00)
#define I2C_ADDR_BITS (SET_BASE+0x01)
#define I2C_DATA_BITS (SET_BASE+0x02)
#define I2C_SLAVE_ADDR (SET_BASE+0x03)
//---------------------------------------------------------------------------------------------------------------------------
extern void Uart1_Init(u32 bps);
extern void Uart1_DeInit(void);
//---------------------------------------------------------------------------------------------------------------------------
extern void Uart1_Set(u8 cmd, u8 val);
//---------------------------------------------------------------------------------------------------------------------------
// 采用查询方式使用串口
extern void Uart1_TxBuf(void* buf, UART_LEN_T len); // blocking
extern void Uart1_RxBuf(void* buf, UART_LEN_T len, u32 timeout); // blocking
extern void Uart1_RxLine(void* buf, UART_LEN_T len, u32 timeout); // blocking
//---------------------------------------------------------------------------------------------------------------------------
// 采用中断+FIFO方式使用串口
extern void Uart1_IT_TxBuf(void* buf, UART_LEN_T len); // non-blocking
extern void Uart1_IT_RxBuf(void* buf, UART_LEN_T len, u32 timeout); // blocking
//---------------------------------------------------------------------------------------------------------------------------
// 采用DMA方式使用串口
extern void Uart1_DMA_TxBuf(void* buf, UART_LEN_T len); // non-blocking
extern void Uart1_DMA_RxBuf(void* buf, UART_LEN_T len, u32 timeout); // blocking
//---------------------------------------------------------------------------------------------------------------------------
#ifndef __OLED_SSD1306_CFG_H
#define __OLED_SSD1306_CFG_H
#include "type.h"
u8sc OLED_SSD1306_COFIG_TABLE[] =
{
0x2E, // stop scrolling
0xAE, // turn off oled panel
0x00, // set low column address
0x10, // set high column address
0x40, // set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
0x81, // set contrast control register
0xFF, // set SEG Output Current Brightness
0xA1, // set SEG/Column Mapping 0xa0: left to right 0xa1: normal
0xA6, // set normal display
0xA8, // set multiplex ratio(1 to 64)
0x3F, // 1/64 duty
0xC8, // set COM/Row Scan Direction 0xc0: top to bottom 0xc8: normal
0xD3, // set display offset Shift Mapping RAM Counter (0x00~0x3F)
0x00, // not offset
0xD5, // set display clock divide ratio/oscillator frequency
0x80, // set divide ratio, Set Clock as 100 Frames/Sec
// 0xD8,
// 0x05,
0xD9, // set pre-charge period
0xF1, // set Pre-Charge as 15 Clocks & Discharge as 1 Clock
0xDA, // set com pins hardware configuration
0x12, // default com pins hardware configuration
0x20, // set Page Addressing Mode (0x00/0x01/0x02)
0x02, // 0x00:Horizontal Addressing Mode, 0x01:Vertical Addressing Mode, 0x02:Page Addressing Mode
0xDB, // set vcomh
0x20, // set VCOM Deselect Level
0x8D, // set Charge Pump enable/disable
0x14, // set(0x10) disable
0xA4, // disable Entire Display On (0xa4/0xa5)
0xA6, // disable Inverse Display On (0xa6/a7)
0xAF, // turn on oled panel
};
#endif
#ifndef __I2C1_H
#define __I2C1_H
#include "type.h"
#include "setting.h"
#define I2C1_LEN_T u16
extern void I2C1_Init(u32 bps);
extern void I2C1_DeInit(void);
extern void I2C1_Set(u8 cmd, u8 val);
extern void I2C1_Tx1B(u8 addr, u8 reg, u8 dat);
extern u8 I2C1_Rx1B(u8 addr, u8 reg);
extern void I2C1_TxBuf(u8 addr, u8 reg, void* buf, I2C1_LEN_T len);
extern void I2C1_TxRep(u8 addr, u8 reg, u8 dat, I2C1_LEN_T len);
extern void I2C1_DMA_TxBuf(u8 addr, u8 reg, void* buf, I2C1_LEN_T len);
// extern u8* I2C1_RxBuf(u8 addr, u8 reg, void* buf, u32 len);
#endif
#include ".\i2c.h"
#define I2C1_RCC RCC_APB2Periph_GPIOC
#define I2C1_GPIO GPIOC
#define I2C1_SCL_PIN GPIO_Pin_2
#define I2C1_SDA_PIN GPIO_Pin_1
void I2C1_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(I2C1_RCC | RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitStructure.GPIO_Pin = I2C1_SCL_PIN | I2C1_SDA_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(I2C1_GPIO, &GPIO_InitStructure);
}
void I2C1_Init(u32 bps)
{
I2C_InitTypeDef I2C_InitTSturcture;
I2C1_IO_Init();
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
I2C_InitTSturcture.I2C_ClockSpeed = bps;
I2C_InitTSturcture.I2C_Mode = I2C_Mode_I2C;
I2C_InitTSturcture.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitTSturcture.I2C_OwnAddress1 = 0x01;
I2C_InitTSturcture.I2C_Ack = I2C_Ack_Enable;
I2C_InitTSturcture.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_Init(I2C1, &I2C_InitTSturcture);
I2C_Cmd(I2C1, ENABLE);
}
void I2C1_Tx1B(u8 addr, u8 reg, u8 dat)
{
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY) != RESET);
I2C_GenerateSTART(I2C1, ENABLE);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Transmitter);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
I2C_SendData(I2C1, reg);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTING));
I2C_SendData(I2C1, dat);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
I2C_GenerateSTOP(I2C1, ENABLE);
}
u8 I2C1_Rx1B(u8 addr, u8 reg)
{
u8 ret;
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY) != RESET);
I2C_GenerateSTART(I2C1, ENABLE);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Transmitter);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
I2C_SendData(I2C1, reg);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
I2C_GenerateSTART( I2C1, ENABLE );
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(I2C1, reg, I2C_Direction_Receiver);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));
I2C_AcknowledgeConfig(I2C1, DISABLE);
ret = I2C_ReceiveData(I2C1);
I2C_GenerateSTOP(I2C1, ENABLE);
return ret;
}
void I2C1_TxRep(u8 addr, u8 reg, u8 dat, I2C1_LEN_T len)
{
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY) != RESET);
I2C_GenerateSTART(I2C1, ENABLE);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Transmitter);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
I2C_SendData(I2C1, reg);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTING));
while (len--)
{
I2C_SendData(I2C1, dat);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTING));
}
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
I2C_GenerateSTOP(I2C1, ENABLE);
}
void I2C1_TxBuf(u8 addr, u8 reg, void* buf, I2C1_LEN_T len)
{
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY) != RESET);
I2C_GenerateSTART(I2C1, ENABLE);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Transmitter);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
I2C_SendData(I2C1, reg);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTING));
while (len--)
{
I2C_SendData(I2C1, *(u8*)buf);
buf = (u8*)buf + 1;
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTING));
}
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
I2C_GenerateSTOP(I2C1, ENABLE);
}
u8 gf_I2C_DMA_Tx_1st;
void I2C1_Set(u8 cmd, u8 val)
{
DMA_InitTypeDef DMA_InitStructure;
switch (cmd)
{
case IT_ENBLE:
break;
case IT_DISABLE:
break;
case IT_DMA_ENBLE:
break;
case IT_DMA_DISABLE:
break;
case DMA_ENABLE:
if (val & DMA_TX)
{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&I2C1->DATAR);
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)0;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel6, &DMA_InitStructure);
I2C_DMACmd(I2C1, ENABLE);
gf_I2C_DMA_Tx_1st = 1;
}
if (val & DMA_RX)
{
}
break;
case DMA_DISABLE:
break;
case I2C_SLAVE_ADDR:
break;
default:
break;
}
// NVIC_InitTypeDef NVIC_InitStructure;
// NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel6_IRQn;
// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
// NVIC_Init(&NVIC_InitStructure);
// DMA_ITConfig(DMA1_Channel6, DMA_IT_TC, ENABLE);
}
void I2C1_DMA_TxBuf(u8 addr, u8 reg, void* buf, I2C1_LEN_T len)
{
if (gf_I2C_DMA_Tx_1st)
{
gf_I2C_DMA_Tx_1st = 0;
}
else
{
while (DMA_GetFlagStatus(DMA1_FLAG_TC6) == 0);
DMA_ClearFlag(DMA1_FLAG_TC6);
}
DMA_Cmd(DMA1_Channel6, DISABLE);
DMA1_Channel6->MADDR = (u32)buf;
DMA1_Channel6->CNTR = len;
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY) != RESET);
I2C_GenerateSTART(I2C1, ENABLE);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
I2C_Send7bitAddress(I2C1, addr, I2C_Direction_Transmitter);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
I2C_SendData(I2C1, reg);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
DMA_Cmd(DMA1_Channel6, ENABLE);
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
I2C_GenerateSTOP(I2C1, ENABLE);
}
#ifndef __SPI1_H
#define __SPI1_H
#include "type.h"
extern void SPI1_Init(void);
extern void SPI1_Tx1B(u16 dat);
#endif
#include "spi.h"
#define SPI1_RCC RCC_APB2Periph_GPIOC
#define SPI1_GPIO GPIOC
#define SPI1_NSS_PIN GPIO_Pin_1
#define SPI1_SCK_PIN GPIO_Pin_5
#define SPI1_MOSI_PIN GPIO_Pin_6
#define SPI1_MISO_PIN GPIO_Pin_7
void SPI1_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(SPI1_RCC | RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitStructure.GPIO_Pin = SPI1_SCK_PIN | SPI1_MOSI_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(SPI1_GPIO, &GPIO_InitStructure);
}
void SPI1_Init(void)
{
SPI_InitTypeDef SPI_InitStructure;
SPI1_IO_Init();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
SPI_Cmd(SPI1, ENABLE);
}
void SPI1_Tx1B(u16 dat)
{
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
SPI1->DATAR = dat;
}
#ifndef __OLED_SSD1306_CFG_H
#define __OLED_SSD1306_CFG_H
#include "type.h"
u8sc OLED_SSD1306_COFIG_TABLE[] =
{
0x2E, // stop scrolling
0xAE, // turn off oled panel
0x00, // set low column address
0x10, // set high column address
0x40, // set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
0x81, // set contrast control register
0xFF, // set SEG Output Current Brightness
0xA1, // set SEG/Column Mapping 0xa0: left to right 0xa1: normal
0xA6, // set normal display
0xA8, // set multiplex ratio(1 to 64)
0x3F, // 1/64 duty
0xC8, // set COM/Row Scan Direction 0xc0: top to bottom 0xc8: normal
0xD3, // set display offset Shift Mapping RAM Counter (0x00~0x3F)
0x00, // not offset
0xD5, // set display clock divide ratio/oscillator frequency
0x80, // set divide ratio, Set Clock as 100 Frames/Sec
// 0xD8,
// 0x05,
0xD9, // set pre-charge period
0xF1, // set Pre-Charge as 15 Clocks & Discharge as 1 Clock
0xDA, // set com pins hardware configuration
0x12, // default com pins hardware configuration
0x20, // set Page Addressing Mode (0x00/0x01/0x02)
0x00, // 0x00:Horizontal Addressing Mode, 0x01:Vertical Addressing Mode, 0x02:Page Addressing Mode
0xDB, // set vcomh
0x20, // set VCOM Deselect Level
0x8D, // set Charge Pump enable/disable
0x14, // set(0x10) disable
0xA4, // disable Entire Display On (0xa4/0xa5)
0xA6, // disable Inverse Display On (0xa6/a7)
0xAF, // turn on oled panel
};
#endif
#ifndef __OLED_SSD1306_H
#define __OLED_SSD1306_H
#include "type.h"
//#include "lcd.h"
#define LCD_POWER 0x01
#define LCD_BRIGHTNESS 0x02
#define LCD_ROTATION 0x03
#define LCD_H_MIRROR 0x04
#define LCD_V_MIRROR 0x05
#define LCD_REVERSE 0x06
#define LCD_ALL_ON 0x07
extern void OLED_SSD1306_Init(void);
extern void OLED_SSD1306_SetXY(u8 x, u8 page);
extern void OLED_SSD1306_Set(u8 cmd, u8 val);
extern void OLED_SSD1306_Fill(u8 color);
#endif
#include ".\oled_ssd1306.h"
#include ".\oled_ssd1306_cfg.h"
#include "i2c.h"
#define OLED_SSD1306_I2C_ADDR 0x78
#define OLED_SSD1306_I2C_Init() I2C1_Init(400000)
#define OLED_SSD1306_W_CMD(d) I2C1_Tx1B(OLED_SSD1306_I2C_ADDR,OLED_SSD1306_REG_CMD,d)
#define OLED_SSD1306_W_DAT(d) I2C1_Tx1B(OLED_SSD1306_I2C_ADDR,OLED_SSD1306_REG_DAT,d)
#define OLED_SSD1306_W_BUF(buf,n) I2C1_TxBuf(OLED_SSD1306_I2C_ADDR,OLED_SSD1306_REG_DAT,buf,n)
#define OLED_SSD1306_W_REP(dat,n) I2C1_TxRep(OLED_SSD1306_I2C_ADDR,OLED_SSD1306_REG_DAT,dat,n)
#define OLED_SSD1306_MAX_WIDTH (128)
#define OLED_SSD1306_MAX_PAGE (64/8)
#define OLED_SSD1306_REG_CMD 0x00
#define OLED_SSD1306_REG_DAT 0x40
void OLED_SSD1306_Init(void)
{
u8 i = sizeof(OLED_SSD1306_COFIG_TABLE);
OLED_SSD1306_I2C_Init();
while (i--)
{
OLED_SSD1306_W_CMD(OLED_SSD1306_COFIG_TABLE[sizeof(OLED_SSD1306_COFIG_TABLE)-i]);
}
}
void OLED_SSD1306_SetXY(u8 x, u8 page)
{
OLED_SSD1306_W_CMD(0xB0+page);
OLED_SSD1306_W_CMD(x&0x0F);
OLED_SSD1306_W_CMD((x>>4)|0x10);
}
void OLED_SSD1306_Set(u8 cmd, u8 val)
{
switch (cmd)
{
case LCD_POWER:
OLED_SSD1306_W_CMD(0x8D); // Charge Pump enable/disable
OLED_SSD1306_W_CMD(val==0?0x10:0x14); // 0x14: Charge Pump enable, 0x10: disable, default: 0x10
OLED_SSD1306_W_CMD(val==0?0xAE:0xAF); // 0xAE: turn off oled panel, 0xAF: turn on oled panel, default: 0xAF
break;
case LCD_BRIGHTNESS:
OLED_SSD1306_W_CMD(0x81);
OLED_SSD1306_W_CMD(val); // 0x00~0xFF default: 0x7F
break;
case LCD_H_MIRROR:
OLED_SSD1306_W_CMD(val==0?0xA1:0xA0); // default: 0xA1
break;
case LCD_V_MIRROR:
OLED_SSD1306_W_CMD(val==0?0xC0:0xC8); // default: 0xC0
break;
case LCD_REVERSE:
OLED_SSD1306_W_CMD(val==0?0xA6:0xA7); // default: 0xA6
break;
case LCD_ALL_ON:
OLED_SSD1306_W_CMD(val==0?0xA4:0xA5); // default: 0xA4
break;
default:
break;
}
}
void OLED_SSD1306_Fill(u8 color)
{
#ifdef OLED_SSD1306_W_REP
OLED_SSD1306_SetXY(0, 0);
OLED_SSD1306_W_REP(color, OLED_SSD1306_MAX_PAGE * OLED_SSD1306_MAX_WIDTH);
#elif defined OLED_SSD1306_W_BUF
u8 i, buf[OLED_SSD1306_MAX_WIDTH];
for (i=0; i<OLED_SSD1306_MAX_WIDTH; i++)
{
buf[i] = color;
}
for (i=0; i<OLED_SSD1306_MAX_PAGE; i++)
{
OLED_SSD1306_SetXY(0, i);
OLED_SSD1306_W_BUF(buf, OLED_SSD1306_MAX_WIDTH);
}
#else
u16 i = OLED_SSD1306_MAX_PAGE * OLED_SSD1306_MAX_WIDTH;
OLED_SSD1306_SetXY(0, 0);
while (i--)
{
OLED_SSD1306_W_DAT(color);
}
#endif
}
//void OLED_SSD1306_Draw(void* buf, u8 x, u8 page, u8 w, u8 h)
//{
// u8 i, *img;
// img = buf;
// for(i=0; i<(h>>3); i++)
// {
// OLED_SSD1306_SetXY(x, page+i);
// OLED_SSD1306_W_BUF(img, w);
// img+=w;
// }
//}
//
//void OLED_SSD1306_CpyBuf(void* buf, u16 stride)
//{
// u8 i;
// for(i=0; i<OLED_SSD1306_MAX_PAGE; i++)
// {
// OLED_SSD1306_SetXY(0, i);
// OLED_SSD1306_W_BUF(buf, OLED_SSD1306_MAX_WIDTH);
// buf = (u8*)buf + stride;
// }
//}
//void OLED_SSD1306_DisArea(u8 Buffer[][OLED_SSD1306_RES_W], u8 x,u8 y,u8 width,u8 height)
//{
// u8 i;
// height += y;
// y >>= 3;
// height = height&0x07 ? (height>>3)+1 : height>>3;
// for(i=y; i<height; i++)
// {
// OLED_SSD1306_SetPos(x, i);
// OLED_SSD1306_WritenDat(Buffer[i]+x, width);
// }
//}
//void OLED_SSD1306_DisPic(u8 x0,u8 y0,u8 x1,u8 y1,u8* BMP)
//{
// u32 j=0;
// u8 x=0,y=0;
// if(y%8==0)
// y=0;
// else
// y+=1;
// for(y=y0;y<y1;y++)
// {
// OLED_SSD1306_SetPos(x0,y);
// for(x=x0;x<x1;x++)
// {
// OLED_SSD1306_WriteDat(BMP[j]);
// j++;
// }
// }
//}
//void OLED_SSD1306_HMove(u8 Direction ,u8 Speed, u8 PageStart, u8 PageEnd) // Speed: 0~7
//{
// OLED_SSD1306_W_CMD(0x2E); //关闭滚动
// if(Direction)
// OLED_SSD1306_W_CMD(0x26); //水平向左或者右滚动 26/27
// else
// OLED_SSD1306_W_CMD(0x27);
// OLED_SSD1306_W_CMD(0x00); //虚拟字节
// OLED_SSD1306_W_CMD(PageStart); //起始页 0
// if(Speed > 7)
// Speed = 7;
// switch(Speed)
// {
// case 0:
// Speed = 3; // 256 frames
// break;
// case 1:
// Speed = 2; // 128 frames
// break;
// case 2:
// Speed = 1; // 64 frames
// break;
// case 3:
// Speed = 6; // 25 frames
// break;
// case 4:
// Speed = 0; // 5 frames
// break;
// case 5:
// Speed = 5; // 4 frames
// break;
// case 6:
// Speed = 4; // 3 frames
// break;
// case 7:
// Speed = 7; // 2 frames
// break;
// }
// OLED_SSD1306_W_CMD(Speed); //滚动时间间隔
// OLED_SSD1306_W_CMD(PageEnd); //终止页 7
// OLED_SSD1306_W_CMD(0x00); //虚拟字节
// OLED_SSD1306_W_CMD(0xFF); //虚拟字节
// OLED_SSD1306_W_CMD(0x2F); //开启滚动
//}
//void OLED_SSD1306_HVMove(u8 Direction ,u8 Speed, u8 VSpeed, u8 PageStart, u8 PageEnd) // Speed: 0~7
//{
// OLED_SSD1306_W_CMD(0x2E); //关闭滚动
// if(Direction)
// OLED_SSD1306_W_CMD(0x29); //水平垂直和水平滚动左右 29/2a
// else
// OLED_SSD1306_W_CMD(0x2A);
// OLED_SSD1306_W_CMD(0x00); //虚拟字节
// OLED_SSD1306_W_CMD(PageStart); //起始页 0
// if(Speed > 7)
// Speed = 7;
// switch(Speed)
// {
// case 0:
// Speed = 3; // 256 frames
// break;
// case 1:
// Speed = 2; // 128 frames
// break;
// case 2:
// Speed = 1; // 64 frames
// break;
// case 3:
// Speed = 6; // 25 frames
// break;
// case 4:
// Speed = 0; // 5 frames
// break;
// case 5:
// Speed = 5; // 4 frames
// break;
// case 6:
// Speed = 4; // 3 frames
// break;
// case 7:
// Speed = 7; // 2 frames
// break;
// }
// OLED_SSD1306_W_CMD(Speed); //滚动时间间隔
// OLED_SSD1306_W_CMD(PageEnd); //终止页 7
// OLED_SSD1306_W_CMD(VSpeed); //垂直滚动偏移量 1~63
//
// OLED_SSD1306_W_CMD(0xA3);
// OLED_SSD1306_W_CMD(0);
// OLED_SSD1306_W_CMD(64);
//
// OLED_SSD1306_W_CMD(0x2F); //开启滚动
//}
#ifndef __SETTING_H
#define __SETTING_H
#define STATUS 0x01
#define DISABLE 0x00
#define ENABLE (!DISABLE)
#define ROLE 0x02
#define MASTER 0x01
#define SLAVE 0x02
#define HOST 0x01
#define DEVICE 0x02
#define IT_ENBLE 0x03
#define IT_DISABLE 0x04
#define IT_DMA_ENBLE 0x05
#define IT_DMA_DISABLE 0x06
#define IT_NONE 0x00
#define IT_TXE 0x01
#define IT_TXC 0x02
#define IT_TXH 0x04
#define IT_RXNE 0x08
#define IT_RXC 0x10
#define IT_RXH 0x20
#define IT_IDLE 0x40
#define IT_ERR 0x80
#define PIN_ENBLE 0x07
#define PIN_DISABLE 0x08
#define DMA_ENABLE 0x09
#define DMA_DISABLE 0x0A
#define DMA_TX 0x01
#define DMA_RX 0x02
#define PRIORITY 0x0B
#define PRIORITY_MAIN 0x0B
#define PRIORITY_SUB 0x0C
#define FIFO_SIZE_TX 0x0D
#define FIFO_SIZE_RX 0x0E
#define FIFO_DMA_SIZE_TX 0x0F
#define FIFO_DMA_SIZE_RX 0x10
#define PIN_REMAP(n) (0x20|(n))
#define PIN_UNREMAP(n) (0x30|(n))
// UART
#define PIN_TX 0x01
#define PIN_RX 0x02
#define PIN_CTS 0x04
#define PIN_RTS 0x08
// SPI
#define PIN_CLK 0x01
#define PIN_NSS 0x02
#define PIN_MOSI 0x04
#define PIN_MISO 0x08
#define PIN_SIO0 0x10
#define PIN_SIO1 0x20
#define PIN_SIO2 0x40
#define PIN_SIO3 0x80
// I2C
#define PIN_CLK 0x01
#define PIN_DAT 0x02
#define SET_BASE 0x40
// UART
#define UART_BPS (SET_BASE+0x00)
#define UART_PARITY (SET_BASE+0x01)
#define PARITY_NONE 0x00
#define PARITY_ODD 0x01
#define PARITY_EVEN 0x02
#define UART_DATA_BITS (SET_BASE+0x02)
#define UART_STOP_BITS (SET_BASE+0x03)
#define STOP_BITS_0_5 0x01
#define STOP_BITS_1 0x02
#define STOP_BITS_1_5 0x03
#define STOP_BITS_2 0x04
// SPI
#define SPI_SPEED (SET_BASE+0x00)
#define SPI_PHASE (SET_BASE+0x01)
#define SPI_POLARITY (SET_BASE+0x02)
#define SPI_DATA_BITS (SET_BASE+0x03)
#define SPI_FIRST_BIT (SET_BASE+0x04)
#define FIRST_BIT_MSB 0x01
#define FIRST_BIT_LSB 0x02
// I2C
#define I2C_SPEED (SET_BASE+0x00)
#define I2C_ADDR_BITS (SET_BASE+0x01)
#define I2C_DATA_BITS (SET_BASE+0x02)
#define I2C_SLAVE_ADDR (SET_BASE+0x03)
#endif
#ifndef __OLED_SSD1327_H
#define __OLED_SSD1327_H
#include "type.h"
extern void OLED_SSD1327_Init(void);
extern void OLED_SSD1327_SetXY(u8 x, u8 page);
extern void OLED_SSD1327_Set(u8 cmd, u8 val);
extern void OLED_SSD1327_Fill(u8 color);
extern void OLED_SSD1327_Fill222(void);
#endif
#include "oled_ssd1327.h"
#include "spi.h"
#define OLED_1in5_WIDTH 128
#define OLED_1in5_HEIGHT 128
#define OLED_SSD1327_RCC RCC_APB2Periph_GPIOC
#define OLED_SSD1327_GPIO GPIOC
#define OLED_SSD1327_DC_PIN GPIO_Pin_4
#define OLED_SSD1327_CS_PIN GPIO_Pin_7
#define OLED_SSD1327_RST_PIN GPIO_Pin_3
#define OLED_SSD1327_DC_H GPIO_SetBits( OLED_SSD1327_GPIO,OLED_SSD1327_DC_PIN)
#define OLED_SSD1327_DC_L GPIO_ResetBits(OLED_SSD1327_GPIO,OLED_SSD1327_DC_PIN)
#define OLED_SSD1327_CS_H GPIO_SetBits( OLED_SSD1327_GPIO,OLED_SSD1327_CS_PIN)
#define OLED_SSD1327_CS_L GPIO_ResetBits(OLED_SSD1327_GPIO,OLED_SSD1327_CS_PIN)
#define OLED_SSD1327_RST_H GPIO_SetBits( OLED_SSD1327_GPIO,OLED_SSD1327_RST_PIN)
#define OLED_SSD1327_RST_L GPIO_ResetBits(OLED_SSD1327_GPIO,OLED_SSD1327_RST_PIN)
#define OLED_SSD1327_SPI_Init() SPI1_Init()
#define OLED_SSD1327_W_CMD(d) OLED_SSD1327_DC_L;SPI1_Tx1B(d)
#define OLED_SSD1327_W_DAT(d) OLED_SSD1327_DC_H;SPI1_Tx1B(d)
#define OLED_SSD1327_W_BUF(buf,n) I2C1_TxBuf(OLED_SSD1306_I2C_ADDR,OLED_SSD1306_REG_DAT,buf,n)
#define OLED_SSD1327_W_REP(dat,n) I2C1_TxRep(OLED_SSD1306_I2C_ADDR,OLED_SSD1306_REG_DAT,dat,n)
void OLED_SSD1327_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(OLED_SSD1327_RCC, ENABLE);
GPIO_InitStructure.GPIO_Pin = OLED_SSD1327_DC_PIN | OLED_SSD1327_CS_PIN | OLED_SSD1327_RST_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(OLED_SSD1327_GPIO, &GPIO_InitStructure);
}
void OLED_SSD1327_Init(void)
{
OLED_SSD1327_IO_Init();
OLED_SSD1327_SPI_Init();
OLED_SSD1327_CS_L;
OLED_SSD1327_RST_H;
Delay_Ms(100);
OLED_SSD1327_RST_L;
Delay_Ms(100);
OLED_SSD1327_RST_H;
Delay_Ms(100);
OLED_SSD1327_W_CMD(0xae); // turn off oled panel
OLED_SSD1327_W_CMD(0x15); // set column address
OLED_SSD1327_W_CMD(0x00); // start column 0
OLED_SSD1327_W_CMD(0x7f); // end column 127
OLED_SSD1327_W_CMD(0x75); // set row address
OLED_SSD1327_W_CMD(0x00); // start row 0
OLED_SSD1327_W_CMD(0x7f); // end row 127
OLED_SSD1327_W_CMD(0x81); // set contrast control
OLED_SSD1327_W_CMD(0x80);
OLED_SSD1327_W_CMD(0xA0); // gment remap
OLED_SSD1327_W_CMD(0x51);
OLED_SSD1327_W_CMD(0xa1); // start line
OLED_SSD1327_W_CMD(0x00);
OLED_SSD1327_W_CMD(0xa2); // display offset
OLED_SSD1327_W_CMD(0x00);
OLED_SSD1327_W_CMD(0xa4); // rmal display
OLED_SSD1327_W_CMD(0xa8); // set multiplex ratio
OLED_SSD1327_W_CMD(0x7f);
OLED_SSD1327_W_CMD(0xb1); // set phase leghth
OLED_SSD1327_W_CMD(0xf1);
OLED_SSD1327_W_CMD(0xb3); // set dclk
OLED_SSD1327_W_CMD(0x00); // 80Hz:0xc1 90Hz:0xe1 100Hz:0x00 110Hz:0x30 120Hz:0x50 130Hz:0x70 01
OLED_SSD1327_W_CMD(0xab);
OLED_SSD1327_W_CMD(0x01);
OLED_SSD1327_W_CMD(0xb6); // set phase leghth
OLED_SSD1327_W_CMD(0x0f);
OLED_SSD1327_W_CMD(0xbe);
OLED_SSD1327_W_CMD(0x0f);
OLED_SSD1327_W_CMD(0xbc);
OLED_SSD1327_W_CMD(0x08);
OLED_SSD1327_W_CMD(0xd5);
OLED_SSD1327_W_CMD(0x62);
OLED_SSD1327_W_CMD(0xfd);
OLED_SSD1327_W_CMD(0x12);
Delay_Ms(200);
OLED_SSD1327_W_CMD(0xAF); // Turn on the OLED display
}
void OLED_SSD1327_SetXY(u8 x, u8 y)
{
OLED_SSD1327_W_CMD(0x15);
OLED_SSD1327_W_CMD(x/2);
OLED_SSD1327_W_CMD(0x3F);
OLED_SSD1327_W_CMD(0x75);
OLED_SSD1327_W_CMD(y);
OLED_SSD1327_W_CMD(0x7F);
}
void OLED_SSD1327_SetWin(u8 Xstart, u8 Ystart, u8 Xend, u8 Yend)
{
OLED_SSD1327_W_CMD(0x15);
OLED_SSD1327_W_CMD(Xstart/2);
OLED_SSD1327_W_CMD(Xend/2 - 1);
OLED_SSD1327_W_CMD(0x75);
OLED_SSD1327_W_CMD(Ystart);
OLED_SSD1327_W_CMD(Yend - 1);
}
void OLED_SSD1327_Fill(u8 color)
{
u16 i;
OLED_SSD1327_SetXY(0, 0);
for(i=0; i<OLED_1in5_WIDTH*OLED_1in5_HEIGHT/2; i++)
{
OLED_SSD1327_W_DAT(color);
}
}
void OLED_SSD1327_Fill222(void)
{
u16 i;
OLED_SSD1327_SetXY(0, 2);
for(i=0; i<32; i++)
{
OLED_SSD1327_W_DAT(0xff);
}
OLED_SSD1327_SetXY(4, 0);
for(i=0; i<2; i++)
{
OLED_SSD1327_W_DAT(0xff);
}
}
//void OLED_1in5_Display(const UBYTE *Image)
//{
// u16 i, j, temp;
// OLED_SetWindow(0, 0, 128, 128);
// for(i=0; i<OLED_1in5_HEIGHT; i++)
// for(j=0; j<OLED_1in5_WIDTH/2; j++)
// {
// temp = Image[j + i*64];
// OLED_SSD1327_W_DAT(temp);
// }
//}
#ifndef __FIFO_H
#define __FIFO_H
#ifdef __cplusplus
extern "C" {
#endif
#include "type.h"
#define FIFO_LEN_T u32
extern void* Fifo_Malloc(FIFO_LEN_T size);
extern void Fifo_Free(void* fifo);
extern FIFO_LEN_T Fifo_Query(void* fifo);
extern FIFO_LEN_T Fifo_Push(void* fifo, void* buf, FIFO_LEN_T len);
extern FIFO_LEN_T Fifo_Pull(void* fifo, void* buf, FIFO_LEN_T len);
#ifdef __cplusplus
}
#endif
#endif
#include ".\fifo.h"
typedef struct
{
void* addr;
FIFO_LEN_T head;
FIFO_LEN_T tail;
FIFO_LEN_T size;
} Fifo_t;
void* Fifo_Malloc(FIFO_LEN_T size)
{
Fifo_t* fifo;
void* addr = Mem_Malloc(size);
if (addr == NULL) return NULL;
fifo = (Fifo_t*)Mem_Malloc(sizeof(Fifo_t));
if (fifo == (Fifo_t*)NULL)
{
Mem_Free(addr);
}
else
{
fifo->head = 0;
fifo->tail = 0;
fifo->addr = addr;
fifo->size = size;
}
return fifo;
}
void Fifo_Free(void* fifo)
{
void* addr = ((Fifo_t*)fifo)->addr;
Mem_Free(fifo);
Mem_Free(addr);
}
FIFO_LEN_T Fifo_Query(void* fifo)
{
FIFO_LEN_T size;
if (((Fifo_t*)fifo)->head > ((Fifo_t*)fifo)->tail)
{
size = ((Fifo_t*)fifo)->size - ((Fifo_t*)fifo)->head + ((Fifo_t*)fifo)->tail;
}
else if (((Fifo_t*)fifo)->head < ((Fifo_t*)fifo)->tail)
{
size = ((Fifo_t*)fifo)->tail - ((Fifo_t*)fifo)->head;
}
else
{
return 0;
}
return size;
}
FIFO_LEN_T Fifo_Push(void* fifo, void* buf, FIFO_LEN_T len)
{
FIFO_LEN_T size;
if (((Fifo_t*)fifo)->head > ((Fifo_t*)fifo)->tail)
{
size = ((Fifo_t*)fifo)->size - ((Fifo_t*)fifo)->head;
if (len > ((Fifo_t*)fifo)->tail + size) return 0;
if (len > size)
{
Mem_Cpy(((Fifo_t*)fifo)->addr + ((Fifo_t*)fifo)->head, buf, size);
Mem_Cpy(((Fifo_t*)fifo)->addr, buf + size, len - size);
((Fifo_t*)fifo)->head = len - size;
}
else
{
Mem_Cpy(((Fifo_t*)fifo)->addr + ((Fifo_t*)fifo)->head, buf, len);
((Fifo_t*)fifo)->head = (len == size) ? 0 : ((Fifo_t*)fifo)->head + len;
}
}
else if (((Fifo_t*)fifo)->head < ((Fifo_t*)fifo)->tail)
{
size = ((Fifo_t*)fifo)->tail - ((Fifo_t*)fifo)->head;
if (len > size) return 0;
Mem_Cpy(((Fifo_t*)fifo)->addr + ((Fifo_t*)fifo)->head, buf, len);
((Fifo_t*)fifo)->head += len;
}
else
{
return 0;
}
return len;
}
FIFO_LEN_T Fifo_Pull(void* fifo, void* buf, FIFO_LEN_T len)
{
FIFO_LEN_T size;
if (((Fifo_t*)fifo)->head > ((Fifo_t*)fifo)->tail)
{
size = ((Fifo_t*)fifo)->head - ((Fifo_t*)fifo)->tail;
if (len > size) len = size;
Mem_Cpy(buf, ((Fifo_t*)fifo)->addr + ((Fifo_t*)fifo)->tail, len);
((Fifo_t*)fifo)->tail += len;
}
else if (((Fifo_t*)fifo)->head < ((Fifo_t*)fifo)->tail)
{
size = ((Fifo_t*)fifo)->size - ((Fifo_t*)fifo)->tail;
if (len > size)
{
if (len > ((Fifo_t*)fifo)->head + size) len = ((Fifo_t*)fifo)->head + size;
Mem_Cpy(buf, ((Fifo_t*)fifo)->addr + ((Fifo_t*)fifo)->tail, size);
Mem_Cpy(buf + size, ((Fifo_t*)fifo)->addr, len - size);
((Fifo_t*)fifo)->tail = len - size;
}
else
{
Mem_Cpy(buf, ((Fifo_t*)fifo)->addr + ((Fifo_t*)fifo)->tail, len);
((Fifo_t*)fifo)->tail = (len == size) ? 0 : ((Fifo_t*)fifo)->tail + len;
}
}
else
{
return 0;
}
return len;
}
API实现方式
基于51单片机实现API
- 项目
- 项目
- 项目
- 项目
- 项目1
- 项目2
- 项目3
- 计划任务
- 完成任务
基于STM32单片机实现API
一个简单的表格是这么创建的:
项目 | Value |
---|---|
电脑 | $1600 |
手机 | $12 |
导管 | $1 |
设定内容居中、居左、居右
使用:---------:
居中
使用:----------
居左
使用----------:
居右
第一列 | 第二列 | 第三列 |
---|---|---|
第一列文本居中 | 第二列文本居右 | 第三列文本居左 |
SmartyPants
SmartyPants将ASCII标点字符转换为“智能”印刷标点HTML实体。例如:
TYPE | ASCII | HTML |
---|---|---|
Single backticks | 'Isn't this fun?' | ‘Isn’t this fun?’ |
Quotes | "Isn't this fun?" | “Isn’t this fun?” |
Dashes | -- is en-dash, --- is em-dash | – is en-dash, — is em-dash |
创建一个自定义列表
-
Markdown
- Text-to- HTML conversion tool Authors
- John
- Luke
如何创建一个注脚
一个具有注脚的文本。1
注释也是必不可少的
Markdown将文本转换为 HTML。
KaTeX数学公式
您可以使用渲染LaTeX数学表达式 KaTeX:
Gamma公式展示 Γ ( n ) = ( n − 1 ) ! ∀ n ∈ N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb N Γ(n)=(n−1)!∀n∈N 是通过欧拉积分
Γ ( z ) = ∫ 0 ∞ t z − 1 e − t d t . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. Γ(z)=∫0∞tz−1e−tdt.
你可以找到更多关于的信息 LaTeX 数学表达式here.
新的甘特图功能,丰富你的文章
- 关于 甘特图 语法,参考 这儿,
UML 图表
可以使用UML图表进行渲染。 Mermaid. 例如下面产生的一个序列图:
这将产生一个流程图。:
- 关于 Mermaid 语法,参考 这儿,
FLowchart流程图
我们依旧会支持flowchart的流程图:
- 关于 Flowchart流程图 语法,参考 这儿.
导出与导入
导出
如果你想尝试使用此编辑器, 你可以在此篇文章任意编辑。当你完成了一篇文章的写作, 在上方工具栏找到 文章导出 ,生成一个.md文件或者.html文件进行本地保存。
导入
如果你想加载一篇你写过的.md文件,在上方工具栏可以选择导入功能进行对应扩展名的文件导入,
继续你的创作。
我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客:
- 全新的界面设计 ,将会带来全新的写作体验;
- 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示;
- 增加了 图片拖拽 功能,你可以将本地的图片直接拖拽到编辑区域直接展示;
- 全新的 KaTeX数学公式 语法;
- 增加了支持甘特图的mermaid语法2 功能;
- 增加了 多屏幕编辑 Markdown文章功能;
- 增加了 焦点写作模式、预览模式、简洁写作模式、左右区域同步滚轮设置 等功能,功能按钮位于编辑区域与预览区域中间;
- 增加了 检查列表 功能。
撤销:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜体:Ctrl/Command + I
标题:Ctrl/Command + Shift + H
无序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
检查列表:Ctrl/Command + Shift + C
插入代码:Ctrl/Command + Shift + K
插入链接:Ctrl/Command + Shift + L
插入图片:Ctrl/Command + Shift + G
查找:Ctrl/Command + F
替换:Ctrl/Command + G
直接输入1次#,并按下space后,将生成1级标题。
输入2次#,并按下space后,将生成2级标题。
以此类推,我们支持6级标题。有助于使用TOC
语法后生成一个完美的目录。
强调文本 强调文本
加粗文本 加粗文本
标记文本
删除文本
引用文本
H2O is是液体。
210 运算结果是 1024.
链接: link.
图片:
带尺寸的图片:
居中的图片:
居中并且带尺寸的图片:
当然,我们为了让用户更加便捷,我们增加了图片拖拽功能。
去博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片
.
注脚的解释 ↩︎