Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
More cosmetics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dual Tachyon authored and Dual Tachyon committed Oct 18, 2023
1 parent c426a76 commit ffd11a2
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ void MENU_KeyHandler(uint8_t Key)
if (gRadioMode != RADIO_MODE_RX) {
RADIO_Tune(gSettings.CurrentVfo);
}
UI_DrawMain(1);
UI_DrawMain(true);
BEEP_Play(440, 4, 80);
break;

Expand Down
8 changes: 4 additions & 4 deletions app/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void RADIO_Init(void)
RADIO_Tune(gCurrentVfo);

if (gSettings.DtmfState != DTMF_STATE_KILLED) {
UI_DrawMain(0);
UI_DrawMain(false);
BK4819_EnableVox(gSettings.Vox);
if (!gpio_input_data_bit_read(GPIOB, BOARD_GPIOB_KEY_PTT)) {
if (!gpio_input_data_bit_read(GPIOF, BOARD_GPIOF_KEY_SIDE1)) {
Expand Down Expand Up @@ -373,7 +373,7 @@ void VFO_SetMode(uint8_t Mode)
if (gRadioMode != RADIO_MODE_RX && gRadioMode != RADIO_MODE_TX) {
RADIO_Tune(gSettings.CurrentVfo);
}
UI_DrawMain(1);
UI_DrawMain(true);
}
}

Expand Down Expand Up @@ -434,7 +434,7 @@ void RADIO_NoaaRetune(void)
}
RADIO_Retune();
RADIO_Tune(gSettings.CurrentVfo);
UI_DrawMain(1);
UI_DrawMain(true);
}

void RADIO_NoaaTune(void)
Expand Down Expand Up @@ -490,7 +490,7 @@ void RADIO_StartTX(bool bUseMic)
gpio_bits_set(GPIOA, BOARD_GPIOA_LED_RED);
VOX_Timer = 0;
if (gDTMF_InputMode) {
UI_DrawMain(1);
UI_DrawMain(true);
}
Task_UpdateScreen();
UI_DrawMainBitmap(false, gSettings.CurrentVfo);
Expand Down
20 changes: 10 additions & 10 deletions app/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "radio/settings.h"

