Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game to click menu & multiple battery voltage stats #285

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ driver/*.sys
*.map
genuine/
wrkspc.txt
.vscode/*
Binary file modified bin/myevic.bin
Binary file not shown.
1 change: 1 addition & 0 deletions inc/dataflash.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ typedef struct
/* 04000000 */ unsigned int chkmodeoff:1;
/* 08000000 */ unsigned int dfmt2:1;
/* 10000000 */ unsigned int pcurve:1;
/* 20000000 */ unsigned int battvs:1;

// Do not exceed 32 bits;
// if you may do so, create another bitfield.
Expand Down
1 change: 1 addition & 0 deletions inc/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum
CLICK_ACTION_NEXT_MODE,
CLICK_ACTION_ON_OFF,
CLICK_ACTION_PROFILE,
CLICK_ACTION_GAME,
CLICK_ACTION_MAX
};

Expand Down
11 changes: 9 additions & 2 deletions src/eh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,21 +1253,28 @@ __myevic__ void EventHandler()
break;

case 4:
if ( ++dfAPT > 8 ) dfAPT = 0;
if ( ++dfAPT > 9 ) dfAPT = 0;
break;

case 5:
if ( !dfStatus.battpc )
{
dfStatus.battpc = 1;
dfStatus.battv = 0;
dfStatus.battvs = 0;
}
else if ( !dfStatus.battv )
else if ( dfStatus.battpc && !dfStatus.battv && !dfStatus.battvs )
{
dfStatus.battv = 1;
}
else if ( dfStatus.battpc && dfStatus.battv && !dfStatus.battvs && NumBatteries >= 2 )
{
dfStatus.battv = 0;
dfStatus.battvs = 1;
}
else
{
dfStatus.battvs = 0;
dfStatus.battv = 0;
dfStatus.battpc = 0;
}
Expand Down
8 changes: 8 additions & 0 deletions src/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ __myevic__ void GetUserInput()
case CLICK_ACTION_PROFILE:
FireClicksEvent = EVENT_NEXT_PROFILE; // Cycle profile
break;

case CLICK_ACTION_GAME:
FireClicksEvent = 40; // Game
break;
}
if ( dfStatus.off )
{
Expand Down Expand Up @@ -1266,6 +1270,10 @@ __myevic__ int CustomEvents()
ShowProfNum = 30;
break;

case 40: // Game
fbStartGame();
break;

case EVENT_POWER_CURVE:
SetScreen( 107, 30 );
EditModeTimer = 3000;
Expand Down
21 changes: 15 additions & 6 deletions src/mainview.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,15 @@ __myevic__ void DrawAPTLine( int line )
break;
}

case 6: // Board temperature
case 6: // Battery percentage
{
DrawString( String_BATT_s, 0, line+2 );
DrawValue( BatteryPercent>99?30:38, line, BatteryPercent, 0, 0x1F, 0 );
DrawImage( 55, line+2, 0xC2 );
break;
}

case 7: // Board temperature
{
DrawString( String_BOARD_s, 0, line+2 );

Expand All @@ -326,7 +334,7 @@ __myevic__ void DrawAPTLine( int line )
break;
}

case 7: // Real-time atomizer resistance
case 8: // Real-time atomizer resistance
{
int rez = AtoError ? 0 : AtoRezMilli;
int nd = ( rez < 1000 ) ? 3 : 4;
Expand All @@ -338,7 +346,7 @@ __myevic__ void DrawAPTLine( int line )
break;
}

case 8: // Real-time clock
case 9: // Real-time clock
{
S_RTC_TIME_DATA_T rtd;
GetRTC( &rtd );
Expand Down Expand Up @@ -672,7 +680,7 @@ __myevic__ void ShowMainView()
if ( dfMode != 6 )
{
DrawHLine( 0, 43, 63, 1 );
DrawHLine( 0, 107, 63, 1 );
DrawHLine( 0, 106, 63, 1 );

ShowBattery();

Expand Down Expand Up @@ -706,7 +714,9 @@ __myevic__ void ShowMainView()
}
else
{
DrawInfoLines();
if ( !dfStatus.logomid || dfStatus.logomid && HideLogo ) {
DrawInfoLines();
}
}
}

Expand All @@ -721,7 +731,6 @@ __myevic__ void ShowMainView()
DrawFillRect( 0, 52, 63, 70, 0 );
}
}

DrawLOGO( 0, 0 );
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ __myevic__ void ClicksMenuIDraw( int it, int line, int sel )
case CLICK_ACTION_PROFILE:
DrawString( String_ProfPlus, 20, line+2 );
break;

case CLICK_ACTION_GAME:
DrawString( String_Game, 20, line+2 );
break;
}
}

Expand Down
114 changes: 102 additions & 12 deletions src/screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,45 +526,135 @@ __myevic__ void ShowBattery()

