-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/BoschSensortec/BSEC-Ardui…
- Loading branch information
Showing
11 changed files
with
916 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The compensated temperature, compensated humidity, IAQ & Static IAQ are not supported in this example code | ||
because bsec expects the time to be ticking but during deepsleep the time resets to 0. | ||
|
||
To overcome this the sleep duration can be added to the millis and passed to bsec from the example code. | ||
Changes in bsec.c is also needed for this to work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** Global Library includes */ | ||
|
||
/** Local Library includes */ | ||
|
||
#include "OLED_featherwing_display.h" | ||
|
||
/** Global variables */ | ||
ImageList image_list[NUMBER_OF_IMAGES]; | ||
|
||
// Create an SSD1306 display object | ||
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire); | ||
|
||
/** Function definitions */ | ||
|
||
/********************************************************************************/ | ||
void initialize_display() | ||
{ | ||
// Decode logos from uint32_t x 32 (32x32) to uint8_t x 128 | ||
decodeLogo(image_list[0].image, logo_bosch); | ||
decodeLogo(image_list[1].image, logo_temp); | ||
decodeLogo(image_list[2].image, logo_pres); | ||
decodeLogo(image_list[3].image, logo_hum); | ||
decodeLogo(image_list[4].image, logo_gas); | ||
// Initialize the OLED display | ||
display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_I2C_ADDR); // initialize with the I2C addr 0x3C (for the 128x32) | ||
display.clearDisplay(); | ||
display.display(); | ||
} | ||
|
||
/********************************************************************************/ | ||
void display_print_string(String text, uint8_t x_axis, uint8_t y_axis, uint8_t text_size) | ||
{ | ||
display.clearDisplay(); | ||
display.setTextSize(text_size); | ||
display.setTextColor(WHITE); | ||
display.setCursor(x_axis, y_axis); | ||
display.println(text); | ||
display.display(); | ||
} | ||
/********************************************************************************/ | ||
|
||
void display_print_multi_string(String line1, uint8_t x_axis1, uint8_t y_axis1, uint8_t text_size1, String line2_0, | ||
String line2, | ||
uint8_t x_axis2, uint8_t y_axis2, uint8_t text_size2) | ||
{ | ||
display.clearDisplay(); | ||
display.setTextSize(text_size1); | ||
display.setTextColor(WHITE); | ||
display.setCursor(x_axis1, y_axis1); | ||
display.println(line1); | ||
|
||
display.setTextSize(text_size2); | ||
display.setTextColor(WHITE); | ||
display.setCursor(x_axis2, y_axis2); | ||
display.println(line2); | ||
|
||
display.setTextSize(1); | ||
display.setTextColor(WHITE); | ||
display.setCursor(110, 16); | ||
display.println(" A"); | ||
display.setCursor(110, 24); | ||
display.println(line2_0); | ||
|
||
display.display(); | ||
} | ||
|
||
/********************************************************************************/ | ||
void display_bosch_logo(String fwVersion) | ||
{ | ||
display.clearDisplay(); | ||
display.drawBitmap(0, 0, image_list[0].image, 32, 32, WHITE); | ||
display.setTextSize(2); | ||
display.setTextColor(WHITE); | ||
display.setCursor(40, 10); | ||
display.println("BOSCH"); | ||
display.setTextSize(1); | ||
display.setCursor(40, 00); | ||
display.println(fwVersion); | ||
display.display(); | ||
} | ||
|
||
void display_print_img_string(String label, String value, uint8_t bmp, uint8_t label_size, uint8_t value_size) | ||
{ | ||
display.clearDisplay(); | ||
display.drawBitmap(0, 0, image_list[bmp].image, 32, 32, WHITE); | ||
display.setTextSize(label_size); | ||
display.setTextColor(WHITE); | ||
display.setCursor(40, 0); | ||
display.println(label); | ||
display.setTextSize(value_size); | ||
display.setCursor(40, 20); | ||
display.println(value); | ||
display.display(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** Global Library includes */ | ||
|
||
#ifndef __OLED_FEATHERWING_DISPLAY_H_ | ||
#define __OLED_FEATHERWING_DISPLAY_H_ | ||
|
||
#include <Wire.h> | ||
#include <Adafruit_SSD1306.h> | ||
#include <Adafruit_GFX.h> | ||
|
||
/** Local Library includes */ | ||
|
||
#include "logos.h" | ||
|
||
/** Defines and consts */ | ||
#define NUMBER_OF_IMAGES 5u | ||
#define DISPLAY_I2C_ADDR 0x3c | ||
|
||
/** Structs and enums */ | ||
|
||
struct ImageList | ||
{ | ||
uint8_t image[128]; | ||
}; | ||
|
||
extern ImageList image_list[NUMBER_OF_IMAGES]; | ||
|
||
/** Function declarations */ | ||
|
||
/** | ||
* @brief Function used to initialize local objects for images with | ||
* global consts from logos.h file | ||
*/ | ||
void initialize_display(); | ||
|
||
/** | ||
* @brief Function used to clear display and print the input string | ||
* @param text [input] Input string that needs to be printed on display. | ||
*/ | ||
void display_print_string(String text, uint8_t x_axis, uint8_t y_axis, uint8_t text_size); | ||
|
||
/** | ||
* @brief Function used to clear display and print the input string | ||
* @param text [input] Input string that needs to be printed on display. | ||
*/ | ||
void display_print_multi_string(String line1, uint8_t x_axis1, uint8_t y_axis1, uint8_t text_size1, | ||
String line2_0, | ||
String line2, uint8_t x_axis2, uint8_t y_axis2, uint8_t text_size2); | ||
|
||
/** | ||
* @brief Function used to display BOSCH logo on OLED display. | ||
* @param fwVersion [input] Firmware version that needs to be printed on OLED Display | ||
*/ | ||
void display_bosch_logo(String fwVersion); | ||
|
||
/** | ||
* @brief Function used to clear display and print input label and string based on bmp Index. | ||
* @param label [input] Title which needs to be printed on display | ||
* @param value [input] Value which needs to be printed on display | ||
* @param bmp [input] Index number corresponding to bmp files | ||
* @param label_size [input] Size of label string to be printed on OLED display | ||
* @param value_size [input] Size of value string to be printed on OLED display | ||
*/ | ||
void display_print_img_string(String label, String value, uint8_t bmp, uint8_t label_size, uint8_t value_size); | ||
|
||
/** Global variables */ | ||
|
||
extern Adafruit_SSD1306 display; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Install Adafruit SSD1306, Adafruit GFX Library & Adafruit BusIO from the Arduino Library Manager | ||
|
||
Versions used for testing | ||
Adafruit SSD1306 version 2.3.1 | ||
Adafruit GFX Library version 1.9.0 | ||
Adafruit BusIO version 1.3.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "logos.h" | ||
|
||
void decodeLogo(uint8_t *bitmap, const uint32_t *logo) | ||
{ | ||
uint8_t i, j; | ||
|
||
for (i = 0; i < 128; i++) | ||
bitmap[i] = 0; | ||
|
||
for (i = 0; i < 4; i++) { | ||
for (j = 0; j < 32; j++) | ||
{ | ||
bitmap[(4 * j) + i] = (((logo[i * 8] & 1 << j) >> j) << 7) | | ||
(((logo[(i * 8) + 1] & 1 << j) >> j) << 6) | | ||
(((logo[(i * 8) + 2] & 1 << j) >> j) << 5) | | ||
(((logo[(i * 8) + 3] & 1 << j) >> j) << 4) | | ||
(((logo[(i * 8) + 4] & 1 << j) >> j) << 3) | | ||
(((logo[(i * 8) + 5] & 1 << j) >> j) << 2) | | ||
(((logo[(i * 8) + 6] & 1 << j) >> j) << 1) | | ||
(((logo[(i * 8) + 7] & 1 << j) >> j)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef __LOGOS_H_ | ||
#define __LOGOS_H_ | ||
|
||
#include <Arduino.h> | ||
|
||
void decodeLogo(uint8_t *bitmap, const uint32_t *logo); | ||
|
||
const uint8_t lockBmp[32] = { | ||
B00000000, B00000000, | ||
B00000000, B00000000, | ||
B00000011, B11000000, | ||
B00001100, B00110000, | ||
B00011000, B00011000, | ||
B00011000, B00011000, | ||
B00011000, B00011000, | ||
B00011000, B00011000, | ||
B00111111, B11111100, | ||
B00111110, B01111100, | ||
B00111100, B00111100, | ||
B00111100, B00111100, | ||
B00111110, B01111100, | ||
B00111110, B01111100, | ||
B00111111, B11111100, | ||
B00011111, B11111000 }; | ||
|
||
const uint32_t logo_bosch[32] = { 0x00000000, 0x000FF000, 0x003FFC00, | ||
0x00F00F00, 0x03C003C0, 0x071FF8E0, 0x067FFE60, 0x0CE00730, 0x19C00398, | ||
0x3B8001DC, 0x33FFFFCC, 0x33FFFFCC, 0x60381C06, 0x60381C06, 0x60381C06, | ||
0x60381C06, 0x60381C06, 0x60381C06, 0x60381C06, 0x60381C06, 0x33FFFFCC, | ||
0x33FFFFCC, 0x3B8001DC, 0x19C00398, 0x0CE00730, 0x067FFE60, 0x071FF8E0, | ||
0x03C003C0, 0x00F00F00, 0x003FFC00, 0x000FF000, 0x00000000 }; | ||
|
||
const uint32_t logo_temp[32] = { 0x00000000, 0x00000000, 0x00001000, 0x00001000, | ||
0x00011080, 0x00011080, 0x000113E0, 0x00011080, 0x00011080, 0x00001000, | ||
0x03C01000, 0x07E01000, 0x1C3FFFFC, 0x193FFFFE, 0x3B80100E, 0x3904522E, | ||
0x1C3FFFFE, 0x1FFFFFFC, 0x08301000, 0x10101000, 0x20081000, 0x40441000, | ||
0x40441000, 0x47C41000, 0x40441000, 0x40441000, 0x20081000, 0x10101000, | ||
0x08201000, 0x07C00000, 0x00000000 }; | ||
|
||
const uint32_t logo_hum[32] = { 0x00000000, 0x00000000, 0x01FF0000, 0x03FFC000, | ||
0x0701F000, 0x0E007800, 0x1C7C1C00, 0x38E00E00, 0x71800700, 0x73000380, | ||
0x730001C0, 0x720000E0, 0x72000070, 0x72001FF0, 0x710071E0, 0x38006670, | ||
0x1FF0CC18, 0x0C09980C, 0x10059006, 0x23E3900C, 0x21A1C818, 0x42E16070, | ||
0x400131C0, 0x43E11F00, 0x40810000, 0x20810000, 0x23E20000, 0x10040000, | ||
0x0C080000, 0x03F00000, 0x00000000, 0x00000000 }; | ||
|
||
const uint32_t logo_pres[32] = { 0x00000000, 0x00000400, 0x00000400, 0x1F1FC400, | ||
0x31BFE404, 0x64FFF008, 0x6E607C10, 0x64303F80, 0x30181C40, 0x180C0C20, | ||
0x0E060C20, 0x07030C20, 0x03C18C2E, 0x03E0DC20, 0x03B87840, 0x038C3F80, | ||
0x03871C00, 0x0381CE40, 0x07C07320, 0x08201990, 0x10101EC0, 0x20081BE0, | ||
0x400418F0, 0x4FE47838, 0x4124F000, 0x4124C000, 0x40C7C000, 0x200F8000, | ||
0x101F0000, 0x08200000, 0x07C00000, 0x00000000 }; | ||
|
||
const uint32_t logo_gas[32] = { 0x00000000, 0x038000F8, 0x0440018C, 0x08200306, | ||
0x08200202, 0x08600202, 0x04900202, 0x0389F706, 0x0047F98C, 0x002F10F8, | ||
0x001E2080, 0x00382100, 0x00381380, 0x00380F80, 0x003E0380, 0x00390380, | ||
0x00108380, 0x00208700, 0x07E11E80, 0x0833FC40, 0x101DF238, 0x23880124, | ||
0x444400C2, 0x48240082, 0x49240082, 0x4F240044, 0x41040038, 0x20080000, | ||
0x10100000, 0x08200000, 0x07C00000, 0x00000000 }; | ||
|
||
#endif |
Oops, something went wrong.