static uint8_t Buffer[256];
static uint8_t WriteIndex;
static uint8_t BufferLength;
static uint8_t Region;
static bool bFlashing;
static uint8_t g_Unused;
Expand Down Expand Up @@ -123,18 +123,18 @@ void HandlerUSART1(void)
if (USART1->ctrl1_bit.rdbfien && USART1->sts & USART_RDBF_FLAG) {
uint8_t Cmd;

Buffer[WriteIndex++] = USART1->dt;
Buffer[BufferLength++] = USART1->dt;

WriteIndex %= 256;
BufferLength %= 256;
Cmd = Buffer[0];
if (WriteIndex == 1 && Cmd != 0x35 && !(Cmd >= 0x40 && Cmd <= 0x4C) && Cmd != 0x52) {
if (BufferLength == 1 && Cmd != 0x35 && !(Cmd >= 0x40 && Cmd <= 0x4C) && Cmd != 0x52) {
UART_IsRunning = false;
UART_Timer = 0;
UART_SendByte(0xFF);
WriteIndex = 0;
BufferLength = 0;
} else {
if ((Cmd == 0x35 && WriteIndex == 5) || (Cmd == 0x52 && WriteIndex == 4) || (Cmd >= 0x40 && Cmd <= 0x4C && WriteIndex == 132)) {
if (CalcSum(Buffer, WriteIndex - 1) == Buffer[WriteIndex - 1]) {
if ((Cmd == 0x35 && BufferLength == 5) || (Cmd == 0x52 && BufferLength == 4) || (Cmd >= 0x40 && Cmd <= 0x4C && BufferLength == 132)) {
if (CalcSum(Buffer, BufferLength - 1) == Buffer[BufferLength - 1]) {
gpio_bits_flip(GPIOA, BOARD_GPIOA_LED_RED);
UART_IsRunning = true;
UART_Timer = 1000;
Expand Down Expand Up @@ -164,8 +164,8 @@ void HandlerUSART1(void)
gpio_bits_reset(GPIOA, BOARD_GPIOA_LED_RED);
UART_SendByte(0xFF);
}
WriteIndex = 0;
} else if (Cmd == 0x32 && WriteIndex == 5) {
BufferLength = 0;
} else if (Cmd == 0x32 && BufferLength == 5) {
if (CalcSum(Buffer, 4) + 1 == Buffer[4]) {
UART_IsRunning = true;
UART_Timer = 1000;
Expand All @@ -178,7 +178,7 @@ void HandlerUSART1(void)
UART_IsRunning = false;
UART_Timer = 0;
}
WriteIndex = 0;
BufferLength = 0;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion radio/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void StopDetect(void)
}

RADIO_Tune(gSettings.CurrentVfo);
UI_DrawMain(1);
UI_DrawMain(true);
}

static bool GetDcsCode(uint32_t Golay)
Expand Down
3 changes: 3 additions & 0 deletions task/fmscanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ void Task_CheckScannerFM(void)
}

SCHEDULER_ClearTask(TASK_FM_SCANNER);

if (BK1080_CheckSignal()) {
FM_Play();
return;
}

if (gVfoMode == VFO_MODE_FM_SCROLL_UP) {
gSettings.FmFrequency++;
if (gSettings.FmFrequency > 1080) {
Expand All @@ -45,6 +47,7 @@ void Task_CheckScannerFM(void)
gSettings.FmFrequency = 1080;
}
}

BK1080_Tune(gSettings.FmFrequency);
BK1080_SetVolume(0);
SPEAKER_TurnOff(SPEAKER_OWNER_FM);
Expand Down
4 changes: 2 additions & 2 deletions task/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static void HandlerLong(KEY_t Key)
} else {
DTMF_ResetString();
gDTMF_InputMode = false;
UI_DrawMain(1);
UI_DrawMain(true);
bBeep740 = false;
}
break;
Expand Down Expand Up @@ -489,7 +489,7 @@ static void HandlerLong(KEY_t Key)
gSettings.DualDisplay ^= 1;
SETTINGS_SaveGlobals();
VOX_Timer = 0;
UI_DrawMain(1);
UI_DrawMain(true);
break;

case KEY_STAR:
Expand Down
2 changes: 1 addition & 1 deletion task/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void Task_CheckLockScreen(void)
Timer = TIMER_Calculate(gSettings.LockTimer);
if (gSettings.LockTimer == 0 || gSettings.Lock || gScreenMode != SCREEN_MAIN || gEnableLocalAlarm || gScannerMode || gDTMF_InputMode || gSettings.DtmfState != DTMF_STATE_NORMAL || gReceptionMode) {
gLockTimer = 0;
} else if (Timer <= (gLockTimer / 1000)) {
} else if ((gLockTimer / 1000) >= Timer) {
LOCK_Toggle();
}
}
Expand Down
4 changes: 2 additions & 2 deletions task/ptt.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Task_CheckPTT(void)
if (gRadioMode != RADIO_MODE_RX) {
RADIO_Tune(gSettings.CurrentVfo);
}
UI_DrawMain(1);
UI_DrawMain(true);
gPttPressed = true;
}
} else {
Expand Down Expand Up @@ -92,7 +92,7 @@ void Task_CheckPTT(void)
return;
} else if (gRadioMode == RADIO_MODE_TX) {
UI_DrawVox();
if (Timer && Timer <= (gPttTimeout / 1000)) {
if (Timer && (gPttTimeout / 1000) >= Timer) {
PTT_SetLock(PTT_LOCK_VOX);
RADIO_EndTX();
}
Expand Down
4 changes: 2 additions & 2 deletions task/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ void Task_UpdateScreen(void)
gRedrawScreen = false;
if (!FUN_08006d64()) {
if (gScreenMode == SCREEN_MAIN && !gReceptionMode) {
UI_DrawMain(1);
UI_DrawMain(true);
}
} else if (gScreenMode == SCREEN_MAIN && !gReceptionMode) {
if (gVfoMode == VFO_MODE_MAIN) {
UI_DrawMain(1);
UI_DrawMain(true);
} else if (gRadioMode != RADIO_MODE_RX) {
FM_Resume();
}
Expand Down
4 changes: 2 additions & 2 deletions task/vox.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static bool CheckStatus(void)
uint16_t Value;

Value = BK4819_ReadRegister(0x64);
if (gVoxTable[gSettings.VoxLevel] + 150 <= Value) {
if (Value >= gVoxTable[gSettings.VoxLevel] + 150) {
return true;
}
if (Value <= gVoxTable[gSettings.VoxLevel] + 145) {
Expand All @@ -68,7 +68,7 @@ void Task_VoxUpdate(void)
uint16_t Delay;

Delay = VOX_Counter++ / 64;
if (gSettings.VoxDelay <= Delay) {
if (Delay >= gSettings.VoxDelay) {
VOX_IsTransmitting = false;
VOX_Counter = 0;
RADIO_EndTX();
Expand Down
13 changes: 5 additions & 8 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "ui/main.h"
#include "ui/vfo.h"

static void DrawMode0(void)
static void DrawStatusBar(void)
{
DISPLAY_Fill(0, 159, 0, 96, COLOR_BLACK);
DISPLAY_DrawRectangle0(0, 41, 160, 1, gSettings.BorderColor);
Expand All @@ -44,16 +44,13 @@ static void DrawMode0(void)
UI_DrawBattery();
}

void UI_DrawMain(uint8_t Mode)
void UI_DrawMain(bool bSkipStatus)
{
switch (Mode) {
case 0:
DrawMode0();
break;
case 1:
if (bSkipStatus) {
DISPLAY_Fill(0, 159, 0, 81, COLOR_BLACK);
DISPLAY_DrawRectangle0(0, 41, 160, 1, gSettings.BorderColor);
break;
} else {
DrawStatusBar();
}

if (gSettings.DualDisplay == 0 && (gRadioMode != RADIO_MODE_RX || gSettings.CurrentVfo == gCurrentVfo)) {
Expand Down
3 changes: 2 additions & 1 deletion ui/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#ifndef UI_MAIN_H
#define UI_MAIN_H

#include <stdbool.h>
#include <stdint.h>

void UI_DrawMain(uint8_t Mode);
void UI_DrawMain(bool bSkipStatus);
void UI_DrawRepeaterMode(void);
void UI_DrawBattery(void);

Expand Down

0 comments on commit ffd11a2

Please sign in to comment.