diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 321de3c..dcb34e9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -21,24 +21,47 @@ - - - - + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + - + @@ -233,6 +256,7 @@ + 1701689801897 diff --git a/Makefile b/Makefile index 533f309..734548d 100644 --- a/Makefile +++ b/Makefile @@ -4,56 +4,56 @@ # 1 = enable # ---- COMPILER/LINKER OPTIONS ---- -ENABLE_CLANG := 0 -ENABLE_SWD := 0 -ENABLE_OVERLAY := 0 -ENABLE_LTO := 1 +ENABLE_CLANG ?= 0 +ENABLE_SWD ?= 0 +ENABLE_OVERLAY ?= 0 +ENABLE_LTO ?= 1 # ---- STOCK QUANSHENG FERATURES ---- -ENABLE_UART := 1 -ENABLE_AIRCOPY := 0 -ENABLE_FMRADIO := 1 -ENABLE_NOAA := 0 -ENABLE_VOICE := 0 -ENABLE_VOX := 1 -ENABLE_ALARM := 0 -ENABLE_TX1750 := 0 -ENABLE_PWRON_PASSWORD := 0 -ENABLE_DTMF_CALLING := 1 -ENABLE_FLASHLIGHT := 1 +ENABLE_UART ?= 1 +ENABLE_AIRCOPY ?= 0 +ENABLE_FMRADIO ?= 1 +ENABLE_NOAA ?= 0 +ENABLE_VOICE ?= 0 +ENABLE_VOX ?= 1 +ENABLE_ALARM ?= 0 +ENABLE_TX1750 ?= 0 +ENABLE_PWRON_PASSWORD ?= 0 +ENABLE_DTMF_CALLING ?= 1 +ENABLE_FLASHLIGHT ?= 1 # ---- CUSTOM MODS ---- -ENABLE_BIG_FREQ := 1 -ENABLE_SMALL_BOLD := 1 -ENABLE_KEEP_MEM_NAME := 1 -ENABLE_WIDE_RX := 1 -ENABLE_TX_WHEN_AM := 0 -ENABLE_F_CAL_MENU := 0 -ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0 -ENABLE_BOOT_BEEPS := 0 -ENABLE_SHOW_CHARGE_LEVEL := 0 -ENABLE_REVERSE_BAT_SYMBOL := 0 -ENABLE_NO_CODE_SCAN_TIMEOUT := 1 -ENABLE_AM_FIX := 1 -ENABLE_SQUELCH_MORE_SENSITIVE := 1 -ENABLE_FASTER_CHANNEL_SCAN := 1 -ENABLE_RSSI_BAR := 1 -ENABLE_AUDIO_BAR := 1 -ENABLE_COPY_CHAN_TO_VFO := 1 -ENABLE_SPECTRUM := 1 -ENABLE_REDUCE_LOW_MID_TX_POWER:= 0 -ENABLE_BYP_RAW_DEMODULATORS := 0 -ENABLE_BLMIN_TMP_OFF := 0 -ENABLE_SCAN_RANGES := 1 -ENABLE_MDC1200 := 1 -ENABLE_MDC1200_SHOW_OP_ARG := 1 -ENABLE_MDC1200_SIDE_BEEP := 0 -ENABLE_MDC1200_CONRACT := 1 +ENABLE_BIG_FREQ ?= 1 +ENABLE_SMALL_BOLD ?= 1 +ENABLE_KEEP_MEM_NAME ?= 1 +ENABLE_WIDE_RX ?= 1 +ENABLE_TX_WHEN_AM ?= 0 +ENABLE_F_CAL_MENU ?= 0 +ENABLE_CTCSS_TAIL_PHASE_SHIFT ?= 0 +ENABLE_BOOT_BEEPS ?= 0 +ENABLE_SHOW_CHARGE_LEVEL ?= 0 +ENABLE_REVERSE_BAT_SYMBOL ?= 0 +ENABLE_NO_CODE_SCAN_TIMEOUT ?= 1 +ENABLE_AM_FIX ?= 1 +ENABLE_SQUELCH_MORE_SENSITIVE ?= 1 +ENABLE_FASTER_CHANNEL_SCAN ?= 1 +ENABLE_RSSI_BAR ?= 1 +ENABLE_AUDIO_BAR ?= 1 +ENABLE_COPY_CHAN_TO_VFO ?= 1 +ENABLE_SPECTRUM ?= 1 +ENABLE_REDUCE_LOW_MID_TX_POWER?= 0 +ENABLE_BYP_RAW_DEMODULATORS ?= 0 +ENABLE_BLMIN_TMP_OFF ?= 0 +ENABLE_SCAN_RANGES ?= 1 +ENABLE_MDC1200 ?= 1 +ENABLE_MDC1200_SHOW_OP_ARG ?= 1 +ENABLE_MDC1200_SIDE_BEEP ?= 0 +ENABLE_MDC1200_CONRACT ?= 1 # ---- DEBUGGING ---- -ENABLE_AM_FIX_SHOW_DATA := 0 -ENABLE_AGC_SHOW_DATA := 0 +ENABLE_AM_FIX_SHOW_DATA ?= 0 +ENABLE_AGC_SHOW_DATA ?= 0 ############################################################# @@ -174,27 +174,21 @@ OBJS += ui/ui.o OBJS += ui/welcome.o OBJS += version.o OBJS += main.o - -ifeq ($(OS), Windows_NT) - TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -else - TOP := $(shell pwd) -endif - -ifdef OS # windows - RM = del - FixPath = $(subst /,\,$1) - WHERE = where - NULL_OUTPUT = nul +ifeq ($(OS), Windows_NT) # windows + TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) + RM = del /Q + FixPath = $(subst /,\,$1) + WHERE = where + NULL_OUTPUT = nul else # unix - ifeq ($(shell uname), Linux) - RM = rm -f - FixPath = $1 - WHERE = which - NULL_OUTPUT = /dev/null - endif + TOP := $(shell pwd) + RM = rm -f + FixPath = $1 + WHERE = which + NULL_OUTPUT = /dev/null endif + AS = arm-none-eabi-gcc LD = arm-none-eabi-gcc @@ -212,11 +206,11 @@ endif OBJCOPY = arm-none-eabi-objcopy SIZE = arm-none-eabi-size -AUTHOR_STRING := LOSEHU +AUTHOR_STRING ?= LOSEHU # the user might not have/want git installed # can set own version string here (max 7 chars) ifneq (, $(shell $(WHERE) git)) - VERSION_STRING := $(shell git describe --tags --exact-match 2>$(NULL_OUTPUT)) + VERSION_STRING ?= $(shell git describe --tags --exact-match 2>$(NULL_OUTPUT)) ifeq (, $(VERSION_STRING)) VERSION_STRING := $(shell git rev-parse --short HEAD) endif diff --git a/am_fix.c b/am_fix.c index 339f563..00db8a5 100644 --- a/am_fix.c +++ b/am_fix.c @@ -100,95 +100,46 @@ static const t_gain_table gain_table[] = {0x0000,-93}, // 1 .. 0 0 0 0 .. -28dB -24dB -8dB -33dB .. -93dB {0x0008,-91}, // 2 .. 0 0 1 0 .. -28dB -24dB -6dB -33dB .. -91dB - {0x0100,-89}, // 3 .. 1 0 0 0 .. -24dB -24dB -8dB -33dB .. -89dB - {0x0020,-88}, // 4 .. 0 1 0 0 .. -28dB -19dB -8dB -33dB .. -88dB - {0x0108,-87}, // 5 .. 1 0 1 0 .. -24dB -24dB -6dB -33dB .. -87dB - {0x0028,-86}, // 6 .. 0 1 1 0 .. -28dB -19dB -6dB -33dB .. -86dB - {0x0018,-85}, // 7 .. 0 0 3 0 .. -28dB -24dB 0dB -33dB .. -85dB - {0x0200,-84}, // 8 .. 2 0 0 0 .. -19dB -24dB -8dB -33dB .. -84dB - {0x0101,-83}, // 9 .. 1 0 0 1 .. -24dB -24dB -8dB -27dB .. -83dB - {0x0208,-82}, // 10 .. 2 0 1 0 .. -19dB -24dB -6dB -33dB .. -82dB - {0x0118,-81}, // 11 .. 1 0 3 0 .. -24dB -24dB 0dB -33dB .. -81dB - {0x0038,-80}, // 12 .. 0 1 3 0 .. -28dB -19dB 0dB -33dB .. -80dB - {0x0220,-79}, // 13 .. 2 1 0 0 .. -19dB -19dB -8dB -33dB .. -79dB - {0x0201,-78}, // 14 .. 2 0 0 1 .. -19dB -24dB -8dB -27dB .. -78dB - {0x0228,-77}, // 15 .. 2 1 1 0 .. -19dB -19dB -6dB -33dB .. -77dB - {0x0218,-76}, // 16 .. 2 0 3 0 .. -19dB -24dB 0dB -33dB .. -76dB - {0x0119,-75}, // 17 .. 1 0 3 1 .. -24dB -24dB 0dB -27dB .. -75dB - {0x0240,-74}, // 18 .. 2 2 0 0 .. -19dB -14dB -8dB -33dB .. -74dB - {0x0221,-73}, // 19 .. 2 1 0 1 .. -19dB -19dB -8dB -27dB .. -73dB - {0x0248,-72}, // 20 .. 2 2 1 0 .. -19dB -14dB -6dB -33dB .. -72dB - {0x0238,-71}, // 21 .. 2 1 3 0 .. -19dB -19dB 0dB -33dB .. -71dB - {0x0219,-70}, // 22 .. 2 0 3 1 .. -19dB -24dB 0dB -27dB .. -70dB - {0x0260,-69}, // 23 .. 2 3 0 0 .. -19dB -9dB -8dB -33dB .. -69dB - {0x0241,-68}, // 24 .. 2 2 0 1 .. -19dB -14dB -8dB -27dB .. -68dB - {0x0268,-67}, // 25 .. 2 3 1 0 .. -19dB -9dB -6dB -33dB .. -67dB - {0x0280,-66}, // 26 .. 2 4 0 0 .. -19dB -6dB -8dB -33dB .. -66dB - {0x0300,-65}, // 27 .. 3 0 0 0 .. 0dB -24dB -8dB -33dB .. -65dB - {0x02A0,-64}, // 28 .. 2 5 0 0 .. -19dB -4dB -8dB -33dB .. -64dB - {0x0308,-63}, // 29 .. 3 0 1 0 .. 0dB -24dB -6dB -33dB .. -63dB - {0x02C0,-62}, // 30 .. 2 6 0 0 .. -19dB -2dB -8dB -33dB .. -62dB - {0x0290,-61}, // 31 .. 2 4 2 0 .. -19dB -6dB -3dB -33dB .. -61dB - {0x0320,-60}, // 32 .. 3 1 0 0 .. 0dB -19dB -8dB -33dB .. -60dB - {0x0301,-59}, // 33 .. 3 0 0 1 .. 0dB -24dB -8dB -27dB .. -59dB - {0x0328,-58}, // 34 .. 3 1 1 0 .. 0dB -19dB -6dB -33dB .. -58dB - {0x0318,-57}, // 35 .. 3 0 3 0 .. 0dB -24dB 0dB -33dB .. -57dB - {0x02C1,-56}, // 36 .. 2 6 0 1 .. -19dB -2dB -8dB -27dB .. -56dB - {0x0340,-55}, // 37 .. 3 2 0 0 .. 0dB -14dB -8dB -33dB .. -55dB - {0x0321,-54}, // 38 .. 3 1 0 1 .. 0dB -19dB -8dB -27dB .. -54dB - {0x0348,-53}, // 39 .. 3 2 1 0 .. 0dB -14dB -6dB -33dB .. -53dB - {0x0338,-52}, // 40 .. 3 1 3 0 .. 0dB -19dB 0dB -33dB .. -52dB - {0x0319,-51}, // 41 .. 3 0 3 1 .. 0dB -24dB 0dB -27dB .. -51dB - {0x0360,-50}, // 42 .. 3 3 0 0 .. 0dB -9dB -8dB -33dB .. -50dB - {0x0341,-49}, // 43 .. 3 2 0 1 .. 0dB -14dB -8dB -27dB .. -49dB - {0x0368,-48}, // 44 .. 3 3 1 0 .. 0dB -9dB -6dB -33dB .. -48dB - {0x0380,-47}, // 45 .. 3 4 0 0 .. 0dB -6dB -8dB -33dB .. -47dB - {0x0339,-46}, // 46 .. 3 1 3 1 .. 0dB -19dB 0dB -27dB .. -46dB - {0x03A0,-45}, // 47 .. 3 5 0 0 .. 0dB -4dB -8dB -33dB .. -45dB - {0x0361,-44}, // 48 .. 3 3 0 1 .. 0dB -9dB -8dB -27dB .. -44dB - {0x03C0,-43}, // 49 .. 3 6 0 0 .. 0dB -2dB -8dB -33dB .. -43dB - {0x0390,-42}, // 50 .. 3 4 2 0 .. 0dB -6dB -3dB -33dB .. -42dB - {0x03E0,-41}, // 51 .. 3 7 0 0 .. 0dB 0dB -8dB -33dB .. -41dB - {0x03B0,-40}, // 52 .. 3 5 2 0 .. 0dB -4dB -3dB -33dB .. -40dB - {0x03E8,-39}, // 53 .. 3 7 1 0 .. 0dB 0dB -6dB -33dB .. -39dB - {0x03D0,-38}, // 54 .. 3 6 2 0 .. 0dB -2dB -3dB -33dB .. -38dB - {0x03C1,-37}, // 55 .. 3 6 0 1 .. 0dB -2dB -8dB -27dB .. -37dB - {0x03F0,-36}, // 56 .. 3 7 2 0 .. 0dB 0dB -3dB -33dB .. -36dB - {0x03E1,-35}, // 57 .. 3 7 0 1 .. 0dB 0dB -8dB -27dB .. -35dB - {0x03B1,-34}, // 58 .. 3 5 2 1 .. 0dB -4dB -3dB -27dB .. -34dB - {0x03F8,-33}, // 59 .. 3 7 3 0 .. 0dB 0dB 0dB -33dB .. -33dB - {0x03D1,-32}, // 60 .. 3 6 2 1 .. 0dB -2dB -3dB -27dB .. -32dB - {0x03C2,-31}, // 61 .. 3 6 0 2 .. 0dB -2dB -8dB -21dB .. -31dB - {0x03F1,-30}, // 62 .. 3 7 2 1 .. 0dB 0dB -3dB -27dB .. -30dB - {0x03E2,-29}, // 63 .. 3 7 0 2 .. 0dB 0dB -8dB -21dB .. -29dB - {0x03B2,-28}, // 64 .. 3 5 2 2 .. 0dB -4dB -3dB -21dB .. -28dB - {0x03F9,-27}, // 65 .. 3 7 3 1 .. 0dB 0dB 0dB -27dB .. -27dB - {0x03D2,-26}, // 66 .. 3 6 2 2 .. 0dB -2dB -3dB -21dB .. -26dB - {0x03C3,-25}, // 67 .. 3 6 0 3 .. 0dB -2dB -8dB -15dB .. -25dB - {0x03F2,-24}, // 68 .. 3 7 2 2 .. 0dB 0dB -3dB -21dB .. -24dB - {0x03E3,-23}, // 69 .. 3 7 0 3 .. 0dB 0dB -8dB -15dB .. -23dB - {0x03B3,-22}, // 70 .. 3 5 2 3 .. 0dB -4dB -3dB -15dB .. -22dB - {0x03FA,-21}, // 71 .. 3 7 3 2 .. 0dB 0dB 0dB -21dB .. -21dB - {0x03D3,-20}, // 72 .. 3 6 2 3 .. 0dB -2dB -3dB -15dB .. -20dB - {0x03C4,-19}, // 73 .. 3 6 0 4 .. 0dB -2dB -8dB -9dB .. -19dB - {0x03F3,-18}, // 74 .. 3 7 2 3 .. 0dB 0dB -3dB -15dB .. -18dB - {0x03E4,-17}, // 75 .. 3 7 0 4 .. 0dB 0dB -8dB -9dB .. -17dB - {0x03C5,-16}, // 76 .. 3 6 0 5 .. 0dB -2dB -8dB -6dB .. -16dB - {0x03FB,-15}, // 77 .. 3 7 3 3 .. 0dB 0dB 0dB -15dB .. -15dB - {0x03E5,-14}, // 78 .. 3 7 0 5 .. 0dB 0dB -8dB -6dB .. -14dB - {0x03C6,-13}, // 79 .. 3 6 0 6 .. 0dB -2dB -8dB -3dB .. -13dB - {0x03F4,-12}, // 80 .. 3 7 2 4 .. 0dB 0dB -3dB -9dB .. -12dB - {0x03E6,-11}, // 81 .. 3 7 0 6 .. 0dB 0dB -8dB -3dB .. -11dB - {0x03C7,-10}, // 82 .. 3 6 0 7 .. 0dB -2dB -8dB 0dB .. -10dB - {0x03FC, -9}, // 83 .. 3 7 3 4 .. 0dB 0dB 0dB -9dB .. -9dB - {0x03E7, -8}, // 84 .. 3 7 0 7 .. 0dB 0dB -8dB 0dB .. -8dB - {0x03BE, -7}, // 85 .. 3 5 3 6 .. 0dB -4dB 0dB -3dB .. -7dB original - {0x03FD, -6}, // 86 .. 3 7 3 5 .. 0dB 0dB 0dB -6dB .. -6dB - {0x03DE, -5}, // 87 .. 3 6 3 6 .. 0dB -2dB 0dB -3dB .. -5dB - {0x03BF, -4}, // 88 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB - {0x03FE, -3}, // 89 .. 3 7 3 6 .. 0dB 0dB 0dB -3dB .. -3dB - {0x03DF, -2}, // 90 .. 3 6 3 7 .. 0dB -2dB 0dB 0dB .. -2dB - {0x03FF, 0}, // 91 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB + {0x0010,-88}, // 3 .. 0 0 2 0 .. -28dB -24dB -3dB -33dB .. -88dB + {0x0001,-87}, // 4 .. 0 0 0 1 .. -28dB -24dB -8dB -27dB .. -87dB + {0x0009,-85}, // 5 .. 0 0 1 1 .. -28dB -24dB -6dB -27dB .. -85dB + {0x0011,-82}, // 6 .. 0 0 2 1 .. -28dB -24dB -3dB -27dB .. -82dB + {0x0002,-81}, // 7 .. 0 0 0 2 .. -28dB -24dB -8dB -21dB .. -81dB + {0x000A,-79}, // 8 .. 0 0 1 2 .. -28dB -24dB -6dB -21dB .. -79dB + {0x0012,-76}, // 9 .. 0 0 2 2 .. -28dB -24dB -3dB -21dB .. -76dB + {0x0003,-75}, // 10 .. 0 0 0 3 .. -28dB -24dB -8dB -15dB .. -75dB + {0x000B,-73}, // 11 .. 0 0 1 3 .. -28dB -24dB -6dB -15dB .. -73dB + {0x0013,-70}, // 12 .. 0 0 2 3 .. -28dB -24dB -3dB -15dB .. -70dB + {0x0004,-69}, // 13 .. 0 0 0 4 .. -28dB -24dB -8dB -9dB .. -69dB + {0x000C,-67}, // 14 .. 0 0 1 4 .. -28dB -24dB -6dB -9dB .. -67dB + {0x000D,-64}, // 15 .. 0 0 1 5 .. -28dB -24dB -6dB -6dB .. -64dB + {0x001C,-61}, // 16 .. 0 0 3 4 .. -28dB -24dB 0dB - 9dB .. -61dB + {0x001D,-58}, // 17 .. 0 0 3 5 .. -28dB -24dB 0dB -6dB .. -58dB + {0x001E,-55}, // 18 .. 0 0 3 6 .. -28dB -24dB 0dB -3dB .. -55dB + {0x001F,-52}, // 19 .. 0 0 3 7 .. -28dB -24dB 0dB 0dB .. -52dB + {0x003E,-50}, // 20 .. 0 1 3 6 .. -28dB -19dB 0dB -3dB .. -50dB + {0x003F,-47}, // 21 .. 0 1 3 7 .. -28dB -19dB 0dB 0dB .. -47dB + {0x005E,-45}, // 22 .. 0 2 3 6 .. -28dB -14dB 0dB -3dB .. -45dB + {0x005F,-42}, // 23 .. 0 2 3 7 .. -28dB -14dB 0dB 0dB .. -42dB + {0x007E,-40}, // 24 .. 0 3 3 6 .. -28dB -9dB 0dB -3dB .. -40dB + {0x007F,-37}, // 25 .. 0 3 3 7 .. -28dB -9dB 0dB 0dB .. -37dB + {0x009F,-34}, // 26 .. 0 4 3 7 .. -28dB -6dB 0dB 0dB .. -34dB + {0x00BF,-32}, // 27 .. 0 5 3 7 .. -28dB -4dB 0dB 0dB .. -32dB + {0x00DF,-30}, // 28 .. 0 6 3 7 .. -28dB -2dB 0dB 0dB .. -30dB + {0x00FF,-28}, // 29 .. 0 7 3 7 .. -28dB 0dB 0dB 0dB .. -28dB + {0x01DF,-26}, // 30 .. 1 6 3 7 .. -24dB -2dB 0dB 0dB .. -26dB + {0x01FF,-24}, // 31 .. 1 7 3 7 .. -24dB 0dB 0dB 0dB .. -24dB + {0x02BF,-23}, // 32 .. 2 5 3 7 .. -19dB -4dB 0dB 0dB .. -23dB + {0x02DF,-21}, // 33 .. 2 6 3 7 .. -19dB -2dB 0dB -0dB .. -21dB + {0x02FF,-19}, // 34 .. 2 7 3 7 .. -19dB 0dB 0dB 0dB .. -19dB + {0x035E,-17}, // 35 .. 3 2 3 6 .. 0dB -14dB 0dB -3dB .. -17dB + {0x035F,-14}, // 36 .. 3 2 3 7 .. 0dB -14dB 0dB 0dB .. -14dB + {0x037E,-12}, // 37 .. 3 3 3 6 .. 0dB -9dB 0dB -3dB .. -12dB + {0x037F,-9}, // 38 .. 3 3 3 7 .. 0dB -9dB 0dB 0dB .. -9dB + {0x038F,-6}, // 39 .. 3 4 3 7 .. 0dB - 6dB 0dB 0dB .. -6dB + {0x03BF,-4}, // 40 .. 3 5 3 7 .. 0dB -4dB 0dB 0dB .. -4dB + {0x03DF,-2}, // 41 .. 3 6 3 7 .. 0dB - 2dB 0dB 0dB .. -2dB + {0x03FF,0} // 42 .. 3 7 3 7 .. 0dB 0dB 0dB 0dB .. 0dB }; const uint8_t gain_table_size = ARRAY_SIZE(gain_table); #else diff --git a/app/action.c b/app/action.c index 50e2166..643c317 100644 --- a/app/action.c +++ b/app/action.c @@ -55,7 +55,6 @@ inline static void ACTION_ScanRestart() { ACTION_Scan(true); }; void (*action_opt_table[])(void) = { [ACTION_OPT_NONE] = &FUNCTION_NOP, - [ACTION_OPT_FLASHLIGHT] = &ACTION_FlashLight, [ACTION_OPT_POWER] = &ACTION_Power, [ACTION_OPT_MONITOR] = &ACTION_Monitor, [ACTION_OPT_SCAN] = &ACTION_ScanRestart, @@ -64,6 +63,11 @@ void (*action_opt_table[])(void) = { [ACTION_OPT_VFO_MR] = &COMMON_SwitchVFOMode, [ACTION_OPT_SWITCH_DEMODUL] = &ACTION_SwitchDemodul, +#ifdef ENABLE_FLASHLIGHT + [ACTION_OPT_FLASHLIGHT] = &ACTION_FlashLight, +#else + [ACTION_OPT_FLASHLIGHT] = &FUNCTION_NOP, +#endif #ifdef ENABLE_VOX [ACTION_OPT_VOX] = &ACTION_Vox, #else diff --git a/app/app.c b/app/app.c index 6811b74..186ba31 100644 --- a/app/app.c +++ b/app/app.c @@ -21,7 +21,6 @@ #include #include "mdc1200.h" #include "app/action.h" -#include "debugging.h" #ifdef ENABLE_AIRCOPY #include "app/aircopy.h" #endif @@ -36,7 +35,9 @@ #include "app/main.h" #include "app/menu.h" #include "app/scanner.h" +#ifdef ENABLE_UART #include "app/uart.h" +#endif #include "ARMCM0.h" #include "audio.h" #include "board.h" @@ -1133,27 +1134,28 @@ static void CheckKeys(void) void APP_TimeSlice10ms(void) { + gNextTimeslice = false; gFlashLightBlinkCounter++; - #ifdef ENABLE_BOOT_BEEPS - if (boot_counter_10ms > 0) - if ((boot_counter_10ms % 25) == 0) - AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL); + if (boot_counter_10ms > 0 && (boot_counter_10ms % 25) == 0) { + AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL); + } #endif #ifdef ENABLE_AM_FIX - if (gRxVfo->Modulation == MODULATION_AM) -AM_fix_10ms(gEeprom.RX_VFO); + if (gRxVfo->Modulation == MODULATION_AM) { + AM_fix_10ms(gEeprom.RX_VFO); + } #endif - if (UART_IsCommandAvailable()) - { +#ifdef ENABLE_UART + if (UART_IsCommandAvailable()) { __disable_irq(); UART_HandleCommand(); __enable_irq(); } - +#endif if (gReducedService) return; @@ -1312,6 +1314,7 @@ void cancelUserInputModes(void) // this is called once every 500ms void APP_TimeSlice500ms(void) { + gNextTimeslice_500ms = false; bool exit_menu = false; // Skipped authentic device check @@ -1374,86 +1377,23 @@ void APP_TimeSlice500ms(void) #endif // Skipped authentic device check + if (!gCssBackgroundScan #ifdef ENABLE_FMRADIO - if (gFmRadioCountdown_500ms > 0) - { - gFmRadioCountdown_500ms--; - if (gFmRadioMode) // 1of11 - return; - } + && (gFM_ScanState == FM_SCAN_OFF || gAskToSave) #endif - - if (gBacklightCountdown_500ms > 0 && !gAskToSave && !gCssBackgroundScan && - // don't turn off backlight if user is in backlight menu option - - !(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX))) - { - if (--gBacklightCountdown_500ms == 0) { - if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) { - // backlight is not set to be always on - BACKLIGHT_TurnOff(); - } - } - } - - - - if (gReducedService) - { - BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent); - - if (gBatteryCurrent > 500 || gBatteryCalibration[3] < gBatteryCurrentVoltage) - { -#ifdef ENABLE_OVERLAY - overlay_FLASH_RebootToBootloader(); -#else - NVIC_SystemReset(); -#endif - } - - return; - } - - gBatteryCheckCounter++; - - // Skipped authentic device check - - if (gCurrentFunction != FUNCTION_TRANSMIT) - { - - if ((gBatteryCheckCounter & 1) == 0) - { - BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryVoltageIndex++], &gBatteryCurrent); - if (gBatteryVoltageIndex > 3) - gBatteryVoltageIndex = 0; - BATTERY_GetReadings(true); - } - } - - // regular display updates (once every 2 sec) - if need be - if ((gBatteryCheckCounter & 3) == 0) - { - if (gChargingWithTypeC ) - gUpdateStatus = true; -#ifdef ENABLE_SHOW_CHARGE_LEVEL - if (gChargingWithTypeC) - gUpdateDisplay = true; -#endif - } - -#ifdef ENABLE_FMRADIO - if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) && !gCssBackgroundScan) -#else - if (!gCssBackgroundScan) -#endif - { + ) { + if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning() #ifdef ENABLE_AIRCOPY - if (gScanStateDir == SCAN_OFF && gScreenToDisplay != DISPLAY_AIRCOPY && !SCANNER_IsScanning()) -#else - if (gScanStateDir == SCAN_OFF && !SCANNER_IsScanning()) + && gScreenToDisplay != DISPLAY_AIRCOPY #endif - { + ) { + if (gKeyLockCountdown > 0 && !gDTMF_InputMode && gScreenToDisplay != DISPLAY_MENU) { + if (--gKeyLockCountdown == 0) { + gEeprom.KEY_LOCK = true; // lock the keyboard + gUpdateStatus = true; // lock symbol needs showing + } + } if (exit_menu) { @@ -1488,25 +1428,25 @@ void APP_TimeSlice500ms(void) gUpdateStatus = true; gUpdateDisplay = true; - { - GUI_DisplayType_t disp = DISPLAY_INVALID; + GUI_DisplayType_t disp = DISPLAY_INVALID; #ifdef ENABLE_FMRADIO - if (gFmRadioMode && ! FUNCTION_IsRx()) { - disp = DISPLAY_FM; - } + if (gFmRadioMode && ! FUNCTION_IsRx()) { + disp = DISPLAY_FM; + } #endif - if (disp == DISPLAY_INVALID) - { + if (disp == DISPLAY_INVALID) { #ifndef ENABLE_NO_CODE_SCAN_TIMEOUT - if (!SCANNER_IsScanning()) + if (!SCANNER_IsScanning()) #endif - disp = DISPLAY_MAIN; + { + disp = DISPLAY_MAIN; } + } - if (disp != DISPLAY_INVALID) - GUI_SelectNextDisplay(disp); + if (disp != DISPLAY_INVALID) { + GUI_SelectNextDisplay(disp); } } } @@ -1798,101 +1738,97 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gUpdateStatus = true; } - if (!bFlag) - { - if (gCurrentFunction == FUNCTION_TRANSMIT) - { // transmitting - + if (bFlag) { + goto Skip; + } + if (gCurrentFunction == FUNCTION_TRANSMIT) { #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - if (gAlarmState == ALARM_STATE_OFF) -#endif - { - char Code; - - if (Key == KEY_PTT) - { - GENERIC_Key_PTT(bKeyPressed); - goto Skip; - } - - if (Key == KEY_SIDE2) - { // transmit 1750Hz tone - Code = 0xFE; - } - else - { - Code = DTMF_GetCharacter(Key - KEY_0); - if (Code == 0xFF) - goto Skip; - - // transmit DTMF keys - } - - if (!bKeyPressed || bKeyHeld) - { - if (!bKeyPressed) - { - AUDIO_AudioPathOff(); - - gEnableSpeaker = false; - - BK4819_ExitDTMF_TX(false); - - if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable) - BK4819_DisableScramble(); - else - BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); - } - } - else - { - if (gEeprom.DTMF_SIDE_TONE) - { // user will here the DTMF tones in speaker - AUDIO_AudioPathOn(); - gEnableSpeaker = true; - } - - BK4819_DisableScramble(); - - if (Code == 0xFE) - BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750); - else - BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code); - } - } -#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) - { - ALARM_Off(); - - if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) - FUNCTION_Select(FUNCTION_FOREGROUND); - else - gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; - - if (Key == KEY_PTT) - gPttWasPressed = true; - else - if (!bKeyHeld) - gPttWasReleased = true; - } -#endif - } - - else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) { - ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld); - } - else -#ifdef ENABLE_AIRCOPY - if (!SCANNER_IsScanning() && gScreenToDisplay != DISPLAY_AIRCOPY) -#else - if (!SCANNER_IsScanning()) + if (gAlarmState == ALARM_STATE_OFF) #endif { - ACTION_Handle(Key, bKeyPressed, bKeyHeld); + char Code; + + if (Key == KEY_PTT) + { + GENERIC_Key_PTT(bKeyPressed); + goto Skip; + } + + if (Key == KEY_SIDE2) + { // transmit 1750Hz tone + Code = 0xFE; + } + else + { + + Code = DTMF_GetCharacter(Key - KEY_0); + if (Code == 0xFF) + goto Skip; + + // transmit DTMF keys + } + + if (!bKeyPressed || bKeyHeld) + { + if (!bKeyPressed) + { + AUDIO_AudioPathOff(); + + gEnableSpeaker = false; + + BK4819_ExitDTMF_TX(false); + + if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable) + BK4819_DisableScramble(); + else + BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); + } + } + else + { + if (gEeprom.DTMF_SIDE_TONE) + { // user will here the DTMF tones in speaker + AUDIO_AudioPathOn(); + gEnableSpeaker = true; + } + + BK4819_DisableScramble(); + + if (Code == 0xFE) + BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 1750); + else + BK4819_PlayDTMFEx(gEeprom.DTMF_SIDE_TONE, Code); + } } - else if (!bKeyHeld && bKeyPressed) - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) + else if ((!bKeyHeld && bKeyPressed) || (gAlarmState == ALARM_STATE_TX1750 && bKeyHeld && !bKeyPressed)) { + ALARM_Off(); + + if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) + FUNCTION_Select(FUNCTION_FOREGROUND); + else + gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; + + if (Key == KEY_PTT) + gPttWasPressed = true; + else + if (!bKeyHeld) + gPttWasReleased = true; + } +#endif + } + else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) { + ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld); + } + else if (!SCANNER_IsScanning() +#ifdef ENABLE_AIRCOPY + && gScreenToDisplay != DISPLAY_AIRCOPY +#endif + ) { + ACTION_Handle(Key, bKeyPressed, bKeyHeld); + } + else if (!bKeyHeld && bKeyPressed) { + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } Skip: @@ -1921,25 +1857,24 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gRequestSaveSettings = false; gUpdateStatus = true; } - #ifdef ENABLE_FMRADIO if (gRequestSaveFM) - { - if (!bKeyHeld) - SETTINGS_SaveFM(); - else - gFlagSaveFM = true; - gRequestSaveFM = false; - } + { + gRequestSaveFM = false; + if (!bKeyHeld) + SETTINGS_SaveFM(); + else + gFlagSaveFM = true; + } #endif if (gRequestSaveVFO) { + gRequestSaveVFO = false; if (!bKeyHeld) SETTINGS_SaveVfoIndices(); else gFlagSaveVfo = true; - gRequestSaveVFO = false; } if (gRequestSaveChannel > 0) diff --git a/app/dtmf.c b/app/dtmf.c index 5dced36..4040877 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -109,7 +109,7 @@ bool DTMF_GetContact(const int Index, char *pContact) EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16); i = (int)pContact[0] - ' '; } - return (i < 0 || i >= 95) ? false : true; + return (i >= 0 && i < 95); } bool DTMF_FindContact(const char *pContact, char *pResult) @@ -130,7 +130,7 @@ bool DTMF_FindContact(const char *pContact, char *pResult) if (j == 3) { - memmove(pResult, Contact, 8); +memcpy(pResult, Contact, 8); pResult[8] = 0; return true; } @@ -361,8 +361,8 @@ void DTMF_HandleRequest(void) memset(gDTMF_Callee, 0, sizeof(gDTMF_Callee)); memset(gDTMF_Caller, 0, sizeof(gDTMF_Caller)); - memmove(gDTMF_Callee, gDTMF_RX + Offset + 0, 3); - memmove(gDTMF_Caller, gDTMF_RX + Offset + 4, 3); + memcpy(gDTMF_Callee, gDTMF_RX + Offset + 0, 3); + memcpy(gDTMF_Caller, gDTMF_RX + Offset + 4, 3); DTMF_clear_RX(); diff --git a/app/fm.c b/app/fm.c index 9259a31..5c5bf64 100644 --- a/app/fm.c +++ b/app/fm.c @@ -621,6 +621,7 @@ void FM_Play(void) void FM_Start(void) { + gDualWatchActive = false; gFmRadioMode = true; gFM_ScanState = FM_SCAN_OFF; gFM_RestoreCountdown_10ms = 0; diff --git a/app/generic.c b/app/generic.c index 6c5e50d..dcb9eee 100644 --- a/app/generic.c +++ b/app/generic.c @@ -83,7 +83,10 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld) } else // short pressed { + +#ifdef ENABLE_FMRADIO if (gScreenToDisplay != DISPLAY_FM) +#endif { gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; return; @@ -229,8 +232,14 @@ void GENERIC_Key_PTT(bool bKeyPressed) done: gPttDebounceCounter = 0; - if (gScreenToDisplay != DISPLAY_MENU && gRequestDisplayScreen != DISPLAY_FM) // 1of11 .. don't close the menu + if (gScreenToDisplay != DISPLAY_MENU +#ifdef ENABLE_FMRADIO + && gRequestDisplayScreen != DISPLAY_FM +#endif + ) { + // 1of11 .. don't close the menu gRequestDisplayScreen = DISPLAY_MAIN; + } gUpdateStatus = true; gUpdateDisplay = true; } \ No newline at end of file diff --git a/app/main.c b/app/main.c index 1b6073f..5f979b5 100644 --- a/app/main.c +++ b/app/main.c @@ -583,7 +583,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) { #endif ) { // start entering a DTMF string gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - memmove(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1)); + memcpy(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1)); gDTMF_InputBox_Index = 0; gDTMF_InputMode = true; diff --git a/app/mdc1200.c b/app/mdc1200.c index ef90a1a..942bbbd 100644 --- a/app/mdc1200.c +++ b/app/mdc1200.c @@ -533,7 +533,7 @@ uint16_t extractHex(const char *str) { } return result; } -#ifdef ENABLE_MDC1200_CONRACT +#ifdef ENABLE_MDC1200_CONTACT uint8_t contact_num=0; uint16_t MDC_ADD[4] = {0x1D48, 0x1D88, 0x1DC8,0x1F08}; void mdc1200_update_contact_num() diff --git a/app/menu.c b/app/menu.c index 7e2a8c1..9ae6d36 100644 --- a/app/menu.c +++ b/app/menu.c @@ -691,7 +691,7 @@ void MENU_AcceptSetting(void) { GUI_SelectNextDisplay(DISPLAY_MAIN); gDTMF_InputMode = true; gDTMF_InputBox_Index = 3; - memmove(gDTMF_InputBox, gDTMF_ID, 4); + memcpy(gDTMF_InputBox, gDTMF_ID, 4); gRequestDisplayScreen = DISPLAY_INVALID; } return; @@ -1339,6 +1339,9 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; if (!gCssBackgroundScan) { + /* Backlight related menus set full brightness. Set it back to the configured value, + just in case we are exiting from one of them. */ + BACKLIGHT_TurnOn(); if (gIsInSubMenu) { if (gInputBoxIndex == 0 || UI_MENU_GetCurrentMenuId() != MENU_OFFSET) { gAskForConfirmation = 0; @@ -1459,8 +1462,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { edit_index = 0; // 'edit_index' is going to be used as the cursor position // make a copy so we can test for change when exiting the menu item - memmove(edit_original, edit, sizeof(edit_original)); - + memcpy(edit_original, edit, sizeof(edit_original)); return; } else if (edit_index >= 0 && edit_index < 10) { // editing the channel name characters @@ -1637,8 +1639,9 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) gRequestDisplayScreen = DISPLAY_MENU; - if (UI_MENU_GetCurrentMenuId() != MENU_ABR && - gEeprom.BACKLIGHT_TIME == 0) // backlight always off and not in the backlight menu + if (UI_MENU_GetCurrentMenuId() != MENU_ABR + && UI_MENU_GetCurrentMenuId() != MENU_ABR_MAX + && gEeprom.BACKLIGHT_TIME == 0) // backlight always off and not in the backlight menu { BACKLIGHT_TurnOff(); } diff --git a/app/uart.c b/app/uart.c index e85f632..ab7f085 100644 --- a/app/uart.c +++ b/app/uart.c @@ -480,11 +480,11 @@ bool UART_IsCommandAvailable(void) if (TailIndex < Index) { const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index; - memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize); - memmove(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex); + memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize); + memcpy(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex); } else - memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index); + memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index); TailIndex = DMA_INDEX(TailIndex, 2); if (TailIndex < gUART_WriteIndex) diff --git a/audio.c b/audio.c index e0b4fa7..db75b88 100644 --- a/audio.c +++ b/audio.c @@ -205,7 +205,7 @@ volatile bool gFlagPlayQueuedVoice; VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID; -void AUDIO_PlayVoice(uint8_t VoiceID) +static void AUDIO_PlayVoice(uint8_t VoiceID) { unsigned int i; diff --git a/audio.h b/audio.h index e32575f..55662aa 100644 --- a/audio.h +++ b/audio.h @@ -149,7 +149,6 @@ static inline void AUDIO_AudioPathOff(void) { extern volatile bool gFlagPlayQueuedVoice; extern VOICE_ID_t gAnotherVoiceID; - void AUDIO_PlayVoice(uint8_t VoiceID); void AUDIO_PlaySingleVoice(bool bFlag); void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID); uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value); diff --git a/bitmaps.c b/bitmaps.c index e98a987..3ac1a0c 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -5,84 +5,87 @@ // turn your monitor 90-deg anti-clockwise to see the images const uint8_t BITMAP_POWERSAVE[8] = -{ - #if 0 - // "S" - 0b00000000, - 0b00100110, - 0b01001001, - 0b01001001, - 0b01001001, - 0b01001001, - 0b01001001, - 0b00110010 - #else - // "PS" - 0b00000000, - 0b01111111, - 0b00010001, - 0b00001110, - 0b00000000, - 0b01000110, - 0b01001001, - 0b00110001 - #endif -}; + { + // "PS" + 0b00000000, + 0b01111111, + 0b00010001, + 0b00001110, + 0b00000000, + 0b01000110, + 0b01001001, + 0b00110001 + + }; const uint8_t BITMAP_TX[8] = -{ // "TX" - 0b00000000, - 0b00000001, - 0b00000001, - 0b01111111, - 0b00000001, - 0b00000001, - 0b00000000, - 0b00000000 -}; + { // "TX" + 0b00000000, + 0b00000001, + 0b00000001, + 0b01111111, + 0b00000001, + 0b00000001, + 0b00000000, + 0b00000000 + }; const uint8_t BITMAP_RX[8] = -{ // "RX" - 0b00000000, - 0b01111111, - 0b00001001, - 0b00011001, - 0b01100110, - 0b00000000, - 0b00000000, - 0b00000000 -}; + { // "RX" + 0b00000000, + 0b01111111, + 0b00001001, + 0b00011001, + 0b01100110, + 0b00000000, + 0b00000000, + 0b00000000 + }; + +const uint8_t BITMAP_FM[10] = + { // "FM" + 0b00000000, + 0b01111111, + 0b00001001, + 0b00000001, + 0b00000000, + 0b01111111, + 0b00000010, + 0b00001100, + 0b00000010, + 0b01111111 + }; const uint8_t BITMAP_BatteryLevel[2] = -{ - 0b01011101, - 0b01011101 -}; + { + 0b01011101, + 0b01011101 + }; #ifndef ENABLE_REVERSE_BAT_SYMBOL - // Quansheng way (+ pole to the left) - const uint8_t BITMAP_BatteryLevel1[17] = - { - 0b00000000, - 0b00111110, - 0b00100010, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01000001, - 0b01111111 - }; +// Quansheng way (+ pole to the left) +const uint8_t BITMAP_BatteryLevel1[17] = + { + 0b00000000, + 0b00111110, + 0b00100010, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01000001, + 0b01111111 + }; #else - // reversed (+ pole to the right) +// reversed (+ pole to the right) const uint8_t BITMAP_BatteryLevel1[17] = { 0b00000000, @@ -106,40 +109,40 @@ const uint8_t BITMAP_BatteryLevel[2] = #endif const uint8_t BITMAP_USB_C[9] = -{ // USB symbol - 0b00000000, - 0b00011100, - 0b00100111, - 0b01000100, - 0b01000100, - 0b01000100, - 0b01000100, - 0b00100111, - 0b00011100 -}; + { // USB symbol + 0b00000000, + 0b00011100, + 0b00100111, + 0b01000100, + 0b01000100, + 0b01000100, + 0b01000100, + 0b00100111, + 0b00011100 + }; const uint8_t BITMAP_KeyLock[6] = -{ // teeny padlock symbol - 0b00000000, - 0b01111100, - 0b01000110, - 0b01000101, - 0b01000110, - 0b01111100 -}; + { // teeny padlock symbol + 0b00000000, + 0b01111100, + 0b01000110, + 0b01000101, + 0b01000110, + 0b01111100 + }; const uint8_t BITMAP_F_Key[6] = -{ // F-Key symbol - 0b00000000, - 0b01011111, - 0b01000101, - 0b01000101, - 0b01000101, - 0b01000001 -}; + { // F-Key symbol + 0b00000000, + 0b01011111, + 0b01000101, + 0b01000101, + 0b01000101, + 0b01000001 + }; #ifdef ENABLE_VOX - const uint8_t BITMAP_VOX[18] = +const uint8_t BITMAP_VOX[18] = { // "VOX" 0b00000000, 0b00011111, @@ -162,75 +165,61 @@ const uint8_t BITMAP_F_Key[6] = }; #endif -#if 0 - const uint8_t BITMAP_WX[12] = - { // "WX" - 0b00000000, - 0b01111111, - 0b00100000, - 0b00011000, - 0b00100000, - 0b01111111, - 0b00000000, - 0b01100011, - 0b00010100, - 0b00001000, - 0b00010100, - 0b01100011 - }; -#else - // 'XB' (cross-band/cross-VFO) - const uint8_t BITMAP_XB[12] = - { // "XB" - 0b00000000, - 0b01100011, - 0b00010100, - 0b00001000, - 0b00010100, - 0b01100011, - 0b00000000, - 0b01111111, - 0b01001001, - 0b01001001, - 0b01001001, - 0b00110110 - }; -#endif -const uint8_t BITMAP_TDR1[15] = -{ // "DWR" - 0b01111111, - 0b01000001, - 0b01000001, - 0b00111110, - 0b00000000, - 0b01111111, - 0b00100000, - 0b00011000, - 0b00100000, - 0b01111111, - 0b00000000, - 0b01111111, - 0b00011001, - 0b00101001, - 0b01000110 -}; +// 'XB' (cross-band/cross-VFO) +const uint8_t BITMAP_XB[12] = + { // "XB" + 0b00000000, + 0b01100011, + 0b00010100, + 0b00001000, + 0b00010100, + 0b01100011, + 0b00000000, + 0b01111111, + 0b01001001, + 0b01001001, + 0b01001001, + 0b00110110 + }; -const uint8_t BITMAP_TDR2[9] = -{ // "><" .. DW on hold - 0b00100010, - 0b00110110, - 0b00011100, - 0b00001000, - 0b00000000, - 0b00001000, - 0b00011100, - 0b00110110, - 0b00100010, -}; + +const uint8_t BITMAP_TDR1[16] = + { // "DWR" + 0b00000000, + 0b01111111, + 0b01000001, + 0b01000001, + 0b00111110, + 0b00000000, + 0b01111111, + 0b00100000, + 0b00011000, + 0b00100000, + 0b01111111, + 0b00000000, + 0b01111111, + 0b00011001, + 0b00101001, + 0b01000110 + }; + +const uint8_t BITMAP_TDR2[10] = + { // "><" .. DW on hold + 0b00000000, + 0b00100010, + 0b00110110, + 0b00011100, + 0b00001000, + 0b00000000, + 0b00001000, + 0b00011100, + 0b00110110, + 0b00100010, + }; #ifdef ENABLE_VOICE - const uint8_t BITMAP_VoicePrompt[9] = +const uint8_t BITMAP_VoicePrompt[9] = { 0b00000000, 0b00011000, @@ -245,7 +234,7 @@ const uint8_t BITMAP_TDR2[9] = #endif #ifdef ENABLE_NOAA - const uint8_t BITMAP_NOAA[11] = +const uint8_t BITMAP_NOAA[11] = { // "NS" 0b00000000, 0b01111111, @@ -262,76 +251,64 @@ const uint8_t BITMAP_TDR2[9] = #endif const uint8_t BITMAP_Antenna[5] = -{ - 0b00000011, - 0b00000101, - 0b01111111, - 0b00000101, - 0b00000011 -}; - -const uint8_t BITMAP_MARKER[8] = -{ - 0b11111111, - 0b11111111, - 0b01111110, - 0b01111110, - 0b00111100, - 0b00111100, - 0b00011000, - 0b00011000 -}; + { + 0b00000011, + 0b00000101, + 0b01111111, + 0b00000101, + 0b00000011 + }; const uint8_t BITMAP_VFO_Default[8] = -{ - 0b00000000, - 0b01111111, - 0b01111111, - 0b00111110, - 0b00111110, - 0b00011100, - 0b00011100, - 0b00001000 -}; + { + 0b00000000, + 0b01111111, + 0b01111111, + 0b00111110, + 0b00111110, + 0b00011100, + 0b00011100, + 0b00001000 + }; const uint8_t BITMAP_VFO_NotDefault[8] = -{ - 0b00000000, - 0b01000001, - 0b01000001, - 0b00100010, - 0b00100010, - 0b00010100, - 0b00010100, - 0b00001000 -}; + { + 0b00000000, + 0b01000001, + 0b01000001, + 0b00100010, + 0b00100010, + 0b00010100, + 0b00010100, + 0b00001000 + }; const uint8_t BITMAP_ScanList1[6] = -{ // 'I' symbol - 0b00000000, - 0b00000000, - 0b01000010, - 0b01111110, - 0b01000010, - 0b00000000 -}; + { // 'I' symbol + 0b00000000, + 0b00000000, + 0b01000010, + 0b01111110, + 0b01000010, + 0b00000000 + }; const uint8_t BITMAP_ScanList2[6] = -{ // 'II' symbol - 0b00000000, - 0b01000010, - 0b01111110, - 0b01000010, - 0b01111110, - 0b01000010 -}; + { // 'II' symbol + 0b00000000, + 0b01000010, + 0b01111110, + 0b01000010, + 0b01111110, + 0b01000010 + }; const uint8_t BITMAP_compand[6] = -{ - 0b00000000, - 0b00111100, - 0b01000010, - 0b01000010, - 0b01000010, - 0b00100100 -}; + { + 0b00000000, + 0b00111100, + 0b01000010, + 0b01000010, + 0b01000010, + 0b00100100 + }; \ No newline at end of file diff --git a/bitmaps.h b/bitmaps.h index f346c49..c3d23f1 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -7,7 +7,7 @@ extern const uint8_t BITMAP_POWERSAVE[8]; extern const uint8_t BITMAP_TX[8]; extern const uint8_t BITMAP_RX[8]; - +extern const uint8_t BITMAP_FM[10]; extern const uint8_t BITMAP_BatteryLevel[2]; extern const uint8_t BITMAP_BatteryLevel1[17]; @@ -18,26 +18,24 @@ extern const uint8_t BITMAP_KeyLock[6]; extern const uint8_t BITMAP_F_Key[6]; #ifdef ENABLE_VOX - extern const uint8_t BITMAP_VOX[18]; +extern const uint8_t BITMAP_VOX[18]; #endif extern const uint8_t BITMAP_XB[12]; -extern const uint8_t BITMAP_TDR1[15]; -extern const uint8_t BITMAP_TDR2[9]; +extern const uint8_t BITMAP_TDR1[16]; +extern const uint8_t BITMAP_TDR2[10]; #ifdef ENABLE_VOICE - extern const uint8_t BITMAP_VoicePrompt[9]; +extern const uint8_t BITMAP_VoicePrompt[9]; #endif #ifdef ENABLE_NOAA - extern const uint8_t BITMAP_NOAA[11]; +extern const uint8_t BITMAP_NOAA[11]; #endif extern const uint8_t BITMAP_Antenna[5]; -extern const uint8_t BITMAP_MARKER[8]; - extern const uint8_t BITMAP_VFO_Default[8]; extern const uint8_t BITMAP_VFO_NotDefault[8]; @@ -46,5 +44,4 @@ extern const uint8_t BITMAP_ScanList2[6]; extern const uint8_t BITMAP_compand[6]; -#endif - +#endif \ No newline at end of file diff --git a/board.c b/board.c index 44a77ac..ad1951a 100644 --- a/board.c +++ b/board.c @@ -497,6 +497,9 @@ void BOARD_Init(void) #ifdef ENABLE_FMRADIO BK1080_Init(0, false); #endif - CRC_Init(); -} +#if defined(ENABLE_UART) || defined(ENABLED_AIRCOPY) + CRC_Init(); +#endif + +} diff --git a/debugging.h b/debugging.h index 9f1bed9..1ea660c 100644 --- a/debugging.h +++ b/debugging.h @@ -1,6 +1,6 @@ #ifndef DEBUGGING_H #define DEBUGGING_H - +#ifdef ENABLE_UART #include "driver/uart.h" #include "driver/bk4819.h" #include "string.h" @@ -9,28 +9,31 @@ #include "am_fix.h" -static inline void LogUart(char * str) + +static inline void LogUart(const char *const str) { - UART_Send(str, strlen(str)); + UART_Send(str, strlen(str)); } static inline void LogRegUart(uint16_t reg) { - uint16_t regVal = BK4819_ReadRegister(reg); - char buf[32]; - sprintf(buf, "reg%02X: %04X\n", reg, regVal); - LogUart(buf); + uint16_t regVal = BK4819_ReadRegister(reg); + char buf[32]; + sprintf(buf, "reg%02X: %04X\n", reg, regVal); + LogUart(buf); } - static inline void LogPrint() { - uint16_t rssi = BK4819_GetRSSI(); - uint16_t reg7e = BK4819_ReadRegister(0x7E); - char buf[32]; - sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", - (reg7e >> 15), (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111, (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi); - LogUart(buf); + uint16_t rssi = BK4819_GetRSSI(); + uint16_t reg7e = BK4819_ReadRegister(0x7E); + char buf[32]; + sprintf(buf, "reg7E: %d %2d %6d %2d %d rssi: %d\n", (reg7e >> 15), + (reg7e >> 12) & 0b111, (reg7e >> 5) & 0b1111111, + (reg7e >> 2) & 0b111, (reg7e >> 0) & 0b11, rssi); + LogUart(buf); } +#endif + #endif \ No newline at end of file diff --git a/driver/backlight.c b/driver/backlight.c index e4442ac..52e8fe6 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -64,12 +64,12 @@ void BACKLIGHT_TurnOn(void) { case 1: // 5 sec case 2: // 10 sec case 3: // 20 sec - gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 10; + gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 1)) * 5; break; case 4: // 1 min case 5: // 2 min case 6: // 4 min - gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 120; + gBacklightCountdown_500ms = 1 + (2 << (gEeprom.BACKLIGHT_TIME - 4)) * 60; break; case 7: // always on gBacklightCountdown_500ms = 0; @@ -96,7 +96,16 @@ bool BACKLIGHT_IsOn() { return backlightOn; } -void BACKLIGHT_SetBrightness(uint8_t brigtness) { +static uint8_t currentBrightness; + +void BACKLIGHT_SetBrightness(uint8_t brigtness) +{ + currentBrightness = brigtness; PWM_PLUS0_CH0_COMP = (1 << brigtness) - 1; //PWM_PLUS0_SWLOAD = 1; } + +uint8_t BACKLIGHT_GetBrightness(void) +{ + return currentBrightness; +} \ No newline at end of file diff --git a/driver/backlight.h b/driver/backlight.h index 59e1551..f22791b 100644 --- a/driver/backlight.h +++ b/driver/backlight.h @@ -36,6 +36,6 @@ void BACKLIGHT_TurnOn(); void BACKLIGHT_TurnOff(); bool BACKLIGHT_IsOn(); void BACKLIGHT_SetBrightness(uint8_t brigtness); - +uint8_t BACKLIGHT_GetBrightness(void); #endif diff --git a/driver/bk4819.c b/driver/bk4819.c index 0ce24e9..901c979 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -16,13 +16,13 @@ #include // NULL -#include "audio.h" +#include "../audio.h" +#include "../bsp/dp32g030/gpio.h" +#include "../bsp/dp32g030/portcon.h" #include "bk4819.h" -#include "bsp/dp32g030/gpio.h" -#include "bsp/dp32g030/portcon.h" -#include "driver/gpio.h" -#include "driver/system.h" -#include "driver/systick.h" +#include "gpio.h" +#include "system.h" +#include "systick.h" #ifdef ENABLE_MDC1200 #include "app/mdc1200.h" #endif diff --git a/driver/crc.c b/driver/crc.c index b1aaa8d..cb6a92c 100644 --- a/driver/crc.c +++ b/driver/crc.c @@ -14,9 +14,8 @@ * limitations under the License. */ -#include "bsp/dp32g030/crc.h" -#include "driver/crc.h" -#include "driver/uart.h" +#include "../bsp/dp32g030/crc.h" +#include "crc.h" void CRC_Init(void) { diff --git a/driver/keyboard.c b/driver/keyboard.c index d0e1ace..6dfb813 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -117,19 +117,12 @@ KEY_Code_t KEYBOARD_Poll(void) GPIOA->DATA &= keyboard[j].set_to_zero_mask; // Read all 4 GPIO pins at once .. with de-noise, max of 8 sample loops - for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++) - { - uint16_t reg2; - - SYSTICK_DelayUs(1); - - reg2 = GPIOA->DATA; - if (reg != reg2) - { // noise - reg = reg2; - i = 0; - } - } + for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++) { + SYSTICK_DelayUs(1); + uint16_t reg2 = GPIOA->DATA; + i *= reg == reg2; + reg = reg2; + } if (i < 3) break; // noise is too bad diff --git a/driver/system.c b/driver/system.c index b956662..a605248 100644 --- a/driver/system.c +++ b/driver/system.c @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "bsp/dp32g030/pmu.h" -#include "bsp/dp32g030/syscon.h" -#include "driver/system.h" -#include "driver/systick.h" +#include "../bsp/dp32g030/pmu.h" +#include "../bsp/dp32g030/syscon.h" +#include "system.h" +#include "systick.h" void SYSTEM_DelayMs(uint32_t Delay) { diff --git a/driver/systick.c b/driver/systick.c index e836c37..086dce6 100644 --- a/driver/systick.c +++ b/driver/systick.c @@ -15,9 +15,8 @@ */ #include "ARMCM0.h" -#include "driver/systick.h" -#include "misc.h" - +#include "systick.h" +#include "../misc.h" // 0x20000324 static uint32_t gTickMultiplier; @@ -26,21 +25,25 @@ void SYSTICK_Init(void) SysTick_Config(480000); gTickMultiplier = 48; } - void SYSTICK_DelayUs(uint32_t Delay) { - const uint32_t ticks = Delay * gTickMultiplier; - uint32_t i = 0; - uint32_t Start = SysTick->LOAD; - uint32_t Previous = SysTick->VAL; - do { - uint32_t Current; - uint32_t Delta; - while ((Current = SysTick->VAL) == Previous) {} - Delta = (Current < Previous) ? -Current : Start - Current; - i += Delta + Previous; - Previous = Current; - } while (i < ticks); + const uint32_t ticks = Delay * gTickMultiplier; + uint32_t elapsed_ticks = 0; + uint32_t Start = SysTick->LOAD; + uint32_t Previous = SysTick->VAL; + do { + uint32_t Current; + + do { + Current = SysTick->VAL; + } while (Current == Previous); + + uint32_t Delta = ((Current < Previous) ? - Current : Start - Current); + + elapsed_ticks += Delta + Previous; + + Previous = Current; + } while (elapsed_ticks < ticks); } void SYSTICK_Delay250ns(const uint32_t Delay) diff --git a/font.c b/font.c index 006aad2..07cf361 100644 --- a/font.c +++ b/font.c @@ -347,285 +347,342 @@ const uint8_t gFont3x5[][3] = }; #endif -const uint8_t gFontChinese_out[1678]={ - 0X88,0X48,0X2E,0X08,0X08,0X7F,0X8A, - 0X4A,0X2A,0X08,0X00,0XA8,0X06, - 0X40,0X82,0X3E,0X00,0X25,0XD5, - 0X0F,0XC5,0X3F,0X05,0X05,0X80, - 0XA9,0XAA,0XE2,0X84,0XF2,0XA7, - 0XA8,0X06,0XD0,0X77,0XD0,0X5F, - 0XD0,0XA7,0X01,0X46,0X0A,0XAA, - 0X4A,0X0A,0XCF,0XCB,0X0B,0X4B, - 0XAA,0X0A,0X02,0X00,0X0C,0X00, - 0X24,0XFF,0X14,0X00,0X2A,0XEE, - 0X3B,0XAA,0X6E,0X2A,0X00,0X8E, - 0X5A,0X8A,0X3F,0X20,0XD0,0X3F, - 0X00,0X02,0XC1,0X8E,0XB0,0X9F, - 0X00,0X30,0X68,0X59,0XE5,0XCC, - 0XF6,0XE5,0X54,0X8D,0XF0,0X47, - 0XC8,0X47,0XA0,0X95,0X46,0X3A, - 0X09,0X29,0X29,0X29,0XAD,0X6B, - 0X09,0X09,0X39,0X01,0X00,0X3A, - 0X00,0X19,0X61,0X01,0XFF,0X01, - 0X01,0XFF,0X01,0X61,0X19,0X00, - 0XEA,0XBA,0X0A,0X82,0X82,0XBB, - 0XEB,0XAA,0XAA,0XAB,0XBB,0X02, - 0X02,0X00,0XAC,0X3A,0X40,0X44, - 0XF3,0X4F,0X01,0XA4,0XF7,0XA5, - 0XFD,0XA6,0X07,0X04,0XA3,0X91, - 0X92,0XFC,0X53,0X00,0XF8,0X03, - 0X89,0X30,0X02,0XFF,0X00,0X38, - 0X60,0X90,0X04,0X87,0X64,0X1C, - 0X07,0X34,0XD4,0X55,0X35,0X02, - 0X04,0X86,0X56,0X69,0X82,0X3E, - 0X00,0X65,0XA5,0X9F,0X55,0X25, - 0X25,0X00,0X80,0XA9,0XAA,0X22, - 0XA1,0XA9,0XB7,0XE1,0XA5,0XB5, - 0XAD,0XA5,0X25,0X21,0X11,0XAA, - 0XAB,0X10,0X10,0X10,0X10,0XF6, - 0X51,0X50,0X50,0X50,0XD0,0X13, - 0X68,0X80,0X1A,0XFE,0X02,0X02, - 0XFA,0X8B,0X8A,0XFA,0X02,0X02, - 0XFE,0X00,0X03,0X80,0X0E,0X01, - 0XE1,0X1F,0X01,0X01,0X3F,0X80, - 0XBF,0X80,0X80,0XBF,0XA1,0X51, - 0X65,0XA3,0X2A,0XA1,0X63,0XB3, - 0X6B,0X22,0XA3,0X68,0X01,0XC0, - 0XEA,0X3A,0X24,0XE8,0X03,0XBC, - 0XB7,0XB4,0XFE,0XB7,0XB6,0XBC, - 0X03,0X98,0XAA,0X2A,0X1C,0X00, - 0XFF,0X08,0X00,0X04,0XFC,0X07, - 0X04,0X04,0X04,0X30,0XB0,0XAA, - 0X92,0XD5,0X97,0X95,0X16,0XB4, - 0X96,0XD5,0X97,0X95,0X92,0X86, - 0X43,0X0A,0XF0,0X1F,0X10,0X11, - 0XD1,0X1F,0X11,0X15,0X19,0X00, - 0X60,0XEA,0XAA,0X48,0XFC,0X2B, - 0X00,0XE0,0X13,0X10,0X14,0X10, - 0X10,0X00,0X30,0X06,0X00,0X22, - 0X12,0XFA,0X06,0X43,0X4A,0X4A, - 0XEA,0X5A,0X42,0X02,0X30,0XE0, - 0XC0,0X42,0X43,0XFB,0X5A,0X7F, - 0XEB,0X4A,0X7B,0XC3,0X02,0X80, - 0XAE,0XBF,0X82,0XC0,0X3F,0X00, - 0X20,0XA8,0XBA,0XAA,0XAA,0X2A, - 0X08,0XC0,0XB0,0XEA,0X24,0XE8, - 0X03,0X08,0XE8,0X6F,0X5B,0X6D, - 0XEB,0X0B,0X00,0X98,0XAA,0X2A, - 0XFF,0X11,0XFF,0X10,0XFF,0X11, - 0XFF,0X00,0X7E,0X00,0XFF,0X31, - 0X31,0XF8,0X7F,0XE0,0X3F,0X00, - 0X81,0X68,0X4A,0X7E,0X8A,0X2A, - 0XC1,0X40,0X38,0X84,0X80,0X4E, - 0XA2,0XAE,0X90,0XAE,0XA2,0X42, - 0X8E,0X80,0X40,0XC5,0X14,0X00, - 0X10,0X52,0X8B,0XCC,0XEB,0XA8, - 0XA8,0X98,0X80,0X80,0X07,0XAC, - 0XEA,0X24,0XFF,0X14,0X00,0X11, - 0X11,0X11,0X11,0X11,0X11,0XFF, - 0X0E,0XAA,0X3A,0XC9,0X3F,0X05, - 0X80,0XBE,0XD2,0X93,0XBE,0XD2, - 0X93,0XBE,0XC3,0XBA,0X1E,0X92, - 0XF1,0X90,0X92,0X0F,0XC0,0X07, - 0X00,0XF0,0X0F,0X80,0X06,0XE8, - 0X80,0XA8,0XA8,0XAA,0XAA,0XFD, - 0XA8,0XA9,0XAA,0XA8,0X82,0X10, - 0X1B,0XA4,0X24,0XFF,0X14,0X00, - 0X1E,0X5A,0XD0,0X7F,0X50,0XDA, - 0X5E,0X0E,0X7A,0X29,0X86,0XA2, - 0XAA,0XAA,0XF6,0XB7,0XAA,0XA6, - 0XA2,0X02,0X86,0XC6,0X90,0X82, - 0XC0,0X3F,0XC0,0X04,0XA2,0X61, - 0X36,0XA4,0X2F,0X22,0XC1,0X80, - 0X46,0X12,0X0E,0X7A,0XE9,0X6B, - 0X69,0X69,0X69,0X7B,0X09,0X00, - 0XA8,0X56,0X2A,0X14,0X14,0XF4, - 0X14,0X14,0X14,0X04,0X3F,0XC4, - 0X05,0X86,0XBA,0X05,0X34,0X82, - 0XBA,0XC2,0XBF,0X92,0X12,0XC0, - 0X7C,0X64,0XE5,0XFD,0X94,0XAA, - 0XEA,0X2F,0X21,0XE1,0X0F,0X40, - 0X40,0X41,0X46,0XF0,0X4F,0X50, - 0X05,0XE8,0X50,0X48,0XC4,0XA3, - 0XA2,0XBE,0XA2,0XB6,0XEA,0X13, - 0X00,0XC0,0XAA,0X0E,0X7E,0X4A, - 0X4A,0X4A,0XFF,0X4A,0X4A,0X4A, - 0X7E,0X00,0X80,0X00,0XAB,0X3A, - 0X84,0XA4,0XA6,0XB6,0XDE,0X97, - 0X96,0XB6,0X96,0X04,0X84,0X6A, - 0XA5,0X2A,0X20,0XA0,0XA3,0XA2, - 0XFE,0XA2,0XAE,0XA2,0X23,0X20, - 0XA8,0X06,0XA9,0X03,0XFC,0X07, - 0X14,0X26,0XC5,0X24,0X15,0X06, - 0XFC,0X03,0X18,0X00,0XD0,0X88, - 0XFE,0X88,0X00,0X1E,0XFB,0X52, - 0XDE,0XB3,0XFA,0X1E,0X00,0XBC, - 0X8E,0X84,0XF4,0X92,0XB2,0X90, - 0X90,0XF2,0X92,0XB4,0X04,0X80, - 0XBB,0XEE,0X02,0XF2,0X55,0X59, - 0X5F,0X51,0X51,0X5F,0XF9,0X05, - 0X02,0XA0,0XAE,0XAB,0X20,0X24, - 0XA6,0X25,0X24,0XE4,0X27,0X24, - 0XA4,0X20,0X21,0X06,0X3A,0X40, - 0X00,0XFE,0X52,0X52,0X52,0X53, - 0X52,0X52,0XFE,0X00,0X00,0XAC, - 0XAA,0X03,0XA2,0X9A,0X86,0XA2, - 0X32,0X00,0X01,0XE1,0X1F,0X01, - 0X7F,0X45,0X18,0X26,0XA1,0XF0, - 0X00,0X0F,0X05,0X05,0XF5,0X2E, - 0X11,0X81,0X00,0X5C,0X0D,0X40, - 0X48,0X50,0X60,0XC3,0X7C,0XC0, - 0X63,0X50,0X48,0X40,0X6A,0XC0, - 0XEA,0X32,0X12,0X16,0XDA,0X1B, - 0X1A,0XDA,0X16,0X12,0X32,0X00, - 0X1A,0XB0,0X0E,0X80,0XBF,0X82, - 0X92,0XF7,0X96,0X96,0XB7,0X92, - 0X00,0X80,0XA9,0XA5,0X02,0X20, - 0XA0,0XBF,0XAA,0XEA,0XAA,0XBA, - 0XAA,0X2F,0X00,0X00,0XAB,0X3A, - 0X00,0XFC,0X17,0X94,0XD6,0XD6, - 0XD6,0X77,0X55,0X15,0X1D,0X19, - 0XC0,0XEA,0X04,0XC9,0X02,0X00, - 0XF9,0XAA,0XAF,0XA8,0XAC,0XFA, - 0X01,0X03,0X03,0X4E,0X82,0X3E, - 0X00,0X01,0X05,0X2D,0XE1,0X3F, - 0X01,0X01,0X80,0XA9,0XAA,0XCA, - 0X43,0X42,0X42,0X42,0XF2,0X4F, - 0X42,0X42,0X42,0XC2,0X03,0XC0, - 0X00,0XB0,0X4D,0X21,0X01,0XFC, - 0X03,0X58,0XE3,0XF8,0XE3,0X58, - 0X6B,0XAC,0XAA,0X24,0XFF,0X14, - 0X00,0X16,0X52,0XBB,0X92,0X72, - 0X16,0X00,0X0E,0X6A,0X2A,0XCB, - 0XBE,0X0A,0X41,0X3E,0X80,0X8A, - 0XEA,0XBF,0XAA,0X0F,0XCB,0XEA, - 0XFA,0X5F,0X51,0XF5,0X09,0X00, - 0XF0,0X1F,0X14,0XF8,0X07,0XB0, - 0X11,0X03,0XF8,0X0B,0XFA,0X03, - 0X90,0X98,0XA8,0XFC,0X87,0XA4, - 0X90,0X00,0X80,0X03,0X00,0X00, - 0X00,0X00,0X00,0XFF,0X08,0X08, - 0X08,0X00,0X00,0XAA,0XAE,0X2A, - 0X16,0XDD,0X14,0X12,0X00,0X0A, - 0XCA,0X1F,0X65,0XA5,0X95,0X16, - 0X5A,0X9E,0XD0,0XBF,0X90,0X0F, - 0X10,0XF8,0X19,0XF9,0X01,0X0F, - 0X40,0X05,0X6A,0X04,0X04,0X04, - 0X04,0XFC,0X07,0X24,0X44,0X84, - 0X04,0X00,0X00,0X0C,0X00,0XFE, - 0X01,0X7E,0X02,0XFA,0X02,0X7E, - 0X00,0X7E,0X00,0XFF,0X63,0X24, - 0XBA,0XBF,0XA0,0X3F,0X00,0X3F, - 0X81,0X7D,0X25,0X3D,0X01,0X3F, - 0XC0,0X00,0X0E,0XE0,0X2F,0X20, - 0X21,0XA6,0X30,0X23,0XAC,0X23, - 0X00,0X60,0XAA,0XAE,0X20,0XF0, - 0X0F,0X10,0XF0,0X10,0X17,0X18, - 0X10,0XF3,0X10,0X30,0XAA,0XAB, - 0X09,0X0D,0XFD,0X4B,0X39,0X00, - 0X7D,0X05,0XFF,0X05,0X7D,0X39, - 0X60,0X24,0X8A,0X9E,0XD6,0XBF, - 0X96,0X1A,0XC2,0X0F,0X72,0X8A, - 0X66,0X75,0X19,0X0D,0X90,0X2C, - 0X01,0XC0,0X6F,0X20,0X23,0XF5, - 0X29,0X65,0X33,0X18,0X46,0X06, - 0XFC,0X97,0XFE,0X03,0X01,0X94, - 0X98,0XF0,0X9B,0X94,0X04,0X83, - 0X91,0X20,0X22,0XBA,0X3A,0X36, - 0XF2,0X2A,0XA5,0X11,0X20,0X00, - 0X05,0X0E,0X05,0X00,0X00,0X20, - 0X18,0XC6,0X01,0X06,0X38,0X00, - 0X00,0X80,0X01,0X40,0X22,0X61, - 0XFF,0X65,0X25,0X0F,0X41,0X75, - 0XE5,0X4F,0XC5,0XC7,0X35,0X38, - 0XF8,0X0B,0XFA,0X03,0X70,0X52, - 0X7E,0X16,0X7F,0X52,0X72,0X02, - 0X1A,0X93,0X44,0X53,0X56,0XDA, - 0X52,0X54,0X53,0X7A,0XD2,0X56, - 0X5A,0X00,0XA1,0X03,0XDB,0X16, - 0X10,0X00,0X40,0XE0,0X5F,0X50, - 0XE2,0X13,0X8E,0X86,0X19,0X09, - 0XE0,0XAF,0X12,0X88,0X60,0X12, - 0X15,0X19,0X65,0X82,0XD0,0X81, - 0X91,0XD0,0XAB,0XEE,0XAB,0XDA, - 0X03,0X24,0X9D,0XC5,0X27,0X3D, - 0X44,0X4E,0X5D,0X4C,0XFB,0X4A, - 0X00,0X79,0X0A,0X88,0X6F,0X88, - 0X0A,0X79,0X1C,0X06,0X24,0X90, - 0XDF,0XB2,0X94,0X3F,0X00,0X01, - 0X19,0XC1,0X3F,0X81,0XE1,0XA0, - 0X83,0X10,0X2D,0X00,0X00,0XE1, - 0X8F,0XF0,0X87,0X40,0XC2,0X3B, - 0XC0,0XAA,0X27,0XE8,0X03,0X00, - 0XFC,0X07,0X94,0XFF,0X96,0X07, - 0XFC,0XB3,0X05,0XE8,0X04,0X04, - 0X84,0X64,0X1F,0X24,0X44,0X84, - 0X04,0X04,0X00,0X1A,0X40,0X0A, - 0X10,0X0C,0X03,0X00,0XC0,0X3F, - 0X00,0X00,0X01,0X06,0X18,0XA0, - 0X03,0X00,0X45,0X65,0X5B,0XC9, - 0X4B,0X47,0X25,0X4B,0X05,0X05, - 0X80,0X6A,0X01,0X20,0XF0,0X0F, - 0X00,0XF8,0XAB,0XAA,0XAF,0XAA, - 0XAB,0XBA,0X33,0XCE,0XCC,0X92, - 0X72,0XFE,0X51,0X80,0X54,0XBA, - 0X33,0X32,0XAA,0X66,0X30,0X6A, - 0X01,0X08,0X49,0X89,0X29,0X1F, - 0X99,0X69,0X09,0X09,0X08,0X80, - 0X06,0X90,0X92,0X2F,0X00,0X19, - 0X19,0XD5,0X1F,0X11,0X11,0X11, - 0XF0,0X3F,0XE0,0X80,0X43,0X44, - 0X44,0XFE,0X45,0X44,0X44,0XFC, - 0X47,0X44,0X40,0X60,0X00,0X03, - 0X00,0X80,0X7E,0XEA,0X2A,0X2A, - 0X2B,0X2A,0X2A,0XEE,0X00,0XC6, - 0XAA,0X8E,0XA2,0X9A,0X7F,0X12, - 0X00,0X07,0XC0,0X0F,0X20,0X11, - 0X0A,0X0C,0X16,0X00,0X81,0X40, - 0X31,0X09,0X07,0X31,0X41,0X8F, - 0X00,0X01,0XA0,0X01,0X06,0X00, - 0X10,0X90,0X90,0X94,0XF8,0X93, - 0X90,0X90,0X10,0X00,0XA0,0XBA, - 0X2A,0X07,0X99,0X61,0X99,0X07, - 0X00,0X07,0X99,0X61,0X99,0X07, - 0X46,0X62,0X64,0X78,0X6B,0X6A, - 0X7B,0X69,0X6B,0X38,0X00,0X1F, - 0XC0,0XFF,0XBA,0X8E,0X0E,0X02, - 0XF2,0X92,0X9E,0X9A,0X9A,0XFA, - 0X0A,0X0A,0X02,0X00,0X80,0X1A, - 0X00,0XF8,0X2B,0XA8,0XAB,0XA8, - 0XA4,0XA4,0XA4,0X23,0X00,0X18, - 0XAB,0X0E,0X08,0XFC,0X03,0X00, - 0X32,0X52,0X56,0XD7,0X56,0X52, - 0X32,0X0C,0XE8,0X00,0X00,0X00, - 0X3E,0X00,0XC0,0X3F,0X02,0X02, - 0X02,0X00,0X80,0XAE,0XAB,0XAA, - 0XA8,0XE6,0X9F,0X12,0XC8,0X36, - 0XE0,0X2F,0X20,0X63,0X0C,0X03, - 0X0E,0X84,0X84,0X44,0X24,0XF4, - 0X0F,0X24,0X44,0X84,0X04,0X01, - 0X00,0X0C,0X00,0X84,0X44,0XA4, - 0X9C,0X84,0XFF,0X84,0X9C,0XA4, - 0X44,0X84,0X00,0X0C,0X00,0XC2, - 0X3F,0X12,0X00,0X88,0X3F,0XC4, - 0X1F,0X0A,0X12,0X5E,0X00,0XAB, - 0XCE,0XB2,0XAF,0X02,0X80,0X42, - 0X2A,0X9A,0X2A,0X4A,0X8A,0XC2, - 0X02,0X1A,0XFC,0X07,0X04,0XE4, - 0X25,0X25,0XE5,0X05,0X04,0XFC, - 0X03,0XAC,0XAA,0X3A,0X08,0X04, - 0X44,0X4A,0X4A,0XF9,0X4A,0X4A, - 0X44,0X04,0X08,0XA8,0XAE,0X0A, - 0X84,0XB4,0XD6,0X94,0X96,0X34, - 0XC4,0X7F,0X62,0XE2,0X1D,0XAB, - 0X33,0X00,0XF0,0X9F,0X94,0X94, - 0XF4,0X9F,0X94,0X94,0XF4,0X0F, - 0X60,0XC0,0XE0,0X10,0XF8,0X07, - 0XE4,0X93,0X88,0X88,0XF8,0X8B, - 0X84,0X00,0X30,0X99,0X64,0X10, - 0X10,0XFF,0X10,0X18,0X54,0X92, - 0X11,0X10,0X10,0X00,0XB0,0X41, - 0X8A,0XBC,0X84,0X85,0XB6,0XD6, - 0X96,0XB6,0X85,0X84,0X3C,0XC0, - 0X50,0X85,0X03 -}; \ No newline at end of file + +const uint8_t gFontChinese_out[2013]={ + + 0X20,0X20,0X3E,0XA0,0X20,0XBF,0X24, + 0X24,0X24,0XA4,0X20,0XA0,0X89, + 0X74,0X22,0X01,0X00,0X11,0X21, + 0X0F,0X44,0XF4,0X4F,0X44,0XF4, + 0X4F,0X04,0X84,0X34,0XA4,0X89, + 0XB8,0X88,0X10,0XDE,0X10,0XFF, + 0X12,0X92,0XF9,0X0D,0XEB,0X09, + 0XF9,0X89,0X24,0X01,0X49,0X43, + 0X29,0XA0,0X28,0XA5,0X69,0X3D, + 0X2B,0XAD,0X28,0XA5,0X28,0X20, + 0X22,0X22,0X2F,0X22,0X22,0X88, + 0X88,0XFF,0X48,0XA4,0XAC,0XB5, + 0XE6,0XB4,0XAC,0XA4,0X80,0X0F, + 0XA8,0X4B,0XB4,0XE8,0X0F,0X00, + 0XF8,0X0F,0X02,0XF1,0X8E,0X80, + 0X88,0X87,0X30,0X01,0X8F,0X24, + 0X21,0X84,0X48,0X2A,0X98,0X7F, + 0X28,0X4A,0X10,0XEF,0X08,0XF8, + 0X08,0XB9,0X55,0X0B,0X58,0X52, + 0XC8,0X40,0X40,0X42,0X52,0X62, + 0X42,0X4A,0X46,0X42,0XC0,0X10, + 0X11,0X99,0X1F,0X11,0X11,0X20, + 0X42,0X82,0XFE,0X02,0X02,0X02, + 0XFE,0X82,0X42,0X20,0X88,0XF8, + 0X88,0XF8,0X88,0X08,0X21,0X6D, + 0XA5,0X25,0X35,0X25,0XA5,0X65, + 0X25,0X0D,0X01,0X5F,0X55,0X55, + 0X55,0X0F,0X88,0X68,0XFF,0X48, + 0X02,0XFA,0XAF,0XAA,0XAF,0XFA, + 0X02,0X00,0X0F,0XAA,0X36,0XA6, + 0X8A,0XF8,0X8F,0X04,0XE0,0X0F, + 0X20,0XC8,0X00,0XFE,0X01,0X80, + 0X0F,0X30,0X49,0X03,0XC3,0X0E, + 0X08,0X88,0X78,0XCF,0X48,0X48, + 0X49,0XCA,0X08,0X08,0X24,0X89, + 0X54,0X52,0X84,0X18,0X21,0X0F, + 0X84,0X94,0XA4,0X84,0XAF,0X94, + 0X84,0X04,0X84,0X87,0XAC,0X89, + 0XA9,0X8C,0X44,0X54,0X55,0XD6, + 0X74,0X5C,0X54,0X56,0X55,0X54, + 0X44,0X24,0X99,0X99,0X9F,0X99, + 0X48,0X40,0X40,0XC0,0X5F,0X62, + 0X42,0X42,0X42,0X42,0X4E,0X80, + 0X34,0X00,0X80,0X88,0X07,0XFC, + 0X04,0X04,0XE6,0X25,0X24,0X24, + 0XE4,0X04,0X04,0XFC,0X0F,0X30, + 0X22,0X32,0X88,0X8F,0X80,0XF0, + 0X8F,0X80,0X80,0X0F,0XC0,0X4F, + 0X40,0XC0,0X8F,0X16,0X88,0X07, + 0X4F,0XF4,0X46,0X32,0X82,0XB2, + 0X46,0X6B,0X52,0X4A,0X62,0X12, + 0X66,0XE0,0X88,0XF8,0X88,0XE8, + 0X10,0X22,0X0E,0X00,0XFC,0X55, + 0XF5,0X5F,0X55,0XFD,0X05,0X8C, + 0X87,0X8B,0X99,0X99,0XBA,0X78, + 0X00,0XFF,0X04,0X08,0XF8,0X09, + 0X0A,0X08,0X08,0X08,0X00,0X0F, + 0XF0,0X88,0X88,0X20,0XA1,0XF4, + 0XA7,0X24,0X05,0X24,0XA5,0XF4, + 0XA7,0X24,0X11,0X59,0X91,0X1F, + 0X51,0X19,0X00,0XFE,0X02,0X42, + 0X42,0X42,0XFA,0X42,0X42,0X42, + 0X02,0X78,0X88,0X88,0X8F,0XA9, + 0X88,0X88,0XF8,0X8F,0X04,0XC0, + 0X4F,0X50,0X60,0X40,0X40,0X00, + 0XF8,0X80,0X07,0X00,0X00,0X84, + 0X44,0XF4,0X0C,0X87,0X94,0X94, + 0XD4,0XB4,0X94,0X84,0X00,0X0F, + 0X00,0XF8,0X00,0X00,0X71,0X51, + 0X5D,0X75,0XD5,0X77,0X55,0X55, + 0X7D,0X01,0X81,0XF8,0X88,0X8E, + 0XF8,0X88,0X10,0XFC,0X03,0X04, + 0X54,0X54,0X55,0X56,0X54,0X54, + 0X04,0XF0,0X00,0X5F,0X55,0XF5, + 0X00,0X11,0X21,0X0F,0XA0,0XBF, + 0XEA,0XAA,0XAA,0XBA,0XAA,0X8F, + 0X34,0XB4,0XAA,0XAA,0XBA,0XFE, + 0X22,0XFE,0X20,0XFE,0X22,0XFE, + 0X20,0XFC,0X00,0XFF,0X87,0X0F, + 0X87,0X0F,0X81,0XEF,0X2F,0XE3, + 0X0C,0X80,0X44,0X25,0X15,0X2F, + 0X45,0X85,0XF4,0X12,0X24,0X81, + 0X0F,0X61,0X10,0XD0,0X48,0X54, + 0XD2,0X11,0XD2,0X54,0X48,0XD0, + 0X10,0X70,0X22,0X07,0X0F,0X74, + 0X00,0X00,0X81,0X48,0X79,0X4E, + 0X4C,0X4A,0X4A,0XC9,0X08,0X18, + 0X01,0X4F,0X44,0X44,0XF4,0X88, + 0X88,0XFF,0X48,0X48,0X02,0X22, + 0X22,0X22,0X22,0XFE,0X80,0X0F, + 0X40,0X44,0X44,0X8F,0X88,0XF8, + 0X8F,0X24,0X7F,0X29,0X29,0X2F, + 0X79,0X29,0X0F,0XF8,0XF0,0X44, + 0X47,0XF4,0X42,0X22,0X5E,0X92, + 0X12,0XF2,0X00,0XFC,0X00,0X00, + 0XFF,0X80,0X24,0X01,0X10,0X88, + 0X0F,0X44,0X44,0X45,0X45,0XFD, + 0X47,0X4D,0X45,0X45,0X04,0X44, + 0X24,0X8F,0X14,0X42,0X9A,0X88, + 0X88,0XFF,0X48,0XBC,0XAA,0XA0, + 0XFF,0XA0,0XAA,0XBE,0X80,0X0F, + 0X98,0X4A,0XA4,0X89,0XA1,0XA0, + 0XA4,0XA6,0XFD,0XA4,0XA4,0XA2, + 0XA8,0X80,0X01,0X59,0X91,0X1F, + 0X51,0X09,0X78,0X00,0XFF,0X08, + 0XC4,0X3F,0XC4,0X04,0XF4,0X44, + 0X24,0X00,0X4F,0X83,0X24,0X61, + 0X48,0X20,0XD0,0X57,0X5D,0X55, + 0X55,0X55,0X55,0XD5,0X17,0X00, + 0X9A,0X5B,0X55,0XB5,0X89,0X08, + 0X48,0X48,0XC8,0X48,0X48,0X08, + 0XFF,0X08,0X09,0X0A,0X88,0X78, + 0X44,0X04,0X43,0X0E,0X42,0X4A, + 0XF2,0X4F,0X02,0X22,0XED,0X24, + 0X24,0XE5,0X8D,0X47,0X9F,0XB9, + 0XAA,0XBA,0XFE,0X22,0X22,0XFE, + 0X00,0X08,0X48,0X88,0X08,0XFF, + 0X08,0X27,0X72,0X00,0X90,0XF8, + 0X80,0X42,0X22,0X0E,0X0B,0XFB, + 0X8A,0X4A,0X2A,0X4A,0X8E,0X00, + 0XF0,0XAA,0XAA,0XAA,0X0F,0XFC, + 0X24,0X24,0X24,0XFF,0X24,0X24, + 0X24,0XFC,0X00,0X00,0X13,0X11, + 0X97,0X99,0X89,0X0E,0X22,0XA2, + 0XA2,0XAE,0XFA,0XAB,0XAA,0XAA, + 0X2A,0X02,0X82,0X9A,0X4A,0X44, + 0X9A,0X88,0X04,0XF4,0X94,0X94, + 0X94,0X9F,0X94,0X94,0X94,0XF4, + 0X04,0X88,0X34,0X00,0X70,0X88, + 0X0C,0XE0,0X2F,0X21,0X22,0X2C, + 0XA2,0X21,0XE0,0X0F,0X00,0X80, + 0X27,0X01,0X21,0X30,0XF4,0X10, + 0X10,0XFF,0X10,0X3E,0XAB,0XA2, + 0XBE,0XA2,0XAB,0X3E,0X44,0X23, + 0XF0,0XAA,0XFA,0X80,0X94,0XAA, + 0XC9,0X88,0X88,0X88,0XC8,0XA8, + 0X99,0X8A,0X84,0X8F,0XF8,0XF8, + 0X88,0X8F,0X80,0X3E,0X2A,0XEA, + 0X2A,0X2A,0X2A,0XEA,0X2A,0X3E, + 0X80,0X98,0XFA,0X88,0XF8,0X9A, + 0X08,0X01,0X21,0X29,0X21,0X21, + 0X2F,0X21,0X21,0X09,0X01,0X41, + 0X12,0X80,0X0F,0X00,0X61,0X00, + 0XFC,0X24,0X24,0X26,0X25,0X24, + 0X24,0X24,0XFC,0X00,0XF0,0X99, + 0X99,0X99,0XF9,0X00,0X21,0X2D, + 0X23,0X09,0X01,0X80,0XF0,0X8F, + 0X80,0X80,0X3F,0X22,0X32,0X68, + 0X81,0X78,0X12,0X12,0XEA,0XBF, + 0XA0,0XA0,0XA7,0XAA,0XEA,0X09, + 0X0C,0X00,0X2F,0X22,0XA2,0X0F, + 0X00,0X22,0X42,0X82,0X0E,0XF2, + 0X03,0X82,0X4E,0X22,0X02,0X82, + 0X24,0X01,0X00,0X87,0XE8,0X82, + 0X82,0XBA,0XAA,0XAA,0XAB,0XAA, + 0XAA,0XBA,0X82,0X82,0X89,0X26, + 0X22,0X62,0X88,0X0D,0XE0,0XAF, + 0XA0,0XE8,0XAB,0XBA,0XAA,0XEA, + 0XAB,0XA8,0X80,0X07,0X98,0X4A, + 0XA4,0X89,0X04,0XF4,0X55,0X56, + 0X54,0X5C,0X54,0X56,0X55,0XF4, + 0X04,0XF0,0X55,0X55,0X55,0XF5, + 0X00,0XF0,0X5F,0X50,0X5A,0X5A, + 0X5A,0X5E,0X55,0X55,0X71,0X80, + 0X27,0X22,0X72,0X99,0XC9,0X10, + 0X22,0X04,0X00,0XF2,0X54,0X50, + 0X5F,0X50,0X54,0XF2,0X24,0X01, + 0X1F,0X11,0X91,0X0F,0X11,0X21, + 0X0F,0X80,0X80,0X82,0X8C,0X80, + 0XF0,0X8F,0X80,0X34,0X84,0X88, + 0XAA,0X8B,0X00,0XF8,0X88,0X88, + 0X88,0XFF,0X88,0X88,0X88,0XF8, + 0X00,0X10,0X00,0XF0,0X00,0X10, + 0X80,0X49,0X3D,0X8B,0X08,0XE0, + 0X4F,0X82,0XFA,0X8F,0X4A,0X42, + 0X24,0X02,0X9F,0XF8,0X98,0X88, + 0X88,0XFF,0X48,0X00,0X4C,0XC4, + 0X75,0X46,0XC4,0X4C,0X80,0X0F, + 0X88,0X25,0X52,0X48,0X39,0X2F, + 0X49,0XC6,0X8D,0XA8,0XFA,0XAF, + 0XEA,0X8B,0X00,0X4F,0X7A,0XAA, + 0XAF,0XAA,0X00,0XFE,0X2A,0XAA, + 0X2A,0X3E,0X00,0XFE,0X02,0X02, + 0XFE,0XF0,0X24,0X61,0XF0,0X20, + 0XE3,0X2F,0XE0,0X0F,0XA0,0X24, + 0X25,0XE4,0X1F,0X14,0X95,0X34, + 0X31,0X00,0X88,0X0F,0X00,0X00, + 0X00,0X00,0X00,0XFF,0X10,0X10, + 0X10,0X10,0X10,0X00,0X88,0X88, + 0X8F,0X88,0X88,0X88,0X49,0X3D, + 0X8B,0X08,0X80,0X84,0XF4,0X4F, + 0X52,0X6A,0X42,0X24,0X82,0X48, + 0X53,0XE8,0X42,0XF2,0X2E,0XE2, + 0X01,0X3D,0X21,0X21,0X21,0X3F, + 0XE0,0X70,0X72,0X11,0X11,0X89, + 0X27,0X20,0X20,0X20,0XE0,0X2F, + 0X20,0X21,0X22,0X24,0X28,0X00, + 0X00,0XF0,0X00,0X00,0X01,0X10, + 0XFC,0X03,0XFE,0XC2,0X02,0XFE, + 0X00,0XFC,0X00,0XFF,0XF0,0X48, + 0X43,0X08,0X81,0XCF,0X4F,0XC0, + 0X0F,0XC0,0X4F,0X60,0X5E,0X42, + 0X4E,0XC0,0X3F,0X31,0XF0,0X10, + 0X11,0XF8,0X00,0XFC,0X04,0X44, + 0X84,0X15,0XE6,0X04,0X04,0XE4, + 0X04,0X78,0X88,0X8B,0XC8,0X8B, + 0X08,0XC1,0X3F,0X80,0X80,0X86, + 0X98,0XA0,0X80,0X80,0X8E,0X00, + 0X0F,0X88,0X8B,0XBC,0X88,0X20, + 0X2A,0XF2,0X2E,0X60,0X00,0XF2, + 0X1A,0XD6,0X12,0XF2,0X80,0X0F, + 0X00,0X49,0X43,0X89,0XA2,0XAE, + 0XFB,0XAE,0XAA,0X8A,0XF0,0X8F, + 0X90,0XAE,0X40,0X44,0X2F,0X82, + 0X34,0XE4,0X22,0X44,0X00,0XFC, + 0X24,0XE4,0X24,0X3F,0X24,0XE4, + 0X0C,0X24,0X78,0X88,0X25,0X85, + 0X28,0XE0,0X2F,0XE5,0X2F,0X94, + 0XA4,0X84,0XAF,0X94,0X04,0X24, + 0X23,0X9F,0X34,0X30,0X84,0X00, + 0X82,0X92,0XDA,0XD6,0XB2,0XB1, + 0X91,0X89,0XC1,0X80,0X48,0X02, + 0XF8,0X00,0X42,0X09,0X00,0X00, + 0X00,0X08,0XF6,0X01,0X06,0X08, + 0X00,0X00,0X80,0X24,0X01,0X00, + 0X21,0X84,0X22,0XEA,0XBF,0XEA, + 0X2A,0X54,0X53,0XFA,0X56,0XF0, + 0X40,0XF0,0XF2,0X10,0XF9,0X31, + 0XE0,0X2F,0XE0,0X0F,0X00,0X77, + 0X55,0X57,0X58,0X77,0X05,0X37, + 0X31,0X90,0X35,0X3F,0X95,0X44, + 0X53,0X52,0X56,0X52,0X7C,0X53, + 0XD2,0X56,0X52,0X42,0X11,0X53, + 0X91,0XF9,0X11,0X81,0X49,0X3D, + 0X8B,0X28,0XE0,0X2F,0X28,0X20, + 0XE3,0X02,0X4E,0X24,0X6A,0X81, + 0X25,0X85,0X00,0XFE,0X2A,0XA9, + 0X00,0X28,0XE7,0X21,0X21,0XEF, + 0X08,0XF2,0X01,0X88,0X25,0X85, + 0X88,0X40,0X3F,0XA5,0X6F,0X05, + 0X9F,0X78,0X16,0X94,0XFE,0X84, + 0X17,0X97,0X0F,0X22,0X2F,0X94, + 0XF3,0X92,0X00,0XF2,0X14,0X10, + 0XDF,0X10,0X14,0XF2,0XF0,0X84, + 0X49,0X12,0X42,0X09,0XE8,0XBF, + 0XAA,0XEA,0X0F,0X80,0X84,0X88, + 0XF0,0X8F,0X40,0X12,0XF8,0X00, + 0X89,0X0F,0X22,0X44,0X40,0XFC, + 0X20,0X10,0XFF,0X08,0X04,0XFC, + 0X00,0X24,0X70,0X88,0X8B,0X99, + 0X1C,0X21,0X0F,0X00,0XF0,0X1F, + 0X92,0XDA,0X9B,0X1A,0XF2,0X0F, + 0X27,0X78,0X30,0XB2,0XF8,0X10, + 0X10,0X10,0X10,0XD0,0X3F,0XD0, + 0X10,0X10,0X10,0X10,0X88,0X34, + 0X00,0X30,0X84,0X08,0X00,0X0C, + 0X03,0X00,0XF0,0X0F,0X00,0X00, + 0X01,0X06,0X18,0X00,0X88,0X0F, + 0X00,0X10,0X90,0X54,0XB6,0X95, + 0X5C,0X54,0X34,0X94,0X36,0X54, + 0X90,0XA0,0XAA,0X9A,0X45,0X24, + 0X00,0XC1,0X3F,0X00,0XE8,0XAF, + 0XA2,0XBE,0XA2,0XAE,0XE2,0X0E, + 0X1F,0XF0,0X71,0X71,0XF9,0X12, + 0XD2,0XFE,0X91,0X08,0X44,0XAB, + 0X52,0X6A,0X46,0XC0,0X01,0X0F, + 0X98,0X54,0X12,0X00,0X84,0X94, + 0XA4,0X84,0X84,0X8F,0XA4,0X94, + 0X84,0X04,0X84,0X48,0X12,0X10, + 0X42,0X88,0X00,0XF9,0X02,0X20, + 0X20,0XA2,0XFA,0X22,0X22,0X02, + 0XFE,0XF0,0X20,0X41,0X07,0X88, + 0X0F,0X24,0X24,0XE4,0X2F,0X24, + 0X24,0XE4,0X2F,0X24,0X04,0X04, + 0X68,0X01,0X00,0X0F,0X00,0X00, + 0X00,0XFC,0XA4,0XA4,0XA5,0XA6, + 0XA4,0XA4,0XA4,0XBC,0X68,0XF1, + 0X44,0X44,0X44,0X2F,0X21,0XED, + 0X1F,0X09,0X84,0X03,0XF0,0X0F, + 0X40,0X80,0X1B,0XF0,0X80,0X48, + 0X24,0X01,0X20,0X10,0X2C,0X23, + 0XE0,0X20,0X20,0X23,0XEC,0X10, + 0X20,0X80,0X34,0X80,0X88,0X07, + 0X00,0X80,0X88,0X88,0X98,0XA8, + 0X8F,0X88,0X88,0X88,0X08,0X80, + 0X88,0X88,0X8F,0X88,0X88,0X12, + 0X62,0X82,0X62,0X1E,0X00,0X1E, + 0X62,0X82,0X62,0X1E,0X68,0X61, + 0X80,0X24,0X61,0X18,0XDC,0X55, + 0X55,0X5D,0XD5,0X15,0X0C,0XC0, + 0X0F,0XF0,0XFF,0X55,0X57,0XF5, + 0X10,0XF8,0X20,0X20,0XAF,0X69, + 0X29,0X29,0X29,0X29,0X2F,0X20, + 0X20,0X00,0X11,0X11,0X91,0X79, + 0X00,0X00,0XE0,0X2F,0X21,0X29, + 0X29,0X19,0X19,0X19,0X09,0X89, + 0X16,0XF0,0X44,0X44,0XF4,0X20, + 0X10,0XFC,0X03,0X82,0XBA,0XAA, + 0XAB,0XAA,0XBA,0X82,0X00,0X0F, + 0X21,0XEA,0X22,0X01,0X00,0X80, + 0X0F,0X00,0X00,0XF0,0X0F,0X01, + 0X01,0X01,0X80,0XF8,0X88,0XF8, + 0X88,0X88,0X12,0XD2,0XFE,0X51, + 0X90,0XC8,0X07,0XF4,0X04,0X54, + 0X8C,0X01,0X0F,0X12,0XF8,0X00, + 0X23,0X20,0X20,0X28,0X24,0X22, + 0XEF,0X20,0X22,0X24,0X28,0X10, + 0X01,0X00,0X0F,0X00,0X10,0X04, + 0X04,0X84,0X64,0X14,0XFF,0X14, + 0X64,0X84,0X04,0X04,0X12,0X22, + 0XF2,0X22,0X12,0X02,0X01,0XF1, + 0X0F,0X01,0XC2,0X0F,0XF1,0X8F, + 0X40,0XC8,0X4F,0X34,0X02,0X87, + 0X89,0XE8,0X98,0XF7,0X94,0X84, + 0X10,0X48,0X44,0X53,0X64,0XC8, + 0X10,0XF0,0X24,0X00,0X42,0X0B, + 0X00,0XE0,0X2F,0X20,0X20,0X2F, + 0X29,0X29,0X2F,0X20,0XE0,0X0F, + 0X4F,0X44,0X44,0X44,0XF4,0X10, + 0X10,0X28,0X24,0X22,0XE1,0X22, + 0X24,0X28,0X10,0X10,0X98,0X99, + 0XF9,0X99,0X99,0X08,0XA2,0X2A, + 0X3B,0X2A,0XAB,0X0A,0XE2,0X2F, + 0X20,0XE3,0X0C,0X4F,0X44,0X0F, + 0X2F,0X12,0X00,0XFE,0X92,0X92, + 0X92,0XFE,0X92,0X92,0X92,0XFE, + 0X00,0X78,0X00,0X70,0X80,0XF8, + 0X00,0X02,0XC1,0X3F,0XE0,0X2F, + 0X22,0XE2,0X1F,0X12,0X02,0X02, + 0XF0,0X70,0X52,0X38,0XF4,0X20, + 0X20,0X20,0XFF,0X28,0X28,0XE4, + 0X24,0X22,0X22,0X20,0X00,0XF0, + 0X24,0X10,0X42,0X24,0X28,0XA8, + 0XAB,0XAA,0XBA,0XAA,0XAA,0XAA, + 0X2B,0X28,0XF8,0X00,0XAE,0XAA, + 0X0E,0XF8,}; \ No newline at end of file diff --git a/font.h b/font.h index 3073291..bbd91ff 100644 --- a/font.h +++ b/font.h @@ -18,14 +18,11 @@ #define FONT_H #include -extern const uint8_t gFontChinese_out[1678]; -#define CHAR_SIZE 20U -#define CHAR_COL 10U -#define CHAR_ROW 11U -#define GET_BIT(byte, bitPosition) (((byte) >> (bitPosition)) & 0x01U) +extern const uint8_t gFontChinese_out[2013]; +#define CHN_FONT_WIDTH 11U +#define CHN_FONT_HIGH 12U + -//extern const uint8_t gFontChinese[123][16] ; -//gFontBig extern const uint8_t gFontBigDigits[11][20/*20*/]; extern const uint8_t gFont3x5[96][3]; extern const uint8_t gFontSmall[95 - 1][6]; diff --git a/helper/battery.c b/helper/battery.c index 75bc28c..0ebd824 100644 --- a/helper/battery.c +++ b/helper/battery.c @@ -37,9 +37,9 @@ bool gLowBatteryConfirmed; uint16_t gBatteryCheckCounter; typedef enum { - BATTERY_LOW_INACTIVE, - BATTERY_LOW_ACTIVE, - BATTERY_LOW_CONFIRMED + BATTERY_LOW_INACTIVE, + BATTERY_LOW_ACTIVE, + BATTERY_LOW_CONFIRMED } BatteryLow_t; @@ -49,175 +49,175 @@ const uint16_t lowBatteryPeriod = 30; volatile uint16_t gPowerSave_10ms; +const uint16_t Voltage2PercentageTable[][7][2] = { + [BATTERY_TYPE_1600_MAH] = { + {828, 100}, + {814, 97 }, + {760, 25 }, + {729, 6 }, + {630, 0 }, + {0, 0 }, + {0, 0 }, + }, + + [BATTERY_TYPE_2200_MAH] = { + {832, 100}, + {813, 95 }, + {740, 60 }, + {707, 21 }, + {682, 5 }, + {630, 0 }, + {0, 0 }, + }, +}; + +static_assert(ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_1600_MAH]) == + ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH])); + + unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV) { - const uint16_t crv1600[][2] = { - {828, 100}, - {814, 97 }, - {760, 25 }, - {729, 6 }, - {630, 0 }, - {0, 0 } - }; + const uint16_t (*crv)[2] = Voltage2PercentageTable[gEeprom.BATTERY_TYPE]; + const int mulipl = 1000; + for (unsigned int i = 1; i < ARRAY_SIZE(Voltage2PercentageTable[BATTERY_TYPE_2200_MAH]); i++) { + if (voltage_10mV > crv[i][0]) { + const int a = (crv[i - 1][1] - crv[i][1]) * mulipl / (crv[i - 1][0] - crv[i][0]); + const int b = crv[i][1] - a * crv[i][0] / mulipl; + const int p = a * voltage_10mV / mulipl + b; + return MIN(p, 100); + } + } - const uint16_t crv2200[][2] = { - {832, 100}, - {813, 95 }, - {740, 60 }, - {707, 21 }, - {682, 5 }, - {630, 0 }, - {0, 0 } - }; - - const BATTERY_Type_t type = gEeprom.BATTERY_TYPE; - const uint16_t(*crv)[2]; - uint8_t size; - if (type == BATTERY_TYPE_2200_MAH) { - crv = crv2200; - size = ARRAY_SIZE(crv2200); - } - else { - crv = crv1600; - size = ARRAY_SIZE(crv1600); - } - - const int mulipl = 1000; - for (int i = 1; i < size; i++) { - if (voltage_10mV > crv[i][0]) { - int a = (crv[i - 1][1] - crv[i][1]) * mulipl / (crv[i - 1][0] - crv[i][0]); - int b = crv[i][1] - a * crv[i][0] / mulipl; - int p = a * voltage_10mV / mulipl + b; - return MIN(p, 100); - } - } - return 0; + return 0; } void BATTERY_GetReadings(const bool bDisplayBatteryLevel) { - const uint8_t PreviousBatteryLevel = gBatteryDisplayLevel; - const uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4; + const uint8_t PreviousBatteryLevel = gBatteryDisplayLevel; + const uint16_t Voltage = (gBatteryVoltages[0] + gBatteryVoltages[1] + gBatteryVoltages[2] + gBatteryVoltages[3]) / 4; - + gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3]; - gBatteryVoltageAverage = (Voltage * 760) / gBatteryCalibration[3]; - - if(gBatteryVoltageAverage > 890) - gBatteryDisplayLevel = 7; // battery overvoltage - else if(gBatteryVoltageAverage < 630) - gBatteryDisplayLevel = 0; // battery critical - else { - gBatteryDisplayLevel = 1; - const uint8_t levels[] = {5,17,41,65,88}; - uint8_t perc = BATTERY_VoltsToPercent(gBatteryVoltageAverage); - for(uint8_t i = 6; i >= 1; i--){ - if (perc > levels[i-2]) { - gBatteryDisplayLevel = i; - break; - } - } - } + if(gBatteryVoltageAverage > 890) + gBatteryDisplayLevel = 7; // battery overvoltage + else if(gBatteryVoltageAverage < 630) + gBatteryDisplayLevel = 0; // battery critical + else { + gBatteryDisplayLevel = 1; + const uint8_t levels[] = {5,17,41,65,88}; + uint8_t perc = BATTERY_VoltsToPercent(gBatteryVoltageAverage); + for(uint8_t i = 6; i >= 1; i--){ + if (perc > levels[i-2]) { + gBatteryDisplayLevel = i; + break; + } + } + } - if ((gScreenToDisplay == DISPLAY_MENU) ) - gUpdateDisplay = true; + if ((gScreenToDisplay == DISPLAY_MENU)) + gUpdateDisplay = true; - if (gBatteryCurrent < 501) - { - if (gChargingWithTypeC) - { - gUpdateStatus = true; - gUpdateDisplay = true; - } + if (gBatteryCurrent < 501) + { + if (gChargingWithTypeC) + { + gUpdateStatus = true; + gUpdateDisplay = true; + } - gChargingWithTypeC = false; - } - else - { - if (!gChargingWithTypeC) - { - gUpdateStatus = true; - gUpdateDisplay = true; - BACKLIGHT_TurnOn(); - } + gChargingWithTypeC = false; + } + else + { + if (!gChargingWithTypeC) + { + gUpdateStatus = true; + gUpdateDisplay = true; + BACKLIGHT_TurnOn(); + } - gChargingWithTypeC = true; - } + gChargingWithTypeC = true; + } - if (PreviousBatteryLevel != gBatteryDisplayLevel) - { - if(gBatteryDisplayLevel > 2) - gLowBatteryConfirmed = false; - else if (gBatteryDisplayLevel < 2) - { - gLowBattery = true; - } - else - { - gLowBattery = false; + if (PreviousBatteryLevel != gBatteryDisplayLevel) + { + if(gBatteryDisplayLevel > 2) + gLowBatteryConfirmed = false; + else if (gBatteryDisplayLevel < 2) + { + gLowBattery = true; + } + else + { + gLowBattery = false; - if (bDisplayBatteryLevel) - UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink); - } - - if(!gLowBatteryConfirmed) - gUpdateDisplay = true; + if (bDisplayBatteryLevel) + UI_DisplayBattery(gBatteryDisplayLevel, gLowBatteryBlink); + } - lowBatteryCountdown = 0; - } + if(!gLowBatteryConfirmed) + gUpdateDisplay = true; + + lowBatteryCountdown = 0; + } } -void BATTERY_TimeSlice500ms(void) +void BATTERY_TimeSlice500ms(void) { - if (gLowBattery) - { - gLowBatteryBlink = ++lowBatteryCountdown & 1; + if (!gLowBattery) { + return; + } - UI_DisplayBattery(0, gLowBatteryBlink); + gLowBatteryBlink = ++lowBatteryCountdown & 1; - if (gCurrentFunction != FUNCTION_TRANSMIT) - { // not transmitting + UI_DisplayBattery(0, gLowBatteryBlink); - if (lowBatteryCountdown < lowBatteryPeriod) - { - if (lowBatteryCountdown == lowBatteryPeriod-1 && !gChargingWithTypeC && !gLowBatteryConfirmed) - AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP); - } - else - { - lowBatteryCountdown = 0; + if (gCurrentFunction == FUNCTION_TRANSMIT) { + return; + } - if (!gChargingWithTypeC) - { // not on charge - if(!gLowBatteryConfirmed) { - AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP); + // not transmitting + + if (lowBatteryCountdown < lowBatteryPeriod) { + if (lowBatteryCountdown == lowBatteryPeriod-1 && !gChargingWithTypeC && !gLowBatteryConfirmed) { + AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP); + } + return; + } + + lowBatteryCountdown = 0; + + if (gChargingWithTypeC) { + return; + } + + // not on charge + if (!gLowBatteryConfirmed) { + AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP); #ifdef ENABLE_VOICE - AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE); + AUDIO_SetVoiceID(0, VOICE_ID_LOW_VOLTAGE); #endif - } - if (gBatteryDisplayLevel == 0) - { + } + + if (gBatteryDisplayLevel != 0) { #ifdef ENABLE_VOICE - AUDIO_PlaySingleVoice(true); + AUDIO_PlaySingleVoice(false); +#endif + return; + } + +#ifdef ENABLE_VOICE + AUDIO_PlaySingleVoice(true); #endif - gReducedService = true; + gReducedService = true; - //if (gCurrentFunction != FUNCTION_POWER_SAVE) - FUNCTION_Select(FUNCTION_POWER_SAVE); + FUNCTION_Select(FUNCTION_POWER_SAVE); - ST7565_HardwareReset(); + ST7565_HardwareReset(); - if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) - BACKLIGHT_TurnOff(); // turn the backlight off - } -#ifdef ENABLE_VOICE - else - AUDIO_PlaySingleVoice(false); -#endif - } - } - } - } + if (gEeprom.BACKLIGHT_TIME < (ARRAY_SIZE(gSubMenu_BACKLIGHT) - 1)) { + BACKLIGHT_TurnOff(); + } } \ No newline at end of file diff --git a/helper/battery.h b/helper/battery.h index 9b863a0..65418a7 100644 --- a/helper/battery.h +++ b/helper/battery.h @@ -40,9 +40,9 @@ typedef enum { BATTERY_TYPE_UNKNOWN } BATTERY_Type_t; -unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV); -void BATTERY_GetReadings(const bool bDisplayBatteryLevel); + +unsigned int BATTERY_VoltsToPercent(unsigned int voltage_10mV); +void BATTERY_GetReadings(bool bDisplayBatteryLevel); void BATTERY_TimeSlice500ms(void); -#endif - +#endif \ No newline at end of file diff --git a/main.c b/main.c index 25a8182..3d9d2dc 100644 --- a/main.c +++ b/main.c @@ -14,6 +14,7 @@ * limitations under the License. */ #include "ui/ui.h" +#include #include #include // NULL @@ -22,33 +23,40 @@ #ifdef ENABLE_AM_FIX #include "am_fix.h" #endif +#include "audio.h" +#include "board.h" +#include "misc.h" +#include "radio.h" +#include "settings.h" +#include "version.h" #include "app/app.h" #include "app/dtmf.h" -#include "audio.h" #include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/syscon.h" -#include "board.h" #include "driver/backlight.h" #include "driver/bk4819.h" #include "driver/gpio.h" #include "driver/system.h" #include "driver/systick.h" +#ifdef ENABLE_UART #include "driver/uart.h" +#endif #include "helper/battery.h" #include "helper/boot.h" -#include "misc.h" -#include "radio.h" -#include "settings.h" + #include "ui/lock.h" #include "ui/welcome.h" #include "ui/menu.h" -#include "version.h" #include "driver/eeprom.h" -void _putchar(char c) -{ - UART_Send((uint8_t *)&c, 1); -} +void _putchar(__attribute__((unused)) char c) +{ + +#ifdef ENABLE_UART + UART_Send((uint8_t *)&c, 1); +#endif + +} void Main(void) { //BOOT_Mode_t BootMode; @@ -67,15 +75,14 @@ void Main(void) SYSTICK_Init(); BOARD_Init(); - UART_Init(); + boot_counter_10ms = 250; // 2.5 sec +#ifdef ENABLE_UART + UART_Init(); +#endif - //UART_Send(UART_Version, strlen(UART_Version)); - // Not implementing authentic device checks - - memset(&gEeprom, 0, sizeof(gEeprom)); memset(gDTMF_String, '-', sizeof(gDTMF_String)); gDTMF_String[sizeof(gDTMF_String) - 1] = 0; @@ -98,9 +105,9 @@ void Main(void) RADIO_SetupRegisters(true); - for (unsigned int i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++) - BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent); - + for (unsigned int i = 0; i < ARRAY_SIZE(gBatteryVoltages); i++) { + BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent); + } BATTERY_GetReadings(false); #ifdef ENABLE_AM_FIX @@ -208,13 +215,11 @@ void Main(void) if (gNextTimeslice) { APP_TimeSlice10ms(); - gNextTimeslice = false; } if (gNextTimeslice_500ms) { APP_TimeSlice500ms(); - gNextTimeslice_500ms = false; } } } diff --git a/misc.c b/misc.c index 854478d..a5bbf72 100644 --- a/misc.c +++ b/misc.c @@ -87,9 +87,7 @@ bool gSetting_KILLED; //bool gSetting_350EN; uint8_t gSetting_F_LOCK; bool gSetting_ScrambleEnable; -#ifdef ENABLE_AIRCOPY -uint8_t gAircopySendCountdown; -#endif + #ifdef ENABLE_AM_FIX bool gSetting_AM_fix; diff --git a/misc.h b/misc.h index cad9c04..63f3a7c 100644 --- a/misc.h +++ b/misc.h @@ -16,7 +16,7 @@ #ifndef MISC_H #define MISC_H - +#include "assert.h" #include #include @@ -163,9 +163,7 @@ extern uint32_t gCustomAesKey[4]; extern bool bHasCustomAesKey; extern uint32_t gChallenge[4]; extern uint8_t gTryCount; -#ifdef ENABLE_AIRCOPY -extern uint8_t gAircopySendCountdown; -#endif + extern uint16_t gEEPROM_RSSI_CALIB[7][4]; extern uint16_t gEEPROM_1F8A; diff --git a/radio.c b/radio.c index 1158e2d..629fbd5 100644 --- a/radio.c +++ b/radio.c @@ -736,53 +736,40 @@ void RADIO_SetupRegisters(bool switchToForeground) #endif #ifdef ENABLE_VOX - #ifdef ENABLE_NOAA - #ifdef ENABLE_FMRADIO - if (gEeprom.VOX_SWITCH && !gFmRadioMode && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->Modulation == MODULATION_FM) - #else - if (gEeprom.VOX_SWITCH && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) && gCurrentVfo->Modulation == MODULATION_FM) - #endif - #else - #ifdef ENABLE_FMRADIO - if (gEeprom.VOX_SWITCH && !gFmRadioMode && gCurrentVfo->Modulation == MODULATION_FM) - #else - if (gEeprom.VOX_SWITCH && gCurrentVfo->Modulation == MODULATION_FM) - #endif - #endif - { - BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD); - InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST; - } - else + if (gEeprom.VOX_SWITCH && gCurrentVfo->Modulation == MODULATION_FM +#ifdef ENABLE_NOAA + && !IS_NOAA_CHANNEL(gCurrentVfo->CHANNEL_SAVE) #endif - BK4819_DisableVox(); - +#ifdef ENABLE_FMRADIO + && !gFmRadioMode +#endif + ){ + BK4819_EnableVox(gEeprom.VOX1_THRESHOLD, gEeprom.VOX0_THRESHOLD); + InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST; + } + else +#endif + { + BK4819_DisableVox(); + } // RX expander BK4819_SetCompander((gRxVfo->Modulation == MODULATION_FM && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0); - #if 0 if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) - { - BK4819_DisableDTMF(); - } - else - { - BK4819_EnableDTMF(); - InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND; - } + { + BK4819_DisableDTMF(); + } + else + { + BK4819_EnableDTMF(); + InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND; + } #else - if (gCurrentFunction != FUNCTION_TRANSMIT) - { - BK4819_DisableDTMF(); + BK4819_DisableDTMF(); + + if (gCurrentFunction != FUNCTION_TRANSMIT) { BK4819_EnableDTMF(); InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND; - - - - } - else - { - BK4819_DisableDTMF(); } #endif RADIO_SetupAGC(gRxVfo->Modulation == MODULATION_AM, false); @@ -1056,14 +1043,12 @@ void RADIO_PrepareTX(void) #ifdef ENABLE_DTMF_CALLING if (gDTMF_ReplyState == DTMF_REPLY_ANI) { - if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) - { - gDTMF_IsTx = true; - gDTMF_CallState = DTMF_CALL_STATE_NONE; + gDTMF_IsTx = gDTMF_CallMode == DTMF_CALL_MODE_DTMF; + + if (gDTMF_IsTx) { + gDTMF_CallState = DTMF_CALL_STATE_NONE; gDTMF_TxStopCountdown_500ms = DTMF_txstop_countdown_500ms; - } - else - { + } else { gDTMF_CallState = DTMF_CALL_STATE_CALL_OUT; } } @@ -1139,13 +1124,11 @@ void RADIO_SendEndOfTransmission(void) { BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE); } - if ( + if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH) #ifdef ENABLE_DTMF_CALLING - gDTMF_CallState == DTMF_CALL_STATE_NONE && + && gDTMF_CallState == DTMF_CALL_STATE_NONE #endif - (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || - gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)) - { // end-of-tx + ) { // end-of-tx if (gEeprom.DTMF_SIDE_TONE) { AUDIO_AudioPathOn(); diff --git a/radio.h b/radio.h index d0bd415..a2a7a17 100644 --- a/radio.h +++ b/radio.h @@ -155,7 +155,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int confi void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo); void RADIO_ApplyOffset(VFO_Info_t *pInfo); void RADIO_SelectVfos(void); -void RADIO_SetupRegisters(bool bSwitchToFunction0); +void RADIO_SetupRegisters(bool switchToForeground); #ifdef ENABLE_NOAA void RADIO_ConfigureNOAA(void); #endif diff --git a/settings.c b/settings.c index 5c9e367..017e193 100644 --- a/settings.c +++ b/settings.c @@ -22,7 +22,6 @@ #endif #include "driver/bk4819.h" #include "driver/eeprom.h" -#include "driver/uart.h" #include "misc.h" #include "settings.h" #include "ui/menu.h" @@ -44,7 +43,7 @@ void SETTINGS_InitEEPROM(void) uint8_t Data[16]; memset(Data, 0, sizeof(Data)); - + memset(&gEeprom, 0, sizeof(gEeprom)); // 0E70..0E77 EEPROM_ReadBuffer(0x0E70, Data, 8); gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST; @@ -132,10 +131,21 @@ void SETTINGS_InitEEPROM(void) memmove(&gEeprom.POWER_ON_PASSWORD, Data, 4); // 0EA0..0EA7 -#ifdef ENABLE_VOICE EEPROM_ReadBuffer(0x0EA0, Data, 8); - gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH; +#ifdef ENABLE_VOICE + gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH; #endif +#ifdef ENABLE_RSSI_BAR + if((Data[1] < 200 && Data[1] > 90) && (Data[2] < Data[1]-9 && Data[2] > 50)) { + gEeprom.S0_LEVEL = Data[1]; + gEeprom.S9_LEVEL = Data[2]; + } + else { + gEeprom.S0_LEVEL = 130; + gEeprom.S9_LEVEL = 76; + } +#endif + // 0EA8..0EAF EEPROM_ReadBuffer(0x0EA8, Data, 8); @@ -531,9 +541,12 @@ void SETTINGS_SaveSettings(void) memset(State, 0xFF, sizeof(State)); #ifdef ENABLE_VOICE State[0] = gEeprom.VOICE_PROMPT; - EEPROM_WriteBuffer(0x0EA0, State); #endif - +#ifdef ENABLE_RSSI_BAR + State[1] = gEeprom.S0_LEVEL; + State[2] = gEeprom.S9_LEVEL; +#endif + EEPROM_WriteBuffer(0x0EA0, State); #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) State[0] = gEeprom.ALARM_MODE; #else diff --git a/settings.h b/settings.h index bfc5dde..e514ba2 100644 --- a/settings.h +++ b/settings.h @@ -252,6 +252,10 @@ typedef struct { #endif uint8_t BACKLIGHT_MAX; BATTERY_Type_t BATTERY_TYPE; +#ifdef ENABLE_RSSI_BAR + uint8_t S0_LEVEL; + uint8_t S9_LEVEL; +#endif uint32_t MDC1200_ID; } EEPROM_Config_t; diff --git a/ui/battery.c b/ui/battery.c index 631fe23..36e7f0f 100644 --- a/ui/battery.c +++ b/ui/battery.c @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include #include #include @@ -21,36 +21,34 @@ #include "driver/st7565.h" #include "functions.h" #include "ui/battery.h" +#include "../misc.h" void UI_DrawBattery(uint8_t* bitmap, uint8_t level, uint8_t blink) { - if (level < 2 && blink == 1) { - memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1)); - } - else - { - memmove(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); - if (level > 2) - { - unsigned int i; - uint8_t bars = level - 2; - if (bars > 4) - bars = 4; - for (i = 0; i < bars; i++) - { - #ifndef ENABLE_REVERSE_BAT_SYMBOL - memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2); - #else - memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2); - #endif - } - } - } + if (level < 2 && blink == 1) { + memset(bitmap, 0, sizeof(BITMAP_BatteryLevel1)); + return; + } + + memcpy(bitmap, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); + + if (level <= 2) { + return; + } + + const uint8_t bars = MIN(4, level - 2); + for (int i = 0; i < bars; i++) { +#ifndef ENABLE_REVERSE_BAT_SYMBOL + memcpy(bitmap + sizeof(BITMAP_BatteryLevel1) - 4 - (i * 3), BITMAP_BatteryLevel, 2); +#else + memcpy(bitmap + 3 + (i * 3) + 0, BITMAP_BatteryLevel, 2); +#endif + } } void UI_DisplayBattery(uint8_t level, uint8_t blink) { - uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)]; - UI_DrawBattery(bitmap, level, blink); + uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)]; + UI_DrawBattery(bitmap, level, blink); ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, bitmap, sizeof(bitmap)); -} +} \ No newline at end of file diff --git a/ui/helper.c b/ui/helper.c index d47fa72..39e9ce1 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -23,6 +23,7 @@ #include "ui/inputbox.h" #include "misc.h" #include "chinese.h" + #ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0])) #endif @@ -31,9 +32,9 @@ uint8_t menu_set_flag = 0; void set_bit(uint8_t *value, uint8_t bit_position, uint8_t bit_value) { if (bit_value == 0) { - *value = *value & ~(1 << bit_position); // ��ָ��λ����Ϊ 0 + *value = *value & ~(1 << bit_position); } else { - *value = *value | (1 << bit_position); // ��ָ��λ����Ϊ 1 + *value = *value | (1 << bit_position); } } @@ -92,7 +93,7 @@ void UI_PrintCharSmall(char character, uint8_t Start, uint8_t Line) { // Display the character if it's a printable character if (character > ' ') { - const unsigned int index = (unsigned int)character - ' ' - 1; + const unsigned int index = (unsigned int) character - ' ' - 1; if (index < ARRAY_SIZE(gFontSmall)) { memmove(pFb, &gFontSmall[index], char_width); } @@ -102,8 +103,7 @@ void UI_PrintCharSmall(char character, uint8_t Start, uint8_t Line) { void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) { uint8_t Length = strlen(pString); - if (menu_set_flag == 1) - { + if (menu_set_flag == 1) { Length = Length > 7 ? 7 : Length; menu_set_flag = 0; } @@ -112,9 +112,9 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ uint8_t chn_flag[Length]; for (size_t j = 0; j < Length; j++) { chn_flag[j] = is_chn(pString[j]); - if (chn_flag[j] == 255&&pString[j]!='\n'&&pString[j]!='\0')sum_pixel += 7; + if (chn_flag[j] == 255 && pString[j] != '\n' && pString[j] != '\0')sum_pixel += 7; - else if(chn_flag[j] != 255)sum_pixel += 12; + else if (chn_flag[j] != 255)sum_pixel += 12; } if (End > Start) @@ -122,42 +122,39 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ // if(Start+sum_pixel>=128)Start=128-sum_pixel; uint8_t *pFb = gFrameBuffer[Line] + Start; uint8_t *pFb1 = gFrameBuffer[Line + 1] + Start; - uint8_t now_pixel = 0; for (i = 0; i < Length; i++) { if (chn_flag[i] == 255) { if (pString[i] > ' ') { const unsigned int index = (unsigned int) pString[i] - ' ' - 1; if (index < ARRAY_SIZE(gFontSmall)) { - memmove(pFb + now_pixel + 1, &gFontSmall[index], 6); + memcpy(pFb + now_pixel + 1, &gFontSmall[index], 6); } now_pixel += 7; - - } else if(pString[i] == ' ') - + } else if (pString[i] == ' ') now_pixel += 7; - - - } else { - uint8_t bit_cnt = 0; - uint8_t cntt = 0; uint8_t gFontChinese[22] = {0}; - for (int j = 0; j < 110; j++) { - if (IS_BIT_SET(gFontChinese_out[(j + chn_flag[i] * 110) / 8], (j + chn_flag[i] * 110) % 8)) - set_bit(&gFontChinese[cntt], bit_cnt, 1); - bit_cnt++; - if ((bit_cnt == 8 && cntt < 11) || (bit_cnt == 2 && cntt >= 11)) { - bit_cnt = 0; - - cntt++; + unsigned int local = CHN_FONT_HIGH * CHN_FONT_WIDTH * chn_flag[i] / 8; + unsigned int local_bit = (CHN_FONT_HIGH * CHN_FONT_WIDTH * chn_flag[i]) % 8; + for (unsigned char i = 0; i < CHN_FONT_WIDTH * 2; ++i) { + unsigned char j_end = 8; + if (i >= CHN_FONT_WIDTH) + j_end = CHN_FONT_HIGH - 8; + for (unsigned char j = 0; j < j_end; ++j) { + if (IS_BIT_SET(gFontChinese_out[local], local_bit)) + set_bit(&gFontChinese[i], j, 1); + local_bit++; + if (local_bit == 8) { + local_bit = 0; + local++; + } } } - memmove(pFb + now_pixel + 1, &gFontChinese[0], 11); - memmove(pFb1 + now_pixel + 1, &gFontChinese[11], 11); + memcpy(pFb + now_pixel + 1, &gFontChinese[0], 11); + memcpy(pFb1 + now_pixel + 1, &gFontChinese[11], 11); + -// memmove(gFrameBuffer[Line + 0] + Start, &gFontChinese[0], 11); -// memmove(gFrameBuffer[Line + 1] + Start, &gFontChinese[11], 11); now_pixel += 12; } } @@ -194,7 +191,7 @@ void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer) { if (pString[i] > ' ') { const unsigned int index = (unsigned int) pString[i] - ' ' - 1; if (index < ARRAY_SIZE(gFontSmall)) - memmove(buffer + (i * (char_width + 1)) + 1, &gFontSmall[index], char_width); + memcpy(buffer + (i * (char_width + 1)) + 1, &gFontSmall[index], char_width); } } } @@ -237,18 +234,15 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center) } -void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black) -{ +void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black) { const uint8_t pattern = 1 << (y % 8); - if(black) - buffer[y/8][x] |= pattern; + if (black) + buffer[y / 8][x] |= pattern; else - buffer[y/8][x] &= ~pattern; + buffer[y / 8][x] &= ~pattern; } - - void UI_DisplayPopup(const char *string) { for (uint8_t i = 0; i < 7; i++) { memset(gFrameBuffer[i], 0x00, 128); diff --git a/ui/lock.c b/ui/lock.c index 0c84169..33d4a8d 100644 --- a/ui/lock.c +++ b/ui/lock.c @@ -142,14 +142,14 @@ void UI_DisplayLock(void) gDebounceCounter = 0; gKeyReading0 = Key; } - +#ifdef ENABLE_UART if (UART_IsCommandAvailable()) { __disable_irq(); UART_HandleCommand(); __enable_irq(); } - +#endif if (gUpdateDisplay) { Render(); diff --git a/ui/main.c b/ui/main.c index a2e1cdd..6598fdb 100644 --- a/ui/main.c +++ b/ui/main.c @@ -20,9 +20,8 @@ #include "driver/uart.h" #include "app/dtmf.h" #include "app/chFrScanner.h" -#include "debugging.h" -#ifdef ENABLE_AM_FIX_SHOW_DATA +#ifdef ENABLE_AM_FIX #include "am_fix.h" #endif @@ -197,15 +196,17 @@ void DisplayRSSIBar(const bool now) { } - const int16_t s0_dBm = -130; // S0 .. base level -const int16_t rssi_dBm = +const int16_t s0_dBm = -gEeprom.S0_LEVEL; // S0 .. base level + const int16_t rssi_dBm = BK4819_GetRSSI_dBm() #ifdef ENABLE_AM_FIX + ((gSetting_AM_fix && gRxVfo->Modulation == MODULATION_AM) ? AM_fix_get_gain_diff() : 0) #endif + dBmCorrTable[gRxVfo->Band]; - const uint8_t s_level = MIN(MAX((rssi_dBm - s0_dBm) / 6, 0), 9); // S0 - S9 - uint8_t overS9dBm = MIN(MAX(rssi_dBm - (s0_dBm + 9*6), 0), 99); + + int s0_9 = gEeprom.S0_LEVEL - gEeprom.S9_LEVEL; + const uint8_t s_level = MIN(MAX((int32_t)(rssi_dBm - s0_dBm)*100 / (s0_9*100/9), 0), 9); // S0 - S9 + uint8_t overS9dBm = MIN(MAX(rssi_dBm + gEeprom.S9_LEVEL, 0), 99); uint8_t overS9Bars = MIN(overS9dBm/10, 4); if(overS9Bars == 0) { @@ -416,13 +417,13 @@ void UI_DisplayMain(void) { // highlight the selected/used VFO with a marker if (isMainVFO) - memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + memcpy(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); } else // active TX VFO { // highlight the selected/used VFO with a marker if (isMainVFO) - memmove(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); + memcpy(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); else - memmove(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); + memcpy(p_line0 + 0, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); } if (gCurrentFunction == FUNCTION_TRANSMIT) { // transmitting @@ -537,15 +538,15 @@ void UI_DisplayMain(void) { const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; if (att.scanlist1) - memmove(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); + memcpy(p_line0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); if (att.scanlist2) - memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + memcpy(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); // compander symbol #ifndef ENABLE_BIG_FREQ if (att.compander) - memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + memcpy(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); #else // TODO: // find somewhere else to put the symbol #endif @@ -624,9 +625,9 @@ void UI_DisplayMain(void) { if (att.compander) #ifdef ENABLE_BIG_FREQ - memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); + memcpy(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); #else - memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + memcpy(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); #endif } } diff --git a/ui/menu.c b/ui/menu.c index afce6ed..f32aa86 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -436,7 +436,7 @@ void UI_DisplayMenu(void) { //const void *BITMAP_CurrentIndicator = BITMAP_MARKER; if (gIsInSubMenu) - memmove(gFrameBuffer[2] + 40, BITMAP_MARKER, sizeof(BITMAP_MARKER)); + memmove(gFrameBuffer[2] + 40, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); // draw the menu index number/count绘制菜单索引号/总数 : sprintf(String, "%2u/%u", 1 + gMenuCursor, gMenuListCount); @@ -499,7 +499,11 @@ void UI_DisplayMenu(void) { memset(String, 0, sizeof(String)); bool already_printed = false; +/* Brightness is set to max in some entries of this menu. Return it to the configured brightness + level the "next" time we enter here.I.e., when we move from one menu to another. + It also has to be set back to max when pressing the Exit key. */ + BACKLIGHT_TurnOn(); switch (UI_MENU_GetCurrentMenuId()) { case MENU_SQL: sprintf(String, "%d", gSubMenuSelection); @@ -904,7 +908,7 @@ void UI_DisplayMenu(void) { if (!gIsDtmfContactValid) strcpy(String, "NULL"); else - memmove(String, Contact, 8); + memcpy(String, Contact, 8); break; #endif // case MENU_PONMSG: @@ -1091,7 +1095,7 @@ void UI_DisplayMenu(void) { #ifdef ENABLE_DTMF_CALLING if (UI_MENU_GetCurrentMenuId() == MENU_D_LIST && gIsDtmfContactValid) { Contact[11] = 0; - memmove(&gDTMF_ID, Contact + 8, 4); + memcpy(&gDTMF_ID, Contact + 8, 4); sprintf(String, "ID:%s", Contact + 8); UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 5); } diff --git a/ui/status.c b/ui/status.c index 313b3ba..41f0775 100644 --- a/ui/status.c +++ b/ui/status.c @@ -36,172 +36,139 @@ void UI_DisplayStatus() { - uint8_t *line = gStatusLine; - unsigned int x = 0; - unsigned int x1 = 0; - gUpdateStatus = false; - memset(gStatusLine, 0, sizeof(gStatusLine)); + uint8_t *line = gStatusLine; + unsigned int x = 0; // ************** // POWER-SAVE indicator - if (gCurrentFunction == FUNCTION_TRANSMIT) - { - memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX)); - x1 = x + sizeof(BITMAP_TX); + if (gCurrentFunction == FUNCTION_TRANSMIT) { + memcpy(line + x, BITMAP_TX, sizeof(BITMAP_TX)); } - else - if (FUNCTION_IsRx()) - { - memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX)); - x1 = x + sizeof(BITMAP_RX); + else if (FUNCTION_IsRx()) { + memcpy(line + x, BITMAP_RX, sizeof(BITMAP_RX)); } - else - if (gCurrentFunction == FUNCTION_POWER_SAVE) - { - memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE)); - x1 = x + sizeof(BITMAP_POWERSAVE); + else if (gCurrentFunction == FUNCTION_POWER_SAVE) { + memcpy(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE)); } - x += sizeof(BITMAP_POWERSAVE); + x += 8; + unsigned int x1 = x; #ifdef ENABLE_NOAA - // NOASS SCAN indicator - if (gIsNoaaMode) - { - memmove(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA)); - x1 = x + sizeof(BITMAP_NOAA); - } - x += sizeof(BITMAP_NOAA); -#else - // hmmm, what to put in it's place + if (gIsNoaaMode) { // NOASS SCAN indicator + memcpy(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA)); + x1 = x + sizeof(BITMAP_NOAA); + } + x += sizeof(BITMAP_NOAA); #endif #ifdef ENABLE_DTMF_CALLING - if (gSetting_KILLED) - { + if (gSetting_KILLED) { memset(line + x, 0xFF, 10); x1 = x + 10; } else #endif - { - // SCAN indicator - if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) - { +#ifdef ENABLE_FMRADIO + if (gFmRadioMode) { // FM indicator + memcpy(line + x, BITMAP_FM, sizeof(BITMAP_FM)); + x1 = x + sizeof(BITMAP_FM); + } + else +#endif + { // SCAN indicator + if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) { char * s = ""; - if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning()) - { // channel mode + if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning()) { // channel mode switch(gEeprom.SCAN_LIST_DEFAULT) { case 0: s = "1"; break; case 1: s = "2"; break; case 2: s = "*"; break; } } - else - { // frequency mode + else { // frequency mode s = "S"; } - UI_PrintStringSmallBuffer(s, line + x); - x1 = x + 7; + UI_PrintStringSmallBuffer(s, line + x + 1); + x1 = x + 10; } } - x += 7; // font character width + x += 10; // font character width #ifdef ENABLE_VOICE // VOICE indicator - if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF) - { - memmove(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt)); - x1 = x + sizeof(BITMAP_VoicePrompt); - } - x += sizeof(BITMAP_VoicePrompt) + 1; -#else - // hmmm, what to put in it's place + if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF){ + memcpy(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt)); + x1 = x + sizeof(BITMAP_VoicePrompt); + } + x += sizeof(BITMAP_VoicePrompt); #endif - x++; if(!SCANNER_IsScanning()) { uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2; if(dw == 1 || dw == 3) { // DWR - dual watch + respond if(gDualWatchActive) - memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5)); + memcpy(line + x + (dw==1?0:2), BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5)); else - memmove(line + x + 3, BITMAP_TDR2, sizeof(BITMAP_TDR2)); + memcpy(line + x + 3, BITMAP_TDR2, sizeof(BITMAP_TDR2)); } else if(dw == 2) { // XB - crossband - memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB)); + memcpy(line + x + 2, BITMAP_XB, sizeof(BITMAP_XB)); } } - x += sizeof(BITMAP_TDR1) + 2; + x += sizeof(BITMAP_TDR1) + 1; #ifdef ENABLE_VOX // VOX indicator - if (gEeprom.VOX_SWITCH) - { - memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX)); - x1 = x + sizeof(BITMAP_VOX); - } - x += sizeof(BITMAP_VOX) + 2; + if (gEeprom.VOX_SWITCH) { + memcpy(line + x, BITMAP_VOX, sizeof(BITMAP_VOX)); + x1 = x + sizeof(BITMAP_VOX) + 1; + } + x += sizeof(BITMAP_VOX) + 1; #endif - x = MAX(x, 61u); - x1 = x; + x = MAX(x1, 61u); // KEY-LOCK indicator - if (gEeprom.KEY_LOCK) - { - - memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); + if (gEeprom.KEY_LOCK) { + memcpy(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock)); x += sizeof(BITMAP_KeyLock); x1 = x; - //按键锁定禁止发射 - // RADIO_SetVfoState(VFO_STATE_TX_DISABLE); - } - else - if (gWasFKeyPressed) - { - memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key)); + else if (gWasFKeyPressed) { + memcpy(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key)); x += sizeof(BITMAP_F_Key); x1 = x; } { // battery voltage or percentage - char s[16]; - unsigned int space_needed; - - unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 3; + char s[8] = ""; + unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0; if (gChargingWithTypeC) x2 -= sizeof(BITMAP_USB_C); // the radio is on charge - +// switch (gSetting_battery_text) { // default: // case 0: // break; // -// case 1: // voltage -// { - const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V - sprintf(s, "%u.%02uV", voltage / 100, voltage % 100); - space_needed = (7 * strlen(s)); - if (x2 >= (x1 + space_needed)) - { - UI_PrintStringSmallBuffer(s, line + x2 - space_needed); - } +// case 1: { // voltage +// const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V +// sprintf(s, "%u.%02uV", voltage / 100, voltage % 100); // break; // } - +// // case 2: // percentage -// { -// sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage)); -// space_needed = (7 * strlen(s)); -// if (x2 >= (x1 + space_needed)) -// UI_PrintStringSmallBuffer(s, line + x2 - space_needed); -// } + sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage)); +// break; +// } + unsigned int space_needed = (7 * strlen(s)); + if (x2 >= (x1 + space_needed)) + UI_PrintStringSmallBuffer(s, line + x2 - space_needed); } // move to right side of the screen @@ -209,7 +176,7 @@ void UI_DisplayStatus() // USB-C charge indicator if (gChargingWithTypeC) - memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C)); + memcpy(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C)); x += sizeof(BITMAP_USB_C); // BATTERY LEVEL indicator diff --git a/uv-k5font/font.xlsx b/uv-k5font/font.xlsx index d2cb098..b5d83a7 100644 Binary files a/uv-k5font/font.xlsx and b/uv-k5font/font.xlsx differ diff --git a/version.c b/version.c index c3c60eb..80106a7 100644 --- a/version.c +++ b/version.c @@ -4,7 +4,7 @@ #ifdef GIT_HASH #define VER GIT_HASH #else - #define VER "108" + #define VER "109" #endif #ifndef ONE_OF_ELEVEN_VER