Skip to content

Commit e836a4c

Browse files
authored
Merge pull request solosky#254 from VocalFan/main
Small optimizations
2 parents b99fd2c + 1b35552 commit e836a4c

File tree

2 files changed

+67
-56
lines changed

2 files changed

+67
-56
lines changed

fw/application/src/hal/hal_spi_flash.c

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -149,38 +149,48 @@ ret_code_t hal_spi_flash_info(flash_info_t *info) {
149149
memory_type_capacity = rx[1];
150150
memory_type_capacity = (memory_type_capacity << 8) | rx[2];
151151

152-
if (memory_type_capacity == MTC_MX25L25645_GM2I) {
153-
NRF_LOG_INFO("MX25L25645GM2I-10G detection");
154-
info->block_count = 8192;
155-
} else if (memory_type_capacity == MTC_W25Q128_BV) {
156-
NRF_LOG_INFO("W25Q128BV detection");
157-
info->block_count = 4096;
158-
} else if (memory_type_capacity == MTC_W25Q64_BV_CV) {
159-
NRF_LOG_INFO("W25Q64BV or W25Q64CV detection");
160-
info->block_count = 2048;
161-
} else if (memory_type_capacity == MTC_W25Q64_DW) {
162-
NRF_LOG_INFO("W25Q64DW detection");
163-
info->block_count = 2048;
164-
} else if (memory_type_capacity == MTC_W25Q32_BV) {
165-
NRF_LOG_INFO("W25Q32BV detection");
166-
info->block_count = 1024;
167-
} else if (memory_type_capacity == MTC_W25Q32_DW) {
168-
NRF_LOG_INFO("W25Q32DW detection");
169-
info->block_count = 1024;
170-
} else if (memory_type_capacity == MTC_W25Q16_BV_CL_CV) {
171-
NRF_LOG_INFO("W25Q16BV or W25Q16CL or W25Q16CV detection");
172-
info->block_count = 512;
173-
} else if (memory_type_capacity == MTC_W25Q16_DW) {
174-
NRF_LOG_INFO("W25Q16DW detection");
175-
info->block_count = 512;
176-
} else {
177-
NRF_LOG_INFO("Memory Capacity error! %d", memory_type_capacity);
178-
info->block_count = 0;
179-
return NRF_ERROR_INVALID_PARAM;
152+
switch (memory_type_capacity) {
153+
case MTC_MX25L25645_GM2I:
154+
NRF_LOG_INFO("MX25L25645GM2I-10G detection");
155+
info->block_count = 8192;
156+
break;
157+
case MTC_W25Q128_BV:
158+
NRF_LOG_INFO("W25Q128BV detection");
159+
info->block_count = 4096;
160+
break;
161+
case MTC_W25Q64_BV_CV:
162+
NRF_LOG_INFO("W25Q64BV or W25Q64CV detection");
163+
info->block_count = 2048;
164+
break;
165+
case MTC_W25Q64_DW:
166+
NRF_LOG_INFO("W25Q64DW detection");
167+
info->block_count = 2048;
168+
break;
169+
case MTC_W25Q32_BV:
170+
NRF_LOG_INFO("W25Q32BV detection");
171+
info->block_count = 1024;
172+
break;
173+
case MTC_W25Q32_DW:
174+
NRF_LOG_INFO("W25Q32DW detection");
175+
info->block_count = 1024;
176+
break;
177+
case MTC_W25Q16_BV_CL_CV:
178+
NRF_LOG_INFO("W25Q16BV or W25Q16CL or W25Q16CV detection");
179+
info->block_count = 512;
180+
break;
181+
case MTC_W25Q16_DW:
182+
NRF_LOG_INFO("W25Q16DW detection");
183+
info->block_count = 512;
184+
break;
185+
default:
186+
NRF_LOG_INFO("Memory Capacity error! %d", memory_type_capacity);
187+
info->block_count = 0;
188+
return NRF_ERROR_INVALID_PARAM;
180189
}
181190
return NRF_SUCCESS;
182191
}
183192

193+
184194
ret_code_t hal_spi_flash_read(uint32_t address, void *buffer, size_t size) {
185195

186196
uint8_t tx[4];

fw/application/src/i18n/language.c

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,35 @@ const char *getLangString(L_StringID stringID) {
3232
void setLanguage(Language lang) { currentLanguage = lang; }
3333

3434
const char *getLangDesc(Language lang) {
35-
if (lang == LANGUAGE_ZH_HANS) {
36-
return "简体中文";
37-
} else if (lang == LANGUAGE_EN_US) {
38-
return "English";
39-
} else if (lang == LANGUAGE_ZH_TW) {
40-
return "繁體中文(臺灣)";
41-
} else if (lang == LANGUAGE_ES_ES) {
42-
return "Español";
43-
} else if (lang == LANGUAGE_IT_IT) {
44-
return "Italiano";
45-
} else if (lang == LANGUAGE_HU_HU) {
46-
return "Magyar";
47-
} else if (lang == LANGUAGE_DE_DE) {
48-
return "Deutsch";
49-
} else if (lang == LANGUAGE_FR_FR) {
50-
return "Français";
51-
} else if (lang == LANGUAGE_NL_NL) {
52-
return "Dutch (Nederlands)";
53-
} else if (lang == LANGUAGE_PT_BR) {
54-
return "Português(Brazil)";
55-
} else if (lang == LANGUAGE_JA_JP) {
56-
return "日本語";
57-
} else if (lang == LANGUAGE_PT_PT) {
58-
return "Português(Portugal)";
59-
} else if (lang == LANGUAGE_RU_RU) {
60-
return "Русский";
61-
} else {
62-
return "@@LANG@@";
35+
switch (lang) {
36+
case LANGUAGE_ZH_HANS:
37+
return "简体中文";
38+
case LANGUAGE_EN_US:
39+
return "English";
40+
case LANGUAGE_ZH_TW:
41+
return "繁體中文(臺灣)";
42+
case LANGUAGE_ES_ES:
43+
return "Español";
44+
case LANGUAGE_IT_IT:
45+
return "Italiano";
46+
case LANGUAGE_HU_HU:
47+
return "Magyar";
48+
case LANGUAGE_DE_DE:
49+
return "Deutsch";
50+
case LANGUAGE_FR_FR:
51+
return "Français";
52+
case LANGUAGE_NL_NL:
53+
return "Dutch (Nederlands)";
54+
case LANGUAGE_PT_BR:
55+
return "Português(Brazil)";
56+
case LANGUAGE_JA_JP:
57+
return "日本語";
58+
case LANGUAGE_PT_PT:
59+
return "Português(Portugal)";
60+
case LANGUAGE_RU_RU:
61+
return "Русский";
62+
default:
63+
return "@@LANG@@";
6364
}
6465
}
6566

0 commit comments

Comments
 (0)