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

Commit

Permalink
Experimental theme support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dual Tachyon authored and Dual Tachyon committed Sep 18, 2023
1 parent 4ce6370 commit a4ba05c
Show file tree
Hide file tree
Showing 15 changed files with 344 additions and 93 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ OBJS += ui/menu.o
OBJS += ui/rssi.o
OBJS += ui/scanner.o
OBJS += ui/status.o
OBJS += ui/theme.o
OBJS += ui/ui.o
OBJS += ui/welcome.o
OBJS += version.o
Expand Down
6 changes: 6 additions & 0 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#if defined(ENABLE_OVERLAY)
#include "sram-overlay.h"
#endif
#include "ui/theme.h"

static const uint32_t gDefaultFrequencyTable[5] = {
14502500,
Expand Down Expand Up @@ -706,6 +707,11 @@ void BOARD_EEPROM_Init(void)
}
}

EEPROM_ReadBuffer(0x1D00, &gUI_Theme, sizeof(gUI_Theme));
if (gUI_Theme.Aircopy.Status.X0 >= 128 || gUI_Theme.Aircopy.Status.X1 >= 128 || gUI_Theme.Aircopy.Status.W == 255 || !gUI_Theme.Aircopy.Status.W) {
bRestoreTheme = true;
}

bHasCustomAesKey = false;
}

Expand Down
9 changes: 9 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "radio.h"
#include "settings.h"
#include "ui/lock.h"
#include "ui/theme.h"
#include "ui/welcome.h"
#include "version.h"

Expand Down Expand Up @@ -89,6 +90,14 @@ void Main(void)
BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[i], &gBatteryCurrent);
}

if (KEYBOARD_Poll() == KEY_F) {
bRestoreTheme = true;
}

if (bRestoreTheme) {
gUI_Theme = gUI_ThemeDefault;
}

BATTERY_GetReadings(false);
if (!gChargingWithTypeC && !gBatteryDisplayLevel) {
FUNCTION_Select(FUNCTION_POWER_SAVE);
Expand Down
2 changes: 2 additions & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ uint16_t gCurrentRSSI;

uint8_t gIsLocked = 0xFF;

bool bRestoreTheme;

// --------

void NUMBER_Get(char *pDigits, uint32_t *pInteger)
Expand Down
2 changes: 2 additions & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ extern uint16_t gCurrentRSSI;

extern uint8_t gIsLocked;

extern bool bRestoreTheme;

// --------

void NUMBER_Get(char *pDigits, uint32_t *pInteger);
Expand Down
11 changes: 6 additions & 5 deletions ui/aircopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ui/aircopy.h"
#include "ui/helper.h"
#include "ui/inputbox.h"
#include "ui/theme.h"

void UI_DisplayAircopy(void)
{
Expand All @@ -37,14 +38,14 @@ void UI_DisplayAircopy(void)
} else {
strcpy(String, "AIR COPY(CMP)");
}
UI_PrintString(String, 2, 127, 0, 8, true);
UI_PrintString(String, gUI_Theme.Aircopy.Status.X0, gUI_Theme.Aircopy.Status.X1, gUI_Theme.Aircopy.Status.Y, gUI_Theme.Aircopy.Status.W, true);

if (gInputBoxIndex == 0) {
NUMBER_ToDigits(gRxVfo->ConfigRX.Frequency, String);
UI_DisplayFrequency(String, 16, 2, 0, 0);
UI_DisplaySmallDigits(2, String + 6, 97, 3);
UI_DisplayFrequency(String, gUI_Theme.Aircopy.Freq.X, gUI_Theme.Aircopy.Freq.Y, false, false);
UI_DisplaySmallDigits(gUI_Theme.Aircopy.Digits.Count, String + 6, gUI_Theme.Aircopy.Digits.X, gUI_Theme.Aircopy.Digits.Y);
} else {
UI_DisplayFrequency(gInputBox, 16, 2, 1, 0);
UI_DisplayFrequency(gInputBox, gUI_Theme.Aircopy.Freq.X, gUI_Theme.Aircopy.Freq.Y, true, false);
}

memset(String, 0, sizeof(String));
Expand All @@ -54,7 +55,7 @@ void UI_DisplayAircopy(void)
} else if (gAirCopyIsSendMode == 1) {
sprintf(String, "SND:%d", gAirCopyBlockNumber);
}
UI_PrintString(String, 2, 127, 4, 8, true);
UI_PrintString(String, gUI_Theme.Aircopy.Mode.X0, gUI_Theme.Aircopy.Mode.X1, gUI_Theme.Aircopy.Mode.Y, gUI_Theme.Aircopy.Mode.W, true);
ST7565_BlitFullScreen();
}

