Refactoring

This commit is contained in:
Krzysiek Egzmont
2023-12-04 22:53:59 +01:00
parent e2b81bf9c8
commit e039e65ee4
9 changed files with 88 additions and 171 deletions

View File

@@ -81,11 +81,6 @@ typedef struct
// //
// these 4 tables need a measuring/calibration update // these 4 tables need a measuring/calibration update
// //
//
// QUESTION: why do I have to surround the negative numbers in brackets ???
// if I don't add the brackets, reading the table returns unexpected/different values !!!
//
//
//// static const int16_t lna_short_dB[] = { -19, -16, -11, 0}; // was (but wrong) //// static const int16_t lna_short_dB[] = { -19, -16, -11, 0}; // was (but wrong)
// static const int16_t lna_short_dB[] = { (-33), (-30), (-24), 0}; // corrected'ish // static const int16_t lna_short_dB[] = { (-33), (-30), (-24), 0}; // corrected'ish
// static const int16_t lna_dB[] = { (-24), (-19), (-14), ( -9), (-6), (-4), (-2), 0}; // static const int16_t lna_dB[] = { (-24), (-19), (-14), ( -9), (-6), (-4), (-2), 0};
@@ -220,7 +215,7 @@ unsigned int hold_counter[2] = {0, 0};
int16_t rssi_gain_diff[2] = {0, 0}; int16_t rssi_gain_diff[2] = {0, 0};
// used to limit the max RF gain // used to limit the max RF gain
unsigned int max_index = ARRAY_SIZE(gain_table) - 1; const unsigned max_index = ARRAY_SIZE(gain_table) - 1;
// -89dBm, any higher and the AM demodulator starts to saturate/clip/distort // -89dBm, any higher and the AM demodulator starts to saturate/clip/distort
const int16_t desired_rssi = (-89 + 160) * 2; const int16_t desired_rssi = (-89 + 160) * 2;
@@ -230,13 +225,13 @@ void AM_fix_init(void)
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
gain_table_index[i] = original_index; // re-start with original QS setting gain_table_index[i] = original_index; // re-start with original QS setting
} }
// use the full range of available gains
max_index = ARRAY_SIZE(gain_table) - 1;
} }
void AM_fix_reset(const int vfo) void AM_fix_reset(const unsigned vfo)
{ // reset the AM fixer upper { // reset the AM fixer upper
if (vfo > 1)
return;
#ifdef ENABLE_AM_FIX_SHOW_DATA #ifdef ENABLE_AM_FIX_SHOW_DATA
counter = 0; counter = 0;
#endif #endif
@@ -254,10 +249,10 @@ void AM_fix_reset(const int vfo)
// won't/don't do it for itself, we're left to bodging it ourself by // won't/don't do it for itself, we're left to bodging it ourself by
// playing with the RF front end gain setting // playing with the RF front end gain setting
// //
void AM_fix_10ms(const int vfo) void AM_fix_10ms(const unsigned vfo)
{ {
int16_t diff_dB; if(vfo > 1)
int16_t rssi; return;
switch (gCurrentFunction) switch (gCurrentFunction)
{ {
@@ -286,6 +281,7 @@ void AM_fix_10ms(const int vfo)
} }
#endif #endif
int16_t rssi;
{ // sample the current RSSI level { // sample the current RSSI level
// average it with the previous rssi (a bit of noise/spike immunity) // average it with the previous rssi (a bit of noise/spike immunity)
const int16_t new_rssi = BK4819_GetRSSI(); const int16_t new_rssi = BK4819_GetRSSI();
@@ -310,7 +306,6 @@ void AM_fix_10ms(const int vfo)
gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo]; gCurrentRSSI[vfo] = rssi - rssi_gain_diff[vfo];
#endif #endif
// automatically adjust the RF RX gain // automatically adjust the RF RX gain
// update the gain hold counter // update the gain hold counter
@@ -318,7 +313,7 @@ void AM_fix_10ms(const int vfo)
hold_counter[vfo]--; hold_counter[vfo]--;
// dB difference between actual and desired RSSI level // dB difference between actual and desired RSSI level
diff_dB = (rssi - desired_rssi) / 2; int16_t diff_dB = (rssi - desired_rssi) / 2;
if (diff_dB > 0) { // decrease gain if (diff_dB > 0) { // decrease gain
unsigned int index = gain_table_index[vfo]; // current position we're at unsigned int index = gain_table_index[vfo]; // current position we're at
@@ -359,7 +354,6 @@ void AM_fix_10ms(const int vfo)
{ // apply the new settings to the front end registers { // apply the new settings to the front end registers
const unsigned int index = gain_table_index[vfo]; const unsigned int index = gain_table_index[vfo];
// remember the new table index // remember the new table index
@@ -385,15 +379,20 @@ void AM_fix_10ms(const int vfo)
} }
#ifdef ENABLE_AM_FIX_SHOW_DATA #ifdef ENABLE_AM_FIX_SHOW_DATA
void AM_fix_print_data(const unsigned vfo, char *s) {
void AM_fix_print_data(const int vfo, char *s) { if (s != NULL && vfo < ARRAY_SIZE(gain_table_index)) {
if (s != NULL && vfo >= 0 && vfo < (int)ARRAY_SIZE(gain_table_index)) {
const unsigned int index = gain_table_index[vfo]; const unsigned int index = gain_table_index[vfo];
sprintf(s, "%2u %4ddB %3u", index, gain_table[index].gain_dB, prev_rssi[vfo]); sprintf(s, "%2u %4ddB %3u", index, gain_table[index].gain_dB, prev_rssi[vfo]);
counter = 0; counter = 0;
} }
} }
#endif #endif
int16_t AM_fix_get_rssi_gain_diff(const unsigned vfo)
{
if(vfo > 1)
return 0;
return rssi_gain_diff[vfo];
}
#endif #endif

View File

@@ -21,14 +21,13 @@
#include <stdbool.h> #include <stdbool.h>
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
extern int16_t rssi_gain_diff[2];
void AM_fix_init(void); void AM_fix_init(void);
void AM_fix_reset(const int vfo); void AM_fix_reset(const unsigned vfo);
void AM_fix_10ms(const int vfo); void AM_fix_10ms(const unsigned vfo);
#ifdef ENABLE_AM_FIX_SHOW_DATA #ifdef ENABLE_AM_FIX_SHOW_DATA
void AM_fix_print_data(const int vfo, char *s); void AM_fix_print_data(const unsigned vfo, char *s);
#endif #endif
int16_t AM_fix_get_rssi_gain_diff(const unsigned vfo);
#endif #endif

View File

@@ -16,6 +16,7 @@
#include <string.h> #include <string.h>
#include "am_fix.h"
#include "app/action.h" #include "app/action.h"
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
#include "app/aircopy.h" #include "app/aircopy.h"
@@ -44,7 +45,6 @@
#include "driver/keyboard.h" #include "driver/keyboard.h"
#include "driver/st7565.h" #include "driver/st7565.h"
#include "driver/system.h" #include "driver/system.h"
#include "am_fix.h"
#include "dtmf.h" #include "dtmf.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "frequencies.h" #include "frequencies.h"
@@ -73,7 +73,7 @@ static void UpdateRSSI(const int vfo)
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// add RF gain adjust compensation // add RF gain adjust compensation
if (gEeprom.VfoInfo[vfo].Modulation == MODULATION_AM && gSetting_AM_fix) if (gEeprom.VfoInfo[vfo].Modulation == MODULATION_AM && gSetting_AM_fix)
rssi -= rssi_gain_diff[vfo]; rssi -= AM_fix_get_rssi_gain_diff(vfo);
#endif #endif
if (gCurrentRSSI[vfo] == rssi) if (gCurrentRSSI[vfo] == rssi)
@@ -171,8 +171,6 @@ static void CheckForIncoming(void)
static void HandleIncoming(void) static void HandleIncoming(void)
{ {
bool bFlag;
if (!g_SquelchLost) { // squelch is closed if (!g_SquelchLost) { // squelch is closed
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
if (gDTMF_RX_index > 0) if (gDTMF_RX_index > 0)
@@ -185,7 +183,7 @@ static void HandleIncoming(void)
return; return;
} }
bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF); bool bFlag = (gScanStateDir == SCAN_OFF && gCurrentCodeType == CODE_TYPE_OFF);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0) { if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gNOAACountdown_10ms > 0) {
@@ -199,7 +197,9 @@ static void HandleIncoming(void)
gFoundCTCSS = false; gFoundCTCSS = false;
} }
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL)) { if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE
&& (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
{
gFoundCDCSS = false; gFoundCDCSS = false;
} }
else if (!bFlag) else if (!bFlag)
@@ -444,11 +444,11 @@ static void HandleFunction(void)
} }
} }
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) void APP_StartListening(FUNCTION_Type_t function, const bool reset_am_fix)
{ {
(void)reset_am_fix; (void)reset_am_fix;
const unsigned int chan = gEeprom.RX_VFO; const unsigned int vfo = gEeprom.RX_VFO;
// const unsigned int chan = gRxVfo->CHANNEL_SAVE; // const unsigned int chan = gRxVfo->CHANNEL_SAVE;
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
@@ -462,7 +462,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
#endif #endif
// clear the other vfo's rssi level (to hide the antenna symbol) // clear the other vfo's rssi level (to hide the antenna symbol)
gVFO_RSSI_bar_level[(chan + 1) & 1u] = 0; gVFO_RSSI_bar_level[!vfo] = 0;
AUDIO_AudioPathOn(); AUDIO_AudioPathOn();
gEnableSpeaker = true; gEnableSpeaker = true;
@@ -478,7 +478,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gRxVfo->CHANNEL_SAVE = gNoaaChannel + NOAA_CHANNEL_FIRST; gRxVfo->CHANNEL_SAVE = gNoaaChannel + NOAA_CHANNEL_FIRST;
gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel]; gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel];
gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel]; gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel];
gEeprom.ScreenChannel[chan] = gRxVfo->CHANNEL_SAVE; gEeprom.ScreenChannel[vfo] = gRxVfo->CHANNEL_SAVE;
gNOAA_Countdown_10ms = 500; // 5 sec gNOAA_Countdown_10ms = 500; // 5 sec
gScheduleNOAA = false; gScheduleNOAA = false;
@@ -504,35 +504,28 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix) { // AM RX mode if (gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix) { // AM RX mode
if (reset_am_fix) if (reset_am_fix)
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency AM_fix_reset(vfo); // TODO: only reset it when moving channel/frequency
AM_fix_10ms(chan); AM_fix_10ms(vfo);
} }
#endif #endif
// AF gain - original QS values
// if (gRxVfo->Modulation != MODULATION_FM){
// BK4819_WriteRegister(BK4819_REG_48, 0xB3A8);
// }
// else
{
BK4819_WriteRegister(BK4819_REG_48, BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1 ( 0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2 (gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
}
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished
#endif #endif
RADIO_SetModulation(gRxVfo->Modulation); // no need, set it now RADIO_SetModulation(gRxVfo->Modulation); // no need, set it now
FUNCTION_Select(Function); FUNCTION_Select(function);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (Function == FUNCTION_MONITOR || gFmRadioMode) if (function == FUNCTION_MONITOR || gFmRadioMode)
#else #else
if (Function == FUNCTION_MONITOR) if (function == FUNCTION_MONITOR)
#endif #endif
{ // squelch is disabled { // squelch is disabled
if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu

View File

@@ -24,7 +24,7 @@
#include "radio.h" #include "radio.h"
void APP_EndTransmission(void); void APP_EndTransmission(void);
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix); void APP_StartListening(FUNCTION_Type_t function, const bool reset_am_fix);
uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper); uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper);
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction); uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction);
void APP_Update(void); void APP_Update(void);

