|
@@ -1,25 +1,17 @@
|
|
//oled
|
|
//oled
|
|
|
|
|
|
|
|
+unsigned long t = 0;
|
|
|
|
|
|
-//#define HAS_18x4LCD
|
|
|
|
-
|
|
|
|
-#define HAS_u8x8log
|
|
|
|
-
|
|
|
|
|
|
+#define HAS_18x4LCD
|
|
|
|
|
|
|
|
+//#define HAS_u8x8log
|
|
#if defined(HAS_u8x8log)
|
|
#if defined(HAS_u8x8log)
|
|
- #include <Arduino.h>
|
|
|
|
- // #include <U8g2lib.h>
|
|
|
|
- #include <U8x8lib.h>
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display
|
|
|
|
- U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(U8X8_PIN_NONE);
|
|
|
|
|
|
+ #include "u8g2.h"
|
|
|
|
+#endif
|
|
|
|
|
|
- // U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- U8X8LOG u8x8log;
|
|
|
|
|
|
|
|
|
|
+#ifdef U8X8_HAVE_HW_SPI
|
|
|
|
+#include <SPI.h>
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#include "progmem__const.h"
|
|
#include "progmem__const.h"
|
|
@@ -47,10 +39,10 @@ const byte address[6] = "00001";
|
|
//#endif
|
|
//#endif
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- #if defined(HAS_18x4LCD)
|
|
|
|
- #include <LiquidCrystal_I2C.h>
|
|
|
|
- LiquidCrystal_I2C lcd(0x27,16,4); // set the LCD address to 0x27 or 0x20
|
|
|
|
- #endif
|
|
|
|
|
|
+#if defined(HAS_18x4LCD)
|
|
|
|
+ #include <LiquidCrystal_I2C.h>
|
|
|
|
+ LiquidCrystal_I2C lcd(0x27,16,4); // set the LCD address to 0x27 or 0x20
|
|
|
|
+#endif
|
|
|
|
|
|
// #include "struct.h"
|
|
// #include "struct.h"
|
|
#define HAS_QMC5883LCompass
|
|
#define HAS_QMC5883LCompass
|
|
@@ -77,52 +69,53 @@ bool blinkState = false;
|
|
|
|
|
|
void setup()
|
|
void setup()
|
|
{
|
|
{
|
|
- #if defined(HAS_u8x8log)
|
|
|
|
- #include "u8g2__setup.h"
|
|
|
|
- #endif
|
|
|
|
- //#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
|
|
|
- Wire.begin();
|
|
|
|
- //#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
|
|
|
|
- // Fastwire::setup(400, true);
|
|
|
|
- //#endif
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
Serial.begin(115200);
|
|
Serial.begin(115200);
|
|
while (!Serial); // Waiting for Serial Monitor
|
|
while (!Serial); // Waiting for Serial Monitor
|
|
//Serial.println("\nCompass ang gyro test ");
|
|
//Serial.println("\nCompass ang gyro test ");
|
|
- SPFT(title);
|
|
|
|
-
|
|
|
|
- #include "scan.h"
|
|
|
|
- #if defined(HAS_QMC5883LCompass)
|
|
|
|
- SPFT(compass); SPFT(init);
|
|
|
|
- compass.init();
|
|
|
|
- #endif
|
|
|
|
- #if defined(HAS_MPU6050)
|
|
|
|
- SPFT(gyroscope);SPFT(init);
|
|
|
|
- accelgyro.initialize();
|
|
|
|
- if(accelgyro.testConnection()) {
|
|
|
|
- SPFT(ok);
|
|
|
|
- } else {SPFT(failed);}
|
|
|
|
- accelgyro.setMotionDetectionDuration(80);
|
|
|
|
- #endif
|
|
|
|
|
|
+ //SPFT(title);
|
|
|
|
+ Wire.begin();
|
|
|
|
+
|
|
|
|
+#if defined(HAS_u8x8log)
|
|
|
|
+ #include "u8g2__setup.h"
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ SPFT(title);
|
|
|
|
+
|
|
|
|
+#include "scan.h"
|
|
|
|
+
|
|
|
|
+#if defined(HAS_QMC5883LCompass)
|
|
|
|
+ SPFT(compass); SPFT(init);
|
|
|
|
+ // Serial.print("Compass init;");
|
|
|
|
+ compass.init();SPFT(ok);
|
|
|
|
+#endif
|
|
|
|
+#if defined(HAS_MPU6050)
|
|
|
|
+ SPFT(gyroscope);SPFT(init);
|
|
|
|
+ //Serial.print("accelgyro init;");
|
|
|
|
+ accelgyro.initialize();
|
|
|
|
+ if(accelgyro.testConnection()) {
|
|
|
|
+ SPFT(ok);
|
|
|
|
+ //Serial.println("[OK]");
|
|
|
|
+ } else {
|
|
|
|
+ SPFT(failed);
|
|
|
|
+ //Serial.println("[failed]");
|
|
|
|
+ }
|
|
|
|
+ accelgyro.setMotionDetectionDuration(80);
|
|
|
|
+#endif
|
|
|
|
|
|
pinMode(LED_PIN, OUTPUT);
|
|
pinMode(LED_PIN, OUTPUT);
|
|
|
|
|
|
-//lcd.backlight();
|
|
|
|
-//lcd.setCursor(3,0);
|
|
|
|
-//lcd.print("Hello, world!");
|
|
|
|
- #if defined(HAS_18x4LCD)
|
|
|
|
- #include "LiquidCrystal_I2C_setup.h"
|
|
|
|
- #endif
|
|
|
|
|
|
+#if defined(HAS_18x4LCD)
|
|
|
|
+ #include "LiquidCrystal_I2C_setup.h"
|
|
|
|
+#endif
|
|
// setZeroMotionDetectionThreshold(154);
|
|
// setZeroMotionDetectionThreshold(154);
|
|
|
|
|
|
|
|
|
|
#if defined(HAS_nRF24L01)
|
|
#if defined(HAS_nRF24L01)
|
|
- radio.begin();
|
|
|
|
- radio.openWritingPipe(address);
|
|
|
|
- radio.setPALevel(RF24_PA_MIN);
|
|
|
|
- radio.stopListening();
|
|
|
|
|
|
+ Serial.print("radio init;");
|
|
|
|
+ radio.begin();
|
|
|
|
+ radio.openWritingPipe(address);
|
|
|
|
+ radio.setPALevel(RF24_PA_MIN);
|
|
|
|
+ radio.stopListening(); Serial.println("[OK]");
|
|
#endif
|
|
#endif
|
|
|
|
|
|
}
|
|
}
|
|
@@ -130,8 +123,15 @@ void setup()
|
|
|
|
|
|
void loop()
|
|
void loop()
|
|
{
|
|
{
|
|
-
|
|
|
|
- u8x8log.print("millis=");
|
|
|
|
|
|
+if ( t < millis() ) {
|
|
|
|
+ t = millis() + 15000; // every 15 seconds
|
|
|
|
+ // u8g2.print("\f"); // \f = form feed: clear the screen
|
|
|
|
+ }
|
|
|
|
+ // u8g2.print("millis=");
|
|
|
|
+ // u8g2.print(millis());
|
|
|
|
+ // u8g2.print("\n");
|
|
|
|
+
|
|
|
|
+ Serial.println("[L]");
|
|
//uint8_t tiles[8] = { B00001111,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0};
|
|
//uint8_t tiles[8] = { B00001111,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0};
|
|
//u8x8.drawTile(0, U8LOG_HEIGHT+1, 1, tiles);
|
|
//u8x8.drawTile(0, U8LOG_HEIGHT+1, 1, tiles);
|
|
|
|
|