Skip to content

Analog power bar & more responsive UI. #347

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

Open
wants to merge 1 commit 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 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 pwrbar:1;

// Do not exceed 32 bits;
// if you may do so, create another bitfield.
Expand Down
2 changes: 2 additions & 0 deletions inc/miscs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ extern void qix_diddle(int16_t *ptr );

extern void Snow( int );

extern void AnimPwrBar( int );

extern uint8_t LEDRed;
extern uint8_t LEDGreen;
extern uint8_t LEDBlue;
Expand Down
2 changes: 2 additions & 0 deletions inc/myevic.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ typedef struct
/* 00200000 */ int fading:1;
/* 00400000 */ int led_on:1;
/* 00800000 */ int splash:1;

/* 01000000 */ int animpwrbar:1;
}

gFlags_t;
Expand Down
1 change: 1 addition & 0 deletions inc/screens.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ extern const uint8_t String_4[];
extern const uint8_t String_OnOff[];
extern const uint8_t String_ModePlus[];
extern const uint8_t String_PPwr[];
extern const uint8_t String_PwrBar[];
extern const uint8_t String_Clicks[];
extern const uint8_t String_BAT[];
extern const uint8_t String_GEN[];
Expand Down
1 change: 1 addition & 0 deletions src/eh.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ __myevic__ void EventHandler()
if ( !gFlags.firing || LastInputs != 1 )
StopFire();
gFlags.refresh_display = 1;
gFlags.animpwrbar = 0; // Screen 2 may decide to set this.
Screen = 2;
ScreenDuration = 1;
return;
Expand Down
19 changes: 7 additions & 12 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,11 @@ __myevic__ void Main()
anim3d( 0 );
}

if ( Screen == 2 && gFlags.animpwrbar )
{
AnimPwrBar( 0 );
}

