From 3258396ae90defeec48097b2f47f4a641b3d9f8e Mon Sep 17 00:00:00 2001 From: Anton Jacker Date: Fri, 24 Nov 2023 15:16:43 +0100 Subject: [PATCH] test vTask and serial --- src/Dezibot.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ src/Dezibot.h | 26 ++++++++++++--------- 2 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 src/Dezibot.cpp diff --git a/src/Dezibot.cpp b/src/Dezibot.cpp new file mode 100644 index 0000000..509f068 --- /dev/null +++ b/src/Dezibot.cpp @@ -0,0 +1,61 @@ +// +// Created by Anton Jacker on 24.11.23. +// + + +#include "Dezibot.h" +#include +#include +#include +#include + + +#define SCREEN_WIDTH 128 // OLED display width, in pixels +#define SCREEN_HEIGHT 64 // OLED display height, in pixels + +// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) +// The pins for I2C are defined by the Wire-library. +// On an arduino UNO: A4(SDA), A5(SCL) +// On an arduino MEGA 2560: 20(SDA), 21(SCL) +// On an arduino LEONARDO: 2(SDA), 3(SCL), ... +#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) +#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 +Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); + +#define GPIO_LED 48 + +void Dezibot::begin(void) { + Adafruit_NeoPixel ledStrip = Adafruit_NeoPixel(3, GPIO_LED, NEO_GRB + NEO_KHZ800); + if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { + Serial.println(F("SSD1306 allocation failed")); + for (;;); // Don't proceed, loop forever + } + + display.clearDisplay(); + display.drawPixel(10, 10, SSD1306_WHITE); + + Serial.begin(9600); + Serial.println("start"); + + + vTaskDelay(1000); + + while (1) { + /* Blink off (output low) */ + ledStrip.setPixelColor(1, ledStrip.Color(100, 100, 100)); + ledStrip.show(); // Aktualisiere die Farbe des Pixels + vTaskDelay(1000); + /* Blink on (output high) */ + ledStrip.setPixelColor(1, ledStrip.Color(0, 0, 0)); + ledStrip.show(); // Aktualisiere die Farbe des Pixels + vTaskDelay(1000); + + struct timeval tv_now; + gettimeofday(&tv_now, NULL); + int64_t time_us = (int64_t) tv_now.tv_sec * 1000000L + (int64_t) tv_now.tv_usec; + + + Serial.println(time_us); + + } +} \ No newline at end of file diff --git a/src/Dezibot.h b/src/Dezibot.h index 11a60ce..07fe014 100644 --- a/src/Dezibot.h +++ b/src/Dezibot.h @@ -10,21 +10,24 @@ */ #ifndef Dezibot_h #define Dezibot_h -#include "Motion.h" -#include "LightDetection.h" -#include "ColorDetection.h" -#include "MultiColorLight.h" -#include "MotionDetection.h" -class Dezibot{ + +#include "motion/Motion.h" +#include "lightDetection/LightDetection.h" +#include "colorDetection/ColorDetection.h" +#include "multiColorLight/MultiColorLight.h" +#include "motionDetection/MotionDetection.h" + +class Dezibot { protected: public: -Motion motion; -LightDetection lightDetection; -ColorDetection colorDetection; -MultiColorLight multiColorLight; -MotionDetection motionDetection; + Motion motion; + LightDetection lightDetection; + ColorDetection colorDetection; + MultiColorLight multiColorLight; + MotionDetection motionDetection; + void begin(void); /* Display display IRCommuncation irCommuncation (beinhaltet Kommuniaktion / Annhärung...) @@ -42,4 +45,5 @@ String robotName */ }; + #endif //Dezibot_h \ No newline at end of file