first commit, Denk proof backuping
This commit is contained in:
commit
9b52e0a9dc
45
.vscode/c_cpp_properties.json
vendored
Normal file
45
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Mac",
|
||||||
|
"includePath": [
|
||||||
|
"/usr/include",
|
||||||
|
"/usr/local/include"
|
||||||
|
],
|
||||||
|
"browse": {
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": ""
|
||||||
|
},
|
||||||
|
"macFrameworkPath": [
|
||||||
|
"/System/Library/Frameworks",
|
||||||
|
"/Library/Frameworks"
|
||||||
|
],
|
||||||
|
"intelliSenseMode": "macos-clang-x64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"/usr/include",
|
||||||
|
"/usr/local/include"
|
||||||
|
],
|
||||||
|
"browse": {
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": ""
|
||||||
|
},
|
||||||
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Win32",
|
||||||
|
"includePath": [
|
||||||
|
"C:/RB3rt/sdk/common/ev3api",
|
||||||
|
"C:/RB3rt/sdk/common/library/lib-ev3cxx"
|
||||||
|
],
|
||||||
|
"browse": {
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": ""
|
||||||
|
},
|
||||||
|
"intelliSenseMode": "windows-msvc-x64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
49
.vscode/settings.json
vendored
Normal file
49
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"files.insertFinalNewline": true,
|
||||||
|
"files.associations": {
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
|
}
|
||||||
|
}
|
59
.vscode/tasks.json
vendored
Normal file
59
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
// Support task for EV3RT and EV3CXX
|
||||||
|
// Author: Jaroslav Páral (jarekparal)
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "C:\\RB3rt\\Make.bat",
|
||||||
|
"args": [
|
||||||
|
"-b",
|
||||||
|
"${fileDirname}"
|
||||||
|
],
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": {
|
||||||
|
"_id": "build",
|
||||||
|
"isDefault": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "upload",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "C:\\RB3rt\\Make.bat",
|
||||||
|
"args": [
|
||||||
|
"-u"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "make",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "C:\\RB3rt\\Make.bat",
|
||||||
|
"args": [
|
||||||
|
"-m",
|
||||||
|
"${fileDirname}"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "lorris",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "c:\\Lorris\\Lorris.exe",
|
||||||
|
"args": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "help",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "start",
|
||||||
|
"args": [
|
||||||
|
"",
|
||||||
|
"https://rb3rt.readthedocs.org"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
42
.vscode/tasks.json.old
vendored
Normal file
42
.vscode/tasks.json.old
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
// Support task for EV3RT and EV3CXX
|
||||||
|
// Author: Jaroslav Páral (jarekparal)
|
||||||
|
"version": "0.1.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"taskName": "build",
|
||||||
|
"command": "C:\\RB3rt\\Make.bat",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"args": ["-b", "${fileDirname}"],
|
||||||
|
"showOutput": "always"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"taskName": "upload",
|
||||||
|
"command": "C:\\RB3rt\\Make.bat",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"args": ["-u"],
|
||||||
|
"showOutput": "always"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"taskName": "make",
|
||||||
|
"command": "C:\\RB3rt\\Make.bat",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"args": ["-m", "${fileDirname}"],
|
||||||
|
"showOutput": "always"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"taskName": "lorris",
|
||||||
|
"command": "c:\\Lorris\\Lorris.exe",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"args": [""],
|
||||||
|
"showOutput": "always"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"taskName": "help",
|
||||||
|
"command": "start",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"args": ["", "https://rb3rt.readthedocs.org"],
|
||||||
|
"showOutput": "always"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 Jaroslav Páral
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
12
Makefile.inc
Normal file
12
Makefile.inc
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
APPL_COBJS +=
|
||||||
|
|
||||||
|
APPL_CXXOBJS +=
|
||||||
|
|
||||||
|
SRCLANG := c++
|
||||||
|
|
||||||
|
ifdef CONFIG_EV3RT_APPLICATION
|
||||||
|
|
||||||
|
# Include libraries
|
||||||
|
include $(EV3RT_SDK_LIB_DIR)/lib-ev3cxx/Makefile
|
||||||
|
|
||||||
|
endif
|
19
app.cfg
Normal file
19
app.cfg
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
INCLUDE("app_common.cfg");
|
||||||
|
|
||||||
|
#include "app.h"
|
||||||
|
|
||||||
|
DOMAIN(TDOM_APP) {
|
||||||
|
CRE_TSK(MAIN_TASK, { TA_ACT, 0, main_task, TMIN_APP_TPRI + 1, STACK_SIZE, NULL });
|
||||||
|
|
||||||
|
// periodic task PRD_TSK_1 that will start automatically
|
||||||
|
//CRE_TSK(PRD_TSK_1, { TA_NULL, 0, periodic_task_1, PRIORITY_PRD_TSK_1, STACK_SIZE, NULL });
|
||||||
|
//EV3_CRE_CYC(CYC_PRD_TSK_1, { TA_STA, PRD_TSK_1, task_activator, PERIOD_PRD_TSK_1, 0 });
|
||||||
|
|
||||||
|
// periodic task PRD_TSK_2 that will not start automatically
|
||||||
|
//CRE_TSK(PRD_TSK_2, { TA_NULL, 0, periodic_task_2, PRIORITY_PRD_TSK_2, STACK_SIZE, NULL });
|
||||||
|
//EV3_CRE_CYC(CYC_PRD_TSK_2, { TA_NULL, PRD_TSK_2, task_activator, PERIOD_PRD_TSK_2, 0 });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ATT_MOD("app.o");
|
||||||
|
|
277
app.cpp
Normal file
277
app.cpp
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
#include "ev3cxx.h"
|
||||||
|
#include "app.h"
|
||||||
|
#include <ctime>
|
||||||
|
#include <functional>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Change notes:
|
||||||
|
|
||||||
|
0.4.0 - 'HELGA' (#50)
|
||||||
|
Fixed
|
||||||
|
|
||||||
|
0.3.0 - 'INGRID' (#42)
|
||||||
|
Some weird magic in calculations of motor speeds
|
||||||
|
|
||||||
|
0.2.7 - 'ERIKA' (#36)
|
||||||
|
Created function run_short for picking up all cubes on short sides
|
||||||
|
|
||||||
|
0.2.5 - 'ERIKA' (#27)
|
||||||
|
Added "boot-up melody"
|
||||||
|
Added btnEnter.waitForClick() for program start
|
||||||
|
Fixed display printouts
|
||||||
|
HW change: gearbox on the left gear changed to 1:1
|
||||||
|
|
||||||
|
0.2.0 - 'ERIKA' (#15)
|
||||||
|
Tested functions for opening and closing doors, updated speeds
|
||||||
|
Added idealMPWRS - base MPWRS to update back to, testing with different speeds for left and right wheels
|
||||||
|
|
||||||
|
0.1.1 - 'ERIKA' (#2)
|
||||||
|
Re-created structs for version, MPWRS, note
|
||||||
|
Re-created function for opening and closing door and function for generating Version ID
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Structure to hole current version (major, minor, patch, codename, id, release_date)
|
||||||
|
MAJOR - Major version number
|
||||||
|
MINOR - Minor changes in code
|
||||||
|
PATCH - Mostly just for testing
|
||||||
|
ID - Increment every time with new version
|
||||||
|
CODENAME - (String) Version name
|
||||||
|
RELEASE_DATE - when was current version released
|
||||||
|
*/
|
||||||
|
struct version
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
|
int patch;
|
||||||
|
std::tm relDate;
|
||||||
|
const char *codename;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Structure to hold motor powers (left and right)
|
||||||
|
struct MPWRS
|
||||||
|
{
|
||||||
|
int lMotorPWR;
|
||||||
|
int rMotorPWR;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Structure to hold notes
|
||||||
|
struct note
|
||||||
|
{
|
||||||
|
uint16_t frequency;
|
||||||
|
int32_t duration;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function to create new program version
|
||||||
|
version createVersion(int versionID, const char *codename, int major, int minor, int patch, int day, int month, int year, int hour, int minute)
|
||||||
|
{
|
||||||
|
version retVersion;
|
||||||
|
retVersion.id = versionID;
|
||||||
|
retVersion.major = major;
|
||||||
|
retVersion.minor = minor;
|
||||||
|
retVersion.patch = patch;
|
||||||
|
retVersion.codename = codename;
|
||||||
|
retVersion.relDate.tm_sec = 0;
|
||||||
|
retVersion.relDate.tm_min = minute;
|
||||||
|
retVersion.relDate.tm_hour = hour;
|
||||||
|
retVersion.relDate.tm_mday = day;
|
||||||
|
retVersion.relDate.tm_mon = month;
|
||||||
|
retVersion.relDate.tm_year = year - 1900;
|
||||||
|
retVersion.relDate.tm_isdst = 0;
|
||||||
|
std::mktime(&retVersion.relDate);
|
||||||
|
|
||||||
|
return retVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to open door
|
||||||
|
void open_door(ev3cxx::Motor hinge)
|
||||||
|
{
|
||||||
|
hinge.onForDegrees(-25, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to close door
|
||||||
|
void close_door(ev3cxx::Motor hinge)
|
||||||
|
{
|
||||||
|
hinge.onForDegrees(25, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function to pick up all cubes on shorter side
|
||||||
|
return true if ran till the end and false if stopped by middle button
|
||||||
|
*/
|
||||||
|
bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSensor gyro)
|
||||||
|
{
|
||||||
|
const int LEFT_THRESHOLD = -3;
|
||||||
|
const int RIGHT_THRESHOLD = 3;
|
||||||
|
const int CORRECTION_MULTIPLIER = 3;
|
||||||
|
const int CYCLE_LIMIT = 0;//75;
|
||||||
|
|
||||||
|
gyro.resetHard();
|
||||||
|
ev3cxx::BrickButton btnEnter(ev3cxx::BrickButtons::ENTER); // Middle button
|
||||||
|
MPWRS motor_powers;
|
||||||
|
// Reset both motor's powers
|
||||||
|
motor_powers.lMotorPWR = idealMPWRS.lMotorPWR;
|
||||||
|
motor_powers.rMotorPWR = idealMPWRS.rMotorPWR;
|
||||||
|
|
||||||
|
int lCounter = 0;
|
||||||
|
int rCounter = 0;
|
||||||
|
|
||||||
|
bool run = true;
|
||||||
|
int cycleCounter = 0;
|
||||||
|
int lastRProblem = 0;
|
||||||
|
int lastLProblem = 0;
|
||||||
|
while (run)
|
||||||
|
{
|
||||||
|
|
||||||
|
motors.on(motor_powers.lMotorPWR, motor_powers.rMotorPWR);
|
||||||
|
tslp_tsk(50);
|
||||||
|
|
||||||
|
|
||||||
|
// Reset both motor's powers
|
||||||
|
motor_powers.lMotorPWR = idealMPWRS.lMotorPWR;
|
||||||
|
motor_powers.rMotorPWR = idealMPWRS.rMotorPWR;
|
||||||
|
|
||||||
|
// Get power of both motors
|
||||||
|
int lPower = motors.leftMotor().currentPower();
|
||||||
|
int rPower = motors.rightMotor().currentPower();
|
||||||
|
int angle = gyro.angle();
|
||||||
|
|
||||||
|
ev3cxx::display.format(4, "Left motor: % \nRight motor: % \nCycles: % \nAngle: % ") % lPower % rPower % cycleCounter % angle;
|
||||||
|
|
||||||
|
// Emergency break using middle button (BTN_ENTER)
|
||||||
|
if (btnEnter.isPressed())
|
||||||
|
{
|
||||||
|
run = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check gyro angle and change driving speed to fix the angle
|
||||||
|
// To the left
|
||||||
|
if (angle > LEFT_THRESHOLD) {
|
||||||
|
//ev3_speaker_play_tone(NOTE_A5, 250);
|
||||||
|
int correction = angle - LEFT_THRESHOLD;
|
||||||
|
motor_powers.lMotorPWR += correction * CORRECTION_MULTIPLIER;
|
||||||
|
ev3_speaker_play_tone(correction*1000,50);
|
||||||
|
// Check if the motor is stuck
|
||||||
|
if(lPower == 0){
|
||||||
|
ev3_speaker_play_tone(NOTE_A5,250);
|
||||||
|
|
||||||
|
// Set lastProblem na cycleCounter because there is a problem
|
||||||
|
lastLProblem = cycleCounter;
|
||||||
|
|
||||||
|
// Check if lastProblem was in previous cycle
|
||||||
|
if(cycleCounter - 1 == lastLProblem){
|
||||||
|
lCounter += 1;
|
||||||
|
// If 5 problems occured than try to fix the problem
|
||||||
|
if(lCounter == 6){
|
||||||
|
ev3_speaker_play_tone(NOTE_C4, 250);
|
||||||
|
ev3cxx::setColor(RED);
|
||||||
|
}
|
||||||
|
// Reset counter
|
||||||
|
} else {
|
||||||
|
lCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// To the right
|
||||||
|
} else if (angle < RIGHT_THRESHOLD) {
|
||||||
|
//ev3_speaker_play_tone(NOTE_A4, 250);
|
||||||
|
int correction = angle - RIGHT_THRESHOLD;
|
||||||
|
motor_powers.rMotorPWR += correction * CORRECTION_MULTIPLIER;
|
||||||
|
ev3_speaker_play_tone(correction*1000,50);
|
||||||
|
// Check if the motor is stuck
|
||||||
|
if(rPower == 0){
|
||||||
|
ev3_speaker_play_tone(NOTE_A4,250);
|
||||||
|
|
||||||
|
// Set lastProblem na cycleCounter because there is a problem
|
||||||
|
lastRProblem = cycleCounter;
|
||||||
|
|
||||||
|
// Check if lastProblem was in previous cycle
|
||||||
|
if(cycleCounter - 1 == lastRProblem){
|
||||||
|
rCounter += 1;
|
||||||
|
// If 5 problems occured than try to fix the problem
|
||||||
|
if(rCounter == 6){
|
||||||
|
ev3_speaker_play_tone(NOTE_C5, 250);
|
||||||
|
ev3cxx::setColor(ORANGE);
|
||||||
|
}
|
||||||
|
// Reset counter
|
||||||
|
} else {
|
||||||
|
rCounter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cycleCounter++;
|
||||||
|
|
||||||
|
if(cycleCounter == CYCLE_LIMIT) {
|
||||||
|
run = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void main_task(intptr_t unused)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Create version info
|
||||||
|
// version createVersion(int versionID, const char *codename, int major, int minor, int patch, int day, int month, int year, int hour, int minute)
|
||||||
|
const version VERSION = createVersion(51, "HELGA", 0, 4, 0, 8, 11, 2023, 15, 40);
|
||||||
|
|
||||||
|
// Set-up screen
|
||||||
|
ev3cxx::display.resetScreen();
|
||||||
|
ev3cxx::display.setFont(EV3_FONT_MEDIUM);
|
||||||
|
|
||||||
|
// Print version information on screen
|
||||||
|
ev3cxx::display.format(" DOBREMYSL\nVERSION: % .% .% #% \nNAME: % ") % VERSION.major % VERSION.minor % VERSION.patch % VERSION.id % VERSION.codename;
|
||||||
|
|
||||||
|
// Play starting melody
|
||||||
|
ev3_speaker_set_volume(100);
|
||||||
|
ev3_speaker_play_tone(NOTE_C5, 400);
|
||||||
|
tslp_tsk(500);
|
||||||
|
ev3_speaker_play_tone(NOTE_F5, 400);
|
||||||
|
tslp_tsk(500);
|
||||||
|
ev3_speaker_play_tone(NOTE_G5, 400);
|
||||||
|
tslp_tsk(500);
|
||||||
|
ev3_speaker_play_tone(NOTE_A5, 100);
|
||||||
|
tslp_tsk(200);
|
||||||
|
ev3_speaker_play_tone(NOTE_F5, 650);
|
||||||
|
tslp_tsk(950);
|
||||||
|
ev3_speaker_play_tone(NOTE_F4, 75);
|
||||||
|
tslp_tsk(110);
|
||||||
|
ev3_speaker_play_tone(NOTE_F4, 75);
|
||||||
|
tslp_tsk(110);
|
||||||
|
ev3_speaker_play_tone(NOTE_F4, 75);
|
||||||
|
tslp_tsk(200);
|
||||||
|
|
||||||
|
// Set up motor powers
|
||||||
|
MPWRS idealMPWRS;
|
||||||
|
idealMPWRS.lMotorPWR = 87;
|
||||||
|
idealMPWRS.rMotorPWR = 50;
|
||||||
|
|
||||||
|
MPWRS motor_powers;
|
||||||
|
motor_powers.lMotorPWR = idealMPWRS.lMotorPWR;
|
||||||
|
motor_powers.rMotorPWR = idealMPWRS.rMotorPWR;
|
||||||
|
|
||||||
|
// Set up motors
|
||||||
|
ev3cxx::Motor hinge(ev3cxx::MotorPort::A, ev3cxx::MotorType::LARGE); // Hinge motor
|
||||||
|
ev3cxx::MotorTank motors(ev3cxx::MotorPort::B, ev3cxx::MotorPort::C); // Tank motors
|
||||||
|
ev3cxx::GyroSensor gyro(ev3cxx::SensorPort::S1); // gyro sensor
|
||||||
|
|
||||||
|
// Set up buttons
|
||||||
|
ev3cxx::BrickButton btnEnter(ev3cxx::BrickButtons::ENTER); // Middle button
|
||||||
|
|
||||||
|
// Start program
|
||||||
|
btnEnter.waitForClick();
|
||||||
|
|
||||||
|
//turn_left(motors);
|
||||||
|
bool side_1 = run_short_side(motors, motor_powers, gyro);
|
||||||
|
if(!side_1) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
ev3_speaker_play_tone(NOTE_G5, 500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
106
app.h
Normal file
106
app.h
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* TOPPERS/EV3RT
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 by Yixiao Li <liyixiao7@gmail.com>
|
||||||
|
*
|
||||||
|
* The above copyright holders grant permission gratis to use,
|
||||||
|
* duplicate, modify, or redistribute (hereafter called use) this
|
||||||
|
* software (including the one made by modifying this software),
|
||||||
|
* provided that the following four conditions (1) through (4) are
|
||||||
|
* satisfied.
|
||||||
|
*
|
||||||
|
* (1) When this software is used in the form of source code, the above
|
||||||
|
* copyright notice, this use conditions, and the disclaimer shown
|
||||||
|
* below must be retained in the source code without modification.
|
||||||
|
*
|
||||||
|
* (2) When this software is redistributed in the forms usable for the
|
||||||
|
* development of other software, such as in library form, the above
|
||||||
|
* copyright notice, this use conditions, and the disclaimer shown
|
||||||
|
* below must be shown without modification in the document provided
|
||||||
|
* with the redistributed software, such as the user manual.
|
||||||
|
*
|
||||||
|
* (3) When this software is redistributed in the forms unusable for the
|
||||||
|
* development of other software, such as the case when the software
|
||||||
|
* is embedded in a piece of equipment, either of the following two
|
||||||
|
* conditions must be satisfied:
|
||||||
|
*
|
||||||
|
* (a) The above copyright notice, this use conditions, and the
|
||||||
|
* disclaimer shown below must be shown without modification in
|
||||||
|
* the document provided with the redistributed software, such as
|
||||||
|
* the user manual.
|
||||||
|
*
|
||||||
|
* (b) How the software is to be redistributed must be reported to the
|
||||||
|
* TOPPERS Project according to the procedure described
|
||||||
|
* separately.
|
||||||
|
*
|
||||||
|
* (4) The above copyright holders and the TOPPERS Project are exempt
|
||||||
|
* from responsibility for any type of damage directly or indirectly
|
||||||
|
* caused from the use of this software and are indemnified by any
|
||||||
|
* users or end users of this software from any and all causes of
|
||||||
|
* action whatsoever.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS." THE ABOVE COPYRIGHT HOLDERS AND
|
||||||
|
* THE TOPPERS PROJECT DISCLAIM ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, ITS APPLICABILITY TO A PARTICULAR
|
||||||
|
* PURPOSE. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS AND THE
|
||||||
|
* TOPPERS PROJECT BE LIABLE FOR ANY TYPE OF DAMAGE DIRECTLY OR
|
||||||
|
* INDIRECTLY CAUSED FROM THE USE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Header file of sample program
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common header files
|
||||||
|
*/
|
||||||
|
#include "ev3api.h"
|
||||||
|
#include "target_test.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task priorities (smaller number has higher priority)
|
||||||
|
*/
|
||||||
|
#define PRIORITY_MAIN_TASK (TMIN_APP_TPRI + 1)
|
||||||
|
/* Main task priority */
|
||||||
|
/* Must by higher then HIGH_PRIORITY */
|
||||||
|
|
||||||
|
#define HIGH_PRIORITY (TMIN_APP_TPRI + 2)
|
||||||
|
#define MID_PRIORITY (TMIN_APP_TPRI + 3)
|
||||||
|
#define LOW_PRIORITY (TMIN_APP_TPRI + 4)
|
||||||
|
|
||||||
|
#define PRIORITY_PRD_TSK_1 TMIN_APP_TPRI
|
||||||
|
#define PRIORITY_PRD_TSK_2 TMIN_APP_TPRI
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task periods in ms
|
||||||
|
*/
|
||||||
|
//#define PERIOD_PRD_TSK_1 (100)
|
||||||
|
//#define PERIOD_PRD_TSK_2 (500)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default task stack size in bytes
|
||||||
|
*/
|
||||||
|
#ifndef STACK_SIZE
|
||||||
|
#define STACK_SIZE 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prototypes for configuration
|
||||||
|
*/
|
||||||
|
#ifndef TOPPERS_MACRO_ONLY
|
||||||
|
|
||||||
|
extern void main_task(intptr_t);
|
||||||
|
// extern void periodic_task_1(intptr_t);
|
||||||
|
// extern void periodic_task_2(intptr_t);
|
||||||
|
|
||||||
|
// extern void task_activator(intptr_t tskid);
|
||||||
|
|
||||||
|
#endif /* TOPPERS_MACRO_ONLY */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
28
keybindings.json
Normal file
28
keybindings.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Place your key bindings in this file to overwrite the defaults
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "f5",
|
||||||
|
"command": "workbench.action.tasks.runTask",
|
||||||
|
"args": "build"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "f6",
|
||||||
|
"command": "workbench.action.tasks.runTask",
|
||||||
|
"args": "upload"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "f7",
|
||||||
|
"command": "workbench.action.tasks.runTask",
|
||||||
|
"args": "make"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "f8",
|
||||||
|
"command": "workbench.action.tasks.runTask",
|
||||||
|
"args": "lorris"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "f9",
|
||||||
|
"command": "workbench.action.tasks.runTask",
|
||||||
|
"args": "help"
|
||||||
|
}
|
||||||
|
]
|
Reference in New Issue
Block a user