nouvelles fonctions
This commit is contained in:
parent
6bff550993
commit
95dcc68055
@ -6,7 +6,10 @@ void loop();
|
||||
void setup();
|
||||
long millis();
|
||||
long micros();
|
||||
void delay(unsigned long milli);
|
||||
int abs(int in);
|
||||
double max(double a, double b);
|
||||
double min(double a, double b);
|
||||
void pinMode(int pin, int mode);
|
||||
int analogRead(int pin);
|
||||
void digitalWrite(int pin, int level);
|
||||
@ -21,6 +24,10 @@ class serial_c{
|
||||
void print(std::string txt);
|
||||
void println(int nb);
|
||||
void print(int nb);
|
||||
void print(float nb);
|
||||
void println(float nb);
|
||||
void print(double nb);
|
||||
void println(double nb);
|
||||
};
|
||||
|
||||
extern serial_c Serial;
|
||||
|
2
laby.py
2
laby.py
@ -22,7 +22,7 @@ class Laby:
|
||||
L17=0.20
|
||||
walls = [
|
||||
((0,0),(0,L17)),
|
||||
((0,L17+L4),(0,L17+L4+L2)),
|
||||
#((0,L17+L4),(0,L17+L4+L2)),
|
||||
((0,0),(L8,0)),
|
||||
((L8,0),(L8,L7)),
|
||||
((L8,L7),(L8+L3,L7)),
|
||||
|
30
main.cpp
30
main.cpp
@ -43,11 +43,17 @@ int main(int argc, char** argv){
|
||||
}
|
||||
printf("$dt,%ld;", micros());
|
||||
loop();
|
||||
delay(10);
|
||||
printf("*");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
void delay(unsigned long milli){
|
||||
unsigned long end = millis() + milli;
|
||||
while(millis() <= end);
|
||||
}
|
||||
|
||||
long millis(){
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &end);
|
||||
uint64_t milli = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
@ -66,6 +72,13 @@ int abs(int in){
|
||||
return abs(in);
|
||||
}
|
||||
|
||||
double min(double a, double b){
|
||||
return a<b?a:b;
|
||||
}
|
||||
double max(double a, double b){
|
||||
return a>b?a:b;
|
||||
}
|
||||
|
||||
void pinMode(int pin, int mode){
|
||||
printf("$pm,%d,%d;",pin, mode);
|
||||
}
|
||||
@ -99,6 +112,23 @@ void serial_c::print(int nb){
|
||||
printf("serial : %d", nb);
|
||||
}
|
||||
|
||||
void serial_c::print(float nb){
|
||||
printf("serial : %f", nb);
|
||||
}
|
||||
|
||||
void serial_c::println(float nb){
|
||||
this->print(nb);
|
||||
printf("\n");
|
||||
}
|
||||
void serial_c::print(double nb){
|
||||
printf("serial : %f", nb);
|
||||
}
|
||||
|
||||
void serial_c::println(double nb){
|
||||
this->print(nb);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void serial_c::println(int nb){
|
||||
this->print(nb);
|
||||
printf("\n");
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c54363fde2edebb39355ba264c1b85dd2258bef4
|
||||
Subproject commit 55b6ea6ff947589b354610e1d07d872e799be815
|
Loading…
x
Reference in New Issue
Block a user