if ( dfStatus.battpc )
{
if ( dfStatus.battv )
{
if ( dfStatus.battv ) {
uint16_t bv = gFlags.firing ? RTBattVolts : BatteryVoltage;
DrawValueRight( 20, 118, bv, 2, 0x0B, 0 );
DrawImage( 21, 118, 0x7D );
}
else if ( dfStatus.battvs )
{
switch (NumBatteries) {
case 2: {
if (!gFlags.battery_charging) {
uint16_t bv = gFlags.firing ? RTBVolts[0] : BattVolts[0];
DrawValueRight( 23, 111, bv, 2, 0x15, 0 );
DrawImage( 24, 117, 0x7D );
uint16_t bv2 = gFlags.firing ? RTBVolts[1] : BattVolts[1];
DrawValueRight( 58, 111, bv2, 2, 0x15, 0 );
DrawImage( 59, 117, 0x7D );
}
break;
}
case 3: {
if (!gFlags.battery_charging) {
uint16_t bv = gFlags.firing ? RTBVolts[0] : BattVolts[0];
DrawValueRight( 20, 109, bv, 2, 0x0B, 0 );
DrawImage( 21, 109, 0x7D );
uint16_t bv2 = gFlags.firing ? RTBVolts[1] : BattVolts[1];
DrawValueRight( 57, 109, bv2, 2, 0x0B, 0 );
DrawImage( 58, 109, 0x7D );
uint16_t bv3 = gFlags.firing ? RTBVolts[2] : BattVolts[2];
DrawValueRight( 39, 120, bv3, 2, 0x0B, 0 );
DrawImage( 40, 120, 0x7D );
}
break;
}
case 4: {
if (!gFlags.battery_charging) {
uint16_t bv = gFlags.firing ? RTBVolts[0] : BattVolts[0];
DrawValueRight( 20, 109, bv, 2, 0x0B, 0 );
DrawImage( 21, 109, 0x7D );
uint16_t bv2 = gFlags.firing ? RTBVolts[1] : BattVolts[1];
DrawValueRight( 57, 109, bv2, 2, 0x0B, 0 );
DrawImage( 58, 109, 0x7D );
uint16_t bv3 = gFlags.firing ? RTBVolts[2] : BattVolts[2];
DrawValueRight( 20, 120, bv3, 2, 0x0B, 0 );
DrawImage( 21, 120, 0x7D );
uint16_t bv4 = gFlags.firing ? RTBVolts[4] : BattVolts[4];
DrawValueRight( 57, 120, bv4, 2, 0x0B, 0 );
DrawImage( 58, 120, 0x7D );
}
break;
}
}
}
else
{
DrawValueRight( 18, 118, BatteryPercent, 0, 0x0B, 0 );
DrawImage( 19, 118, 0xC2 );
}
}

if ( gFlags.battery_10pc && !gFlags.battery_charging )
if ( gFlags.battery_10pc && !gFlags.battery_charging) // full battery bar
{
if ( gFlags.draw_battery )
{
if ( dfStatus.battpc )
{
DrawImage( 30, 114, 0xE2 );
}
else
{
DrawImage( 8, 115, 0xC4 );
if ( NumBatteries == 1 || !dfStatus.battvs && NumBatteries > 1 ) {
if ( dfStatus.battpc )
{
DrawImage( 30, 114, 0xE2 );
}
else
{
DrawImage( 8, 115, 0xC4 );
}
}
}
}
else if ( gFlags.draw_battery_charging && gFlags.battery_charging )
{
if ( dfStatus.battpc )
{
DrawImage( 30, 114, 0xE3 );
if (dfStatus.battvs && NumBatteries >= 2) {
switch (NumBatteries) {
case 2: {
uint16_t bv = gFlags.firing ? RTBVolts[0] : BattVolts[0];
DrawValueRight( 23, 111, bv, 2, 0x15, 0 );
DrawImage( 24, 117, 0x7D );
uint16_t bv2 = gFlags.firing ? RTBVolts[1] : BattVolts[1];
DrawValueRight( 58, 111, bv2, 2, 0x15, 0 );
DrawImage( 59, 117, 0x7D );
break;
}
case 3: {
uint16_t bv = gFlags.firing ? RTBVolts[0] : BattVolts[0];
DrawValueRight( 20, 109, bv, 2, 0x0B, 0 );
DrawImage( 21, 109, 0x7D );
uint16_t bv2 = gFlags.firing ? RTBVolts[1] : BattVolts[1];
DrawValueRight( 57, 109, bv2, 2, 0x0B, 0 );
DrawImage( 58, 109, 0x7D );
uint16_t bv3 = gFlags.firing ? RTBVolts[2] : BattVolts[2];
DrawValueRight( 39, 120, bv3, 2, 0x0B, 0 );
DrawImage( 40, 120, 0x7D );
break;
}
case 4: {
uint16_t bv = gFlags.firing ? RTBVolts[0] : BattVolts[0];
DrawValueRight( 20, 109, bv, 2, 0x0B, 0 );
DrawImage( 21, 109, 0x7D );
uint16_t bv2 = gFlags.firing ? RTBVolts[1] : BattVolts[1];
DrawValueRight( 57, 109, bv2, 2, 0x0B, 0 );
DrawImage( 58, 109, 0x7D );
uint16_t bv3 = gFlags.firing ? RTBVolts[2] : BattVolts[2];
DrawValueRight( 39, 120, bv3, 2, 0x0B, 0 );
DrawImage( 40, 120, 0x7D );
uint16_t bv4 = gFlags.firing ? RTBVolts[4] : BattVolts[4];
DrawValueRight( 57, 120, bv4, 2, 0x0B, 0 );
DrawImage( 58, 120, 0x7D );
break;
}
}
}
else {
DrawImage( 30, 114, 0xE3 );
}
}
else
{
DrawImage( 8, 115, 0xC5 );
}
}
else
else if ( NumBatteries == 1 || !dfStatus.battvs && NumBatteries > 1 ) // idle show battery bar
{
if ( dfStatus.battpc )
{
Expand Down