if ( Screen == 60 )
{
AnimateScreenSaver();
Expand Down Expand Up @@ -994,10 +999,7 @@ __myevic__ void Main()
if ( ShowProfNum )
--ShowProfNum;

if ( !( gFlags.firing && ISMODETC(dfMode) ) )
{
DrawScreen();
}
DrawScreen();

if ( KeyTicks < 5 )
{
Expand Down Expand Up @@ -1056,14 +1058,7 @@ __myevic__ void Main()

gFlags.osc_1hz ^= 1;

if ( gFlags.firing )
{
if ( ISMODETC(dfMode) )
{
DrawScreen();
}
}
else
if ( !gFlags.firing )
{
if
( !dfStatus.off
Expand Down
17 changes: 13 additions & 4 deletions src/mainview.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,21 @@ __myevic__ void DrawMode()

//=============================================================================

__myevic__ void DrawPwrLine( int pwr, int line )
__myevic__ void DrawPwrLine( int pwr, int drawbar, int line )
{
if ( BLINKITEM(2) && PD2 && PD3 )
return;

DrawString( String_PWR_s, 0, line+2 );
if ( drawbar )
{
// Note: this always draws on line 52.
AnimPwrBar( 1 );
gFlags.animpwrbar = 1;
}
else
{
DrawString( String_PWR_s, 0, line+2 );
}

if ( pwr < 1000 )
{
Expand Down Expand Up @@ -393,7 +402,7 @@ __myevic__ void DrawInfoLines()
}
else
{
DrawPwrLine( AtoPower( AtoVolts ), 52 );
DrawPwrLine( AtoPower( AtoVolts ), dfStatus.pwrbar, 52 );
}
break;
case 4:
Expand All @@ -420,7 +429,7 @@ __myevic__ void DrawInfoLines()
}
else
{
DrawPwrLine( dfTCPower, 52 );
DrawPwrLine( dfTCPower, 0, 52 );
}
break;
case 4:
Expand Down
16 changes: 15 additions & 1 deletion src/menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,15 @@ __myevic__ void IFMenuIDraw( int it, int line, int sel )
DrawString( dfStatus.priopwr ? String_On : String_Off, 44, line+2 );
break;

case 6: // PwrBar
if ( dfStatus.priopwr ) {
// PwrBar doesn't work in PPwr mode; draw a lock icon.
DrawImage( 44, line+2, 0xC3 );
} else {
DrawString( dfStatus.pwrbar ? String_On : String_Off, 44, line+2 );
}
break;

default:
break;
}
Expand Down Expand Up @@ -555,6 +564,10 @@ __myevic__ void IFMenuOnClick()
dfStatus.priopwr ^= 1;
break;

case 6: // PwrBar
if ( !dfStatus.priopwr ) dfStatus.pwrbar ^= 1;
break;

default: // Exit
UpdateDataFlash();
return;
Expand Down Expand Up @@ -2085,14 +2098,15 @@ const menu_t IFMenu =
0,
IFMenuOnClick+1,
0,
8,
9,
{
{ String_1Watt, 0, 0, 0 },
{ String_1C5F, 0, 0, 0 },
{ String_WakeMP, 0, 0, 0 },
{ String_Font, 0, 0, 0 },
{ String_Temp, 0, 0, 0 },
{ String_PPwr, 0, 0, 0 },
{ String_PwrBar, 0, 0, 0 },
{ String_Clicks, &ClicksMenu, 0, MACTION_SUBMENU },
{ String_Back, 0, EVENT_PARENT_MENU, 0 }
}
Expand Down
53 changes: 53 additions & 0 deletions src/miscs.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,59 @@ __myevic__ void Snow( int redraw )
}
}

//=========================================================================
// Analog Power Bar
//
// When PwBar is enabled, the firing screen calls this (with first=1)
// instead of drawing the "PWR" label. It will also set animpwrbar=1,
// to request updates (with first=0) at 100 Hz.
//
// It's important to clear animpwrbar before switching to Screen 2,
// so that updates only occur under the expected constraints.
//-------------------------------------------------------------------------

__myevic__ void AnimPwrBar( int first )
{
static const int LINE = 52;
static const int WIDTH = 24;
if ( first ) {
// Draw the tick marks.
for ( int x = 0; x <= WIDTH; x += 3 ) {
int h;
if ( x == 0 ) {
h = 2;
} else if ( x % 12 == 0 ) {
h = 1;
} else {
h = 0;
}
DrawVLine( x, LINE, LINE+h, 1 );
DrawVLine( x, LINE+9, LINE+9-h, 1 );
}
} else {
// Animate subsequent frames at 50 Hz.
static uint8_t tscaler = 0;
if ( ++tscaler < 2 ) return;
tscaler = 0;
}

// Zero the bar when not firing, because Screen 2 remains visible
// for ~1 second after firing stops.
const int pwr = gFlags.firing ? AtoPower( AtoVolts ) : 0;
const int pwrmax = dfTCPower;

int bar = ( pwr * WIDTH / pwrmax );
if ( bar < 0 ) bar = 0;
if ( bar > WIDTH ) bar = WIDTH;

DrawFillRect( 0, LINE+3, WIDTH, LINE+6, 0 );
DrawFillRect( 0, LINE+3, bar, LINE+6, 1 );

if ( !first ) {
DisplayRefresh();
}
}


//=========================================================================
// LED Stuff
Expand Down
16 changes: 7 additions & 9 deletions src/screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ void SetScreen( int screen, int duration )


//=========================================================================
// Called at a frequency of 10Hz except when firing in TC modes.
// Called at a frequency of 2Hz when firing in TC modes.
// Called at a frequency of 10Hz

__myevic__ void DrawScreen()
{
Expand All @@ -51,7 +50,11 @@ __myevic__ void DrawScreen()
CurrentFD = FireDuration;
ScreenDuration = ISMODETC(dfMode) ? 1 : 3;
TenthOfSecs = 0;
gFlags.refresh_display = 1;
// Refresh at 2Hz in TC mode, or 10Hz otherwise.
if ( !ISMODETC(dfMode) || FireDuration % 5 == 1 )
{
gFlags.refresh_display = 1;
}
}
else if ( ScreenRefreshTimer && !--ScreenRefreshTimer )
{
Expand Down Expand Up @@ -221,12 +224,7 @@ __myevic__ void DrawScreen()
gFlags.fading = 0;
}

if (( gFlags.firing ) && ISMODETC(dfMode))
TenthOfSecs += 5;
else
TenthOfSecs += 1;

if ( TenthOfSecs < 10 )
if ( ++TenthOfSecs < 10 )
return;

TenthOfSecs = 0;
Expand Down
1 change: 1 addition & 0 deletions src/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ __string__ String_OnOff [] = { 0xAA, 0x8F, 0xD6, 0xBD, 0xAA, 0x87, 0x87, 0 };
__string__ String_ModePlus [] = { 0xA8, 0x90, 0x85, 0x86, 0xBD, 0xD4, 0xD4, 0 };
__string__ String_Clicks [] = { 0x9E, 0x8D, 0x8A, 0x84, 0x8C, 0x94, 0 };
__string__ String_PPwr [] = { 0xAB, 0xAB, 0x98, 0x93, 0 };
__string__ String_PwrBar [] = { 0xAB, 0x98, 0x9D, 0x82, 0x93, 0 }; // "PwBar"
__string__ String_BAT [] = { 0x9D, 0x9C, 0xAF, 0 };
__string__ String_GEN [] = { 0xA2, 0xA0, 0xA9, 0 };
__string__ String_25R [] = { 0x0D, 0x10, 0xAD, 0 };
Expand Down