View File

@@ -282,12 +282,11 @@ uint16_t GetRssi() {
while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) { while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) {
SYSTICK_DelayUs(100); SYSTICK_DelayUs(100);
} }
if(settings.modulationType == MODULATION_AM) if(settings.modulationType == MODULATION_AM) {
{ //return the corrected RSSI to allow for AM_Fixs AGC action.
return BK4819_GetRSSI() - rssi_gain_diff[vfo]; //return the corrected RSSI to allow for AM_Fixs AGC action. return BK4819_GetRSSI() - AM_fix_get_rssi_gain_diff(vfo);
} }
else else {
{
return BK4819_GetRSSI(); return BK4819_GetRSSI();
} }

View File

@@ -493,7 +493,7 @@ void BOARD_Init(void)
BOARD_GPIO_Init(); BOARD_GPIO_Init();
BACKLIGHT_InitHardware(); BACKLIGHT_InitHardware();
BOARD_ADC_Init(); BOARD_ADC_Init();
ST7565_Init(true); ST7565_Init();
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
BK1080_Init(0, false); BK1080_Init(0, false);
#endif #endif

View File

@@ -25,118 +25,51 @@
#include "driver/system.h" #include "driver/system.h"
#include "misc.h" #include "misc.h"
uint8_t gStatusLine[128]; uint8_t gStatusLine[LCD_WIDTH];
uint8_t gFrameBuffer[7][128]; uint8_t gFrameBuffer[FRAME_LINES][LCD_WIDTH];
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap) static void DrawLine(uint8_t column, uint8_t line, const uint8_t * lineBuffer, unsigned size_defVal)
{ {
unsigned int i; ST7565_SelectColumnAndLine(column + 4, line);
SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_SelectColumnAndLine(Column + 4U, Line);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (unsigned i = 0; i < size_defVal; i++) {
if (pBitmap != NULL)
{
for (i = 0; i < Size; i++)
{
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = pBitmap[i]; SPI0->WDR = lineBuffer ? lineBuffer[i] : size_defVal;
} }
}
else
{
for (i = 0; i < Size; i++)
{
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = 0;
}
}
SPI_WaitForUndocumentedTxFifoStatusBit(); SPI_WaitForUndocumentedTxFifoStatusBit();
}
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const uint8_t *pBitmap, const unsigned int Size)
{
SPI_ToggleMasterMode(&SPI0->CR, false);
DrawLine(Column, Line, pBitmap, Size);
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
} }
void ST7565_BlitFullScreen(void) void ST7565_BlitFullScreen(void)
{ {
unsigned int Line;
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_WriteByte(0x40); ST7565_WriteByte(0x40);
for (unsigned line = 0; line < FRAME_LINES; line++) {
for (Line = 0; Line < ARRAY_SIZE(gFrameBuffer); Line++) DrawLine(0, line+1, gFrameBuffer[line], LCD_WIDTH);
{
unsigned int Column;
ST7565_SelectColumnAndLine(4, Line + 1);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (Column = 0; Column < ARRAY_SIZE(gFrameBuffer[0]); Column++)
{
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = gFrameBuffer[Line][Column];
} }
SPI_WaitForUndocumentedTxFifoStatusBit();
}
#if 0
// whats the delay for I wonder, it holds things up :(
SYSTEM_DelayMs(20);
#else
// SYSTEM_DelayMs(1);
#endif
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
} }
void ST7565_BlitStatusLine(void) void ST7565_BlitStatusLine(void)
{ // the top small text line on the display { // the top small text line on the display
unsigned int i;
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_WriteByte(0x40); // start line ? ST7565_WriteByte(0x40); // start line ?
DrawLine(0, 0, gStatusLine, LCD_WIDTH);
ST7565_SelectColumnAndLine(4, 0);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (i = 0; i < ARRAY_SIZE(gStatusLine); i++)
{
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = gStatusLine[i];
}
SPI_WaitForUndocumentedTxFifoStatusBit();
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
} }
void ST7565_FillScreen(uint8_t Value) void ST7565_FillScreen(uint8_t value)
{ {
unsigned int i;
// reset some of the displays settings to try and overcome the radios hardware problem - RF corrupting the display
ST7565_Init(false);
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
for (unsigned i = 0; i < 8; i++) {
for (i = 0; i < 8; i++) DrawLine(0, i, NULL, value);
{
unsigned int j;
ST7565_SelectColumnAndLine(0, i);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (j = 0; j < 132; j++)
{
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = Value;
} }
SPI_WaitForUndocumentedTxFifoStatusBit();
}
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
} }
@@ -205,22 +138,17 @@ uint8_t cmds[] = {
ST7565_CMD_DISPLAY_ON_OFF | 1, // Display ON/OFF: ON ST7565_CMD_DISPLAY_ON_OFF | 1, // Display ON/OFF: ON
}; };
void ST7565_Init(const bool full) void ST7565_Init(void)
{ {
if (full) {
SPI0_Init(); SPI0_Init();
ST7565_HardwareReset(); ST7565_HardwareReset();
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_WriteByte(ST7565_CMD_SOFTWARE_RESET); // software reset ST7565_WriteByte(ST7565_CMD_SOFTWARE_RESET); // software reset
SYSTEM_DelayMs(120); SYSTEM_DelayMs(120);
}
else
SPI_ToggleMasterMode(&SPI0->CR, false);
for(uint8_t i = 0; i < 8; i++) for(uint8_t i = 0; i < 8; i++)
ST7565_WriteByte(cmds[i]); ST7565_WriteByte(cmds[i]);
if (full) {
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1 ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b011); // VB=0 VR=1 VF=1
SYSTEM_DelayMs(1); SYSTEM_DelayMs(1);
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b110); // VB=1 VR=1 VF=0 ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b110); // VB=1 VR=1 VF=0
@@ -230,14 +158,12 @@ void ST7565_Init(const bool full)
ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b111); // VB=1 VR=1 VF=1 ST7565_WriteByte(ST7565_CMD_POWER_CIRCUIT | 0b111); // VB=1 VR=1 VF=1
SYSTEM_DelayMs(40); SYSTEM_DelayMs(40);
}
ST7565_WriteByte(ST7565_CMD_SET_START_LINE | 0); // line 0 ST7565_WriteByte(ST7565_CMD_SET_START_LINE | 0); // line 0
ST7565_WriteByte(ST7565_CMD_DISPLAY_ON_OFF | 1); // D=1 ST7565_WriteByte(ST7565_CMD_DISPLAY_ON_OFF | 1); // D=1
SPI_WaitForUndocumentedTxFifoStatusBit(); SPI_WaitForUndocumentedTxFifoStatusBit();
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
if (full)
ST7565_FillScreen(0x00); ST7565_FillScreen(0x00);
} }

