Skip to content
Snippets Groups Projects
Commit 2494325e authored by tag2y19's avatar tag2y19
Browse files

Add screen option to syscfg

parent f838504f
Branches
No related tags found
No related merge requests found
...@@ -166,6 +166,7 @@ int main( void ) { ...@@ -166,6 +166,7 @@ int main( void ) {
static void screen_init( void ) { static void screen_init( void ) {
#if MYNEWT_VAL( SCREEN )
hal_i2c_enable( 0 ); hal_i2c_enable( 0 );
static const uint8_t init[] = { static const uint8_t init[] = {
...@@ -198,21 +199,29 @@ static void screen_init( void ) { ...@@ -198,21 +199,29 @@ static void screen_init( void ) {
text16( "Hi!!! :)", frame, 0, 0 ); text16( "Hi!!! :)", frame, 0, 0 );
i2c_write( frame_buffer, sizeof frame_buffer ); i2c_write( frame_buffer, sizeof frame_buffer );
#endif
} }
static void i2c_write( const uint8_t* d, size_t s ) { static void i2c_write( const uint8_t* d, size_t s ) {
#if MYNEWT_VAL( SCREEN )
while ( 0 != hal_i2c_master_write( 0, while ( 0 != hal_i2c_master_write( 0,
&( (struct hal_i2c_master_data) { &( (struct hal_i2c_master_data) {
.address = 0x78 >> 1, .address = 0x78 >> 1,
.len = s, .len = s,
.buffer = (void*) d, .buffer = (void*) d,
} ), 2 * s, 1 ) ); } ), 2 * s, 1 ) );
#else
(void) d;
(void) s;
#endif
} }
static int text8( const char* text, uint8_t* frame, int line, int x ) { static int text8( const char* text, uint8_t* frame, int line, int x ) {
#if MYNEWT_VAL( SCREEN )
uint8_t* write_pos = frame + ( line * 128 ) + x; uint8_t* write_pos = frame + ( line * 128 ) + x;
int i = 0; int i = 0;
...@@ -243,11 +252,18 @@ static int text8( const char* text, uint8_t* frame, int line, int x ) { ...@@ -243,11 +252,18 @@ static int text8( const char* text, uint8_t* frame, int line, int x ) {
} }
return i; return i;
#else
(void) frame;
(void) line;
(void) x;
return strlen( text );
#endif
}; };
static int text16( const char* text, uint8_t* frame, int line, int x ) { static int text16( const char* text, uint8_t* frame, int line, int x ) {
#if MYNEWT_VAL( SCREEN )
uint8_t* write_pos = frame + ( line * 128 ) + x; uint8_t* write_pos = frame + ( line * 128 ) + x;
int i = 0; int i = 0;
...@@ -279,6 +295,12 @@ static int text16( const char* text, uint8_t* frame, int line, int x ) { ...@@ -279,6 +295,12 @@ static int text16( const char* text, uint8_t* frame, int line, int x ) {
} }
return i; return i;
#else
(void) frame;
(void) line;
(void) x;
return strlen( text );
#endif
}; };
......
...@@ -11,6 +11,9 @@ syscfg.defs: ...@@ -11,6 +11,9 @@ syscfg.defs:
CPUTIME_FREQ: CPUTIME_FREQ:
description: "Frequency for the cputime counter" description: "Frequency for the cputime counter"
value: '50000' value: '50000'
SCREEN:
description: "Is there a screen there"
value: '0'
syscfg.vals: syscfg.vals:
BLE_ROLE_BROADCASTER: 1 BLE_ROLE_BROADCASTER: 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment