Skip to content

Commit

Permalink
ah whatever, some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
manu committed Sep 21, 2023
1 parent 133e9c5 commit a3e3b30
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 193 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set(ENABLE_OVERLAY 0)
set(ENABLE_SWD 1)
set(ENABLE_TX1750 1)
set(ENABLE_UART 1)
set(ENABLE_BATT_MODS 1) # Also saves space

if (ENABLE_AIRCOPY)
add_compile_definitions(ENABLE_AIRCOPY)
Expand Down Expand Up @@ -57,6 +58,9 @@ if (ENABLE_UART)
add_compile_definitions(ENABLE_UART)
endif ()

if (ENABLE_BATT_MODS)
add_compile_definitions(ENABLE_BATT_MODS)
endif ()

# specify cross compilers and tools
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
Expand Down
52 changes: 36 additions & 16 deletions app/userapp_ranking.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,54 @@
#include "misc.h"
#include "driver/bk4819-regs.h"
#include "driver/bk4819.h"
#include "driver/systick.h"
#include "driver/eeprom.h"

//some code stolen from https://github.com/fagci/uv-k5-firmware-fagci-mod/blob/main/app/spectrum.c
static void ResetRSSI() {
uint32_t Reg = BK4819_ReadRegister(BK4819_REG_30);
Reg &= ~1;
BK4819_WriteRegister(BK4819_REG_30, Reg);
Reg |= 1;
BK4819_WriteRegister(BK4819_REG_30, Reg);
}


uint8_t GetRssi() {
SYSTICK_DelayUs(10);
int32_t rssi = (BK4819_GetRSSI() >> 1);
rssi -= 160;
rssi *= (-1);
return rssi & 0xFF;
}

void setF(uint32_t f) {
BK4819_PickRXFilterPathBasedOnFrequency(f);
BK4819_SetFrequency(f);
//??? fagci does it
uint16_t reg = BK4819_ReadRegister(BK4819_REG_30);
BK4819_WriteRegister(BK4819_REG_30, 0);
BK4819_WriteRegister(BK4819_REG_30, reg);

}

