Skip to content

Commit

Permalink
Brackets and whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
CelliesProjects committed Jul 20, 2019
1 parent c69e34f commit 5d8881d
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions oledtask.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
void IRAM_ATTR oledTask( void * pvParameters )
{
void IRAM_ATTR oledTask( void * pvParameters ) {
const TickType_t oledTaskdelayTime = 1000 / UPDATE_FREQ_OLED / portTICK_PERIOD_MS;

OLED.init();
ESP_LOGI( TAG, "OLED initialized." );

if ( preferences.getString( "oledorientation", "normal" ) == "upsidedown" )
{
if ( preferences.getString( "oledorientation", "normal" ) == "upsidedown" ) {
oledOrientation = OLED_ORIENTATION_UPSIDEDOWN;
OLED.flipScreenVertically();
}
Expand All @@ -18,23 +16,19 @@ void IRAM_ATTR oledTask( void * pvParameters )
OLED.display();

while ( !xDimmerTaskHandle )
{
vTaskDelay( 10 / portTICK_PERIOD_MS );
}

oledContrast = preferences.getUInt( "oledcontrast", 15 );
OLED.setContrast( oledContrast << 0x04 );

OLED.setFont( ArialMT_Plain_10 );

while (1)
{
while (1) {
static char content[64];

OLED.clear();

if ( OLED_SHOW_SYSTEMDATA )
{
if ( OLED_SHOW_SYSTEMDATA ) {
//https://github.com/espressif/esp-idf/blob/master/examples/protocols/sntp/main/sntp_example_main.c
struct tm timeinfo;
if ( getLocalTime( &timeinfo, 0 ) )
Expand All @@ -51,39 +45,31 @@ void IRAM_ATTR oledTask( void * pvParameters )
snprintf( content, sizeof( content ), "%s", sketchVersion );
OLED.drawString( 64, 45, content );
}
else
{
else {
const uint8_t BARS_BOTTOM = OLED.getHeight() - 11;
const uint8_t BARS_HEIGHT = BARS_BOTTOM;
const uint8_t BARS_BORDER = 4;
const uint8_t BARS_WIDTH = OLED.getWidth() / NUMBER_OF_CHANNELS;

OLED.drawString( 64, 0, WiFi.localIP().toString() );

for ( uint8_t thisChannel = 0; thisChannel < NUMBER_OF_CHANNELS; thisChannel++ )
{
for ( uint8_t thisChannel = 0; thisChannel < NUMBER_OF_CHANNELS; thisChannel++ ) {
uint8_t x1 = BARS_WIDTH * thisChannel + BARS_BORDER;
uint8_t y1 = ( BARS_BOTTOM ) - ( BARS_BOTTOM * ( channel[thisChannel].currentPercentage / 100 ) ) * 0.6;
uint8_t x2 = BARS_WIDTH - BARS_BORDER;
uint8_t y2 = BARS_BOTTOM - y1;
OLED.fillRect( x1, y1, x2, y2 );

//threeDigitPercentage( content, sizeof( content ), channel[thisChannel].currentPercentage, NO_PERCENTSIGN );

OLED.drawString( x1 + ( BARS_WIDTH / 2 ) - 1, y1 - 11,
threeDigitPercentage( content, sizeof( content ), channel[thisChannel].currentPercentage, NO_PERCENTSIGN ) );
}

if ( logger.sensorCount() )
{
if ( logger.sensorCount() ) {
uint8_t charCount = 0;
for ( uint8_t sensorNumber = 0; sensorNumber < logger.sensorCount(); sensorNumber++ )
charCount += snprintf( content + charCount, sizeof( content ) - charCount, "%.1f°C " , logger.sensorTemp( sensorNumber ) );
}
else
{
snprintf( content, sizeof( content ), "%.2f kB RAM", esp_get_free_heap_size() / 1024.0 );
}
OLED.drawString( 64, BARS_BOTTOM, content );
}

Expand Down

0 comments on commit 5d8881d

Please sign in to comment.