Skip to content

Commit

Permalink
values of interest
Browse files Browse the repository at this point in the history
  • Loading branch information
ClockSelect committed Mar 21, 2021
1 parent e1b20e9 commit 91f3bf2
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 67 deletions.
40 changes: 39 additions & 1 deletion inc/aegis.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ BATT_STATUS;
extern void BMStartup( void );
extern void BMUpdateBattery( void );
extern void BMReadBattery( void );
extern void BMGetCells( uint32_t *v1, uint32_t *v2 );
extern void BMUpdateStatus( void );
extern BATT_STATUS BMGetStatus( void );

Expand Down Expand Up @@ -279,6 +278,13 @@ extern int IsUSBPlugged( void );
#define BOX_IDLE (0x1<<BOX_LCK_Pos)
#define BOX_LOCKED (0x2<<BOX_LCK_Pos)

typedef enum eVapeMode
{
VAPE_MODE_POWER = 0,
VAPE_MODE_MAX
}
VAPE_MODE;

typedef uint8_t BOX_STATE;

extern void BXStartup( void );
Expand All @@ -293,6 +299,38 @@ static FINLINE void BXUserActivity() { bx_last_activity = GetSysTick(); }
static FINLINE uint32_t BXLastActivity() { return bx_last_activity; }


//==============================================================================
// Values of interest
//------------------------------------------------------------------------------

// Enumeration of all values of interest.
// Any value listed above VOI_ENDCONFIG are supposed to be saved in the
// dataflash configuration.
// When adding or removing a value in this enum, the voi_sizes array in
// the voi.c file must also be updated.
typedef enum voi_id_e
{
VOI_BRIGHTNESS,
VOI_ENDCONFIG,
VOI_VCELL1,
VOI_VCELL2,
VOI_BATT_STATUS,
VOI_MAX
}
VOI_ID;

typedef enum voi_user_e
{
VOI_USCREEN,
VOI_UCONFIG
}
VOI_USER;

extern uint8_t VOISet( VOI_ID id, const void *p );
extern void VOIGet( VOI_ID id, void *p );
extern int VOIGetChanged( VOI_ID id, void *p, VOI_USER who );


//==============================================================================
// Timings (in ticks) (1 tick = 1ms)
//------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions inc/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

typedef struct rect
{
uint16_t left;
uint16_t top;
uint16_t right;
uint16_t bottom;
uint8_t left;
uint8_t top;
uint8_t right;
uint8_t bottom;
}
rect_t;

Expand Down
12 changes: 12 additions & 0 deletions inc/screens.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@
#include "aegis.h"


typedef struct screen_elem_s
{
void (*fct)( struct screen_elem_s * );
rect_t rect;
VOI_ID voi;
uint8_t draw;
uint8_t stat;
}
SCREEN_ELEM;


extern void ScrMainInit( void );
extern int ScrMainDraw( void );
extern int ScrMainRefresh( void );
extern void ScrMainClose( void );
extern int ScrMainEvent( Event_t *ev );


extern void ScrIdleInit( void );
extern int ScrIdleDraw( void );
extern void ScrIdleClose( void );
Expand Down
20 changes: 10 additions & 10 deletions notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Board Temperature Sensor ( 10000 * CH3 ) / ( 4096 - CH3 )

Config = 0x55AA55AA + Config Data (52) + CRC32( config data )

0 4 Active Modes Bitfield (0x9FF)
0 4 Selectable Modes Bitfield (0x9FF)
1 4 Flags (Bitfield)
2 4 Puff Count
3 4
Expand All @@ -120,7 +120,7 @@ Config = 0x55AA55AA + Config Data (52) + CRC32( config data )
14 2 VPC-P5
15 2 TC Power Limit
16 1 Mode (0:TCR,1:Power,2:TC,3:VPC,4:Bypass)
17 1 Mode Screen (0:Power,1:Ti,2:Ni,3:?(90),4:SS,5:?(92),6:TCR,10:Bypass,11:VPC)
17 1 Mode Screen (0:Power,1:Ti,2:Ni,3:?(TCR/90),4:SS,5:?(TCR/92),6-8:TCR,9:?(Power),10:Bypass,11-13:VPC,14+:?(TC))
18 1 Screen Brightness (0..100)
19 1 Keys Locked
20 1
Expand All @@ -132,14 +132,14 @@ Config = 0x55AA55AA + Config Data (52) + CRC32( config data )
26 0 (End of Flash config)
27 1 1:Idle,2:Measure,3:Fire (?)
28 2 Puff Time
29 8 CoilResistance
30 8 Coil Current
31 8 Coil Voltage
32 8 Battery Cell 1 (Idle state)
33 8 Battery Cell 2 (Idle state)
34 8
35 8
36 8 Battery Total (Idle state)
29 4 CoilResistance
30 4 Coil Current
31 4 Coil Voltage
32 4 Battery Cell 1 (Idle state)
33 4 Battery Cell 2 (Idle state)
34 4
35 4
36 4 Battery Total (Idle state)
37 1 Atomizer Status (0:Unk,1:Low,3:Ok,4:High,5:NoAto)
38 4 Coil Resistance (Average of #29)
39 4 Coil Current (Average of #30)
Expand Down
23 changes: 13 additions & 10 deletions src/ST7735S.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,15 @@ static void fill_rect( rect_t *r )
address_rect( r );

int nbPix = ( r->right - r->left + 1 ) * ( r->bottom - r->top + 1 );

begin_send_data();

while ( nbPix-- )
{
send_data_word( drawing_color );
send_bytes( &drawing_color, sizeof( drawing_color ), 2 );
}

end_send_data();
}

static void StartBacklightDriver( void )
Expand Down Expand Up @@ -278,10 +283,11 @@ static void CLS( void )

static uint16_t color_rgb_to_565( uint32_t rgb )
{
return ( rgb >> 19 &0xF ) << 11
| ( rgb >> 10 & 0x1F ) << 5
| ( rgb >> 3 & 0xF )
;
return (( rgb >> 10 ) << 13 )
| (( rgb >> 19 ) << 8 )
| (( rgb << 24 ) >> 24 )
| (( rgb << 16 ) >> 29 )
;
}

static void SetColor( uint32_t rgb )
Expand Down Expand Up @@ -352,9 +358,6 @@ static int draw_char( const uint16_t c, int x, int y )

const uint8_t *bitmap = chardesc->bitmap;

uint16_t fg = ( fgcolor << 8 ) | ( fgcolor >> 8 );
uint16_t bg = ( bgcolor << 8 ) | ( bgcolor >> 8 );

begin_send_data();

uint8_t bits;
Expand All @@ -363,7 +366,7 @@ static int draw_char( const uint16_t c, int x, int y )
for ( int i = 0 ; i < cw ; ++i )
{
if ( !( i & 0x7 ) ) bits = *bitmap++;
send_bytes( bits >> 7 ? &fg : &bg, sizeof( uint16_t ), 2 );
send_bytes( bits >> 7 ? &fgcolor : &bgcolor, sizeof( uint16_t ), 2 );
bits <<= 1;
}
}
Expand Down Expand Up @@ -405,7 +408,7 @@ void rainbow( void )
r = 32 * c / 80;
b = ( 32 * ( c + l ) / 240 ) ^ 0x1F;