void USERAPP_ranking_readChannelFreq(uint8_t rssi_val[200]) {

for (uint8_t channel = 0; channel < 200; channel++) {
if(channel != 0 && RADIO_FindNextChannel(channel, RADIO_CHANNEL_UP, false, 0) == 0)
if (channel != 0 && RADIO_FindNextChannel(channel, RADIO_CHANNEL_UP, false, 0) == 0)
continue;

printf("c %i\r\n", channel);

gEeprom.MrChannel[gEeprom.TX_CHANNEL] = channel;
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = channel;

RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
RADIO_SetupRegisters(true);
uint32_t Frequency;
EEPROM_ReadBuffer(channel * 16, &Frequency, 4);
setF(Frequency);

//reset rssi (thanks to fagci)
uint32_t Reg = BK4819_ReadRegister(BK4819_REG_30);
Reg &= ~1;
BK4819_WriteRegister(BK4819_REG_30, Reg);
Reg |= 1;
BK4819_WriteRegister(BK4819_REG_30, Reg);

ResetRSSI();
SYSTEM_DelayMs(10);

int32_t rssi = (((BK4819_GetRSSI() >> 1) & 0xFF) - 160) * -1;

rssi_val[channel] = rssi & 0xFF;
rssi_val[channel] = GetRssi();

USERAPPS_ranking_progress(channel / 2);

Expand Down Expand Up @@ -133,7 +153,7 @@ void USERAPP_ranking_loop() {
updateUI = true;
break;
}
if(updateUI)
if (updateUI)
USERAPPS_ranking_draw(selection, rssi_val, min_rssi);
updateUI = false;
SYSTEM_DelayMs(10);
Expand Down
2 changes: 2 additions & 0 deletions bitmaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

const uint8_t BITMAP_PowerSave[8] = { 0x00, 0x26, 0x49, 0x49, 0x49, 0x49, 0x49, 0x32 };

#if !defined(ENABLE_BATT_MODS)
const uint8_t BITMAP_BatteryLevel1[18] = { 0x00, 0x3E, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x63 };
const uint8_t BITMAP_BatteryLevel2[18] = { 0x00, 0x3E, 0x22, 0x7F, 0x41, 0x5D, 0x5D, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x63 };
const uint8_t BITMAP_BatteryLevel3[18] = { 0x00, 0x3E, 0x22, 0x7F, 0x41, 0x5D, 0x5D, 0x41, 0x5D, 0x5D, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x63 };
const uint8_t BITMAP_BatteryLevel4[18] = { 0x00, 0x3E, 0x22, 0x7F, 0x41, 0x5D, 0x5D, 0x41, 0x5D, 0x5D, 0x41, 0x5D, 0x5D, 0x41, 0x41, 0x41, 0x41, 0x63 };
const uint8_t BITMAP_BatteryLevel5[18] = { 0x00, 0x3E, 0x22, 0x7F, 0x41, 0x5D, 0x5D, 0x41, 0x5D, 0x5D, 0x41, 0x5D, 0x5D, 0x41, 0x5D, 0x5D, 0x41, 0x63 };
#endif

const uint8_t BITMAP_USB_C[9] = { 0x00, 0x1C, 0x27, 0x44, 0x44, 0x44, 0x44, 0x27, 0x1C };
const uint8_t BITMAP_KeyLock[9] = { 0x00, 0x7C, 0x46, 0x45, 0x45, 0x45, 0x45, 0x46, 0x7C };
Expand Down
2 changes: 2 additions & 0 deletions bitmaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

extern const uint8_t BITMAP_PowerSave[8];

#if !defined(ENABLE_BATT_MODS)
extern const uint8_t BITMAP_BatteryLevel1[18];
extern const uint8_t BITMAP_BatteryLevel2[18];
extern const uint8_t BITMAP_BatteryLevel3[18];
extern const uint8_t BITMAP_BatteryLevel4[18];
extern const uint8_t BITMAP_BatteryLevel5[18];
#endif

extern const uint8_t BITMAP_USB_C[9];
extern const uint8_t BITMAP_KeyLock[9];
Expand Down
113 changes: 0 additions & 113 deletions font.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,104 +150,6 @@ const uint8_t gFontSmall[128][8] = {
{0, 0, 0, 0, 0, 0, 0, 0,},
};

const uint8_t gFontBig[95][16] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x70, 0xF8, 0xF8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00, 0x00},
{0x00, 0x1E, 0x3E, 0x00, 0x00, 0x3E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x40, 0xF0, 0xF0, 0x40, 0xF0, 0xF0, 0x40, 0x00, 0x04, 0x1F, 0x1F, 0x04, 0x1F, 0x1F, 0x04, 0x00},
{0x70, 0xF8, 0x88, 0x8F, 0x8F, 0x98, 0x30, 0x00, 0x06, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07, 0x00},
{0x60, 0x60, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x00, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x18, 0x18, 0x00},
{0x00, 0xB0, 0xF8, 0xC8, 0x78, 0xB0, 0x80, 0x00, 0x0F, 0x1F, 0x10, 0x11, 0x0F, 0x1F, 0x10, 0x00},
{0x00, 0x20, 0x3E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xE0, 0xF0, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x00, 0x00},
{0x00, 0x00, 0x08, 0x18, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18, 0x0F, 0x07, 0x00, 0x00},
{0x00, 0x40, 0xC0, 0x80, 0x80, 0xC0, 0x40, 0x00, 0x01, 0x05, 0x07, 0x03, 0x03, 0x07, 0x05, 0x01},
{0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x07, 0x07, 0x01, 0x01, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3C, 0x1C, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x00, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00},
{0xF0, 0xF8, 0x08, 0x88, 0x48, 0xF8, 0xF0, 0x00, 0x0F, 0x1F, 0x12, 0x11, 0x10, 0x1F, 0x0F, 0x00},
{0x00, 0x20, 0x30, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x00},
{0x10, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x30, 0x00, 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x18, 0x00},
{0x10, 0x18, 0x88, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x08, 0x18, 0x10, 0x10, 0x10, 0x1F, 0x0F, 0x00},
{0x80, 0xC0, 0x60, 0x30, 0xF8, 0xF8, 0x00, 0x00, 0x01, 0x01, 0x01, 0x11, 0x1F, 0x1F, 0x11, 0x00},
{0xF8, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x08, 0x00, 0x08, 0x18, 0x10, 0x10, 0x11, 0x1F, 0x0F, 0x00},
{0xE0, 0xF0, 0x98, 0x88, 0x88, 0x80, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F, 0x00},
{0x18, 0x18, 0x08, 0x08, 0x88, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00, 0x00},
{0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F, 0x00},
{0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0xF0, 0x00, 0x00, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x07, 0x00},
{0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1C, 0x0C, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x10, 0x00},
{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00},
{0x00, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00},
{0x30, 0x38, 0x08, 0x88, 0xC8, 0x78, 0x30, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00, 0x00},
{0xE0, 0xF0, 0x10, 0x90, 0x90, 0xF0, 0xE0, 0x00, 0x0F, 0x1F, 0x10, 0x17, 0x17, 0x17, 0x03, 0x00},
{0xC0, 0xE0, 0x30, 0x18, 0x30, 0xE0, 0xC0, 0x00, 0x1F, 0x1F, 0x01, 0x01, 0x01, 0x1F, 0x1F, 0x00},
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x1F, 0x0F, 0x00},
{0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x10, 0x18, 0x0C, 0x00},
{0x08, 0xF8, 0xF8, 0x08, 0x18, 0xF0, 0xE0, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x18, 0x0F, 0x07, 0x00},
{0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x11, 0x18, 0x1C, 0x00},
{0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x01, 0x00, 0x00, 0x00},
{0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, 0x00, 0x07, 0x0F, 0x18, 0x11, 0x11, 0x0F, 0x1F, 0x00},
{0xF8, 0xF8, 0x80, 0x80, 0x80, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00},
{0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, 0x00, 0x0E, 0x1E, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00},
{0x08, 0xF8, 0xF8, 0x80, 0xE0, 0x78, 0x18, 0x00, 0x10, 0x1F, 0x1F, 0x01, 0x03, 0x1E, 0x1C, 0x00},
{0x08, 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x18, 0x1C, 0x00},
{0xF8, 0xF8, 0x70, 0xE0, 0x70, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00},
{0xF8, 0xF8, 0x70, 0xE0, 0xC0, 0xF8, 0xF8, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x01, 0x1F, 0x1F, 0x00},
{0xE0, 0xF0, 0x18, 0x08, 0x18, 0xF0, 0xE0, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07, 0x00},
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00, 0x00},
{0xF0, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0xF0, 0x00, 0x0F, 0x1F, 0x10, 0x1C, 0x78, 0x7F, 0x4F, 0x00},
{0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x10, 0x1F, 0x1F, 0x00, 0x01, 0x1F, 0x1E, 0x00},
{0x30, 0x78, 0xC8, 0x88, 0x88, 0x38, 0x30, 0x00, 0x0C, 0x1C, 0x10, 0x10, 0x11, 0x1F, 0x0E, 0x00},
{0x00, 0x38, 0x18, 0xF8, 0xF8, 0x18, 0x38, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00},
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F, 0x00},
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x03, 0x07, 0x0C, 0x18, 0x0C, 0x07, 0x03, 0x00},
{0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x07, 0x1F, 0x1C, 0x07, 0x1C, 0x1F, 0x07, 0x00},
{0x18, 0x78, 0xE0, 0x80, 0xE0, 0x78, 0x18, 0x00, 0x18, 0x1E, 0x07, 0x01, 0x07, 0x1E, 0x18, 0x00},
{0x00, 0x78, 0xF8, 0x80, 0x80, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00},
{0x38, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x38, 0x00, 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x1C, 0x00},
{0x00, 0x00, 0xF8, 0xF8, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x10, 0x10, 0x00, 0x00},
{0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E, 0x1C, 0x00},
{0x00, 0x00, 0x08, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x00, 0x00},
{0x10, 0x18, 0x0E, 0x07, 0x0E, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40},
{0x00, 0x00, 0x07, 0x0F, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x0E, 0x1F, 0x11, 0x11, 0x0F, 0x1F, 0x10, 0x00},
{0x08, 0xF8, 0xF8, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x10, 0x1F, 0x0F, 0x10, 0x10, 0x1F, 0x0F, 0x00},
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x18, 0x08, 0x00},
{0x00, 0x80, 0xC0, 0x48, 0xF8, 0xF8, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10, 0x00},
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x0F, 0x1F, 0x11, 0x11, 0x11, 0x19, 0x09, 0x00},
{0x80, 0xF0, 0xF8, 0x88, 0x18, 0x30, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00, 0x00},
{0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, 0x00, 0x4F, 0xDF, 0x90, 0x90, 0xFF, 0x7F, 0x00, 0x00},
{0x08, 0xF8, 0xF8, 0x80, 0x40, 0xC0, 0x80, 0x00, 0x10, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00},
{0x00, 0x00, 0x40, 0xD8, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x40, 0xD8, 0xD8, 0x00, 0x00, 0x60, 0xE0, 0x80, 0x80, 0xFF, 0x7F, 0x00},
{0x08, 0xF8, 0xF8, 0x00, 0x80, 0xC0, 0x40, 0x00, 0x10, 0x1F, 0x1F, 0x03, 0x07, 0x1C, 0x18, 0x00},
{0x00, 0x00, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00},
{0xC0, 0xC0, 0xC0, 0x80, 0xC0, 0xC0, 0x80, 0x00, 0x1F, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x1F, 0x00},
{0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00},
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F, 0x00},
{0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x80, 0xFF, 0xFF, 0x90, 0x10, 0x1F, 0x0F, 0x00},
{0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, 0x00, 0x0F, 0x1F, 0x10, 0x90, 0xFF, 0xFF, 0x80, 0x00},
{0x40, 0xC0, 0x80, 0xC0, 0x40, 0xC0, 0x80, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x01, 0x00},
{0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x08, 0x19, 0x13, 0x12, 0x16, 0x1C, 0x08, 0x00},
{0x40, 0x40, 0xF0, 0xF8, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x18, 0x08, 0x00},
{0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10, 0x00},
{0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x07, 0x0F, 0x18, 0x18, 0x0F, 0x07, 0x00},
{0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x0F, 0x1F, 0x18, 0x0E, 0x18, 0x1F, 0x0F, 0x00},
{0x40, 0xC0, 0x80, 0x00, 0x80, 0xC0, 0x40, 0x00, 0x10, 0x18, 0x0F, 0x07, 0x0F, 0x18, 0x10, 0x00},
{0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x8F, 0x9F, 0x90, 0x90, 0xD0, 0x7F, 0x3F, 0x00},
{0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x40, 0x00, 0x18, 0x1C, 0x16, 0x13, 0x11, 0x18, 0x18, 0x00},
{0x00, 0x80, 0x80, 0xF0, 0x78, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x00},
{0x00, 0x00, 0x00, 0x78, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00},
{0x00, 0x08, 0x08, 0x78, 0xF0, 0x80, 0x80, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x00},
{0x10, 0x18, 0x08, 0x18, 0x10, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
};

