中文字库

This commit is contained in:
wu58430 2023-12-20 10:10:45 +08:00
parent 285e9f855a
commit f57f344672
7 changed files with 19373 additions and 22 deletions

View file

@ -22,9 +22,12 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="cea36e80-e289-4d69-9030-7186d540ac0e" name="更改" comment="中英文字符对齐"> <list default="true" id="cea36e80-e289-4d69-9030-7186d540ac0e" name="更改" comment="中英文字符对齐">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/app.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/app.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Makefile" beforeDir="false" afterPath="$PROJECT_DIR$/Makefile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/driver/bk4819.c" beforeDir="false" afterPath="$PROJECT_DIR$/driver/bk4819.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/driver/bk4819.c" beforeDir="false" afterPath="$PROJECT_DIR$/driver/bk4819.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/helper.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/helper.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/font.h" beforeDir="false" afterPath="$PROJECT_DIR$/font.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/main.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.c" beforeDir="false" afterPath="$PROJECT_DIR$/settings.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/uv-k5font/font_new/font.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/uv-k5font/font_new/font.cpp" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View file

@ -45,10 +45,12 @@ ENABLE_REDUCE_LOW_MID_TX_POWER?= 0
ENABLE_BYP_RAW_DEMODULATORS ?= 0 ENABLE_BYP_RAW_DEMODULATORS ?= 0
ENABLE_BLMIN_TMP_OFF ?= 0 ENABLE_BLMIN_TMP_OFF ?= 0
ENABLE_SCAN_RANGES ?= 1 ENABLE_SCAN_RANGES ?= 1
ENABLE_MDC1200 ?= 1 ENABLE_MDC1200 ?= 1
ENABLE_MDC1200_SHOW_OP_ARG ?= 1 ENABLE_MDC1200_SHOW_OP_ARG ?= 1
ENABLE_MDC1200_SIDE_BEEP ?= 0 ENABLE_MDC1200_SIDE_BEEP ?= 0
ENABLE_MDC1200_CONTACT ?= 1 ENABLE_MDC1200_CONTACT ?= 1
ENABLE_CHINESE_FULL1 ?= 0
ENABLE_CHINESE_FULL2 ?= 0
# ---- DEBUGGING ---- # ---- DEBUGGING ----
@ -262,6 +264,12 @@ endif
ifeq ($(ENABLE_MDC1200_CONTACT),1) ifeq ($(ENABLE_MDC1200_CONTACT),1)
CFLAGS += -DENABLE_MDC1200_CONTACT CFLAGS += -DENABLE_MDC1200_CONTACT
endif endif
ifeq ($(ENABLE_CHINESE_FULL1),1)
CFLAGS += -DENABLE_CHINESE_FULL1
endif
ifeq ($(ENABLE_CHINESE_FULL2),1)
CFLAGS += -DENABLE_CHINESE_FULL2
endif
ifeq ($(ENABLE_MDC1200_SHOW_OP_ARG),1) ifeq ($(ENABLE_MDC1200_SHOW_OP_ARG),1)
CFLAGS += -DENABLE_MDC1200_SHOW_OP_ARG CFLAGS += -DENABLE_MDC1200_SHOW_OP_ARG
endif endif

View file