uint32_t c = b << 11 | g << 5 | r;
uint16_t c = b << 11 | g << 5 | r;
send_data_word( c );
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

typedef struct battery_s
{
uint32_t vcell1;
uint32_t vcell2;
uint32_t vtotal;
uint16_t vcell1;
uint16_t vcell2;
uint16_t vtotal;
BATT_STATUS status;
uint8_t cell1_low :1;
uint8_t cell2_low :1;
Expand Down Expand Up @@ -69,13 +69,9 @@ void BMReadBattery( void )
battery.vcell1 = vbat1;
battery.vcell2 = vbat2;
battery.vtotal = vbat1 + vbat2;
}


void BMGetCells( uint32_t *v1, uint32_t *v2 )
{
*v1 = battery.vcell1;
*v2 = battery.vcell2;
VOISet( VOI_VCELL1, &battery.vcell1 );
VOISet( VOI_VCELL2, &battery.vcell2 );
}


Expand All @@ -99,6 +95,8 @@ void BMUpdateStatus( void )
PF4 = 1;
}

VOISet( VOI_BATT_STATUS, &battery.status );

if ( battery.status != old )
{
EMSendEvent1P( EVENT_HARDWARE, EV_H_BATT_STATUS, battery.status );
Expand Down
3 changes: 1 addition & 2 deletions src/box.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ void BXCheckActivity( void )
//------------------------------------------------------------------------------
static void GoToSleep( void )
{
// Quick and dirty. :)

DMShutdown();

DisableSPI0();
Expand Down Expand Up @@ -131,6 +129,7 @@ static void GoToSleep( void )
CLK_PowerDown();
SYS_LockReg();

// Why bother restarting all devices ?
ResetChip( 0 );
}

Expand Down
6 changes: 5 additions & 1 deletion src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ void DMEvent( Event_t *ev )
switch ( ev->p1 )
{
case DISPLAY_ON:
DELAYED_EVENT( 1, EVENT_DISPLAY, EV_D_BRIGHTNESS, 25, 0 );
{
uint8_t b;
VOIGet( VOI_BRIGHTNESS, &b );
DELAYED_EVENT( 1, EVENT_DISPLAY, EV_D_BRIGHTNESS, b, 0 );
break;
}
}
break;
}
Expand Down
3 changes: 1 addition & 2 deletions src/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ int EMGetNextEvent( Event_t *ev )
//==============================================================================

static void EMKeyEvent( Event_t *ev );
static void EMDisplayEvent( Event_t *ev );
static void EMHardwareEvent( Event_t *ev );


Expand All @@ -112,7 +111,7 @@ void EMHandleEvents()
Event_t ev;
EMGetNextEvent( &ev );

PrintEvent( &ev );
// PrintEvent( &ev );

switch ( ev.type )
{
Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ int main( void )
StartupDevices();
StartupBox();

uint8_t b = 25;
VOISet( VOI_BRIGHTNESS, &b );

while ( 1 )
{
SMRefresh();
Expand Down
1 change: 1 addition & 0 deletions src/screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void SMRefresh( void )
{
if ( screen.s->pf_draw() )
{
screen.opening_tick = t;
screen.last_refresh = t;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/screens/screen_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ extern int ScrIdleDraw( void )

extern void ScrIdleClose( void )
{
DMSetBrightness( 25 );
uint8_t b;

VOIGet( VOI_BRIGHTNESS, &b );
DMSetBrightness( b );
}

extern int ScrIdleEvent( Event_t *ev )
Expand Down
Loading

0 comments on commit 91f3bf2

Please sign in to comment.