const uint8_t gFontBigDigits[11][26] = {
{0x00, 0xC0, 0xF0, 0xF8, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xF8, 0xF0, 0xE0, 0x00, 0x07, 0x1F, 0x3F, 0x78, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x1F, 0x0F},
{0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00},
Expand All @@ -261,18 +163,3 @@ const uint8_t gFontBigDigits[11][26] = {
{0x00, 0xF0, 0xF8, 0xB8, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xB8, 0xF0, 0xE0, 0x00, 0x11, 0x33, 0x77, 0x67, 0x66, 0x66, 0x66, 0x76, 0x33, 0x3F, 0x1F, 0x07},
{0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00},
};

const uint8_t gFontSmallDigits[11][7] = {
{0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E},
{0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00},
{0x00, 0x62, 0x51, 0x51, 0x49, 0x49, 0x46},
{0x00, 0x22, 0x41, 0x49, 0x49, 0x4D, 0x32},
{0x00, 0x18, 0x14, 0x12, 0x11, 0x7F, 0x10},
{0x00, 0x27, 0x45, 0x45, 0x45, 0x45, 0x39},
{0x00, 0x3E, 0x49, 0x49, 0x49, 0x49, 0x30},
{0x00, 0x01, 0x71, 0x09, 0x05, 0x03, 0x00},
{0x00, 0x36, 0x49, 0x49, 0x49, 0x49, 0x36},
{0x00, 0x46, 0x49, 0x49, 0x49, 0x29, 0x1E},
{0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00},
};

2 changes: 0 additions & 2 deletions font.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include <stdint.h>

extern const uint8_t gFontSmall[128][8];
extern const uint8_t gFontBig[95][16];
extern const uint8_t gFontBigDigits[11][26];
extern const uint8_t gFontSmallDigits[11][7];

#endif

68 changes: 42 additions & 26 deletions ui/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,55 @@
*/

#include <stddef.h>
#include <string.h>
#include "bitmaps.h"
#include "driver/st7565.h"
#include "functions.h"
#include "ui/battery.h"
#include "external/printf/printf.h"
#include "helper.h"
#include "helper/battery.h"

void UI_DisplayBattery(uint8_t Level)
{
const uint8_t *pBitmap;
bool bClearMode = false;
#if defined(ENABLE_BATT_MODS)
char String[16];
sprintf(String, "%d.%02d", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
UI_PrintStringSmall(String, 96, 127, -1, 8, true);

if (gCurrentFunction != 1) {
switch (Level) {
case 0:
pBitmap = NULL;
bClearMode = true;
break;
case 1:
pBitmap = BITMAP_BatteryLevel1;
break;
case 2:
pBitmap = BITMAP_BatteryLevel2;
break;
case 3:
pBitmap = BITMAP_BatteryLevel3;
break;
case 4:
pBitmap = BITMAP_BatteryLevel4;
break;
default:
pBitmap = BITMAP_BatteryLevel5;
break;
}
ST7565_DrawLine(110, 0, 18, pBitmap, bClearMode);
}
#else
const uint8_t *pBitmap;
bool bClearMode = false;

if (gCurrentFunction != 1) {
switch (Level) {
case 0:
pBitmap = NULL;
bClearMode = true;
break;
case 1:
pBitmap = BITMAP_BatteryLevel1;
break;
case 2:
pBitmap = BITMAP_BatteryLevel2;
break;
case 3:
pBitmap = BITMAP_BatteryLevel3;
break;
case 4:
pBitmap = BITMAP_BatteryLevel4;
break;
default:
pBitmap = BITMAP_BatteryLevel5;
break;
}
if(bClearMode)
memset(gStatusLine + 110, 0, sizeof(BITMAP_BatteryLevel1));
else
memcpy(gStatusLine + 110, pBitmap, sizeof(BITMAP_BatteryLevel1));
}
#endif
}



1 change: 0 additions & 1 deletion ui/battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
#include <stdint.h>

void UI_DisplayBattery(uint8_t Level);

#endif

11 changes: 6 additions & 5 deletions ui/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
for (i = 0; i < Length; i++) {
if (pString[i] >= ' ' && pString[i] < 0x7F) {
uint8_t Index = pString[i];
memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, &gFontSmall[Index][0], 8);
if(Line < 7)
memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, &gFontSmall[Index][0], 8);
else
memcpy(gStatusLine + (i * Width) + Start, &gFontSmall[Index][0], 8);
}
}
}
Expand All @@ -98,9 +101,7 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
}
for (i = 0; i < Length; i++) {
if (pString[i] >= ' ' && pString[i] < 0x7F) {
uint8_t Index = pString[i] - ' ';
memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, &gFontBig[Index][0], 8);
memcpy(gFrameBuffer[Line + 1] + (i * Width) + Start, &gFontBig[Index][8], 8);
memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, gFontSmall[(uint8_t)pString[i]], 8);
}
}
}
Expand Down Expand Up @@ -145,7 +146,7 @@ void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, uint8_t
uint8_t i;

for (i = 0; i < Size; i++) {
memcpy(gFrameBuffer[Y] + (i * 7) + X, gFontSmallDigits[(uint8_t)pString[i]], 7);
memcpy(gFrameBuffer[Y] + (i * 7) + X, gFontSmall[pString[i] + '0'], 7);
}
}

Loading

0 comments on commit a3e3b30

Please sign in to comment.