@ -38,25 +38,86 @@ void EEPROM_ReadBuffer(uint16_t Address, void *pBuffer, uint8_t Size)
I2C_Stop(); I2C_Stop();
} }
void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer) void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer)
{ {
if (pBuffer == NULL || Address >= 0x2000) if (pBuffer == NULL || Address >= 0x2000)
return; return;
uint8_t buffer[8]; uint8_t buffer[8];
EEPROM_ReadBuffer(Address, buffer, 8); EEPROM_ReadBuffer(Address, buffer, 8);
if (memcmp(pBuffer, buffer, 8) != 0) if (memcmp(pBuffer, buffer, 8) != 0)
{ {
I2C_Start(); I2C_Start();
I2C_Write(0xA0); I2C_Write(0xA0);
I2C_Write((Address >> 8) & 0xFF); I2C_Write((Address >> 8) & 0xFF);
I2C_Write((Address >> 0) & 0xFF); I2C_Write((Address >> 0) & 0xFF);
I2C_WriteBuffer(pBuffer, 8); I2C_WriteBuffer(pBuffer, 8);
I2C_Stop(); I2C_Stop();
} }
// give the EEPROM time to burn the data in (apparently takes 5ms) // give the EEPROM time to burn the data in (apparently takes 5ms)
SYSTEM_DelayMs(8); SYSTEM_DelayMs(8);
}
#define AT24C1024_ADDRESS 0xA4
#define AT24C1024_PAGE_SIZE 64
void E1EPROM_ReadBuffer_1024(uint32_t Address, void *pBuffer, uint16_t Size) {
if (pBuffer == NULL || Address >= 0x20000) // Address limit for AT24C1024 (17-bit address)
return;
uint16_t bytesRead = 0;
uint8_t* dataPointer = (uint8_t*)pBuffer;
while (bytesRead < Size) {
uint16_t bytesToRead = (Size - bytesRead < AT24C1024_PAGE_SIZE) ? (Size - bytesRead) : AT24C1024_PAGE_SIZE;
uint16_t offset = Address % AT24C1024_PAGE_SIZE;
I2C_Start();
I2C_Write(AT24C1024_ADDRESS | ((Address >> 16) & 0x01)); // Sending device address and MSB of memory address
I2C_Write((uint8_t)(Address >> 8)); // Sending address high byte
I2C_Write((uint8_t)(Address & 0xFF)); // Sending address low byte
I2C_Start();
I2C_Write(AT24C1024_ADDRESS | 0x01); // Sending device address with read bit
uint8_t buffer[AT24C1024_PAGE_SIZE];
I2C_ReadBuffer(buffer, AT24C1024_PAGE_SIZE);
// Copy the relevant portion of the buffer to the output buffer
memcpy(dataPointer, buffer + offset, bytesToRead);
bytesRead += bytesToRead;
dataPointer += bytesToRead;
Address += bytesToRead;
I2C_Stop();
}
}
void E1EPROM_WriteBuffer_1024(uint32_t Address, const void *pBuffer, uint16_t Size) {
if (pBuffer == NULL || Address >= 0x20000) // Address limit for AT24C1024 (17-bit address)
return;
uint8_t buffer[AT24C1024_PAGE_SIZE];
uint32_t endAddress = Address + Size;
for (uint32_t addr = Address; addr < endAddress; addr += AT24C1024_PAGE_SIZE) {
uint16_t bytesToWrite = (endAddress - addr < AT24C1024_PAGE_SIZE) ? (endAddress - addr) : AT24C1024_PAGE_SIZE;
uint16_t offset = Address % AT24C1024_PAGE_SIZE;
uint16_t remaining = AT24C1024_PAGE_SIZE - offset;
bytesToWrite = (bytesToWrite < remaining) ? bytesToWrite : remaining;
EEPROM_ReadBuffer(addr - offset, buffer, AT24C1024_PAGE_SIZE);
if (memcmp(pBuffer, buffer + offset, bytesToWrite) != 0) {
I2C_Start();
I2C_Write(AT24C1024_ADDRESS | ((addr >> 16) & 0x01)); // Sending device address and MSB of memory address
I2C_Write((uint8_t)(addr >> 8)); // Sending address high byte
I2C_Write((uint8_t)(addr & 0xFF)); // Sending address low byte
I2C_WriteBuffer(pBuffer, bytesToWrite);
I2C_Stop();
}
pBuffer += bytesToWrite;
// give the EEPROM time to burn the data in (assuming 5ms per page write)
SYSTEM_DelayMs(5);
}
} }

View file

@ -21,6 +21,8 @@
void EEPROM_ReadBuffer(uint16_t Address, void *pBuffer, uint8_t Size); void EEPROM_ReadBuffer(uint16_t Address, void *pBuffer, uint8_t Size);
void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer); void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer);
void E1EPROM_ReadBuffer_1024(uint32_t Address, void *pBuffer, uint16_t Size) ;
void E1EPROM_WriteBuffer_1024(uint32_t Address, const void *pBuffer, uint16_t Size) ;
#endif #endif

6
font.h
View file

@ -29,6 +29,12 @@ extern const uint8_t gFontSmall[95 - 1][6];
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
extern const uint8_t gFontSmallBold[95 - 1][6]; extern const uint8_t gFontSmallBold[95 - 1][6];
#endif #endif
#ifdef ENABLE_CHINESE_FULL1
extern uint8_t gFontChinese_out1[57742];
#elifdef ENABLE_CHINESE_FULL2
extern uint8_t gFontChinese_out2[57742];
#endif
#endif #endif

16
main.c
View file

@ -81,7 +81,14 @@ void Main(void)
#ifdef ENABLE_UART #ifdef ENABLE_UART
UART_Init(); UART_Init();
#endif #endif
SETTINGS_InitEEPROM();
#ifdef ENABLE_CHINESE_FULL1
SETTINGS_InitEEPROM();
#elifdef ENABLE_CHINESE_FULL2
SETTINGS_InitEEPROM();
#endif
memset(gDTMF_String, '-', sizeof(gDTMF_String)); memset(gDTMF_String, '-', sizeof(gDTMF_String));
@ -205,6 +212,15 @@ void Main(void)
// for (int i =MDC_ADD[0]; i < MDC_ADD[0]+16; ++i) { // for (int i =MDC_ADD[0]; i < MDC_ADD[0]+16; ++i) {
// EEPROM_WriteBuffer(i,&A[i-MDC_ADD[0]]); // EEPROM_WriteBuffer(i,&A[i-MDC_ADD[0]]);
// } // }
uint8_t B[64];
memset(B,'B',sizeof (B));
E1EPROM_WriteBuffer_1024(0x10000,B,64);
E1EPROM_ReadBuffer_1024(0x10000,B,64);
UART_Send(B,64);
while(1)
{
}
while (1) while (1)
{ {

File diff suppressed because it is too large Load diff