5 changes: 3 additions & 2 deletions ui/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
#include "driver/st7565.h"
#include "functions.h"
#include "ui/battery.h"
#include "ui/theme.h"

void UI_DisplayBattery(uint8_t Level)
{
const uint8_t *pBitmap;
bool bClearMode = false;

if (gCurrentFunction != 1) {
if (gCurrentFunction != FUNCTION_TRANSMIT) {
switch (Level) {
case 0:
pBitmap = NULL;
Expand All @@ -47,7 +48,7 @@ void UI_DisplayBattery(uint8_t Level)
pBitmap = BITMAP_BatteryLevel5;
break;
}
ST7565_DrawLine(110, 0, 18, pBitmap, bClearMode);
ST7565_DrawLine(gUI_Theme.Battery.X, gUI_Theme.Battery.Y, gUI_Theme.Battery.Size, pBitmap, bClearMode);
}
}

14 changes: 7 additions & 7 deletions ui/fmradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ui/fmradio.h"
#include "ui/helper.h"
#include "ui/inputbox.h"
#include "ui/theme.h"
#include "ui/ui.h"

void UI_DisplayFM(void)
Expand All @@ -32,10 +33,8 @@ void UI_DisplayFM(void)

memset(gFrameBuffer, 0, sizeof(gFrameBuffer));

memset(String, 0, sizeof(String));
strcpy(String, "FM");
UI_PrintString("FM", gUI_Theme.FM.Title.X0, gUI_Theme.FM.Title.X1, gUI_Theme.FM.Title.Y, gUI_Theme.FM.Title.W, true);

UI_PrintString(String, 0, 127, 0, 12, true);
memset(String, 0, sizeof(String));

if (gAskToSave) {
Expand Down Expand Up @@ -66,25 +65,26 @@ void UI_DisplayFM(void)
}
}

UI_PrintString(String, 0, 127, 2, 10, true);
UI_PrintString(String, gUI_Theme.FM.Status.X0, gUI_Theme.FM.Status.X1, gUI_Theme.FM.Status.Y, gUI_Theme.FM.Status.W, true);

memset(String, 0, sizeof(String));

if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex)) {
UI_GenerateChannelString(String, gFM_ChannelPosition);
} else if (!gAskToDelete) {
if (gInputBoxIndex == 0) {
NUMBER_ToDigits(gEeprom.FM_FrequencyPlaying * 10000, String);
UI_DisplayFrequency(String, 23, 4, false, true);
UI_DisplayFrequency(String, gUI_Theme.FM.Freq.X, gUI_Theme.FM.Freq.Y, false, true);
} else {
UI_DisplayFrequency(gInputBox, 23, 4, true, false);
UI_DisplayFrequency(gInputBox, gUI_Theme.FM.Freq.X, gUI_Theme.FM.Freq.Y, true, false);
}
ST7565_BlitFullScreen();
return;
} else {
sprintf(String, "CH-%02d", gEeprom.FM_SelectedChannel + 1);
}

UI_PrintString(String, 0, 127, 4, 10, true);
UI_PrintString(String, gUI_Theme.FM.Channel.X0, gUI_Theme.FM.Channel.X1, gUI_Theme.FM.Channel.Y, gUI_Theme.FM.Channel.W, true);
ST7565_BlitFullScreen();
}

5 changes: 3 additions & 2 deletions ui/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ui/helper.h"
#include "ui/inputbox.h"
#include "ui/lock.h"
#include "ui/theme.h"

static void Render(void)
{
Expand All @@ -36,7 +37,7 @@ static void Render(void)
memset(gStatusLine, 0, sizeof(gStatusLine));
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
strcpy(String, "LOCK");
UI_PrintString(String, 0, 127, 1, 10, true);
UI_PrintString(String, gUI_Theme.Lock.Title.X0, gUI_Theme.Lock.Title.X1, gUI_Theme.Lock.Title.Y, gUI_Theme.Lock.Title.W, true);
for (i = 0; i < 6; i++) {
if (gInputBox[i] == 10) {
String[i] = '-';
Expand All @@ -45,7 +46,7 @@ static void Render(void)
}
}
String[6] = 0;
UI_PrintString(String, 0, 127, 3, 12, true);
UI_PrintString(String, gUI_Theme.Lock.Code.X0, gUI_Theme.Lock.Code.X1, gUI_Theme.Lock.Code.Y, gUI_Theme.Lock.Code.W, true);
ST7565_BlitStatusLine();
ST7565_BlitFullScreen();
}
Expand Down
Loading

0 comments on commit a4ba05c

Please sign in to comment.