kamilsss655/ui/fmradio.c

112 lines
2.4 KiB
C
Raw Normal View History

2023-09-09 07:03:56 +00:00
/* Copyright 2023 Dual Tachyon
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2023-09-14 08:56:30 +00:00
#ifdef ENABLE_FMRADIO
2023-09-09 07:03:56 +00:00
#include <string.h>
2023-09-14 08:56:30 +00:00
2023-09-09 07:03:56 +00:00
#include "app/fm.h"
#include "driver/st7565.h"
#include "external/printf/printf.h"
#include "misc.h"
#include "settings.h"
#include "ui/fmradio.h"
#include "ui/helper.h"
#include "ui/inputbox.h"
#include "ui/ui.h"
void UI_DisplayFM(void)
{
2023-09-13 01:01:35 +00:00
unsigned int i;
char String[16];
2023-09-09 07:03:56 +00:00
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
memset(String, 0, sizeof(String));
strcpy(String, "FM");
2023-09-12 14:31:37 +00:00
UI_PrintString(String, 0, 127, 0, 12);
2023-09-09 07:03:56 +00:00
2023-09-13 01:01:35 +00:00
memset(String, 0, sizeof(String));
if (gAskToSave)
{
2023-09-09 07:03:56 +00:00
strcpy(String, "SAVE?");
2023-09-13 01:01:35 +00:00
}
else
if (gAskToDelete)
{
2023-09-09 07:03:56 +00:00
strcpy(String, "DEL?");
2023-09-13 01:01:35 +00:00
}
else
{
if (gFM_ScanState == FM_SCAN_OFF)
{
if (!gEeprom.FM_IsMrMode)
{
for (i = 0; i < 20; i++)
{
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i])
{
sprintf(String, "VFO(CH%02u)", i + 1);
2023-09-09 07:03:56 +00:00
break;
}
}
2023-09-13 01:01:35 +00:00
if (i == 20)
2023-09-09 07:03:56 +00:00
strcpy(String, "VFO");
}
2023-09-13 01:01:35 +00:00
else
sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1);
}
else
{
if (!gFM_AutoScan)
2023-09-09 07:03:56 +00:00
strcpy(String, "M-SCAN");
2023-09-13 01:01:35 +00:00
else
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
2023-09-09 07:03:56 +00:00
}
}
2023-09-12 14:31:37 +00:00
UI_PrintString(String, 0, 127, 2, 10);
2023-09-09 07:03:56 +00:00
2023-09-13 01:01:35 +00:00
memset(String, 0, sizeof(String));
2023-09-14 18:38:28 +00:00
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0))
2023-09-13 01:01:35 +00:00
{
2023-09-09 07:03:56 +00:00
UI_GenerateChannelString(String, gFM_ChannelPosition);
2023-09-13 01:01:35 +00:00
}
else
if (!gAskToDelete)
{
if (gInputBoxIndex == 0)
{
2023-09-09 07:03:56 +00:00
NUMBER_ToDigits(gEeprom.FM_FrequencyPlaying * 10000, String);
UI_DisplayFrequency(String, 23, 4, false, true);
}
2023-09-13 01:01:35 +00:00
else
UI_DisplayFrequency(gInputBox, 23, 4, true, false);
2023-09-09 07:03:56 +00:00
ST7565_BlitFullScreen();
return;
}
2023-09-13 01:01:35 +00:00
else
{
sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1);
}
2023-09-12 14:31:37 +00:00
UI_PrintString(String, 0, 127, 4, 10);
2023-09-13 01:01:35 +00:00
2023-09-09 07:03:56 +00:00
ST7565_BlitFullScreen();
}
2023-09-14 08:56:30 +00:00
#endif