Dezibot4 Lib
Introduction
This repository contains the Library for the Dezibot4.
It is ment to serve as an Arduino-Library. Therefore the rules for arduinolibrary develop apply:
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
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
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.
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
#ifndef ClassName_h
#define ClassName_h
class ClassName{
};
#endif //ClassName_h
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.
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,...)
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)
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
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}.
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.
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
Commitmessages
Commitmessages must follow the gitchangelog pattern.
Language
The language of the project is American English. That includes in particular but not exclusively:
- Sourcecode
- Commit Messages
- Documentation
A german documentation will be provided but does not replace the english documentation.
Documentation
.h Files
/**
* @file Dezibot.h
* @author your name (you@domain.com)
* @brief
* @date 2023-11-19
*
* @copyright Copyright (c) 2023
*
*/
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
/**
* @brief
* @param
* ...
* @return
*
*/
Arduino Settings
- Board: "ESP32-S3-USB-OTG"
- Upload Mode: "UART0 / Hardware CDC"
- USB Mode: "Hardware CDC and JTAG"
- Programmer: "Esptool"
- USB CDC on Boot: Enabled
Using arduino-cli
to compile and upload:
arduino-cli upload /Users/jo/Documents/Arduino/theSketch -p /dev/cu.usbmodem101 -b esp32:esp32:nora_w10
arduino-cli compile /Users/jo/Documents/Arduino/theSketch -p /dev/cu.usbmodem101 -b esp32:esp32:nora_w10
Display
It is important to specify the SDA and SCL ports by using Wire.begin(SDA, SCL)
.
#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);
}