View File

@@ -22,15 +22,16 @@
#define LCD_WIDTH 128 #define LCD_WIDTH 128
#define LCD_HEIGHT 64 #define LCD_HEIGHT 64
#define FRAME_LINES 7
extern uint8_t gStatusLine[128]; extern uint8_t gStatusLine[LCD_WIDTH];
extern uint8_t gFrameBuffer[7][128]; extern uint8_t gFrameBuffer[FRAME_LINES][LCD_WIDTH];
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap); void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const uint8_t *pBitmap, const unsigned int Size);
void ST7565_BlitFullScreen(void); void ST7565_BlitFullScreen(void);
void ST7565_BlitStatusLine(void); void ST7565_BlitStatusLine(void);
void ST7565_FillScreen(uint8_t Value); void ST7565_FillScreen(uint8_t Value);
void ST7565_Init(const bool full); void ST7565_Init(void);
void ST7565_FixInterfGlitch(void); void ST7565_FixInterfGlitch(void);
void ST7565_HardwareReset(void); void ST7565_HardwareReset(void);
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);

View File

@@ -52,5 +52,5 @@ void UI_DisplayBattery(uint8_t level, uint8_t blink)
{ {
uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)]; uint8_t bitmap[sizeof(BITMAP_BatteryLevel1)];
UI_DrawBattery(bitmap, level, blink); UI_DrawBattery(bitmap, level, blink);
ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, sizeof(bitmap), bitmap); ST7565_DrawLine(LCD_WIDTH - sizeof(bitmap), 0, bitmap, sizeof(bitmap));
} }