Skip to content

Commit

Permalink
simple-s-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr022 committed Jul 4, 2023
1 parent 855276b commit cf918e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ format('release-{0}', github.run_number) }}
release_name: ${{ format('Release \#{0} for Project, {1}', github.run_number, steps.date.outputs.date) }}
release_name: ${{ format('Release {0}, {1}', github.run_number, steps.date.outputs.date) }}
draft: false
prerelease: false

Expand Down
37 changes: 16 additions & 21 deletions src/rssi_sbar/rssi_sbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
class CRssiPrinter
{
public:
static constexpr auto ChartStartX = 4*7 + 4;
static constexpr auto ChartStartX = 32;
static constexpr auto BlockSizeX = 4;
static constexpr auto BlockSizeY = 8;
static constexpr auto BlockSpace = 1;
static constexpr auto BlocksCnt = (128 - ChartStartX) / (BlockSizeX + BlockSpace);
static void Handle(const System::TOrgFunctions& Fw, const System::TOrgData& FwData)
{
static bool bIsCleared = true;
static unsigned char u8ChartPosition = 0;
static unsigned char u8SqlDelayCnt = 0xFF;

TUV_K5Display DisplayBuff(FwData.pDisplayBuffer);
Expand All @@ -34,7 +37,6 @@ class CRssiPrinter
bIsCleared = true;
auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0));
memset(pDData, 0, DisplayBuff.SizeX);
u8ChartPosition = 0;
if(*pMenuCheckData != 0xFF)
{
Fw.FlushFramebufferToScreen();
Expand All @@ -46,6 +48,9 @@ class CRssiPrinter

u8SqlDelayCnt++;
bIsCleared = false;

auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0));
memset(pDData, 0, DisplayBuff.SizeX);

Display.SetCoursor(3, 0);
Display.SetFont(&FontSmallNr);
Expand Down Expand Up @@ -73,28 +78,18 @@ class CRssiPrinter
C8RssiString[3] = '0' + u8Rssi % 10;

Display.Print(C8RssiString);

if(u8ChartPosition < ChartStartX || u8ChartPosition >= TUV_K5Display::SizeX)
u8ChartPosition = ChartStartX;

// unsigned char u8Sub = (u8Rssi * 7) >> 7;
// unsigned char u8PrintShift = (u8Sub > 7 ? 7 : u8Sub);
unsigned char u8Sub = (u8Rssi * BlocksCnt) >> 7;
unsigned char u8BlocksToFill = (u8Sub > BlocksCnt ? BlocksCnt : u8Sub);
u8BlocksToFill = BlocksCnt - u8BlocksToFill;
for(unsigned char i = 0; i < u8BlocksToFill; i++)
{
unsigned char u8X = i * (BlockSizeX + BlockSpace) + ChartStartX;
Display.DrawRectangle(u8X, 24, BlockSizeX, BlockSizeY, true);
}
// Turn the proper pixel on, and the ones below it on as well
// The code to turn just the correct pixel on is: U8ScreenHistory[u8ChartPosition - ChartStartX] = (1 << u8PrintShift) & 0xFF;
// U8ScreenHistory[u8ChartPosition - ChartStartX] = ~(0xFF >> (7 - u8PrintShift));

if(u8ChartPosition + 4 < DisplayBuff.SizeX)
{
for(unsigned char i = 0; i < 4; i++)
{
// U8ScreenHistory[u8ChartPosition - ChartStartX + i + 1] = 0;
}
}

// auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0) + ChartStartX);
// memcpy(pDData, U8ScreenHistory, sizeof(U8ScreenHistory));

u8ChartPosition++;
Fw.FlushFramebufferToScreen();
}
};

0 comments on commit cf918e9

Please sign in to comment.