interface
This commit is contained in:
commit
eac1fa7808
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "projet-tuteure-3a"]
|
||||
path = projet-tuteure-3a
|
||||
url = https://gitlab.univ-nantes.fr/E208835U/projet-tuteure-3a
|
9
CMakeLists.txt
Normal file
9
CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
project(smogogus)
|
||||
|
||||
add_definitions("-x c++")
|
||||
include_directories(${PROJECT_SOURCE_DIR})
|
||||
set_source_files_properties(projet-tuteure-3a/photores.ino PROPERTIES LANGUAGE CXX)
|
||||
add_executable(app projet-tuteure-3a/motorController.cpp projet-tuteure-3a/photores.ino main.cpp)
|
||||
add_definitions(-include ../adapter_ard.h)
|
32
adapter_ard.h
Normal file
32
adapter_ard.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef ADAPT_ARD_H
|
||||
#define ADAPT_ARD_H
|
||||
#include <string>
|
||||
|
||||
void loop();
|
||||
void setup();
|
||||
long millis();
|
||||
int abs(int in);
|
||||
void pinMode(int pin, int mode);
|
||||
int analogRead(int pin);
|
||||
void digitalWrite(int pin, int level);
|
||||
void analogWrite(int pin, int dc);
|
||||
|
||||
class serial_c{
|
||||
public:
|
||||
void begin(int br);
|
||||
void println(std::string txt);
|
||||
void print(std::string txt);
|
||||
void println(int nb);
|
||||
void print(int nb);
|
||||
};
|
||||
|
||||
extern serial_c Serial;
|
||||
|
||||
|
||||
#define A0 0
|
||||
#define A1 1
|
||||
#define INPUT 1
|
||||
#define OUTPUT 2
|
||||
#define LOW 0
|
||||
#define HIGH 1
|
||||
#endif
|
69
main.cpp
Normal file
69
main.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "adapter_ard.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
|
||||
serial_c Serial;
|
||||
|
||||
int main(int argc, char** argv){
|
||||
setup();
|
||||
while(1){
|
||||
loop();
|
||||
printf("millis %ld\n", millis());
|
||||
}
|
||||
}
|
||||
|
||||
long millis(){
|
||||
clock_t clk_t;
|
||||
clk_t = clock();
|
||||
long milli=clk_t * 1000 / CLOCKS_PER_SEC;
|
||||
return milli;
|
||||
}
|
||||
|
||||
int abs(int in){
|
||||
return abs(in);
|
||||
}
|
||||
|
||||
void pinMode(int pin, int mode){
|
||||
printf("set pin %d in mode %d\n", pin, mode);
|
||||
printf("$pm,%d,%d",pin, mode);
|
||||
}
|
||||
|
||||
int analogRead(int pin){
|
||||
return 69;
|
||||
}
|
||||
|
||||
void digitalWrite(int pin, int level){
|
||||
printf("set pin %d at level %d\n", pin, level);
|
||||
printf("$dw,%d,%d", pin, level);
|
||||
}
|
||||
|
||||
void analogWrite(int pin, int dc){
|
||||
printf("set pin %d at duty cycle %d\n", pin, dc);
|
||||
printf("$aw,%d,%d", pin, dc);
|
||||
}
|
||||
|
||||
void serial_c::begin(int br){
|
||||
printf("started serial at %d bps\n", br);
|
||||
}
|
||||
|
||||
void serial_c::print(std::string txt){
|
||||
std::cout << "serial : " << txt;
|
||||
}
|
||||
|
||||
void serial_c::println(std::string txt){
|
||||
this->print(txt);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void serial_c::print(int nb){
|
||||
printf("serial : %d", nb);
|
||||
}
|
||||
|
||||
void serial_c::println(int nb){
|
||||
this->print(nb);
|
||||
printf("\n");
|
||||
}
|
1
projet-tuteure-3a
Submodule
1
projet-tuteure-3a
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 89795a10e037c8b55f6e85b2b3e068e8b86a026f
|
Loading…
x
Reference in New Issue
Block a user