mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-19 11:01:46 +02:00
Merge branch 'develop' of ssh://gitlab.imn.htwk-leipzig.de:2244/dezibot/lib into develop
This commit is contained in:
commit
dbe97dc94c
100
README.md
100
README.md
@ -1,7 +1,10 @@
|
||||
# Dezibot4 Lib
|
||||
|
||||
## Introduction
|
||||
|
||||
This repository contains the Library for the Dezibot4.<br>
|
||||
It is ment to serve as an Arduino-Library. Therefore the rules for arduinolibrary develop apply:<br>
|
||||
|
||||
* [Styleguide](https://docs.arduino.cc/learn/contributions/arduino-library-style-guide)
|
||||
* [Libraryspecification](https://arduino.github.io/arduino-cli/0.35/library-specification/)
|
||||
* [Submission-requirements](https://github.com/arduino/library-registry/blob/main/FAQ.md#submission-requirements)
|
||||
@ -9,22 +12,30 @@ It is ment to serve as an Arduino-Library. Therefore the rules for arduinolibrar
|
||||
In the following the most important points and custom conventions are introduced.
|
||||
|
||||
## Code Conventions
|
||||
|
||||
### Don't pass reference
|
||||
To allow easy usability for users not familier with C++, prevent passing around references. It is better to use accessmethods
|
||||
|
||||
To allow easy usability for users not familier with C++, prevent passing around references. It is better to use
|
||||
accessmethods
|
||||
|
||||
### Naming
|
||||
|
||||
* methods are named in lowerCamelCase
|
||||
* classes are named in UpperCamelCase
|
||||
* folders containing components are named in lowerCamelCase
|
||||
* methods are named in lowerCamelCase
|
||||
* constants are named in ALL_CAPS_SNAKE_CASE
|
||||
* Values of Enums follow the conventions of constants
|
||||
|
||||
### Bytestream
|
||||
|
||||
Every class that implements Byte-Based Communication needs to implement the Arduino Streaminterface
|
||||
|
||||
### Components
|
||||
|
||||
Every component has a single .h file and one or more .cpp files.<br>
|
||||
Every component is placed in a seperate folder under src/ that is named equvivalent to the class.
|
||||
The minimal structure of any .h file is<br>
|
||||
|
||||
```c++
|
||||
#ifndef ClassName_h
|
||||
#define ClassName_h
|
||||
@ -35,28 +46,51 @@ class ClassName{
|
||||
```
|
||||
|
||||
## Design Paradigm
|
||||
During desgin, the Dezibot isn't describe using it's part but instead it's functionality. Under the top-level Dezibotclass, there is a class for every functionality of the robot. Each of that classes consists of two parts.
|
||||
|
||||
During desgin, the Dezibot isn't describe using it's part but instead it's functionality. Under the top-level
|
||||
Dezibotclass, there is a class for every functionality of the robot. Each of that classes consists of two parts.
|
||||
|
||||
### Part Instances
|
||||
Each component contains instances of every Robotpart that is used in that component. For example the Motion component contains two motorinstances, one for motorEast and one for motorWest.
|
||||
Using these instances, it is possible to access more specific methods that interacts directly with the component (configure it, setSpeed,...)
|
||||
|
||||
Each component contains instances of every Robotpart that is used in that component. For example the Motion component
|
||||
contains two motorinstances, one for motorEast and one for motorWest.
|
||||
Using these instances, it is possible to access more specific methods that interacts directly with the component (
|
||||
configure it, setSpeed,...)
|
||||
|
||||
### Abstractions
|
||||
The components constains abstractions that combines multiple partMethods to ease the usability. For example for the motioncomponent provides an abstraction for the forwardmovement, that involves two motors and even another component (MotionDetection)
|
||||
|
||||
The components constains abstractions that combines multiple partMethods to ease the usability. For example for the
|
||||
motioncomponent provides an abstraction for the forwardmovement, that involves two motors and even another component (
|
||||
MotionDetection)
|
||||
|
||||
## Contributing
|
||||
When contributing to the project please follow the rules below. At first, follow all rules from this readme. Further rules apply to the usage of git
|
||||
|
||||
When contributing to the project please follow the rules below. At first, follow all rules from this readme. Further
|
||||
rules apply to the usage of git
|
||||
|
||||
### Branching
|
||||
|
||||
Whenever working on the project, create a new branch from the current state of Develop.
|
||||
Branches should be named as `prefix/#issueid-shortdescription` where prefix is from {feature,fix,refactor}.<br>
|
||||
When a branch is ready to be used in production, create a mergerequest.
|
||||
|
||||
### Mergerequests
|
||||
The target of each Mergerequest must be the Develop-Branch. Before the merge, each request must be approved by at least one person with Owner role.<br>
|
||||
|
||||
The target of each Mergerequest must be the Develop-Branch. Before the merge, each request must be approved by at least
|
||||
one person with Owner role.<br>
|
||||
The approve process should consider especially the documentation, naming, implementation.
|
||||
When the merge is approved and no more commits are added, the last commit must increment the versionnumber in the library.properties file, following the rules of [Semantic Versioning](https://semver.org/)
|
||||
When the merge is approved and no more commits are added, the last commit must increment the versionnumber in the
|
||||
library.properties file, following the rules of [Semantic Versioning](https://semver.org/)
|
||||
|
||||
### Commitmessages
|
||||
Commitmessages must follow the [gitchangelog](https://github.com/vaab/gitchangelog/blob/master/src/gitchangelog/gitchangelog.rc.reference) pattern.
|
||||
|
||||
Commitmessages must follow
|
||||
the [gitchangelog](https://github.com/vaab/gitchangelog/blob/master/src/gitchangelog/gitchangelog.rc.reference) pattern.
|
||||
|
||||
### Language
|
||||
|
||||
The language of the project is American English. That includes in particular but not exclusively:
|
||||
|
||||
* Sourcecode
|
||||
* Commit Messages
|
||||
* Documentation
|
||||
@ -64,7 +98,9 @@ The language of the project is American English. That includes in particular but
|
||||
A german documentation will be provided but does not replace the english documentation.
|
||||
|
||||
### Documentation
|
||||
|
||||
#### .h Files
|
||||
|
||||
```C++
|
||||
/**
|
||||
* @file Dezibot.h
|
||||
@ -77,7 +113,12 @@ A german documentation will be provided but does not replace the english documen
|
||||
*/
|
||||
|
||||
```
|
||||
|
||||
In the library, the `.h` files should be included using a relative path.
|
||||
For instance, in `src/Dezibot.h`, to include `src/motion/Motion.h`, you should write `#include "motion/Motion.h"`.
|
||||
|
||||
#### Methods
|
||||
|
||||
```C++
|
||||
/**
|
||||
* @brief
|
||||
@ -88,4 +129,43 @@ A german documentation will be provided but does not replace the english documen
|
||||
*/
|
||||
```
|
||||
|
||||
#### Arduino Settings
|
||||
|
||||
* Board: "ESP32-S3-USB-OTG"
|
||||
* Upload Mode: "UART0 / Hardware CDC"
|
||||
* USB Mode: "Hardware CDC and JTAG"
|
||||
* Programmer: "Esptool"
|
||||
|
||||
#### Display
|
||||
|
||||
It is important to specify the SDA and SCL ports by using `Wire.begin(SDA, SCL)`.
|
||||
|
||||
```c++
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 64
|
||||
|
||||
#define OLED_RESET -1
|
||||
#define SCREEN_ADDRESS 0x3C
|
||||
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
void Dezibot::begin(void) {
|
||||
Wire.begin(1, 2);
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
// Serial.println("SSD1306 allocation failed");
|
||||
for (;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
|
||||
// Draw a single pixel in white
|
||||
display.drawPixel(10, 10, SSD1306_WHITE);
|
||||
|
||||
// Show the display buffer on the screen. You MUST call display() after
|
||||
// drawing commands to make them visible on screen!
|
||||
display.display();
|
||||
vTaskDelay(2000);
|
||||
}
|
||||
```
|
||||
|
@ -19,21 +19,33 @@
|
||||
// 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
|
||||
#define SCREEN_ADDRESS 0x3C ///< 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);
|
||||
Wire.begin(1, 2);
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
Serial.println("SSD1306 allocation failed");
|
||||
for (;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
display.display();
|
||||
vTaskDelay(2000);
|
||||
display.clearDisplay();
|
||||
vTaskDelay(2000);
|
||||
|
||||
// Draw a single pixel in white
|
||||
display.drawPixel(10, 10, SSD1306_WHITE);
|
||||
|
||||
// Show the display buffer on the screen. You MUST call display() after
|
||||
// drawing commands to make them visible on screen!
|
||||
display.display();
|
||||
vTaskDelay(2000);
|
||||
|
||||
Serial.begin(9600);
|
||||
Serial.println("start");
|
||||
|
||||
@ -57,5 +69,14 @@ void Dezibot::begin(void) {
|
||||
|
||||
Serial.println(time_us);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.setCursor(10, 0);
|
||||
display.println(F("scroll"));
|
||||
display.display(); // Show initial text
|
||||
vTaskDelay(1000);
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user