Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2019-2020
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matteo Cucchi
2019-2020
Commits
fc4d91f6
Verified
Commit
fc4d91f6
authored
May 28, 2020
by
Andrea Trentini
Browse files
Options
Downloads
Patches
Plain Diff
plummino usabile
parent
8422a97c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Esempi/Plummino/Plummino.ino
+13
-144
13 additions, 144 deletions
Esempi/Plummino/Plummino.ino
with
13 additions
and
144 deletions
Esempi/Plummino/Plummino.ino
+
13
−
144
View file @
fc4d91f6
...
...
@@ -4,10 +4,12 @@
// TODO LOW splittare in più file
//
#define DEBUG
#define DEBUG
#include
<TaskScheduler.h>
#include
<Wire.h>
#include
<ESP8266WiFi.h>
#include
<WiFiUdp.h>
#include
<ArduinoOTA.h>
...
...
@@ -42,31 +44,11 @@ long hold=0;
String
command
=
""
;
#define MOTORS_CYCLE 100
// CHECK https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED/blob/master/examples/ssd1306_64x48_i2c/ssd1306_64x48_i2c.ino
#define SSD1306_LCDHEIGHT 48
#define SSD1306_LCDWIDTH 96
//#include <SPI.h>
#include
<Wire.h>
#include
<Adafruit_GFX.h>
#include
<Adafruit_SSD1306.h>
// SCL GPIO5
// SDA GPIO4
#define OLED_RESET 0 // GPIO0
Adafruit_SSD1306
oled
(
OLED_RESET
);
/* OLD OLED
#include <SFE_MicroOLED.h> // Include the SFE_MicroOLED library
#include <Wire.h> // Include Wire if you're using I2C
//#include <SPI.h> // Include SPI if you're using SPI
*/
#include
<Adafruit_Sensor.h>
#include
<Adafruit_HMC5883_U.h>
/* Assign a unique ID to this sensor at the same time */
//
#define HMC5883_ADDRESS_MAG
(
0x1E
>> 1)
Adafruit_HMC5883_Unified
mag
=
Adafruit_HMC5883_Unified
(
12345
);
#define HMC5883_ADDRESS_MAG 0x1E
Adafruit_HMC5883_Unified
mag
=
Adafruit_HMC5883_Unified
(
999
);
sensor_t
sensor
;
sensors_event_t
event
;
float
headingDegrees
;
...
...
@@ -97,20 +79,6 @@ int switchprog;
////#include <ArduinoOTA.h>
//#include <Arduino.h>
//////////////////////////////////
// MicroOLED Object Declaration //
/*
#define PIN_RESET 255
#define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D
MicroOLED oled(PIN_RESET, DC_JUMPER); // I2C Example
*/
// Global variables to help drawing
const
int
MAX_Y
=
SSD1306_LCDHEIGHT
;
//oled.getLCDHeight();
const
int
MIDDLE_Y
=
MAX_Y
/
2
;
const
int
MAX_X
=
SSD1306_LCDWIDTH
;
//oled.getLCDWidth();
const
int
MIDDLE_X
=
MAX_X
/
2
;
const
int
PXLINE
=
9
;
//Motor shield I2C Address: 0x30
//PWM frequency: 1000Hz(1kHz)
...
...
@@ -142,10 +110,9 @@ byte packetBuffer[MAX_MSG_SIZE]; //buffer to hold incoming udp packet
////////////////////////////////// Tasks
//#define MOTORS
//#define OLED
#define SERIAL
#define SERIALDRIVE
//
#define SENSORS
#define SENSORS
//#define STRATEGY
#define GPS
#define IMALIVE
...
...
@@ -156,11 +123,6 @@ void callbackMotors();
Task
taskMotors
(
MOTORS_CYCLE
,
TASK_FOREVER
,
&
callbackMotors
);
#endif
#ifdef OLED
void
callbackStatusOled
();
Task
taskStatusOled
(
100
,
TASK_FOREVER
,
&
callbackStatusOled
);
#endif
#ifdef SERIAL
void
callbackStatusSerial
();
Task
taskStatusSerial
(
500
,
TASK_FOREVER
,
&
callbackStatusSerial
);
...
...
@@ -208,27 +170,8 @@ WiFiUDP Udp;
/////////////////////////////////////////////////////
void
setupDisplay
(){
//oled.begin(SSD1306_SWITCHCAPVCC, 0x1E); // initialize with the I2C addr 0x3C (for the 64x48)
oled
.
begin
();
// Initialize the OLED
oled
.
setTextSize
(
1
);
oled
.
setTextColor
(
WHITE
);
/* TODO check cosa c'è nella nuova lib
oled.clear(PAGE); // Clear the display's internal memory
oled.clear(ALL); // Clear the library's display buffer
*/
oled
.
clearDisplay
();
//testdrawline();
oledprint
(
F
(
"setup"
),
0
,
0
);
}
void
setup
()
{
pinMode
(
LED_BUILTIN
,
OUTPUT
);
collisionReset
();
swSer
.
begin
(
9600
);
...
...
@@ -280,11 +223,6 @@ void setup() {
taskMotors
.
enable
();
#endif
#ifdef OLED
runner
.
addTask
(
taskStatusOled
);
taskStatusOled
.
enable
();
#endif
#ifdef SERIAL
runner
.
addTask
(
taskStatusSerial
);
taskStatusSerial
.
enable
();
...
...
@@ -333,8 +271,10 @@ void pingLed() {
void
callbackSensors
()
{
/////////////////////////////////////
// COMPASS
//Serial.println("pre bussola");
mag
.
getSensor
(
&
sensor
);
mag
.
getEvent
(
&
event
);
//Serial.println("post bussola");
// Hold the module so that Z is pointing 'up' and you can measure the heading with x&y
// Calculate heading when the magnetometer is level, then correct for signs of axis.
...
...
@@ -386,6 +326,7 @@ void callbackSensors() {
void
callbackGPS
()
{
////////////////////////////////////////////
// GPS
//Serial.println("gps...");
// TinyGps++
while
(
swSer
.
available
())
{
...
...
@@ -547,19 +488,6 @@ void printLatLon() {
//////////////////////////////////
/*
void oledprint(String s) {
//oled.setFontType(2); // set font type, please see declaration in SFE_MicroOLED.cpp
oled.print(s);
oled.display();
}
*/
void
oledprint
(
String
s
,
int
x
,
int
y
)
{
oled
.
setCursor
(
x
,
y
);
oled
.
print
(
s
);
}
#define ARM 5000
void
callbackStrategy
()
{
...
...
@@ -600,67 +528,6 @@ void callbackStrategy() {
fullStop
();
}
void
callbackStatusOled
()
{
/*
oled.clear(PAGE); // Clear the display's internal memory
oled.clear(ALL); // Clear the library's display buffer
*/
oled
.
clearDisplay
();
// compass
oledprint
(
"h:"
,
0
,
0
);
oled
.
print
(
headingDegrees
);
// collision distance TODO trovare alternativa
//oled.line(MAX_X-2,MAX_Y-1,MAX_X-2,MAX_X-2-obstacleDistance);
/* dir, speed
oledprint("d:",0,1*PXLINE);
oled.print(rudder);
oledprint("s:",0,2*PXLINE);
oled.print(speed);
*/
// lat long
oledprint
(
"lat:"
,
0
,
1
*
PXLINE
);
oled
.
print
(
latitude
);
oledprint
(
"lon:"
,
0
,
2
*
PXLINE
);
oled
.
print
(
longitude
);
/*
oled.setCursor(0,4*PXLINE);
oled.print(left);
oled.setCursor(MIDDLE_X+20,4*PXLINE);
oled.print(right);
*/
// TODO trovare alternativa
//oled.line(MIDDLE_X,MAX_Y,MIDDLE_X+(4*rudder),MAX_Y-PXLINE);
/*
oledprint("X:",0,0);
oled.print(gX);
oled.print(",");
oled.print(gXbase);
oledprint("Y:",0,9);
oled.print(gY);
oled.print(",");
oled.println(gYbase);
oledprint("Z:",0,17);
oled.print(gZ);
oled.print(",");
oled.print(gZbase);
*/
oled
.
display
();
delay
(
1
);
//statusSerial();
//testdrawline();
//testscrolltext();
}
void
callbackMotors
()
{
// pochi comandi per fare qualche demo
...
...
@@ -760,12 +627,14 @@ void compassDetails() {
}
void
collisionReset
()
{
// strano dover fare 'sta cosa, se no non tornano su, mah!
pinMode
(
COLLISION_LEFT
,
OUTPUT
);
pinMode
(
COLLISION_RIGHT
,
OUTPUT
);
digitalWrite
(
COLLISION_LEFT
,
HIGH
);
digitalWrite
(
COLLISION_RIGHT
,
HIGH
);
pinMode
(
COLLISION_LEFT
,
INPUT
);
pinMode
(
COLLISION_RIGHT
,
INPUT
);
pinMode
(
COLLISION_LEFT
,
INPUT_PULLUP
);
pinMode
(
COLLISION_RIGHT
,
INPUT_PULLUP
);
// tra l'altro solo il left, ri-mah!
}
void
readAccelerometer
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment