diff --git a/examples/Accelerometer/Accelerometer.ino b/examples/Accelerometer/Accelerometer.ino index 8ba7eaf..4a178e2 100644 --- a/examples/Accelerometer/Accelerometer.ino +++ b/examples/Accelerometer/Accelerometer.ino @@ -1,13 +1,11 @@ #include "Arduino_SensorKit.h" -SensorKit kit; - void setup() { // put your setup code here, to run once: Serial.begin(9600); while(!Serial); - kit.begin(); + Accelerometer.begin(); } void loop() { diff --git a/examples/Oled_Display/Oled_Display.ino b/examples/Oled_Display/Oled_Display.ino index 4271ecc..68b2a26 100644 --- a/examples/Oled_Display/Oled_Display.ino +++ b/examples/Oled_Display/Oled_Display.ino @@ -1,19 +1,17 @@ #include "Arduino_SensorKit.h" -SensorKit kit; - void setup() { - kit.begin(); + Oled.begin(); } void loop() { int random_value = random(0, 1023); //read value from A0 - Oled.clearBuffer(); // clear the internal memory - Oled.setFont(u8g2_font_ncenB08_tr); // choose a suitable font - Oled.setCursor(0, 10); - Oled.print("Analog Value:"); // write something to the internal memory - Oled.print(random_value); // print random value read from pin A0 - Oled.sendBuffer(); // transfer internal memory to the display + Oled.setFont(u8x8_font_chroma48medium8_r); + Oled.setCursor(0, 33); + Oled.print("Temp: "); + Oled.print(random_value); + Oled.print("C"); + Oled.refreshDisplay(); delay(1000); } diff --git a/examples/Plug_Sketch_Play/Plug_Sketch_Play.ino b/examples/Plug_Sketch_Play/Plug_Sketch_Play.ino index 0c35680..e6db3c4 100644 --- a/examples/Plug_Sketch_Play/Plug_Sketch_Play.ino +++ b/examples/Plug_Sketch_Play/Plug_Sketch_Play.ino @@ -1,7 +1,5 @@ #include "Arduino_SensorKit.h" -SensorKit kit; - int button = 4; int LED = 6; @@ -10,8 +8,6 @@ void setup() { Serial.begin(9600); while (!Serial); - kit.begin(); - pinMode(button , INPUT); pinMode(LED, OUTPUT); diff --git a/examples/Pressure_Sensor/Pressure_Sensor.ino b/examples/Pressure_Sensor/Pressure_Sensor.ino index 141d6d1..e371f5c 100644 --- a/examples/Pressure_Sensor/Pressure_Sensor.ino +++ b/examples/Pressure_Sensor/Pressure_Sensor.ino @@ -1,10 +1,8 @@ #include "Arduino_SensorKit.h" -SensorKit kit; - void setup() { Serial.begin(9600); - kit.begin(); + Pressure.begin(); } void loop() { diff --git a/examples/Temp_and_Humidity/Temp_and_Humidity.ino b/examples/Temp_and_Humidity/Temp_and_Humidity.ino index 272abfe..ae7a742 100644 --- a/examples/Temp_and_Humidity/Temp_and_Humidity.ino +++ b/examples/Temp_and_Humidity/Temp_and_Humidity.ino @@ -1,11 +1,9 @@ //#define DHTPIN 3 // By default its connected to pin D3, it can be changed, define it before the #include of the library #include "Arduino_SensorKit.h" -SensorKit kit; - void setup() { Serial.begin(9600); - kit.begin(); + Environment.begin(); } void loop() { diff --git a/library.properties b/library.properties index 93e56b7..18246d1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_Sensorkit -version=1.0.2 +version=1.0.3 author=Lenard George, Pablo Marquínez maintainer=Arduino sentence=Arduino Sensor Kit diff --git a/src/Arduino_SensorKit.cpp b/src/Arduino_SensorKit.cpp index 7f9ebc6..8684e34 100644 --- a/src/Arduino_SensorKit.cpp +++ b/src/Arduino_SensorKit.cpp @@ -1,25 +1,7 @@ #include "Arduino_Sensorkit.h" //Declare component's classes -U8G2_SSD1306_128X64_NONAME_F_SW_I2C Oled(U8G2_R0, SCL, SDA, U8X8_PIN_NONE); +U8X8_SSD1306_128X64_NONAME_HW_I2C Oled(U8X8_PIN_NONE); DHT Environment(DHTPIN, DHTTYPE); SensorKit_LIS3DHTR Accelerometer; SensorKit_BMP280 Pressure; - -SensorKit::SensorKit(){} - -bool SensorKit::begin(){ - Oled.begin(); - Oled.enableUTF8Print(); - - Accelerometer.begin(); - delay(100); - Accelerometer.setOutputDataRate(LIS3DHTR_DATARATE_50HZ); - - Pressure.begin(); - Environment.begin(); -} - -void SensorKit::end(){ - -} \ No newline at end of file diff --git a/src/Arduino_SensorKit.h b/src/Arduino_SensorKit.h index 010c4f2..3281a23 100644 --- a/src/Arduino_SensorKit.h +++ b/src/Arduino_SensorKit.h @@ -14,8 +14,7 @@ #include "Arduino_SensorKit_BMP280.h" // Pressure #include "Arduino_SensorKit_LIS3DHTR.h" // Accel #include "DHT.h" // Temp & Humidity -#include "U8g2lib.h" // Oled Display - +#include "U8x8lib.h" // Oled Display //Defines #ifndef DHTTYPE @@ -25,15 +24,8 @@ #define DHTPIN 3 #endif -class SensorKit { - public: - SensorKit(); - bool begin(); - void end(); -}; - //Make the declared components from the .cpp to the sketch available -extern U8G2_SSD1306_128X64_NONAME_F_SW_I2C Oled; +extern U8X8_SSD1306_128X64_NONAME_HW_I2C Oled; extern SensorKit_LIS3DHTR Accelerometer; extern SensorKit_BMP280 Pressure; extern DHT Environment;